1 |
bendavid |
1.1 |
// $Id: FillerConversionsDecay.cc,v 1.20 2010/03/18 20:21:00 bendavid Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerConversionsDecay.h"
|
4 |
|
|
#include "DataFormats/Common/interface/RefToPtr.h"
|
5 |
|
|
#include "MitEdm/DataFormats/interface/RefToBaseToPtr.h"
|
6 |
|
|
#include "MitAna/DataTree/interface/StableDataCol.h"
|
7 |
|
|
#include "MitAna/DataTree/interface/DecayDataCol.h"
|
8 |
|
|
#include "MitAna/DataTree/interface/DecayParticleCol.h"
|
9 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
10 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
11 |
|
|
|
12 |
|
|
using namespace std;
|
13 |
|
|
using namespace edm;
|
14 |
|
|
using namespace mithep;
|
15 |
|
|
|
16 |
|
|
//--------------------------------------------------------------------------------------------------
|
17 |
|
|
FillerConversionsDecay::FillerConversionsDecay(const ParameterSet &cfg, const char *name, bool active) :
|
18 |
|
|
BaseFiller(cfg,name,active),
|
19 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","conversions")),
|
20 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName","Conversions")),
|
21 |
|
|
stableDataName_(mitName_ + "_StableDatas"),
|
22 |
|
|
stablePartMapNames_(Conf().exists("stablePartMaps") ?
|
23 |
|
|
Conf().getUntrackedParameter<vector<string> >("stablePartMaps") :
|
24 |
|
|
vector<string>()),
|
25 |
|
|
conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName",
|
26 |
|
|
Form("%sMapName",mitName_.c_str()))),
|
27 |
|
|
decays_(new mithep::DecayParticleArr(250)),
|
28 |
|
|
stableData_(new mithep::StableDataArr(500)),
|
29 |
|
|
conversionMap_(new mithep::ConversionDecayMap)
|
30 |
|
|
{
|
31 |
|
|
// Constructor.
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
//--------------------------------------------------------------------------------------------------
|
35 |
|
|
FillerConversionsDecay::~FillerConversionsDecay()
|
36 |
|
|
{
|
37 |
|
|
// Destructor.
|
38 |
|
|
|
39 |
|
|
delete decays_;
|
40 |
|
|
delete stableData_;
|
41 |
|
|
delete conversionMap_;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
//--------------------------------------------------------------------------------------------------
|
45 |
|
|
void FillerConversionsDecay::BookDataBlock(TreeWriter &tws)
|
46 |
|
|
{
|
47 |
|
|
// Add conversions to tree. Publish and get our objects.
|
48 |
|
|
|
49 |
|
|
tws.AddBranch(mitName_, &decays_);
|
50 |
|
|
OS()->add<mithep::DecayParticleArr>(decays_,mitName_);
|
51 |
|
|
tws.AddBranch(stableDataName_, &stableData_);
|
52 |
|
|
OS()->add<mithep::StableDataArr>(stableData_,stableDataName_);
|
53 |
|
|
|
54 |
|
|
if (!convElectronMapName_.empty()) {
|
55 |
|
|
conversionMap_->SetBrName(mitName_);
|
56 |
|
|
OS()->add(conversionMap_,conversionMapName_);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
for (std::vector<std::string>::const_iterator bmapName = stablePartMapNames_.begin();
|
60 |
|
|
bmapName!=stablePartMapNames_.end(); ++bmapName) {
|
61 |
|
|
if (!bmapName->empty()) {
|
62 |
|
|
const TrackPartMap *map = OS()->get<TrackPartMap>(*bmapName);
|
63 |
|
|
if (map) {
|
64 |
|
|
stablePartMaps_.push_back(map);
|
65 |
|
|
AddBranchDep(mitName_,map->GetBrName());
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
//--------------------------------------------------------------------------------------------------
|
72 |
|
|
void FillerConversionsDecay::FillDataBlock(const edm::Event &event,
|
73 |
|
|
const edm::EventSetup &setup)
|
74 |
|
|
{
|
75 |
|
|
// Fill conversions data structure and maps.
|
76 |
|
|
|
77 |
|
|
decays_->Delete();
|
78 |
|
|
stableData_->Delete();
|
79 |
|
|
conversionMap_->Reset();
|
80 |
|
|
|
81 |
|
|
Handle<reco::ConversionCollection> hConversionProduct;
|
82 |
|
|
GetProduct(edmName_, hConversionProduct, event);
|
83 |
|
|
|
84 |
|
|
conversionMap_->SetEdmProductId(hConversionProduct.id().id());
|
85 |
|
|
|
86 |
|
|
const reco::ConversionCollection inConversions = *(hConversionProduct.product());
|
87 |
|
|
|
88 |
|
|
for (reco::ConversionCollection::const_iterator inConversion = inConversions.begin();
|
89 |
|
|
inConversion != inConversions.end(); ++inConversion) {
|
90 |
|
|
|
91 |
|
|
mithep::DecayParticle *outConversion = decays_->Allocate();
|
92 |
|
|
new (outConversion) mithep::DecayParticle(22);
|
93 |
|
|
|
94 |
|
|
math::XYZTLorentzVectorD convP4 = inConversion->refittedPair4Momentum();
|
95 |
|
|
FourVector p4Fitted(convP4.px(),convP4.py(),convP4.pz(),convP4.energy());
|
96 |
|
|
|
97 |
|
|
outConversion->SetMom(p4Fitted);
|
98 |
|
|
|
99 |
|
|
const reco::Vertex &vtx = inConversion->conversionVertex();
|
100 |
|
|
ThreeVector vtxPos(vtx.x(),vtx.y(),vtx.z());
|
101 |
|
|
|
102 |
|
|
double dlz = vtxPos.z()*TMath::Abs(p4Fitted.Pz())/p4Fitted.Pz();
|
103 |
|
|
ThreeVector momPerp(p4Fitted.Px(),p4Fitted.Py(),0);
|
104 |
|
|
ThreeVector posPerp(vtxPos.x(),vtxPos.y(),0);
|
105 |
|
|
double dl = momPerp.Dot(posPerp)/momPerp.R();
|
106 |
|
|
double dxy = momPerp.Cross(vtxPos).Z()/p4Fitted.Pt();
|
107 |
|
|
|
108 |
|
|
outConversion->SetLz(dlz);
|
109 |
|
|
outConversion->SetLxy(dl);
|
110 |
|
|
outConversion->SetDxy(dxy);
|
111 |
|
|
|
112 |
|
|
outConversion->SetChi2(vtx.chi2());
|
113 |
|
|
outConversion->SetNdof((Int_t)vtx.ndof());
|
114 |
|
|
|
115 |
|
|
outConversion->SetNSharedHits(inConversion->nSharedHits());
|
116 |
|
|
|
117 |
|
|
const std::vector<reco::TrackBaseRef> &trackRefs = inConversion->tracks();
|
118 |
|
|
const std::vector<reco::Track> &refittedTracks = vtx.refittedTracks();
|
119 |
|
|
const std::vector<uint8_t> &nHitsBeforeVtx = inConversion->nHitsBeforeVtx();
|
120 |
|
|
const std::vector<Measurement1DFloat> &dlClosestHitToVtx = inConversion->dlClosestHitToVtx();
|
121 |
|
|
|
122 |
|
|
//fill conversion quality mask
|
123 |
|
|
ConversionQuality &outQuality = outConversion->Quality();
|
124 |
|
|
for (uint i=0; i<16; ++i) {
|
125 |
|
|
outQuality.SetQuality(ConversionQuality::EQuality(i),inConversion->quality(reco::Conversion::ConversionQuality(i)));
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
//fill daughters
|
129 |
|
|
if (stablePartMaps_.size() && trackRefs.size()==2 && refittedTracks.size()==2) {
|
130 |
|
|
for (uint i=0; i<trackRefs.size(); ++i) {
|
131 |
|
|
|
132 |
|
|
const reco::TrackBaseRef &trackRef = trackRefs.at(i);
|
133 |
|
|
const reco::Track &refittedTrack = refittedTracks.at(i);
|
134 |
|
|
|
135 |
|
|
const mithep::Particle *daughter = GetMitParticle(mitedm::refToBaseToPtr(trackRef));
|
136 |
|
|
|
137 |
|
|
mithep::StableData *outStable = stableData_->Allocate();
|
138 |
|
|
new (outStable) mithep::StableData(daughter,
|
139 |
|
|
refittedTrack.px(),refittedTrack.py(),refittedTrack.pz());
|
140 |
|
|
|
141 |
|
|
if (nHitsBeforeVtx.size()>i) {
|
142 |
|
|
outStable->SetNHitsBeforeVtx(nHitsBeforeVtx.at(i));
|
143 |
|
|
}
|
144 |
|
|
if (dlClosestHitToVtx.size()>i) {
|
145 |
|
|
outStable->SetDlClosestHitToVtx(dlClosestHitToVtx.at(i).value());
|
146 |
|
|
outStable->SetDlClosestHitToVtxErr(dlClosestHitToVtx.at(i).error());
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
outConversion->AddDaughterData(outStable);
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
reco::ConversionRef theRef(hConversionProduct, inConversion-inConversions.begin());
|
154 |
|
|
conversionMap_->Add(theRef, outConversion);
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
decays_->Trim();
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
//--------------------------------------------------------------------------------------------------
|
161 |
|
|
mithep::Particle *FillerConversionsDecay::GetMitParticle(edm::Ptr<reco::Track> ptr) const
|
162 |
|
|
{
|
163 |
|
|
// Return our particle referenced by the edm pointer.
|
164 |
|
|
|
165 |
|
|
mithep::Particle *mitPart = 0;
|
166 |
|
|
for (std::vector<const mithep::TrackPartMap*>::const_iterator bmap = stablePartMaps_.begin();
|
167 |
|
|
bmap!=stablePartMaps_.end(); ++bmap) {
|
168 |
|
|
const mithep::TrackPartMap *theMap = *bmap;
|
169 |
|
|
if (theMap->HasMit(ptr)) {
|
170 |
|
|
mitPart = theMap->GetMit(ptr);
|
171 |
|
|
return mitPart;
|
172 |
|
|
}
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
if (!mitPart)
|
176 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillerConversionsDecay::FillDataBlock()\n")
|
177 |
|
|
<< "Error! MITHEP Object "
|
178 |
|
|
<< "not found in AssociationMaps (" << typeid(*this).name() << ")." << std::endl;
|
179 |
|
|
|
180 |
|
|
return mitPart;
|
181 |
|
|
}
|