1 |
bendavid |
1.7 |
// $Id: FillerDecayParts.cc,v 1.6 2008/09/19 11:40:15 bendavid Exp $
|
2 |
paus |
1.1 |
|
3 |
loizides |
1.4 |
#include "MitAna/DataTree/interface/DecayParticle.h"
|
4 |
bendavid |
1.6 |
#include "MitAna/DataTree/interface/DaughterData.h"
|
5 |
paus |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
6 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
7 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
8 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
9 |
|
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
|
10 |
|
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
|
11 |
|
|
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h"
|
12 |
bendavid |
1.2 |
#include "MitEdm/DataFormats/interface/CollectionsEdm.h"
|
13 |
|
|
#include "MitEdm/DataFormats/interface/DecayPart.h"
|
14 |
|
|
#include "MitEdm/DataFormats/interface/BasePart.h"
|
15 |
|
|
#include "MitEdm/DataFormats/interface/BasePartFwd.h"
|
16 |
paus |
1.1 |
#include "MitProd/TreeFiller/interface/FillerDecayParts.h"
|
17 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
18 |
|
|
|
19 |
|
|
using namespace std;
|
20 |
|
|
using namespace edm;
|
21 |
|
|
using namespace mithep;
|
22 |
|
|
|
23 |
|
|
//--------------------------------------------------------------------------------------------------
|
24 |
loizides |
1.4 |
FillerDecayParts::FillerDecayParts(const ParameterSet &cfg, const char *name, bool active) :
|
25 |
paus |
1.1 |
BaseFiller(cfg,name,active),
|
26 |
loizides |
1.4 |
edmName_(Conf().getUntrackedParameter<string>("edmName","")),
|
27 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName","")),
|
28 |
|
|
decays_(new mithep::DecayParticleArr(250))
|
29 |
paus |
1.1 |
{
|
30 |
loizides |
1.4 |
// Constructor.
|
31 |
bendavid |
1.6 |
if (Conf().exists("basePartMaps"))
|
32 |
|
|
basePartMapNames_ = Conf().getUntrackedParameter<vector<string> >("basePartMaps");
|
33 |
paus |
1.1 |
}
|
34 |
|
|
|
35 |
|
|
//--------------------------------------------------------------------------------------------------
|
36 |
|
|
FillerDecayParts::~FillerDecayParts()
|
37 |
|
|
{
|
38 |
loizides |
1.4 |
// Destructor.
|
39 |
|
|
|
40 |
paus |
1.1 |
delete decays_;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
//--------------------------------------------------------------------------------------------------
|
44 |
|
|
void FillerDecayParts::BookDataBlock(TreeWriter &tws)
|
45 |
|
|
{
|
46 |
loizides |
1.4 |
// Add tracks branch to tree and get our map.
|
47 |
|
|
|
48 |
paus |
1.1 |
tws.AddBranch(mitName_.c_str(),&decays_);
|
49 |
bendavid |
1.6 |
|
50 |
|
|
for (std::vector<std::string>::const_iterator bmapName = basePartMapNames_.begin();
|
51 |
|
|
bmapName!=basePartMapNames_.end(); ++bmapName) {
|
52 |
|
|
if (!bmapName->empty())
|
53 |
|
|
basePartMaps_.push_back(OS()->get<BasePartMap>(bmapName->c_str()));
|
54 |
|
|
}
|
55 |
|
|
|
56 |
paus |
1.1 |
}
|
57 |
|
|
|
58 |
|
|
//--------------------------------------------------------------------------------------------------
|
59 |
|
|
void FillerDecayParts::FillDataBlock(const edm::Event &evt,
|
60 |
|
|
const edm::EventSetup &setup)
|
61 |
|
|
{
|
62 |
loizides |
1.4 |
// Fill our EDM DecayPart collection into the MIT DecayParticle collection.
|
63 |
mrudolph |
1.5 |
cout << "Decay part block" << endl;
|
64 |
paus |
1.1 |
decays_->Reset();
|
65 |
loizides |
1.4 |
|
66 |
bendavid |
1.2 |
Handle<mitedm::DecayPartCol> hParts;
|
67 |
paus |
1.1 |
GetProduct(edmName_, hParts, evt);
|
68 |
bendavid |
1.2 |
const mitedm::DecayPartCol *iParts = hParts.product();
|
69 |
paus |
1.1 |
|
70 |
|
|
// loop through all decayParts and fill the information
|
71 |
bendavid |
1.2 |
for (UInt_t i=0; i<iParts->size(); ++i) {
|
72 |
|
|
const mitedm::DecayPart &p =iParts->at(i); // for convenience
|
73 |
paus |
1.1 |
//cout << "MITEDM...\n";p->print();
|
74 |
bendavid |
1.2 |
mithep::DecayParticle *d = decays_->Allocate();
|
75 |
|
|
new (d) mithep::DecayParticle(p.pid(),(mithep::DecayParticle::DecayType)p.decayType());
|
76 |
|
|
|
77 |
|
|
d->SetFittedMass(p.fittedMass());
|
78 |
|
|
d->SetFittedMassError(p.fittedMassError());
|
79 |
|
|
d->SetLxy(p.lxy());
|
80 |
|
|
d->SetLxyError(p.lxyError());
|
81 |
|
|
d->SetLxyToPv(p.lxyToPv());
|
82 |
|
|
d->SetLxyToPvError(p.lxyToPvError());
|
83 |
|
|
d->SetDxy(p.dxy());
|
84 |
|
|
d->SetDxyError(p.dxyError());
|
85 |
|
|
d->SetDxyToPv(p.dxyToPv());
|
86 |
|
|
d->SetDxyToPvError(p.dxyToPvError());
|
87 |
|
|
d->SetLz(p.lz());
|
88 |
|
|
d->SetLzError(p.lzError());
|
89 |
|
|
d->SetLzToPv(p.lzToPv());
|
90 |
|
|
d->SetLzToPvError(p.lzToPvError());
|
91 |
|
|
d->SetCTau(p.cTau());
|
92 |
|
|
d->SetCTauError(p.cTauError());
|
93 |
|
|
d->SetPt(p.pt());
|
94 |
|
|
d->SetPtError(p.ptError());
|
95 |
|
|
d->SetMom(p.fourMomentum());
|
96 |
|
|
d->SetPosition(p.position());
|
97 |
|
|
d->SetError(p.error());
|
98 |
|
|
d->SetBigError(p.bigError());
|
99 |
|
|
|
100 |
mrudolph |
1.5 |
d->SetChi2(p.chi2());
|
101 |
|
|
d->SetNdof(p.ndof());
|
102 |
|
|
|
103 |
bendavid |
1.2 |
//loop through and add daughters
|
104 |
bendavid |
1.6 |
if (basePartMaps_.size()) {
|
105 |
|
|
for (Int_t j=0; j<p.nChild();++j) {
|
106 |
bendavid |
1.7 |
mitedm::BasePartPtr thePtr = p.getChildPtr(j);
|
107 |
bendavid |
1.6 |
mithep::Particle *daughter = 0;
|
108 |
|
|
for (std::vector<const mithep::BasePartMap*>::const_iterator bmap = basePartMaps_.begin();
|
109 |
|
|
bmap!=basePartMaps_.end(); ++bmap) {
|
110 |
|
|
const mithep::BasePartMap *theMap = *bmap;
|
111 |
bendavid |
1.7 |
if (theMap->HasMit(thePtr))
|
112 |
|
|
daughter = theMap->GetMit(thePtr);
|
113 |
bendavid |
1.6 |
}
|
114 |
|
|
|
115 |
|
|
if (!daughter)
|
116 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillerDecayParts::FillDataBlock()\n")
|
117 |
|
|
<< "Error! MITHEP Object "
|
118 |
|
|
<< "not found in AssociationMaps (" << typeid(*this).name() << ")." << std::endl;
|
119 |
|
|
|
120 |
|
|
if (p.nChild()==p.nChildMom())
|
121 |
|
|
d->AddDaughter(daughter, mithep::DaughterData(p.getChildMom(j)));
|
122 |
|
|
else
|
123 |
|
|
d->AddDaughter(daughter);
|
124 |
bendavid |
1.2 |
}
|
125 |
|
|
}
|
126 |
paus |
1.1 |
//cout << "MITHEP...\n";d->print();
|
127 |
|
|
}
|
128 |
|
|
decays_->Trim();
|
129 |
|
|
}
|