ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitConversions/Mods/src/ConversionRemoval.cc
Revision: 1.2
Committed: Thu Dec 17 02:05:17 2009 UTC (15 years, 4 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +6 -1 lines
Error occurred while calculating annotation data.
Log Message:
Added sim rz plot

File Contents

# Content
1 // $Id: ConversionRemoval.cc,v 1.1 2009/12/16 18:10:38 bendavid Exp $
2 #include <TH1.h>
3 #include <TH1F.h>
4 #include <TH2F.h>
5 #include <TCanvas.h>
6
7 #include "MitConversions/Mods/interface/ConversionRemoval.h"
8 #include "MitAna/DataTree/interface/Electron.h"
9 #include "MitAna/DataTree/interface/Track.h"
10 #include "MitAna/DataCont/interface/ObjArray.h"
11 #include "MitAna/DataTree/interface/Names.h"
12 #include "MitCommon/MathTools/interface/MathUtils.h"
13
14 using namespace mithep;
15
16 ClassImp(mithep::ConversionRemoval)
17
18 //__________________________________________________________________________________________________
19 ConversionRemoval::ConversionRemoval(const char *name, const char *title) :
20 BaseMod (name,title),
21 fPtMin (0),
22 fEtaMax (0),
23 fProbMin (0),
24 fNHitsMin(0),
25 fNStereoHitsMin(0),
26 fNPixelHitsMin(0),
27 fExcludePXB1(false),
28 fMassMax(0),
29 fMissedHitsMax(0),
30 fWrongHitsMax(0),
31 fElectronPtMin(0),
32 fElectronEtaMax(0),
33 fComputeEff(kFALSE),
34 fHitBasedMatching(kFALSE),
35 fRequireCleanElectron(kFALSE),
36 fTrackQualityFirstOnly(kFALSE),
37 fMatchWe(kFALSE),
38 fMatchSimConv(kFALSE),
39 fRequireGoodPv(kFALSE),
40 fMaxTrackDzPv(999.99),
41 fMinClusterVtxQual(0.0),
42 fMaxNSharedHits(999),
43 fMinNSharedHits(0),
44 fTracks (0),
45 fGsfTracks (0),
46 fInOutTracks (0),
47 fOutInTracks (0),
48 fElectrons (0),
49 fTrkElectrons(0),
50 fPhotons (0),
51 fMCParticles (0),
52 fMvfConversions (0),
53 fMvfConversionsUnconstrained (0),
54 fPrimaryVertexes(0),
55 fEvtSel(0),
56 fCleanElectrons(0),
57 fMCPartName (Names::gkMCPartBrn),
58 fTrackName (Names::gkTrackBrn),
59 fConvElectronName ("Electrons"),
60 fPhotonName (Names::gkPhotonBrn),
61 fMvfConvName("ConversionRemoval"),
62 fMvfConvUnconstrainedName("ConversionRemovalUnconstrained"),
63 fElectronName(Names::gkElectronBrn),
64 fTrkElectronName("TrackerElectrons"),
65 fGoodElectronsName("ConversionElectrons"),
66 fGoodTwoClusterElectronsName("TwoClusterConversionElectrons"),
67 fBadElectronsName("ConversionRemovedElectrons"),
68 fFakingConversionsName("fakingConversions"),
69 fRemovedElectronsName("removedElectrons"),
70 fAllConversionElectronsName("allConversionElectrons"),
71 hConversionRadius (0),
72 hConversionRadiusBarrel(0),
73 hConversionZ(0),
74 hConversionRPhi (0),
75 hConversionRZ(0),
76 hConversionFoldedRZ(0),
77 hGammaPt (0),
78 hGammaEta (0),
79 hGammaPhi(0),
80 hGammaMass (0),
81 hSimMatchedGammaMass(0),
82 hConvProb (0),
83 hConvChi2 (0),
84 hSimMatchedConvChi2(0),
85 hConvDCotTheta (0),
86 hConvDCotThetaPreCut (0),
87 hConvEOverP (0),
88 hElectronPt (0),
89 hMinElectronPt (0),
90 hSimMinElectronPt (0),
91 hSimMatchedMinElectronPt (0),
92 hSimMatchedMinElectronSimPt (0),
93 hElectronEta (0),
94 hEPairMass (0),
95 hEPairDeltaPhi (0),
96 hGenNumDaughters (0),
97 hGenDaughterPt (0),
98 hGenDecayRadius (0),
99 hSimPt (0),
100 hSimEta(0),
101 hSimConvRadius (0),
102 hSimConvPosition(0),
103 hSimConversionRZ(0),
104 hTrackSimMatchType (0),
105 hParentSimMatchType (0),
106 hSimMatchedConvRadius (0),
107 hSimMatchedConvProb (0),
108 hSimMatchedEPairMass (0),
109 hSimMatchedEPairDeltaPhi (0),
110 hSimMatchedSimConvRadius (0),
111 hSimMatchedConvResolution (0),
112 hSimMatchedConvPhiRes (0),
113 hSimMatchedConvEOverP (0),
114 hSimMatchedElectronPt (0),
115 hSimMatchedGammaPt (0),
116 hSimMatchedGammaEta (0),
117 hSimMatchedSimGammaPt (0),
118 hSimMatchedSimGammaEta (0),
119 hTrackChi2 (0),
120 hTrackProb (0),
121 hTrackNHits (0),
122 hTrackNWrongHits(0),
123 hTrackNMissingHits(0),
124 hNSharedHits(0),
125 hTrackNHitsProb (0),
126 hTrackD0 (0),
127 hTrackDzPv(0),
128 hUnMatchedTrackChi2 (0),
129 hUnMatchedTrackProb (0),
130 hUnMatchedTrackNHits (0),
131 hUnMatchedTrackNHitsProb (0),
132 hUnMatchedTrackD0 (0),
133 hSimMatchedTrackChi2 (0),
134 hSimMatchedTrackProb (0),
135 hSimMatchedTrackNHits (0),
136 hSimMatchedTrackNHitsProb (0),
137 hSimMatchedTrackD0 (0),
138 hLxy(0),
139 hLxyOverLxyErr(0),
140 hLz(0),
141 hLzOverLzErr(0),
142 hDxy(0),
143 hSimMatchedLxy(0),
144 hSimMatchedLz(0),
145 hSimMatchedDxy(0),
146 hNTracks(0),
147 hSimMatchedNTracks(0),
148 hIsolation(0),
149 hSimMatchedIsolation(0),
150 hNConversions(0),
151 hDoubleConvMass(0),
152 hConvGammaMass(0),
153 hPiPiMass(0),
154 hAllConversionElectronChargeAssign(0),
155 hRemovedElectronChargeAssign(0),
156 hTrackAlgo(0),
157 hCharge(0),
158 hPt1Pt2(0),
159 hClusVtxDiff(0),
160 hClusVtxQual(0)
161 {
162 // Constructor.
163 }
164
165 //__________________________________________________________________________________________________
166 void ConversionRemoval::Begin()
167 {
168 // Run startup code on the client machine. For this module, we dont do anything here.
169 }
170
171 //__________________________________________________________________________________________________
172 void ConversionRemoval::SlaveBegin()
173 {
174 // Run startup code on the computer (slave) doing the actual analysis. Here, we typically
175 // initialize histograms and other analysis objects and request branches. For this module, we
176 // request a branch of the MitTree.
177
178 // Request the branches
179 ReqBranch(fTrackName, fTracks);
180 ReqBranch("ConversionInOutTracks", fInOutTracks);
181 ReqBranch("ConversionOutInTracks", fOutInTracks);
182 //ReqBranch(fElectronName, fElectrons);
183 //ReqBranch(fTrkElectronName, fTrkElectrons);
184 ReqBranch(fPhotonName, fPhotons);
185 ReqBranch(fMCPartName, fMCParticles);
186 ReqBranch(fMvfConvName, fMvfConversions);
187 ReqBranch(fMvfConvUnconstrainedName, fMvfConversionsUnconstrained);
188 ReqBranch("PrimaryVertexes",fPrimaryVertexes);
189 ReqBranch("EvtSelData",fEvtSel);
190
191 // Book our histograms
192
193 hConversionRPhi = new TH2F("Photon Conversion Position R-Phi","Conversion Position R-Phi (cm)", 100, -100.0,100.0,100,-100.0,100.0);
194 AddOutput(hConversionRPhi);
195
196 hConversionRZ = new TH2F("Photon Conversion Position R-Z","Conversion Position R-Z (cm)", 1000, -100.0,100.0,1000,-100.0,100.0);
197 AddOutput(hConversionRZ);
198
199 hConversionFoldedRZ = new TH2F("hConversionFoldedRZ","Conversion Position R-Z (cm)", 1000, -100.0,100.0,500,-0.0,100.0);
200 AddOutput(hConversionFoldedRZ);
201
202 hSimConvPosition = new TH2F("Sim Photon Conversion Position","Sim Photon Conversion Position", 200, -200.0,200.0,200,-200.0,200.0);
203 AddOutput(hSimConvPosition);
204
205
206 //TH1::SetDefaultSumw2(kTRUE);
207
208 hConversionRadius = new TH1F("Photon Conversion Radius","Radius (cm)",800,0,200.0);
209 AddOutput(hConversionRadius);
210
211 hConversionRadiusBarrel = new TH1F("hConversionRadiusBarrel","Radius (cm)",800,0,200.0);
212 AddOutput(hConversionRadiusBarrel);
213
214 hConversionZ = new TH1F("Photon Conversion Z position", "Conversion Z position (cm)", 200, -200.0, 200.0);
215 AddOutput(hConversionZ);
216
217 hGammaPt = new TH1F("Photon Pt","Photon Pt (GeV)",400,0,200.0);
218 AddOutput(hGammaPt);
219
220 hGammaEta = new TH1F("Photon Eta","Photon Eta",200,-5.0,5.0);
221 AddOutput(hGammaEta);
222
223 hGammaPhi = new TH1F("hGammaPhi","Photon Phi",200,-1.0*TMath::Pi(),1.0*TMath::Pi());
224 AddOutput(hGammaPhi);
225
226
227 hGammaMass = new TH1F("Photon Invariant Mass","Photon Invariant Mass",200,0,2.0);
228 AddOutput(hGammaMass);
229
230 hSimMatchedGammaMass = new TH1F("SimMatched Photon Invariant Mass","SimMatched Photon Invariant Mass",200,0,20.0);
231 AddOutput(hSimMatchedGammaMass);
232
233 hConvProb = new TH1F("Conversion Vertex fit probability", "Vertex Fit Probability",200,0.0,1.0);
234 AddOutput(hConvProb);
235
236 hConvChi2 = new TH1F("Conversion Vertex fit Chi squared", "Vertex Fit Chi Squared",2000,0.0,100.0);
237 AddOutput(hConvChi2);
238
239 hSimMatchedConvChi2 = new TH1F("Sim Matched Conversion Vertex fit Chi squared", "Sim Matched Vertex Fit Chi Squared",2000,0.0,100.0);
240 AddOutput(hSimMatchedConvChi2);
241
242 hConvDCotTheta = new TH1F("Conversion DCotTheta", "DCotTheta",10001,-10.0,10.0);
243 AddOutput(hConvDCotTheta);
244
245 hConvDCotThetaPreCut = new TH1F("Conversion DCotTheta before fit prob cut", "DCotThetaPreCut",1000,-10.0,10.0);
246 AddOutput(hConvDCotThetaPreCut);
247
248 hConvEOverP = new TH1F("Conversion E over P", "Conversion E over P",200,0.0,50.0);
249 AddOutput(hConvEOverP);
250
251 hElectronPt = new TH1F("Electron Pt","Electron Pt (GeV)",400,0,200.0);
252 AddOutput(hElectronPt);
253
254 hMinElectronPt = new TH1F("Min Electron Pt","Min Electron Pt (GeV)",2000,0,200.0);
255 AddOutput(hMinElectronPt);
256
257 hSimMatchedMinElectronPt = new TH1F("Sim Matched Min Electron Pt","Sim Matched Min Electron Pt (GeV)",2000,0,200.0);
258 AddOutput(hSimMatchedMinElectronPt);
259
260 hSimMatchedMinElectronSimPt = new TH1F("Sim Matched Min Electron Sim Pt","Sim Matched Min Electron Sim Pt (GeV)",2000,0,200.0);
261 AddOutput(hSimMatchedMinElectronSimPt);
262
263 hSimMinElectronPt = new TH1F("Sim Min Electron Pt","Sim Min Electron Pt (GeV)",2000,0,200.0);
264 AddOutput(hSimMinElectronPt);
265
266 hElectronEta = new TH1F("Electron Eta","Electron Eta",200,-5.0,5.0);
267 AddOutput(hElectronEta);
268
269 hEPairMass = new TH1F("Electron Pair Invariant Mass","Electron Pair Invariant Mass",200,0.0,10);
270 AddOutput(hEPairMass);
271
272 hEPairDeltaPhi = new TH1F("Electron Pair Delta Phi","Electron Pair Delta Phi",200,-4.0,4.0);
273 AddOutput(hEPairDeltaPhi);
274
275 hGenNumDaughters = new TH1F("Number of Decay daughters - gen level","Number of Decay daughters - gen level",10,-0.5,9.5);
276 AddOutput(hGenNumDaughters);
277
278 hGenDaughterPt = new TH1F("Pt of decay daugthers - gen level","Pt of decay daugthers - gen level",2000,0,200.0);
279 AddOutput(hGenDaughterPt);
280
281 hGenDecayRadius = new TH1F("Decay vertex radius - gen level","Decay vertex radius - gen level",800,0,200.0);
282 AddOutput(hGenDecayRadius);
283
284 hSimPt = new TH1F("Pt - sim level","Pt - sim level",2000,0,200.0);
285 AddOutput(hSimPt);
286
287 hSimEta = new TH1F("Sim Photon Eta","Photon Eta",200,-5.0,5.0);
288 AddOutput(hSimEta);
289
290 hSimConvRadius = new TH1F("Sim Photon Conversion Radius","Sim Photon Conversion Radius",800,0,200.0);
291 AddOutput(hSimConvRadius);
292
293 hSimConversionRZ = new TH2F("hSimConversionRZ","hSimConversionRZ", 1000, -100.0,100.0,1000,-100.0,100.0);
294 AddOutput(hSimConversionRZ);
295
296 // hTrackD0 = new TH1F("general track D0","general track D0",2000,0,200.0);
297 // AddOutput(hTrackD0);
298
299 hTrackSimMatchType = new TH1F("Conversion Electron matched sim pdg","Conversion Electron matched sim pdg",10001,-5000.5,5000.5);
300 AddOutput(hTrackSimMatchType);
301
302 hParentSimMatchType = new TH1F("Conversion Parent matched sim pdg","Conversion Parent matched sim pdg",10001,-5000.5,5000.5);
303 AddOutput(hParentSimMatchType);
304
305 hSimMatchedConvRadius = new TH1F("Sim Matched Photon Conversion Radius","Sim Matched Photon Conversion Radius",800,0,200.0);
306 AddOutput(hSimMatchedConvRadius);
307
308 hSimMatchedConvProb = new TH1F("Sim Matched Conversion Vertex fit probability", "Sim Matched Vertex Fit Probability",200,0.0,1.0);
309 AddOutput(hSimMatchedConvProb);
310
311 hSimMatchedEPairMass = new TH1F("Sim Matched Electron Pair Invariant Mass","Sim Matched Electron Pair Invariant Mass",200,0.0,10);
312 AddOutput(hSimMatchedEPairMass);
313
314 hSimMatchedEPairDeltaPhi = new TH1F("Sim Matched Electron Pair Delta Phi","Sim Matched Electron Pair Delta Phi",200,-4.0,4.0);
315 AddOutput(hSimMatchedEPairDeltaPhi);
316
317 hSimMatchedSimConvRadius = new TH1F("Sim Matched Photon Sim Conversion Radius","Sim Matched Photon Conversion Sim Radius",800,0,200.0);
318 AddOutput(hSimMatchedSimConvRadius);
319
320 hSimMatchedConvResolution = new TH1F("Sim Matched Photon Conversion Radius Resolution","Sim Matched Photon Conversion Radius Resolution",300,-30.0,30.0);
321 AddOutput(hSimMatchedConvResolution);
322
323 hSimMatchedConvPhiRes = new TH1F("Sim Matched Photon Conversion Phi Resolution","Sim Matched Photon Conversion Phi Resolution",1000,-3.5,3.5);
324 AddOutput(hSimMatchedConvPhiRes);
325
326 hSimMatchedConvEOverP = new TH1F("Sim Matched Conversion E over P", "Sim Matched Conversion E over P",200,0.0,50.0);
327 AddOutput(hSimMatchedConvEOverP);
328
329 hSimMatchedElectronPt = new TH1F("Sim Matched Electron Pt","Sim Matched Electron Pt (GeV)",2000,0,200.0);
330 AddOutput(hSimMatchedElectronPt);
331
332 hSimMatchedGammaPt = new TH1F("Sim Matched Photon Pt","Sim Matched Photon Pt (GeV)",2000,0,200.0);
333 AddOutput(hSimMatchedGammaPt);
334
335 hSimMatchedGammaEta = new TH1F("Sim Matched Photon Eta","Sim Matched Photon Eta",200,-5.0,5.0);
336 AddOutput(hSimMatchedGammaEta);
337
338 hSimMatchedSimGammaPt = new TH1F("Sim Matched Sim Photon Pt","Sim Matched Sim Photon Pt (GeV)",2000,0,200.0);
339 AddOutput(hSimMatchedSimGammaPt);
340
341 hSimMatchedSimGammaEta = new TH1F("Sim Matched Sim Photon Eta","Sim Matched Sim Photon Eta",200,-5.0,5.0);
342 AddOutput(hSimMatchedSimGammaEta);
343
344 hTrackChi2 = new TH1F("Conversion Track RChi squared", "Track RChi Squared",200,0.0,10.0);
345 AddOutput(hTrackChi2);
346
347 hTrackProb = new TH1F("Conversion Track fit probability", "Track Fit Probability",200,0.0,1.0);
348 AddOutput(hTrackProb);
349
350 hTrackNHits = new TH1F("Conversion Track NHits", "Track NHits",37,-0.5,36.5);
351 AddOutput(hTrackNHits);
352
353 hTrackNMissingHits = new TH1F("hTrackNMissingHits", "Track NMissingHits",37,-0.5,36.5);
354 AddOutput(hTrackNMissingHits);
355
356 hTrackNWrongHits = new TH1F("hTrackNWrongHits", "Track NWrongHits",37,-0.5,36.5);
357 AddOutput(hTrackNWrongHits);
358
359 hNSharedHits = new TH1F("hNSharedHits", "hNSharedHits",37,-0.5,36.5);
360 AddOutput(hNSharedHits);
361
362 hTrackNHitsProb = new TH2F("Track NHits-RChi2","Track NHits-RChi2", 37,-0.5,36.5,50,0.0,10.0);
363 AddOutput(hTrackNHitsProb);
364
365 hTrackD0 = new TH1F("Conversion track D0","Conversion track D0",100,-5.0,5.0);
366 AddOutput(hTrackD0);
367
368 hTrackDzPv = new TH1F("hTrackDzPv","Conversion track DZ wrt PV",100,-20.0,20.0);
369 AddOutput(hTrackDzPv);
370
371 hUnMatchedTrackChi2 = new TH1F("UnMatched Conversion Track RChi squared", "UnMatched Track RChi Squared",200,0.0,10.0);
372 AddOutput(hUnMatchedTrackChi2);
373
374 hUnMatchedTrackProb = new TH1F("UnMatched Conversion Track fit probability", "UnMatched Track Fit Probability",200,0.0,1.0);
375 AddOutput(hUnMatchedTrackProb);
376
377 hUnMatchedTrackNHits = new TH1F("UnMatched Conversion Track NHits", "UnMatched Track NHits",37,-0.5,36.5);
378 AddOutput(hUnMatchedTrackNHits);
379
380 hUnMatchedTrackNHitsProb = new TH2F("UnMatched Track NHits-RChi2","UnMatched Track NHits-RChi2", 37,-0.5,36.5,50,0.0,10.0);
381 AddOutput(hUnMatchedTrackNHitsProb);
382
383 hUnMatchedTrackD0 = new TH1F("UnMatched Conversion track D0","UnMatched Conversion track D0",100,-5.0,5.0);
384 AddOutput(hUnMatchedTrackD0);
385
386 hSimMatchedTrackChi2 = new TH1F("SimMatched Conversion Track RChi squared", "SimMatched Track RChi Squared",200,0.0,10.0);
387 AddOutput(hSimMatchedTrackChi2);
388
389 hSimMatchedTrackProb = new TH1F("SimMatched Conversion Track fit probability", "SimMatched Track Fit Probability",200,0.0,1.0);
390 AddOutput(hSimMatchedTrackProb);
391
392 hSimMatchedTrackNHits = new TH1F("SimMatched Conversion Track NHits", "SimMatched Track NHits",37,-0.5,36.5);
393 AddOutput(hSimMatchedTrackNHits);
394
395 hSimMatchedTrackNHitsProb = new TH2F("SimMatched Track NHits-RChi2","SimMatched Track NHits-RChi2", 37,-0.5,36.5,50,0.0,10.0);
396 AddOutput(hSimMatchedTrackNHitsProb);
397
398 hSimMatchedTrackD0 = new TH1F("SimMatched Conversion track D0","SimMatched Conversion track D0",100,-5.0,5.0);
399 AddOutput(hSimMatchedTrackD0);
400
401 hLxy = new TH1F("Conversion Lxy","Conversion Lxy",240,-30.0,30.0);
402 AddOutput(hLxy);
403
404 hLxyOverLxyErr = new TH1F("Conversion Lxy/LxyErr","Conversion Lxy/LxyErr",200,-100.0,100.0);
405 AddOutput(hLxyOverLxyErr);
406
407 hLz = new TH1F("Conversion Lz","Conversion Lz",200,-50.0,50.0);
408 AddOutput(hLz);
409
410 hLzOverLzErr = new TH1F("Conversion Lz/LzErr","Conversion Lz/LzErr",200,-100.0,100.0);
411 AddOutput(hLzOverLzErr);
412
413 hDxy = new TH1F("Conversion Dxy","Conversion Dxy",200,-5.0,5.0);
414 AddOutput(hDxy);
415
416 hSimMatchedLxy = new TH1F("SimMatched Conversion Lxy","SimMatched Conversion Lxy",100,-30.0,30.0);
417 AddOutput(hSimMatchedLxy);
418
419 hSimMatchedLz = new TH1F("SimMatched Conversion Lz","SimMatched Conversion Lz",200,-50.0,50.0);
420 AddOutput(hSimMatchedLz);
421
422 hSimMatchedDxy = new TH1F("SimMatched Conversion Dxy","SimMatched Conversion Dxy",200,-5.0,5.0);
423 AddOutput(hSimMatchedDxy);
424
425 hNTracks = new TH1F("Number of Tracks in the event", "Number of tracks in the event", 401, -0.5,400.5);
426 AddOutput(hNTracks);
427
428 hSimMatchedNTracks = new TH1F("SimMatched Number of Tracks in the event", "SimMatched Number of tracks in the event", 401, -0.5,400.5);
429 AddOutput(hSimMatchedNTracks);
430
431 hIsolation = new TH1F("Track Isolation of Conversion", "Track Isolation of Conversion", 201, -0.5,200.5);
432 AddOutput(hIsolation);
433
434 hSimMatchedIsolation = new TH1F("SimMatched Track Isolation of Conversion", "SimMatched Track Isolation of Conversion", 201, -0.5,200.5);
435 AddOutput(hSimMatchedIsolation);
436
437 hNConversions = new TH1F("Number of Conversions", "Number of Conversions",10,-0.5,10.5);
438 AddOutput(hNConversions);
439
440 hDoubleConvMass = new TH1F("Double Conversion Mass", "Double Conversion Mass", 1000, 0.0, 10.0);
441 AddOutput(hDoubleConvMass);
442
443 hConvGammaMass = new TH1F("Conversion plus Photon Mass", "Conversion plus Photon Mass", 1000, 0.0, 10.0);
444 AddOutput(hConvGammaMass);
445
446 hPiPiMass = new TH1F("Conversion two pion Mass", "Conversion two pion Mass", 1000,0.0,10.0);
447 AddOutput(hPiPiMass);
448
449 hAllConversionElectronPt = new TH1F("hAllConversionElectronPt","Electron Pt (GeV)",2000,0,200.0);
450 AddOutput(hAllConversionElectronPt);
451
452 hAllConversionElectronEta = new TH1F("hAllConversionElectronEta","Electron Eta",200,-5.0,5.0);
453 AddOutput(hAllConversionElectronEta);
454
455 hRemovedElectronPt = new TH1F("hRemovedElectronPt","Electron Pt (GeV)",2000,0,200.0);
456 AddOutput(hRemovedElectronPt);
457
458 hRemovedElectronEta = new TH1F("hRemovedElectronEta","Electron Eta",200,-5.0,5.0);
459 AddOutput(hRemovedElectronEta);
460
461 hAllConversionElectronPtWrongCharge = new TH1F("hAllConversionElectronPtWrongCharge","Electron Pt (GeV)",2000,0,200.0);
462 AddOutput(hAllConversionElectronPtWrongCharge);
463
464 hAllConversionElectronEtaWrongCharge = new TH1F("hAllConversionElectronEtaWrongCharge","Electron Eta",200,-5.0,5.0);
465 AddOutput(hAllConversionElectronEtaWrongCharge);
466
467 hRemovedElectronPtWrongCharge = new TH1F("hRemovedElectronPtWrongCharge","Electron Pt (GeV)",2000,0,200.0);
468 AddOutput(hRemovedElectronPtWrongCharge);
469
470 hRemovedElectronEtaWrongCharge = new TH1F("hRemovedElectronEtaWrongCharge","Electron Eta",200,-5.0,5.0);
471 AddOutput(hRemovedElectronEtaWrongCharge);
472
473 hAllConversionElectronChargeAssign = new TH1F("hAllConversionElectronChargeAssign","Electron Charge Assignment",3.0,-1.5,1.5);
474 AddOutput(hAllConversionElectronChargeAssign);
475
476 hRemovedElectronChargeAssign = new TH1F("hRemovedElectronChargeAssign","Electron Charge Assignment",3.0,-1.5,1.5);
477 AddOutput(hRemovedElectronChargeAssign);
478
479 hTrackAlgo = new TH1F("hTrackAlgo","Conversion Track Algorithm",101,-0.5,100.5);
480 AddOutput(hTrackAlgo);
481
482 hCharge = new TH1F("hCharge","Candidate Charge",5.0,-2.5,2.5);
483 AddOutput(hCharge);
484
485 hPt1Pt2 = new TH2F("hPt1Pt2","Pt1 vs Pt2", 500,0,10.0,500,0.0,10.0);
486 AddOutput(hPt1Pt2);
487
488 hClusVtxDiff = new TH1F("hClusVtxDiff","hClusVtxDiff",201,-0.5,200.5);
489 AddOutput(hClusVtxDiff);
490
491 hClusVtxQual = new TH1F("hClusVtxQual","hClusVtxQual",200,0.0,20);
492 AddOutput(hClusVtxQual);
493
494 fTimer.Start(1e8);
495
496 }
497
498 //__________________________________________________________________________________________________
499 void ConversionRemoval::Process()
500 {
501 // Process entries of the tree. For this module, we just load the branch and fill the histograms.
502 // --> Why is this done on the basis of the name? should be the pointer!
503
504 // BitMask64 testMask;
505 // testMask.SetBit(Track::TIB1S);
506 // testMask.SetBit(Track::TIB2S);
507 // testMask.SetBit(Track::TID1S);
508 // testMask.SetBit(Track::TID2S);
509 // testMask.SetBit(Track::TID3S);
510 // testMask.SetBit(Track::TOB1S);
511 // testMask.SetBit(Track::TOB2S);
512 // testMask.SetBit(Track::TEC1S);
513 // testMask.SetBit(Track::TEC2S);
514 // testMask.SetBit(Track::TEC3S);
515 // testMask.SetBit(Track::TEC4S);
516 // testMask.SetBit(Track::TEC5S);
517 // testMask.SetBit(Track::TEC6S);
518 // testMask.SetBit(Track::TEC7S);
519 // testMask.SetBit(Track::TEC8S);
520 // testMask.SetBit(Track::TEC9S);
521 //
522 // const Long64_t *maskVal = reinterpret_cast<const Long64_t*>(testMask.Bits());
523 //
524 // printf("HitMaskVal = %lli\n",*maskVal);
525 //
526 // Track testTrack;
527 // if (testMask == testTrack.StereoLayers())
528 // printf("stereo mask match\n");
529 // else
530 // printf("stereo mask mismatch\n");
531 //
532
533 LoadBranch(fTrackName);
534 LoadBranch("PrimaryVertexes");
535 LoadBranch("EvtSelData");
536
537 fCleanElectrons = GetObjThisEvt<ElectronCol>(fCleanElectronsName);
538 ObjArray<Electron> *allConversionElectrons = new ObjArray<Electron>;
539 AddObjThisEvt(allConversionElectrons,fAllConversionElectronsName);
540
541 //printf("first loop\n")
542 if (fComputeEff && (!fRequireCleanElectron || fCleanElectrons->GetEntries())) {
543 LoadBranch(fMCPartName);
544 for (UInt_t i=0; i<fCleanElectrons->GetEntries(); ++i) {
545 const Electron *e = fCleanElectrons->At(i);
546 if ( !fMatchSimConv && fMatchWe && SimWeMatch(e) )
547 allConversionElectrons->Add(e);
548 else if (fMatchSimConv && !fMatchWe && SimConversionMatch(e))
549 allConversionElectrons->Add(e);
550 else if (!fMatchSimConv && !fMatchWe)
551 allConversionElectrons->Add(e);
552 }
553
554 for (UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
555 const MCParticle* p = fMCParticles->At(i);
556 const BitMask16 simFailed = FailedSimCuts(p);
557
558 BitMask16 simPtFailed = simFailed;
559 simPtFailed.ClearBit(eSimPt);
560 if (!simPtFailed.NBitsSet())
561 hSimPt->Fill(p->Pt());
562
563 BitMask16 simEtaFailed = simFailed;
564 simEtaFailed.ClearBit(eSimEta);
565 if (!simEtaFailed.NBitsSet())
566 hSimEta->Fill(p->Eta());
567
568 BitMask16 simRhoFailed = simFailed;
569 simRhoFailed.ClearBit(eSimRho);
570 if ( !simRhoFailed.NBitsSet() ) {
571 hSimConvRadius->Fill(p->DecayVertex().Rho());
572 hSimConvPosition->Fill(p->DecayVertex().X(),p->DecayVertex().Y());
573 hSimConversionRZ->Fill(p->DecayVertex().Z(),p->DecayVertex().Y()*p->DecayVertex().Rho()/TMath::Abs(p->DecayVertex().Y()));
574 }
575 Double_t minPt=999;
576 for (UInt_t j=0; j<p->NDaughters(); ++j) {
577 const MCParticle *d = p->Daughter(j);
578 if (TMath::Abs(d->PdgId())==11) {
579 if (d->Pt()<minPt)
580 minPt = d->Pt();
581 }
582 }
583
584 BitMask16 simElectronPtFailed = simFailed;
585 simElectronPtFailed.ClearBit(eSimElectronPt);
586 if ( !simElectronPtFailed.NBitsSet() )
587 hSimMinElectronPt->Fill(minPt);
588
589 }
590 }
591
592 //printf("second loop\n")
593 ObjArray<DecayParticle> *fakingConversions = new ObjArray<DecayParticle>;
594 AddObjThisEvt(fakingConversions,fFakingConversionsName);
595 if (!fRequireCleanElectron || allConversionElectrons->GetEntries()) {
596 LoadBranch(fMvfConvName);
597 for (UInt_t i=0; i<fMvfConversions->GetEntries(); ++i) {
598 const DecayParticle* d = fMvfConversions->At(i);
599 if (!fRequireCleanElectron || ElectronMatch(d,allConversionElectrons))
600 fakingConversions->Add(d);
601 }
602 }
603
604
605 //printf("third loop\n")
606 ObjArray<DecayParticle> goodConversions;
607 ObjArray<Electron> *removedElectrons = new ObjArray<Electron>;
608 AddObjThisEvt(removedElectrons,fRemovedElectronsName);
609 UInt_t nConversions = 0;
610 for (UInt_t i=0; i<fakingConversions->GetEntries(); ++i) {
611 //if (nConversions>=1) continue;
612 const DecayParticle* c = fakingConversions->At(i);
613 const BitMask16 failed = FailedCuts(c);
614
615 // printf("Looking for sim match\n");
616 const MCParticle *simPhoton = SimMatch(c);
617 UInt_t nSimFailed=0;
618 BitMask16 simFailed;
619 //printf("Checking sim cuts\n");
620 if (simPhoton)
621 simFailed = FailedSimCuts(simPhoton);
622
623 //make N-2 plots for decay length
624 BitMask16 decayLengthFailed = failed;
625 decayLengthFailed.ClearBit(eRho);
626 decayLengthFailed.ClearBit(eL);
627 if (!decayLengthFailed.NBitsSet()) {
628 hLxy->Fill(c->Lxy());
629 hLxyOverLxyErr->Fill(c->Lxy()/c->LxyError());
630 hLzOverLzErr->Fill(c->Lz()/c->LzError());
631 hLz->Fill(c->Lz());
632 if (simPhoton && !simFailed.NBitsSet()) {
633 hSimMatchedLxy->Fill(c->Lxy());
634 hSimMatchedLz->Fill(c->Lz());
635 }
636 }
637
638 //make N-1 plots
639 //printf("Make N-1 plots\n");
640
641 BitMask16 ptFailed = failed;
642 ptFailed.ClearBit(ePt);
643 if (!ptFailed.NBitsSet()) {
644 hGammaPt->Fill(c->Pt());
645 if (simPhoton) {
646 BitMask16 simPtFailed = simFailed;
647 simPtFailed.ClearBit(eSimPt);
648 if (!simPtFailed.NBitsSet()) {
649 hSimMatchedGammaPt->Fill(c->Pt());
650 hSimMatchedSimGammaPt->Fill(simPhoton->Pt());
651 }
652 }
653 }
654
655 BitMask16 etaFailed = failed;
656 etaFailed.ClearBit(eEta);
657 if (!etaFailed.NBitsSet()) {
658 hGammaEta->Fill(c->Eta());
659 if (simPhoton) {
660 BitMask16 simEtaFailed = simFailed;
661 simEtaFailed.ClearBit(eSimEta);
662 if (!simEtaFailed.NBitsSet()) {
663 hSimMatchedGammaEta->Fill(c->Eta());
664 hSimMatchedSimGammaEta->Fill(simPhoton->Eta());
665 }
666 }
667 }
668
669 BitMask16 rhoFailed = failed;
670 rhoFailed.ClearBit(eRho);
671 if ( !rhoFailed.NBitsSet() ) {
672 hConversionRadius->Fill(c->Position().Rho());
673 hConversionRPhi->Fill(c->Position().X(), c->Position().Y());
674 hConversionRZ->Fill(c->Position().Z(), c->Position().Rho()*c->Position().Y()/TMath::Abs(c->Position().Y()));
675 hConversionFoldedRZ->Fill(c->Position().Z(), c->Position().Rho());
676 if (c->AbsEta()<1.2)
677 hConversionRadiusBarrel->Fill(c->Position().Rho());
678 if (simPhoton) {
679 BitMask16 simRhoFailed = simFailed;
680 simRhoFailed.ClearBit(eSimRho);
681 if ( !simRhoFailed.NBitsSet() ) {
682 hSimMatchedConvRadius->Fill(c->Position().Rho());
683 hSimMatchedSimConvRadius->Fill(simPhoton->DecayVertex().Rho());
684 }
685 }
686 }
687
688 BitMask16 dxyFailed = failed;
689 dxyFailed.ClearBit(eDxy);
690 if ( !dxyFailed.NBitsSet() ) {
691 hDxy->Fill(c->Dxy());
692 if (simPhoton && !simFailed.NBitsSet() )
693 hSimMatchedDxy->Fill(c->Dxy());
694 }
695
696 BitMask16 probFailed = failed;
697 probFailed.ClearBit(eProb);
698 if (!probFailed.NBitsSet()) {
699 hConvProb->Fill(c->Prob());
700 hConvChi2->Fill(c->Chi2());
701 if (simPhoton && !simFailed.NBitsSet() )
702 hSimMatchedConvProb->Fill(c->Prob());
703 }
704
705 BitMask16 clusVtxFailed = failed;
706 clusVtxFailed.ClearBit(eClusVtx);
707 if (!clusVtxFailed.NBitsSet()) {
708 hClusVtxDiff->Fill(fEvtSel->ClusVtxDiff());
709 hClusVtxQual->Fill(fEvtSel->ClusVtxQual());
710 }
711
712 BitMask16 sharedHitsFailed = failed;
713 sharedHitsFailed.ClearBit(eSharedHits);
714 if (!sharedHitsFailed.NBitsSet()) {
715 hNSharedHits->Fill(c->NSharedHits());
716 }
717
718
719 //printf("Loop over daughters\n");
720
721 BitMask16 daughtersFailed = failed;
722 daughtersFailed.ClearBit(eDaughters);
723 if ( !daughtersFailed.NBitsSet() ) {
724 Double_t minElectronPt = c->Daughter(0)->Pt();
725 Double_t maxElectronPt = c->Daughter(1)->Pt();
726 if (c->Daughter(1)->Pt() < c->Daughter(0)->Pt()) {
727 minElectronPt = c->Daughter(1)->Pt();
728 maxElectronPt = c->Daughter(0)->Pt();
729 }
730
731 const Particle *minPtElectron = c->Daughter(0);
732 BitMask16 minPtElectronFailed;
733 for (UInt_t j=0; j<1; ++j) {
734 const DaughterData* d = c->DaughterDat(j);
735 const StableData *s = dynamic_cast<const StableData*>(d);
736 if (!s)
737 Fatal("FailedElectronCuts", "DaughterData not a StableData");
738
739 const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(c->Daughter(j));
740 if (!dc)
741 Fatal("FailedElectronCuts", "Daughter not a ChargedParticle");
742
743 const Track* t = dc->Trk();
744
745 const BitMask16 electronFailed = FailedElectronCuts(d);
746
747 if (d->Pt() < minElectronPt) {
748 minPtElectron = dc;
749 minPtElectronFailed = electronFailed;
750 }
751
752 BitMask16 failedEPt = electronFailed;
753 failedEPt.ClearBit(eEPt);
754 if (!failedEPt.NBitsSet())
755 hElectronPt->Fill(d->Pt());
756
757 BitMask16 failedEEta = electronFailed;
758 failedEEta.ClearBit(eEEta);
759 if (!failedEEta.NBitsSet())
760 hElectronEta->Fill(d->Eta());
761
762 BitMask16 failedENHits = electronFailed;
763 failedENHits.ClearBit(eENHits);
764 if (!failedENHits.NBitsSet()) {
765 hTrackNHits->Fill(t->NHits());
766 if (1 )
767 hSimMatchedTrackNHits->Fill(t->NHits());
768 }
769
770 BitMask16 failedENMissingHits = electronFailed;
771 failedENMissingHits.ClearBit(eENMissingHits);
772 if (!failedENMissingHits.NBitsSet()) {
773 hTrackNMissingHits->Fill(s->NMissedHits());
774 }
775
776 BitMask16 failedENWrongHits = electronFailed;
777 failedENWrongHits.ClearBit(eENWrongHits);
778 if (!failedENWrongHits.NBitsSet()) {
779 hTrackNWrongHits->Fill(s->NWrongHits());
780 }
781
782 BitMask16 failedEProb = electronFailed;
783 failedEProb.ClearBit(eEProb);
784 if (!failedEProb.NBitsSet()) {
785 hTrackProb->Fill(t->Prob());
786 if (1 ) {
787 hSimMatchedTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
788 hSimMatchedTrackProb->Fill(t->Prob());
789 }
790 }
791
792 BitMask16 failedEProbNHits = electronFailed;
793 failedEProbNHits.ClearBit(eEProb);
794 failedEProbNHits.ClearBit(eENHits);
795 if ( !failedEProbNHits.NBitsSet() ) {
796 hTrackNHitsProb->Fill(t->NHits(),t->RChi2());
797 hTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
798 if (1)
799 hSimMatchedTrackNHitsProb->Fill(t->NHits(),t->RChi2());
800 }
801
802 const mithep::Vertex *pv = fPrimaryVertexes->At(0);
803
804 BitMask16 failedEDzPv = electronFailed;
805 failedEDzPv.ClearBit(eDz);
806 if (!failedEDzPv.NBitsSet()) {
807 hTrackDzPv->Fill(t->Z0()-pv->Z());
808 }
809
810 if ( !electronFailed.NBitsSet()) {
811 hTrackD0->Fill(t->D0());
812 }
813 }
814
815 minPtElectronFailed.ClearBit(eEPt);
816 if (!minPtElectronFailed.NBitsSet()) {
817 hMinElectronPt->Fill(minElectronPt);
818 hPt1Pt2->Fill(maxElectronPt,minElectronPt);
819 if (simPhoton) {
820 BitMask16 simElectronPtFailed = simFailed;
821 simElectronPtFailed.ClearBit(eSimElectronPt);
822 if ( !simElectronPtFailed.NBitsSet() ) {
823 // if (!minPtElectron)
824 // printf("no minptelectron");
825 const ChargedParticle* minElectronC = dynamic_cast<const ChargedParticle*>(minPtElectron);
826 // if (!minElectronC)
827 // printf("no minelectronC\n");
828 const Track *t = minElectronC->Trk();
829 // if (!t)
830 // printf("no t\n");
831 if (t->MCPart())
832 hSimMatchedMinElectronSimPt->Fill(t->MCPart()->Pt());
833 hSimMatchedMinElectronPt->Fill(minElectronPt);
834 }
835 }
836 }
837 }
838
839 //printf("Good conversions only\n");
840 if ( !failed.NBitsSet() ) {
841 goodConversions.Add(c);
842 ++nConversions;
843 //fill photon histograms
844 hConversionZ->Fill(c->Position().Z());
845 hConvDCotTheta->Fill(DCotTheta(c));
846 hGammaMass->Fill(c->Mass());
847 hCharge->Fill(c->Charge());
848 hGammaPhi->Fill(c->Phi());
849
850 for (UInt_t j=0; j<1; ++j) {
851 const Particle* d = c->Daughter(j);
852 const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(d);
853 if (dc) {
854 const Track* t = dc->Trk();
855 hTrackAlgo->Fill(t->Algo());
856 }
857 }
858
859 const Electron *removedElectron = ElectronMatch(c,allConversionElectrons);
860 if (removedElectron) {
861 removedElectrons->Add(removedElectron);
862 }
863
864 if (simPhoton && !simFailed.NBitsSet()) {
865
866 //if (c->Position().Rho() < fRhoMax)
867 hSimMatchedGammaMass->Fill(c->Mass());
868 hSimMatchedConvResolution->Fill(c->Position().Rho() - simPhoton->DecayVertex().Rho());
869 hSimMatchedConvPhiRes->Fill(c->Position().Phi() - simPhoton->DecayVertex().Phi());
870
871 for (UInt_t j=0; j<1; ++j) {
872 const Particle* d = c->Daughter(j);
873 const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(d);
874 if (dc) {
875 const Track* t = dc->Trk();
876 hSimMatchedTrackD0->Fill(t->D0());
877 }
878 }
879 }
880 }
881 }
882 hNConversions->Fill(nConversions);
883 if (nConversions>0)
884 printf("bx number = %i, nConversions = %i\n", GetEventHeader()->BunchCrossing(), nConversions);
885
886 //loop over good conversions only
887 for (UInt_t i=0; i<goodConversions.GetEntries(); ++i) {
888 for (UInt_t j=i+1; j<goodConversions.GetEntries(); ++j) {
889 CompositeParticle *p0 = new CompositeParticle;
890 p0->AddDaughter(goodConversions.At(i));
891 p0->AddDaughter(goodConversions.At(j));
892 hPiPiMass->Fill(p0->Mass());
893 delete p0;
894 }
895 }
896
897
898 for (UInt_t i=0; i<allConversionElectrons->GetEntries(); ++i) {
899 const Electron *e = allConversionElectrons->At(i);
900 hAllConversionElectronPt->Fill(e->Pt());
901 hAllConversionElectronEta->Fill(e->Eta());
902 const MCParticle *mcElectron = SimWeMatch(e);
903 if (mcElectron) {
904 const Double_t chargeAssign = e->Charge()*mcElectron->Charge();
905 hAllConversionElectronChargeAssign->Fill(chargeAssign);
906 if (chargeAssign==-1.0) {
907 hAllConversionElectronPtWrongCharge->Fill(e->Pt());
908 hAllConversionElectronEtaWrongCharge->Fill(e->Eta());
909 }
910 }
911 else
912 hAllConversionElectronChargeAssign->Fill(0.0);
913 }
914
915 for (UInt_t i=0; i<removedElectrons->GetEntries(); ++i) {
916 const Electron *e = removedElectrons->At(i);
917 hRemovedElectronPt->Fill(e->Pt());
918 hRemovedElectronEta->Fill(e->Eta());
919 const MCParticle *mcElectron = SimWeMatch(e);
920 if (mcElectron) {
921 const Double_t chargeAssign = e->Charge()*mcElectron->Charge();
922 hRemovedElectronChargeAssign->Fill(chargeAssign);
923 if (chargeAssign==-1.0) {
924 hRemovedElectronPtWrongCharge->Fill(e->Pt());
925 hRemovedElectronEtaWrongCharge->Fill(e->Eta());
926 }
927 }
928 else
929 hRemovedElectronChargeAssign->Fill(0.0);
930 }
931
932
933 }
934
935 //__________________________________________________________________________________________________
936 void ConversionRemoval::SlaveTerminate()
937 {
938 // Run finishing code on the computer (slave) that did the analysis. For this module, we dont do
939 // anything here.
940 }
941
942 //__________________________________________________________________________________________________
943 void ConversionRemoval::Terminate()
944 {
945
946 fTimer.Stop();
947 printf("Total Analysis Time = %f\n",fTimer.CpuTime());
948
949
950 TCanvas* c1 = new TCanvas();
951 hConversionRadius->Draw();
952
953 TCanvas* c2 = new TCanvas();
954 hConversionRPhi->Draw("col");
955 //c2->SetLogz();
956
957 // Run finishing code on the client computer. For this module, we dont do anything here.
958 }
959
960 BitMask16 ConversionRemoval::FailedCuts(const DecayParticle* c) {
961
962
963 //if (p->GetVertex()->Prob() < 0.005)
964 // return false;
965 UInt_t nFailed = 0;
966
967 BitMask16 failed;
968
969 if ( c->NDaughters() != 2)
970 failed.SetBit(eNDaughters);
971
972 if ( c->Pt() < fPtMin )
973 failed.SetBit(ePt);
974
975 if ( !PassRho(c->Position().Rho()) )
976 failed.SetBit(eRho);
977
978 if ( TMath::Abs(c->Eta()) > fEtaMax )
979 failed.SetBit(eEta);
980
981 if ( c->Lxy() < fLxyMin || c->Lz() < fLzMin )
982 failed.SetBit(eL);
983
984 if ( TMath::Abs(c->Dxy()) > fAbsDxyMax )
985 failed.SetBit(eDxy);
986
987 if ( TMath::Abs(c->Charge()) != 0 )
988 failed.SetBit(eCharge);
989
990 // if (GetEventHeader()->BunchCrossing()!=51 && GetEventHeader()->BunchCrossing()!=2724)
991 // failed.SetBit(eBx);
992
993 // if (fTracks->GetEntries()>150)
994 // failed.SetBit(eBx);
995
996 // Double_t absPhi = TMath::Abs(c->Phi());
997 // if (!( absPhi<(TMath::Pi()/4.0) || absPhi>(3.0*TMath::Pi()/4.0)))
998 // failed.SetBit(eBx);
999 //
1000 if (c->NSharedHits() > fMaxNSharedHits || c->NSharedHits() < fMinNSharedHits)
1001 failed.SetBit(eSharedHits);
1002
1003 const mithep::Vertex *pv = fPrimaryVertexes->At(0);
1004 if (fRequireGoodPv && (pv->NTracksFit()<2 || pv->Prob()<1e-6 || pv->Z()<-12.5 || pv->Z()>12.5) )
1005 failed.SetBit(eBx);
1006
1007 if ( fEvtSel->ClusVtxQual() < fMinClusterVtxQual )
1008 failed.SetBit(eClusVtx);
1009
1010 Bool_t failedElectrons=false;
1011 for (UInt_t i=0; i<c->NDaughters(); ++i) {
1012 const DaughterData* d = c->DaughterDat(i);
1013 const Track *trk = dynamic_cast<const ChargedParticle*>
1014 (c->Daughter(i))->Trk();
1015 Bool_t trackQuality = ( !trk->IsGsf() || !fTrackQualityFirstOnly );
1016 BitMask16 failedElectronCuts = FailedElectronCuts(d, trackQuality);
1017 if (failedElectronCuts.NBitsSet())
1018 failedElectrons=true;
1019 }
1020 if (failedElectrons)
1021 failed.SetBit(eDaughters);
1022
1023 if ( c->Prob() < fProbMin )
1024 failed.SetBit(eProb);
1025
1026 return failed;
1027 // LoadBranch(fMvfConvUnconstrainedName);
1028 // const DecayParticle *unconstrained = MatchingConversion(c, fMvfConversionsUnconstrained);
1029 //
1030 // if (!unconstrained)
1031 // nFailed++;
1032 //
1033 // if ( TwoPionMass(unconstrained) > 0.4 )
1034 // nFailed++;
1035 //hConvDCotTheta->Fill(dCotTheta);
1036
1037 }
1038
1039 Bool_t ConversionRemoval::PassConvCuts(const Conversion* p) {
1040 if (p->NDaughters() != 2)
1041 return false;
1042
1043 Double_t convRadius = p->DecayVertex().Position().Rho();
1044 if (convRadius < 2.0)
1045 //if (convRadius < 2.0 || convRadius > 20.0)
1046 //if (convRadius < 20.0)
1047 return false;
1048
1049 const Electron* pElectron1 = (Electron*)p->Daughter(0);
1050 const Electron* pElectron2 = (Electron*)p->Daughter(1);
1051
1052
1053 //Double_t deltaPhi = TMath::ACos((pElectron1->Px()*pElectron2->Px() + pElectron1->Py()*pElectron2->Py() + pElectron1->Pz()*pElectron2->Pz())/(pElectron1->Mom().P()*pElectron2->Mom().P()));
1054
1055 //if (deltaPhi>0.5)
1056 // return false;
1057 // if (fabs(p->DCotTheta())>0.2)
1058 if (fabs(p->DCotTheta())>0.75)
1059 return false;
1060
1061 if (p->Charge()!=0)
1062 return false;
1063
1064
1065 /* for (Int_t i=0; i<p->NDaughters(); i++) {
1066 const Electron* e = p->Daughter(i);
1067 if (!PassElectronCuts(e))
1068 return false;
1069 } */
1070 //if (p->Mass()<0.6)
1071 // return false;
1072
1073 //if (p->GetVertex().Prob() < 0.2)// || p->GetVertex().Prob() > 0.9)
1074 // return false;
1075
1076 return true;
1077 }
1078
1079 BitMask16 ConversionRemoval::FailedElectronCuts(const DaughterData* d, Bool_t trackQuality) {
1080 //if (p->Pt() < 5.0)
1081 // return false;
1082
1083 BitMask16 failed;
1084
1085 if (d->Pt() < fElectronPtMin)
1086 failed.SetBit(eEPt);
1087
1088 if (TMath::Abs(d->Eta()) > fElectronEtaMax)
1089 failed.SetBit(eEEta);
1090
1091 const StableData *s = dynamic_cast<const StableData*>(d);
1092
1093 if (!s)
1094 Fatal("FailedElectronCuts", "DaughterData not a StableData");
1095
1096 const ChargedParticle* c = dynamic_cast<const ChargedParticle*>(s->Original());
1097
1098 if (!c)
1099 Fatal("FailedElectronCuts", "Daughter not a ChargedParticle");
1100
1101 const Track* t = c->Trk();
1102
1103 if (!t)
1104 Fatal("FailedElectronCuts", "Daughter has no track");
1105
1106 if (s->NMissedHits() > fMissedHitsMax)
1107 failed.SetBit(eENMissingHits);
1108
1109 if (s->NWrongHits() > fWrongHitsMax)
1110 failed.SetBit(eENWrongHits);
1111
1112 if (trackQuality && t->NHits()<fNHitsMin)
1113 failed.SetBit(eENHits);
1114
1115 if (trackQuality && t->NStereoHits()<fNStereoHitsMin)
1116 failed.SetBit(eENStereoHits);
1117
1118 if (trackQuality && t->NPixelHits()<fNPixelHitsMin)
1119 failed.SetBit(eENPixelHits);
1120
1121 if (trackQuality && t->Prob()<fTrackProbMin)
1122 failed.SetBit(eEProb);
1123
1124 //if (trackQuality && fExcludePXB1 && t->Hit(Track::PXB1))
1125 if (trackQuality && fExcludePXB1 && (t->Hit(Track::PXB1)||t->Hit(Track::PXF1)))
1126 failed.SetBit(eEPxb1);
1127
1128 const mithep::Vertex *pv = fPrimaryVertexes->At(0);
1129
1130 if (trackQuality && (TMath::Abs(t->Z0()-pv->Z()) > fMaxTrackDzPv) )
1131 failed.SetBit(eDz);
1132
1133 return failed;
1134 }
1135
1136 Bool_t ConversionRemoval::PassTrackCuts(const Track* t) {
1137
1138 // if ( t->Prob()<fTrackProbMin && t->NHits()<fNHitsMin )
1139
1140 // if (t->NStereoHits() < 2)
1141 // return false;
1142
1143 return false;
1144
1145 }
1146
1147 BitMask16 ConversionRemoval::FailedSimCuts(const MCParticle* p) {
1148
1149 BitMask16 failed;
1150
1151 if (p->PdgId()!=22)
1152 failed.SetBit(eSimPdg);
1153 if (TMath::Abs(p->Eta())>fEtaMax)
1154 failed.SetBit(eSimEta);
1155 //if (p->Pt()<5.0 || p->Pt()>25.0)
1156 //if (p->Pt()<25.0)
1157 if (p->Pt()<fPtMin)
1158 failed.SetBit(eSimPt);
1159
1160 Double_t simRad = p->DecayVertex().Rho();
1161 //if (simRad<2.0 || simRad>128.0)
1162 //if (simRad<2.0 || simRad>20.0)
1163 //if (simRad<20.0 || simRad>128.0)
1164 if ( !PassRho(simRad) )
1165 failed.SetBit(eSimRho);
1166
1167 Int_t nEPlus = 0;
1168 Int_t nEMinus = 0;
1169 Bool_t failedElectronPt=false;
1170 Bool_t failedElectronEta=false;
1171 for (UInt_t j=0; j<p->NDaughters(); j++) {
1172 const MCParticle* pDaughter = p->Daughter(j);
1173 if (pDaughter->PdgId()==11)
1174 nEPlus++;
1175 if (pDaughter->PdgId()==-11)
1176 nEMinus++;
1177 if (TMath::Abs(pDaughter->PdgId())==11) {
1178 if (pDaughter->Pt() < fElectronPtMin)
1179 failedElectronPt = true;
1180 if (TMath::Abs(pDaughter->Eta()) > fElectronEtaMax)
1181 failedElectronEta=true;
1182 }
1183 }
1184 if (failedElectronPt)
1185 failed.SetBit(eSimElectronPt);
1186 if (failedElectronEta)
1187 failed.SetBit(eSimElectronEta);
1188
1189 if (nEPlus!=1 || nEMinus!=1)
1190 failed.SetBit(eSimDaughters);
1191
1192 //get rid of all conversions which either don't produce a clean electron, or which
1193 //were produced from a real primary electron
1194 //if (fRequireCleanElectron && ( !ElectronMatch(p) || GenElectronMatch(p) ) )
1195 if (fRequireCleanElectron && !ElectronMatch(p))
1196 failed.SetBit(eCleanElectron);
1197
1198 return failed;
1199 }
1200
1201 const Electron* ConversionRemoval::ElectronMatch(const MCParticle *p) {
1202 // if (p->HasMother(22))
1203 // return 0;
1204 const Electron *eMatch = 0;
1205 if (fHitBasedMatching) {
1206 for (UInt_t i=0; i<fCleanElectrons->GetEntries(); ++i) {
1207 const Electron *e = fCleanElectrons->At(i);
1208 const MCParticle *ep = e->Trk()->MCPart();
1209 if ( ep && ep->DistinctMother()==p)
1210 return e;
1211 }
1212 }
1213 else {
1214 Double_t minDeltaR = 0.3;
1215 for (UInt_t i=0; i<fCleanElectrons->GetEntries(); ++i) {
1216 const Electron *e = fCleanElectrons->At(i);
1217 Double_t deltaR = MathUtils::DeltaR(*e,*p);
1218 if (deltaR < minDeltaR) {
1219 minDeltaR = deltaR;
1220 eMatch = e;
1221 }
1222 }
1223 }
1224
1225 return eMatch;
1226
1227 }
1228
1229 const MCParticle* ConversionRemoval::GenElectronMatch(const MCParticle *p) {
1230 const MCParticle *mother = p;
1231 while (p) {
1232 if ( p->AbsPdgId()==11 && p->IsGenerated() )
1233 return p;
1234 else
1235 p = p->Mother();
1236 }
1237 return 0;
1238 }
1239
1240 const MCParticle* ConversionRemoval::SimMatch(const DecayParticle* p) {
1241 if ( p->NDaughters()!=2 )
1242 return 0;
1243
1244 const ChargedParticle *electron1 = dynamic_cast<const ChargedParticle*>(p->Daughter(0));
1245 const ChargedParticle *electron2 = dynamic_cast<const ChargedParticle*>(p->Daughter(1));
1246
1247 if (!electron1 || !electron2)
1248 return 0;
1249
1250 const MCParticle *simElectron1 = 0;
1251 const MCParticle *simElectron2 = 0;
1252 if (fHitBasedMatching) {
1253 simElectron1 = electron1->Trk()->MCPart();
1254 simElectron2 = electron2->Trk()->MCPart();
1255 }
1256 else {
1257 LoadBranch(fMCPartName);
1258 for (UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
1259 const MCParticle *mcp = fMCParticles->At(i);
1260 if (mcp->PdgId()==22 && mcp->DecayVertex().Rho()<80.0 && MathUtils::DeltaR(*mcp,*p) < 0.3)
1261 return mcp;
1262 }
1263 return 0;
1264 }
1265
1266 if (simElectron1) {
1267 hTrackSimMatchType->Fill(simElectron1->PdgId());
1268 if (simElectron1->HasMother())
1269 hParentSimMatchType->Fill(simElectron1->Mother()->PdgId());
1270 }
1271
1272 if (simElectron2) {
1273 hTrackSimMatchType->Fill(simElectron2->PdgId());
1274 if (simElectron2->HasMother())
1275 hParentSimMatchType->Fill(simElectron2->Mother()->PdgId());
1276 }
1277
1278
1279 if (!simElectron1) {
1280 const Track *t = electron1->Trk();
1281 hUnMatchedTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
1282 hUnMatchedTrackProb->Fill(t->Prob());
1283 hUnMatchedTrackNHits->Fill(t->NHits());
1284 hUnMatchedTrackNHitsProb->Fill(t->NHits(),t->RChi2());
1285 hUnMatchedTrackD0->Fill(t->D0());
1286 }
1287
1288 if (!simElectron2) {
1289 const Track *t = electron2->Trk();
1290 hUnMatchedTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
1291 hUnMatchedTrackProb->Fill(t->Prob());
1292 hUnMatchedTrackNHits->Fill(t->NHits());
1293 hUnMatchedTrackNHitsProb->Fill(t->NHits(),t->RChi2());
1294 hUnMatchedTrackD0->Fill(t->D0());
1295 }
1296
1297 if (!simElectron1 || !simElectron2) {
1298 //printf("unmatched electron\n");
1299 return 0;
1300 }
1301
1302
1303 if ( TMath::Abs(simElectron1->PdgId())!=11 || TMath::Abs(simElectron2->PdgId())!=11 ) {
1304 //printf("not electrons\n");
1305 return 0;
1306 }
1307
1308 const MCParticle *simPhoton = simElectron1->DistinctMother();
1309
1310 if (!simPhoton) {
1311 // printf("no photon\n");
1312 // hParentSimMatchType->Fill(0);
1313 return 0;
1314 }
1315
1316 if (simElectron2->DistinctMother()!=simPhoton) {
1317 //printf("different mothers\n");
1318 // hParentSimMatchType->Fill(0);
1319 return 0;
1320 }
1321
1322 if (simPhoton->PdgId()!=22) {
1323 //printf("not a photon\n");
1324 return 0;
1325 }
1326
1327 // printf("found common mother with pdg=%i, daughter pdgs: %i, %i\n", simPhoton->PdgId(), simElectron1->PdgId(),simElectron2->PdgId());
1328
1329 // hParentSimMatchType->Fill(simPhoton->PdgId());
1330
1331 return simPhoton;
1332
1333
1334 }
1335
1336 const MCParticle* ConversionRemoval::SimMatch(const Track* t) {
1337
1338 const MCParticle *simElectron1 = 0;
1339 //const MCParticle *simElectron2 = 0;
1340 if (fHitBasedMatching) {
1341 simElectron1 = t->MCPart();
1342 }
1343 else {
1344 LoadBranch(fMCPartName);
1345 //Double_t minDeltaR = 999.9;
1346 for (UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
1347 const MCParticle *p = fMCParticles->At(i);
1348 if (p->PdgId()==22 && p->DecayVertex().Rho()<80.0 && MathUtils::DeltaR(*p,*t) < 0.3)
1349 return p;
1350 }
1351 }
1352
1353 if (!simElectron1) {
1354 //printf("unmatched electron\n");
1355 return 0;
1356 }
1357
1358
1359 if ( TMath::Abs(simElectron1->PdgId())!=11 ) {
1360 //printf("not electrons\n");
1361 return 0;
1362 }
1363
1364 const MCParticle *simPhoton = simElectron1->DistinctMother();
1365
1366 if (!simPhoton) {
1367 // printf("no photon\n");
1368 // hParentSimMatchType->Fill(0);
1369 return 0;
1370 }
1371
1372 if (simPhoton->PdgId()!=22) {
1373 //printf("not a photon\n");
1374 return 0;
1375 }
1376
1377 // printf("found common mother with pdg=%i, daughter pdgs: %i, %i\n", simPhoton->PdgId(), simElectron1->PdgId(),simElectron2->PdgId());
1378
1379 // hParentSimMatchType->Fill(simPhoton->PdgId());
1380
1381 return simPhoton;
1382
1383
1384 }
1385
1386 UInt_t ConversionRemoval::NTracks(const TrackCol *col)
1387 {
1388 UInt_t ntracks=0;
1389 for (UInt_t i=0; i<col->GetEntries(); ++i) {
1390 const Track *t = col->At(i);
1391 if ( PassTrackCuts(t) )
1392 ntracks++;
1393 }
1394
1395 return ntracks;
1396 }
1397
1398 // Double_t ConversionRemoval::TrackPtIsolation(const DecayParticle *p, Double_t r)
1399 // {
1400 // TObjArray conversionTracks;
1401 // for (UInt_t i=0; i<p->NDaughters(); ++i) {
1402 // const ChargedParticle* d = dynamic_cast<const ChargedParticle*>(p->Daughter(i));
1403 // if (d) {
1404 // const Track *t = d->Trk();
1405 // if (t)
1406 // conversionTracks.Add((TObject*)t);
1407 // }
1408 // }
1409 //
1410 //
1411 // LoadBranch(fTrackName);
1412 // Double_t sumPt=0.0;
1413 // for (UInt_t i=0; i<fTracks->GetEntries(); ++i) {
1414 // const Track *t = fTracks->At(i);
1415 // if (conversionTracks.IndexOf(t)==-1) {
1416 // Double_t deltaR = MathUtils::DeltaR(p->Phi(),p->Eta(),t->Phi(),t->Eta());
1417 // if (deltaR<r)
1418 // sumPt = sumPt + 1.0;//sumPt += t->Pt();
1419 // }
1420 // }
1421 //
1422 // return sumPt;
1423 //
1424 // }
1425
1426 Bool_t ConversionRemoval::PassPhotonCuts(const Photon *p)
1427 {
1428 if (p->IsConverted())
1429 return false;
1430
1431 return true;
1432 }
1433
1434 Double_t ConversionRemoval::DCotTheta(const DecayParticle *c)
1435 {
1436 if (c->NDaughters()!=2)
1437 return 0.0;
1438
1439 Double_t theta1 = c->DaughterDat(0)->Theta();
1440 Double_t theta2 = c->DaughterDat(1)->Theta();
1441
1442 Double_t dCotTheta = 1./TMath::Tan(theta1) - 1./TMath::Tan(theta2);
1443 //Double_t dCotTheta = c->DaughterDat(0)->Pt() - c->DaughterDat(1)->Pt();
1444
1445 if (c->DaughterDat(0)->Charge()==1)
1446 return dCotTheta;
1447 else
1448 return (-dCotTheta);
1449 }
1450
1451 Double_t ConversionRemoval::DPhi(const DecayParticle *c)
1452 {
1453 if (c->NDaughters()!=2)
1454 return 0.0;
1455
1456 ThreeVectorC mom1 = ((const StableData*)c->DaughterDat(0))->ThreeMom();
1457 ThreeVectorC mom2 = ((const StableData*)c->DaughterDat(1))->ThreeMom();
1458
1459 Double_t dPhi = TMath::ACos(mom1.Dot(mom2)/(mom1.R()*mom2.R()));
1460
1461 return dPhi;
1462 }
1463
1464 Double_t ConversionRemoval::TwoPionMass(const DecayParticle *c)
1465 {
1466 if (c->NDaughters()!=2)
1467 return 0.0;
1468
1469 StableParticle *pi1 = new StableParticle(211, (Track*)((ChargedParticle*)c->Daughter(0))->Trk());
1470 StableParticle *pi2 = new StableParticle(211, (Track*)((ChargedParticle*)c->Daughter(1))->Trk());
1471
1472 StableData *pi1d = new StableData(pi1, ((StableData*)c->DaughterDat(0))->ThreeMom());
1473 StableData *pi2d = new StableData(pi2, ((StableData*)c->DaughterDat(1))->ThreeMom());
1474
1475 CompositeParticle *meson = new CompositeParticle();
1476 meson->AddDaughter(pi1d);
1477 meson->AddDaughter(pi2d);
1478
1479 Double_t mesonMass = meson->Mass();
1480
1481 delete meson;
1482 delete pi1d;
1483 delete pi2d;
1484 delete pi1;
1485 delete pi2;
1486
1487 return mesonMass;
1488 }
1489
1490 const DecayParticle *ConversionRemoval::MatchingConversion(const DecayParticle *c, const DecayParticleCol *col) const
1491 {
1492 for (UInt_t i=0; i<col->GetEntries(); ++i) {
1493 const DecayParticle *p = col->At(i);
1494 if ( p->HasSameDaughters(c) )
1495 return c;
1496 }
1497
1498 return 0;
1499 }
1500
1501 const Electron *ConversionRemoval::MatchingElectron(const ChargedParticle *c, const ElectronCol *col) const
1502 {
1503 for (UInt_t i=0; i<col->GetEntries(); ++i) {
1504 const Electron *e = col->At(i);
1505
1506 if ( c->Trk() == e->Trk() )
1507 return e;
1508 }
1509
1510 return 0;
1511 }
1512
1513 const Electron *ConversionRemoval::MatchingElectron(const Electron *ein, const ElectronCol *col) const
1514 {
1515 for (UInt_t i=0; i<col->GetEntries(); ++i) {
1516 const Electron *e = col->At(i);
1517
1518 if ( e->SCluster() == ein->SCluster() )
1519 return e;
1520 }
1521
1522 return 0;
1523 }
1524
1525 void ConversionRemoval::AddRhoRange(Double_t lower, Double_t upper)
1526 {
1527 fRhoLbs.push_back(lower);
1528 fRhoUbs.push_back(upper);
1529 }
1530
1531 Bool_t ConversionRemoval::PassRho(Double_t rho)
1532 {
1533 for (UInt_t i=0; i<fRhoLbs.size(); ++i) {
1534 if ( rho>fRhoLbs.at(i) && rho<fRhoUbs.at(i) )
1535 return true;
1536 }
1537
1538 return false;
1539 }
1540
1541 const MCParticle *ConversionRemoval::SimConversionMatch(const Electron *e) {
1542
1543 //LoadBranch(fMCPartName);
1544
1545 if (fHitBasedMatching) {
1546 const MCParticle *p = e->Trk()->MCPart();
1547 if (p && p->DistinctMother() && !FailedSimCuts(p->DistinctMother()).NBitsSet())
1548 return p->DistinctMother();
1549
1550 }
1551 else {
1552 for (UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
1553 const MCParticle *p = fMCParticles->At(i);
1554 //if (MathUtils::DeltaPhi(*e,*p) < 0.3 && !FailedSimCuts(p).NBitsSet())
1555 if ( MathUtils::DeltaPhi(*e,*p) < 0.3 && p->AbsPdgId()==11 && p->DistinctMother() && !FailedSimCuts(p->DistinctMother()).NBitsSet())
1556 return p->DistinctMother();
1557 }
1558 }
1559
1560 return 0;
1561
1562 }
1563
1564
1565 const MCParticle *ConversionRemoval::SimWeMatch(const Electron *e) {
1566
1567 if (fHitBasedMatching) {
1568 const MCParticle *p = e->Trk()->MCPart();
1569 if (p && p->AbsPdgId()==11 && p->DistinctMother() && (p->DistinctMother()->AbsPdgId()==24 || p->DistinctMother()->AbsPdgId()==23) )
1570 return p;
1571 }
1572 else {
1573 for (UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
1574 const MCParticle *p = fMCParticles->At(i);
1575 if (MathUtils::DeltaPhi(*e,*p) < 0.3 && p->AbsPdgId()==11 && p->DistinctMother() && (p->DistinctMother()->AbsPdgId()==24 || p->DistinctMother()->AbsPdgId()==23) )
1576 return p;
1577 }
1578 }
1579
1580 return 0;
1581 }
1582
1583 const Electron *ConversionRemoval::ElectronMatch(const DecayParticle *d, const ElectronCol *c) {
1584
1585 if (d->NDaughters()<2)
1586 return 0;
1587
1588 const ChargedParticle *cp = dynamic_cast<const ChargedParticle*>(d->Daughter(1));
1589 if (!cp)
1590 return 0;
1591
1592 const Track *t = cp->Trk();
1593 if (!t)
1594 return 0;
1595
1596 for (UInt_t i=0; i<c->GetEntries(); ++i) {
1597 const Electron *e = c->At(i);
1598 if (e->Trk()==t)
1599 return e;
1600 }
1601
1602 return 0;
1603
1604 }
1605