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