1 |
loizides |
1.13 |
// $Id: ProducerV2SS.cc,v 1.12 2009/03/20 18:01:48 loizides Exp $
|
2 |
loizides |
1.7 |
|
3 |
mrudolph |
1.3 |
#include "DataFormats/Common/interface/Handle.h"
|
4 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
5 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
6 |
bendavid |
1.8 |
#include "MitEdm/Producers/interface/HitDropperRecord.h"
|
7 |
|
|
#include "MitEdm/Producers/interface/HitDropper.h"
|
8 |
mrudolph |
1.3 |
#include "MitEdm/DataFormats/interface/Types.h"
|
9 |
mrudolph |
1.4 |
#include "MitEdm/DataFormats/interface/Collections.h"
|
10 |
mrudolph |
1.3 |
#include "MitEdm/DataFormats/interface/DecayPart.h"
|
11 |
|
|
#include "MitEdm/DataFormats/interface/StablePart.h"
|
12 |
bendavid |
1.5 |
#include "MitEdm/DataFormats/interface/StableData.h"
|
13 |
mrudolph |
1.3 |
#include "MitEdm/VertexFitInterface/interface/MvfInterface.h"
|
14 |
|
|
#include "MitEdm/VertexFitInterface/interface/HisInterface.h"
|
15 |
|
|
#include "MitEdm/Producers/interface/ProducerV2SS.h"
|
16 |
|
|
|
17 |
|
|
using namespace std;
|
18 |
|
|
using namespace edm;
|
19 |
|
|
using namespace mitedm;
|
20 |
bendavid |
1.5 |
using namespace mithep;
|
21 |
mrudolph |
1.3 |
|
22 |
|
|
//--------------------------------------------------------------------------------------------------
|
23 |
|
|
ProducerV2SS::ProducerV2SS(const ParameterSet& cfg) :
|
24 |
|
|
ProducerD2SS(cfg),
|
25 |
paus |
1.10 |
rhoMin_ (cfg.getUntrackedParameter<double>("minRadius", 0.0)),
|
26 |
|
|
massMin_ (cfg.getUntrackedParameter<double>("minMass", 0.0)),
|
27 |
|
|
massMax_ (cfg.getUntrackedParameter<double>("maxMass", 3.0)),
|
28 |
bendavid |
1.11 |
dZMax_ (cfg.getUntrackedParameter<double>("maxZDistance",5.0)),
|
29 |
|
|
useHitDropper_(cfg.getUntrackedParameter<bool>("useHitDropper",true))
|
30 |
mrudolph |
1.3 |
{
|
31 |
loizides |
1.12 |
// Constructor.
|
32 |
mrudolph |
1.3 |
}
|
33 |
|
|
|
34 |
|
|
//--------------------------------------------------------------------------------------------------
|
35 |
|
|
ProducerV2SS::~ProducerV2SS()
|
36 |
|
|
{
|
37 |
loizides |
1.12 |
// Destructor.
|
38 |
mrudolph |
1.3 |
}
|
39 |
|
|
|
40 |
|
|
//--------------------------------------------------------------------------------------------------
|
41 |
|
|
void ProducerV2SS::produce(Event &evt, const EventSetup &setup)
|
42 |
|
|
{
|
43 |
loizides |
1.12 |
// Produce the output collection.
|
44 |
|
|
|
45 |
mrudolph |
1.3 |
auto_ptr<DecayPartCol> pD(new DecayPartCol());
|
46 |
|
|
|
47 |
|
|
// First input collection
|
48 |
|
|
Handle<StablePartCol> hStables1;
|
49 |
|
|
Handle<StablePartCol> hStables2;
|
50 |
|
|
if (!GetProduct(iStables1_, hStables1, evt) ) {
|
51 |
|
|
cout << "Couldn't get in collection in Producer V2SS" << endl;
|
52 |
|
|
evt.put(pD);
|
53 |
|
|
return;
|
54 |
|
|
}
|
55 |
loizides |
1.7 |
const StablePartCol *pS1 = hStables1.product();
|
56 |
mrudolph |
1.3 |
|
57 |
loizides |
1.7 |
// Second input collection
|
58 |
mrudolph |
1.3 |
if(!GetProduct(iStables2_, hStables2, evt)) {
|
59 |
|
|
cout << "Couldn't get in collection in Producer V2SS" << endl;
|
60 |
|
|
evt.put(pD);
|
61 |
|
|
return;
|
62 |
|
|
}
|
63 |
|
|
const StablePartCol *pS2 = hStables2.product();
|
64 |
bendavid |
1.8 |
|
65 |
|
|
//get hit dropper
|
66 |
|
|
ESHandle<HitDropper> hDropper;
|
67 |
bendavid |
1.11 |
const HitDropper *dropper = 0;
|
68 |
|
|
if (useHitDropper_) {
|
69 |
|
|
setup.get<HitDropperRecord>().get("HitDropper",hDropper);
|
70 |
|
|
dropper = hDropper.product();
|
71 |
|
|
}
|
72 |
mrudolph |
1.3 |
|
73 |
|
|
// -----------------------------------------------------------------------------------------------
|
74 |
|
|
// Simple double loop
|
75 |
|
|
// -----------------------------------------------------------------------------------------------
|
76 |
loizides |
1.7 |
if (0)
|
77 |
|
|
cout << "Starting V finder loop" << endl;
|
78 |
mrudolph |
1.3 |
|
79 |
loizides |
1.7 |
//sX_y: X= pion or proton collection.
|
80 |
|
|
//i, j = 2 loop particles.
|
81 |
|
|
//ex.: s1_i and s2_i are same particle as pion and proton
|
82 |
mrudolph |
1.3 |
for (UInt_t i=0; i<pS1->size(); ++i) {
|
83 |
|
|
const StablePart &s1 = pS1->at(i);
|
84 |
|
|
|
85 |
|
|
UInt_t j;
|
86 |
|
|
if (iStables1_ == iStables2_)
|
87 |
|
|
j = i+1;
|
88 |
|
|
else
|
89 |
|
|
j = 0;
|
90 |
|
|
|
91 |
|
|
for (; j<pS2->size(); ++j) {
|
92 |
|
|
const StablePart &s2 = pS2->at(j);
|
93 |
|
|
|
94 |
|
|
if(s1.charge() + s2.charge() != 0) continue;
|
95 |
|
|
|
96 |
loizides |
1.12 |
// do fast helix fit to check if there's any hope
|
97 |
mrudolph |
1.3 |
const reco::Track * t1 = s1.track();
|
98 |
|
|
const reco::Track * t2 = s2.track();
|
99 |
|
|
HisInterface hisInt(t1,t2);
|
100 |
|
|
const mithep::HelixIntersector *his = hisInt.hISector();
|
101 |
|
|
double dZ0 = -999;
|
102 |
|
|
double dR0 = -999;
|
103 |
|
|
dZ0 = his->IntersectionI(0).DeltaZ();
|
104 |
|
|
dR0 = sqrt(his->IntersectionI(0).Location().X()*his->IntersectionI(0).Location().X()+
|
105 |
|
|
his->IntersectionI(0).Location().Y()*his->IntersectionI(0).Location().Y());
|
106 |
|
|
|
107 |
|
|
TVector3 v1, v2;
|
108 |
|
|
v1 = his->IntersectionI(0).TrackParamsI(0).Momentum();
|
109 |
|
|
v2 = his->IntersectionI(0).TrackParamsI(1).Momentum();
|
110 |
|
|
|
111 |
|
|
double e1 = sqrt(v1.Mag()*v1.Mag() +s1.mass()*s1.mass());
|
112 |
|
|
double x1 = v1.X();
|
113 |
|
|
double y1 = v1.Y();
|
114 |
|
|
double z1 = v1.Z();
|
115 |
|
|
|
116 |
|
|
double e2 = sqrt(v2.Mag()*v2.Mag()+s2.mass()*s2.mass());
|
117 |
|
|
double x2 = v2.X();
|
118 |
|
|
double y2 = v2.Y();
|
119 |
|
|
double z2 = v2.Z();
|
120 |
|
|
|
121 |
|
|
FourVector sum(x1+x2, y1+y2, z1+z2, e1+e2);
|
122 |
|
|
|
123 |
|
|
double mass0 = sqrt(sum.M2());
|
124 |
|
|
|
125 |
loizides |
1.12 |
// Basic cuts on helix intersection
|
126 |
mrudolph |
1.3 |
if(mass0 > massMax_ || mass0<massMin_ || fabs(dZ0) > dZMax_ || dR0 < rhoMin_) continue;
|
127 |
|
|
|
128 |
|
|
// -------------------------------------------------------------------------------------------
|
129 |
|
|
// Do vertex fit for all pairs
|
130 |
loizides |
1.7 |
// -------------------------------------------------------------------------------------------
|
131 |
paus |
1.10 |
mithep::MultiVertexFitterD fit;
|
132 |
loizides |
1.7 |
fit.init(3.8); // Reset to the MC magnetic field of 3.8 Tesla
|
133 |
mrudolph |
1.3 |
fit.setChisqMax(100);
|
134 |
|
|
MvfInterface fitInt(&fit);
|
135 |
paus |
1.10 |
fitInt.addTrack(s1.track(),1,s1.mass(),mithep::MultiVertexFitterD::VERTEX_1);
|
136 |
|
|
fitInt.addTrack(s2.track(),2,s2.mass(),mithep::MultiVertexFitterD::VERTEX_1);
|
137 |
mrudolph |
1.3 |
|
138 |
|
|
|
139 |
|
|
if (fit.fit()){
|
140 |
|
|
|
141 |
|
|
DecayPart *d = new DecayPart(oPid_,DecayPart::Fast);
|
142 |
bendavid |
1.5 |
|
143 |
|
|
// Update temporarily some of the quantities (prob, chi2, nDoF, mass, lxy, pt, fourMomentum)
|
144 |
|
|
d->setProb(fit.prob());
|
145 |
|
|
d->setChi2(fit.chisq());
|
146 |
|
|
d->setNdof(fit.ndof());
|
147 |
|
|
|
148 |
|
|
FourVector p4Fitted(0.,0.,0.,0.);
|
149 |
|
|
p4Fitted += fit.getTrackP4(1);
|
150 |
|
|
p4Fitted += fit.getTrackP4(2);
|
151 |
|
|
d->setFourMomentum(p4Fitted);
|
152 |
paus |
1.10 |
d->setPosition (fit.getVertex (MultiVertexFitterD::VERTEX_1));
|
153 |
|
|
d->setError (fit.getErrorMatrix(MultiVertexFitterD::VERTEX_1));
|
154 |
bendavid |
1.5 |
float mass, massErr;
|
155 |
|
|
const int trksIds[2] = { 1, 2 };
|
156 |
|
|
mass = fit.getMass(2,trksIds,massErr);
|
157 |
|
|
|
158 |
|
|
ThreeVector p3Fitted(p4Fitted.px(), p4Fitted.py(), p4Fitted.pz());
|
159 |
|
|
|
160 |
|
|
//Get decay length in xy plane
|
161 |
|
|
float dl, dlErr;
|
162 |
paus |
1.10 |
dl = fit.getDecayLength (MultiVertexFitterD::PRIMARY_VERTEX, MultiVertexFitterD::VERTEX_1,
|
163 |
|
|
p3Fitted, dlErr);
|
164 |
bendavid |
1.5 |
|
165 |
|
|
//Get Z decay length
|
166 |
|
|
float dlz, dlzErr;
|
167 |
paus |
1.10 |
dlz = fit.getZDecayLength(MultiVertexFitterD::PRIMARY_VERTEX, MultiVertexFitterD::VERTEX_1,
|
168 |
|
|
p3Fitted, dlzErr);
|
169 |
bendavid |
1.5 |
|
170 |
|
|
//get impact parameter
|
171 |
|
|
float dxy, dxyErr;
|
172 |
paus |
1.10 |
dxy = fit.getImpactPar (MultiVertexFitterD::PRIMARY_VERTEX, MultiVertexFitterD::VERTEX_1,
|
173 |
|
|
p3Fitted, dxyErr);
|
174 |
bendavid |
1.5 |
|
175 |
bendavid |
1.8 |
BasePartPtr ptr1(hStables1,i);
|
176 |
|
|
BasePartPtr ptr2(hStables2,j);
|
177 |
|
|
|
178 |
paus |
1.10 |
StableData c1(fit.getTrackP4(1).px(),fit.getTrackP4(1).py(), fit.getTrackP4(1).pz(), ptr1);
|
179 |
|
|
StableData c2(fit.getTrackP4(2).px(),fit.getTrackP4(2).py(), fit.getTrackP4(2).pz(), ptr2);
|
180 |
bendavid |
1.8 |
|
181 |
paus |
1.10 |
const ThreeVector vtxPos = fit.getVertex(MultiVertexFitterD::VERTEX_1);
|
182 |
|
|
const ThreeVector trkMom1(fit.getTrackP4(1).px(),fit.getTrackP4(1).py(),
|
183 |
|
|
fit.getTrackP4(1).pz());
|
184 |
|
|
const ThreeVector trkMom2(fit.getTrackP4(2).px(),fit.getTrackP4(2).py(),
|
185 |
|
|
fit.getTrackP4(2).pz());
|
186 |
bendavid |
1.8 |
|
187 |
|
|
//build corrected HitPattern for StableData, removing hits before the fit vertex
|
188 |
bendavid |
1.11 |
if (useHitDropper_) {
|
189 |
loizides |
1.12 |
reco::HitPattern hits1 = dropper->CorrectedHits(s1.track(),
|
190 |
|
|
vtxPos,
|
191 |
|
|
trkMom1,
|
192 |
|
|
dlErr,
|
193 |
|
|
dlzErr);
|
194 |
|
|
reco::HitPattern hits2 = dropper->CorrectedHits(s2.track(),
|
195 |
|
|
vtxPos,
|
196 |
|
|
trkMom2,
|
197 |
|
|
dlErr,
|
198 |
|
|
dlzErr);
|
199 |
bendavid |
1.11 |
|
200 |
|
|
c1.SetHits(hits1);
|
201 |
|
|
c2.SetHits(hits2);
|
202 |
|
|
c1.SetHitsFilled();
|
203 |
|
|
c2.SetHitsFilled();
|
204 |
|
|
}
|
205 |
bendavid |
1.8 |
|
206 |
paus |
1.10 |
d->addStableChild (c1);
|
207 |
|
|
d->addStableChild (c2);
|
208 |
|
|
d->setFittedMass (mass);
|
209 |
bendavid |
1.5 |
d->setFittedMassError(massErr);
|
210 |
paus |
1.10 |
d->setLxy (dl);
|
211 |
|
|
d->setLxyError (dlErr);
|
212 |
|
|
d->setLxyToPv (dl);
|
213 |
|
|
d->setLxyToPvError (dlErr);
|
214 |
|
|
d->setLz (dlz);
|
215 |
|
|
d->setLzError (dlzErr);
|
216 |
|
|
d->setLzToPv (dlz);
|
217 |
|
|
d->setLzToPvError (dlzErr);
|
218 |
|
|
d->setDxy (dxy);
|
219 |
|
|
d->setDxyError (dxyErr);
|
220 |
|
|
d->setDxyToPv (dxy);
|
221 |
|
|
d->setDxyToPvError (dxyErr);
|
222 |
|
|
|
223 |
loizides |
1.12 |
// put the result into our collection
|
224 |
mrudolph |
1.3 |
pD->push_back(*d);
|
225 |
loizides |
1.13 |
delete d;
|
226 |
mrudolph |
1.3 |
} //done processing fit
|
227 |
loizides |
1.7 |
} //end j loop
|
228 |
mrudolph |
1.3 |
} //end i loop
|
229 |
|
|
|
230 |
|
|
// -----------------------------------------------------------------------------------------------
|
231 |
|
|
// Write the collection even if it is empty
|
232 |
|
|
// -----------------------------------------------------------------------------------------------
|
233 |
loizides |
1.7 |
if (0)
|
234 |
|
|
cout << " V2SS::produce - " << pD->size() << " entries collection created -"
|
235 |
|
|
<< " (Pid: " << oPid_ << ")\n";
|
236 |
mrudolph |
1.3 |
evt.put(pD);
|
237 |
|
|
}
|
238 |
|
|
|
239 |
loizides |
1.12 |
// define this as a plug-in
|
240 |
mrudolph |
1.3 |
DEFINE_FWK_MODULE(ProducerV2SS);
|