1 |
loizides |
1.4 |
// $Id: FillerStableParts.cc,v 1.3 2008/07/30 08:39:51 loizides Exp $
|
2 |
paus |
1.1 |
|
3 |
loizides |
1.4 |
#include "MitAna/DataTree/interface/StableParticle.h"
|
4 |
paus |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
7 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
8 |
|
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
|
9 |
|
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
|
10 |
|
|
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h"
|
11 |
bendavid |
1.2 |
#include "MitEdm/DataFormats/interface/CollectionsEdm.h"
|
12 |
|
|
#include "MitEdm/DataFormats/interface/BasePartFwd.h"
|
13 |
|
|
#include "MitEdm/DataFormats/interface/StablePartEdm.h"
|
14 |
paus |
1.1 |
#include "MitProd/TreeFiller/interface/FillerStableParts.h"
|
15 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
16 |
|
|
|
17 |
|
|
using namespace std;
|
18 |
|
|
using namespace edm;
|
19 |
|
|
using namespace mithep;
|
20 |
|
|
|
21 |
|
|
//--------------------------------------------------------------------------------------------------
|
22 |
loizides |
1.4 |
FillerStableParts::FillerStableParts(const ParameterSet &cfg, const char *name, bool active) :
|
23 |
paus |
1.1 |
BaseFiller(cfg,name,active),
|
24 |
loizides |
1.4 |
edmName_(Conf().getUntrackedParameter<string>("edmName","")),
|
25 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName","")),
|
26 |
|
|
trackMapName_(Conf().getUntrackedParameter<string>("trackMapName","")),
|
27 |
|
|
basePartMapName_(Conf().getUntrackedParameter<string>("basePartMap",
|
28 |
|
|
Form("%sMapName",mitName_.c_str()))),
|
29 |
|
|
trackMap_(0),
|
30 |
|
|
stables_(new mithep::StableParticleArr(250)),
|
31 |
|
|
basePartMap_(new mithep::BasePartMap)
|
32 |
paus |
1.1 |
{
|
33 |
loizides |
1.4 |
// Constructor.
|
34 |
paus |
1.1 |
}
|
35 |
|
|
|
36 |
|
|
//--------------------------------------------------------------------------------------------------
|
37 |
|
|
FillerStableParts::~FillerStableParts()
|
38 |
|
|
{
|
39 |
loizides |
1.4 |
// Destructor.
|
40 |
|
|
|
41 |
paus |
1.1 |
delete stables_;
|
42 |
loizides |
1.4 |
delete basePartMap_;
|
43 |
paus |
1.1 |
}
|
44 |
|
|
|
45 |
|
|
//--------------------------------------------------------------------------------------------------
|
46 |
|
|
void FillerStableParts::BookDataBlock(TreeWriter &tws)
|
47 |
|
|
{
|
48 |
loizides |
1.4 |
// Add tracks branch to tree, get and publish our maps.
|
49 |
|
|
|
50 |
paus |
1.1 |
tws.AddBranch(mitName_.c_str(),&stables_);
|
51 |
loizides |
1.4 |
|
52 |
|
|
OS()->add(basePartMap_,basePartMapName_.c_str());
|
53 |
|
|
if (!trackMapName_.empty())
|
54 |
|
|
trackMap_ = OS()->get<TrackMap>(trackMapName_.c_str());
|
55 |
paus |
1.1 |
}
|
56 |
|
|
|
57 |
|
|
//--------------------------------------------------------------------------------------------------
|
58 |
|
|
void FillerStableParts::FillDataBlock(const edm::Event &evt,
|
59 |
|
|
const edm::EventSetup &setup)
|
60 |
|
|
{
|
61 |
loizides |
1.4 |
// Fill our EDM StablePart collection into the MIT StableParticle collection.
|
62 |
|
|
|
63 |
paus |
1.1 |
stables_->Reset();
|
64 |
loizides |
1.4 |
basePartMap_->Reset();
|
65 |
|
|
|
66 |
bendavid |
1.2 |
Handle<mitedm::StablePartCol> hParts;
|
67 |
paus |
1.1 |
GetProduct(edmName_, hParts, evt);
|
68 |
bendavid |
1.2 |
const mitedm::StablePartCol *iParts = hParts.product();
|
69 |
paus |
1.1 |
|
70 |
|
|
// loop through all StableParts and fill the information
|
71 |
bendavid |
1.2 |
for (UInt_t i=0; i<iParts->size(); ++i) {
|
72 |
loizides |
1.4 |
const mitedm::StablePartEdm &p = iParts->at(i); // for convenience
|
73 |
loizides |
1.3 |
PairIntKey theKey(hParts.id().id(),i);
|
74 |
paus |
1.1 |
//cout << "MITEDM...\n";p->print();
|
75 |
bendavid |
1.2 |
mithep::StableParticle *d = stables_->Allocate();
|
76 |
|
|
new (d) mithep::StableParticle(p.pid());
|
77 |
loizides |
1.4 |
basePartMap_->Add(theKey,d);
|
78 |
bendavid |
1.2 |
if (trackMap_)
|
79 |
|
|
d->SetTrk(trackMap_->GetMit(p.trackRef()));
|
80 |
paus |
1.1 |
//cout << "MITHEP...\n";d->print();
|
81 |
|
|
}
|
82 |
|
|
stables_->Trim();
|
83 |
|
|
}
|