ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitConversions/Mods/src/MvfConversions.cc
Revision: 1.1
Committed: Wed Nov 19 17:33:26 2008 UTC (16 years, 5 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Log Message:
Added MitConversions

File Contents

# User Rev Content
1 bendavid 1.1 // $Id: FullExample.cc,v 1.2 2008/06/09 11:47:03 paus Exp $
2     #include <TH1.h>
3     #include <TH1F.h>
4     #include <TH2F.h>
5     #include <TCanvas.h>
6    
7     #include "MitConversions/Mods/interface/MvfConversions.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::MvfConversions)
17    
18     //__________________________________________________________________________________________________
19     MvfConversions::MvfConversions(const char *name, const char *title) :
20     TAModule (name,title),
21     fPtMin (0),
22     fEtaMax (0),
23     fProbMin (0),
24     fIsoRadius(0),
25     fIsoMax(0),
26     fExcludePXB1(false),
27     fMassMax(0),
28     fMissedHitsMax(0),
29     fWrongHitsMax(0),
30     fElectronPtMin(0),
31     fElectronEtaMax(0),
32     fComputeEff(kFALSE),
33     fTracks (0),
34     fGsfTracks (0),
35     fInOutTracks (0),
36     fOutInTracks (0),
37     fElectrons (0),
38     fPhotons (0),
39     fMCParticles (0),
40     fMvfConversions (0),
41     fMvfConversionsUnconstrained (0),
42     fMCPartName (Names::gkMCPartBrn),
43     fTrackName (Names::gkTrackBrn),
44     fConvElectronName ("Electrons"),
45     fPhotonName (Names::gkPhotonBrn),
46     fMvfConvName("MvfConversions"),
47     fMvfConvUnconstrainedName("MvfConversionsUnconstrained"),
48     fElectronName(Names::gkElectronBrn),
49     hConversionRadius (0),
50     hConversionZ(0),
51     hConversionRPhi (0),
52     hConversionRZ(0),
53     hGammaPt (0),
54     hGammaEta (0),
55     hGammaMass (0),
56     hSimMatchedGammaMass(0),
57     hConvProb (0),
58     hConvChi2 (0),
59     hSimMatchedConvChi2(0),
60     hConvDCotTheta (0),
61     hConvDCotThetaPreCut (0),
62     hConvEOverP (0),
63     hElectronPt (0),
64     hMinElectronPt (0),
65     hSimMinElectronPt (0),
66     hSimMatchedMinElectronPt (0),
67     hSimMatchedMinElectronSimPt (0),
68     hElectronEta (0),
69     hEPairMass (0),
70     hEPairDeltaPhi (0),
71     hGenNumDaughters (0),
72     hGenDaughterPt (0),
73     hGenDecayRadius (0),
74     hSimPt (0),
75     hSimConvRadius (0),
76     hSimConvPosition(0),
77     hTrackSimMatchType (0),
78     hParentSimMatchType (0),
79     hSimMatchedConvRadius (0),
80     hSimMatchedConvProb (0),
81     hSimMatchedEPairMass (0),
82     hSimMatchedEPairDeltaPhi (0),
83     hSimMatchedSimConvRadius (0),
84     hSimMatchedConvResolution (0),
85     hSimMatchedConvPhiRes (0),
86     hSimMatchedConvEOverP (0),
87     hSimMatchedElectronPt (0),
88     hSimMatchedGammaPt (0),
89     hSimMatchedGammaEta (0),
90     hSimMatchedSimGammaPt (0),
91     hSimMatchedSimGammaEta (0),
92     hTrackChi2 (0),
93     hTrackProb (0),
94     hTrackNHits (0),
95     hTrackNHitsProb (0),
96     hTrackD0 (0),
97     hUnMatchedTrackChi2 (0),
98     hUnMatchedTrackProb (0),
99     hUnMatchedTrackNHits (0),
100     hUnMatchedTrackNHitsProb (0),
101     hUnMatchedTrackD0 (0),
102     hSimMatchedTrackChi2 (0),
103     hSimMatchedTrackProb (0),
104     hSimMatchedTrackNHits (0),
105     hSimMatchedTrackNHitsProb (0),
106     hSimMatchedTrackD0 (0),
107     hLxy(0),
108     hLxyOverLxyErr(0),
109     hLz(0),
110     hLzOverLzErr(0),
111     hDxy(0),
112     hSimMatchedLxy(0),
113     hSimMatchedLz(0),
114     hSimMatchedDxy(0),
115     hNTracks(0),
116     hSimMatchedNTracks(0),
117     hIsolation(0),
118     hSimMatchedIsolation(0),
119     hNConversions(0),
120     hDoubleConvMass(0),
121     hConvGammaMass(0),
122     hPiPiMass(0)
123     {
124     // Constructor.
125     }
126    
127     //__________________________________________________________________________________________________
128     void MvfConversions::Begin()
129     {
130     // Run startup code on the client machine. For this module, we dont do anything here.
131     }
132    
133     //__________________________________________________________________________________________________
134     void MvfConversions::SlaveBegin()
135     {
136     // Run startup code on the computer (slave) doing the actual analysis. Here, we typically
137     // initialize histograms and other analysis objects and request branches. For this module, we
138     // request a branch of the MitTree.
139    
140     // Request the branches
141     ReqBranch(fTrackName, fTracks);
142     ReqBranch("ConversionInOutTracks", fInOutTracks);
143     ReqBranch("ConversionOutInTracks", fOutInTracks);
144     ReqBranch(fElectronName, fElectrons);
145     ReqBranch(fPhotonName, fPhotons);
146     ReqBranch(fMCPartName, fMCParticles);
147     ReqBranch(fMvfConvName, fMvfConversions);
148     ReqBranch(fMvfConvUnconstrainedName, fMvfConversionsUnconstrained);
149    
150     // Book our histograms
151    
152     hConversionRPhi = new TH2F("Photon Conversion Position R-Phi","Conversion Position R-Phi (cm)", 100, -100.0,100.0,100,-100.0,100.0);
153     AddOutput(hConversionRPhi);
154    
155     hConversionRZ = new TH2F("Photon Conversion Position R-Z","Conversion Position R-Z (cm)", 1000, -100.0,100.0,1000,-100.0,100.0);
156     AddOutput(hConversionRZ);
157    
158     hSimConvPosition = new TH2F("Sim Photon Conversion Position","Sim Photon Conversion Position", 200, -200.0,200.0,200,-200.0,200.0);
159     AddOutput(hSimConvPosition);
160    
161    
162     //TH1::SetDefaultSumw2(kTRUE);
163    
164     hConversionRadius = new TH1F("Photon Conversion Radius","Radius (cm)",800,0,200.0);
165     AddOutput(hConversionRadius);
166    
167     hConversionZ = new TH1F("Photon Conversion Z position", "Conversion Z position (cm)", 200, -200.0, 200.0);
168     AddOutput(hConversionZ);
169    
170     hGammaPt = new TH1F("Photon Pt","Photon Pt (GeV)",400,0,200.0);
171     AddOutput(hGammaPt);
172    
173     hGammaEta = new TH1F("Photon Eta","Photon Eta",200,-5.0,5.0);
174     AddOutput(hGammaEta);
175    
176     hGammaMass = new TH1F("Photon Invariant Mass","Photon Invariant Mass",200,0,20.0);
177     AddOutput(hGammaMass);
178    
179     hSimMatchedGammaMass = new TH1F("SimMatched Photon Invariant Mass","SimMatched Photon Invariant Mass",200,0,20.0);
180     AddOutput(hSimMatchedGammaMass);
181    
182     hConvProb = new TH1F("Conversion Vertex fit probability", "Vertex Fit Probability",200,0.0,1.0);
183     AddOutput(hConvProb);
184    
185     hConvChi2 = new TH1F("Conversion Vertex fit Chi squared", "Vertex Fit Chi Squared",2000,0.0,100.0);
186     AddOutput(hConvChi2);
187    
188     hSimMatchedConvChi2 = new TH1F("Sim Matched Conversion Vertex fit Chi squared", "Sim Matched Vertex Fit Chi Squared",2000,0.0,100.0);
189     AddOutput(hSimMatchedConvChi2);
190    
191     hConvDCotTheta = new TH1F("Conversion DCotTheta", "DCotTheta",10001,-10.0,10.0);
192     AddOutput(hConvDCotTheta);
193    
194     hConvDCotThetaPreCut = new TH1F("Conversion DCotTheta before fit prob cut", "DCotThetaPreCut",1000,-10.0,10.0);
195     AddOutput(hConvDCotThetaPreCut);
196    
197     hConvEOverP = new TH1F("Conversion E over P", "Conversion E over P",200,0.0,50.0);
198     AddOutput(hConvEOverP);
199    
200     hElectronPt = new TH1F("Electron Pt","Electron Pt (GeV)",400,0,200.0);
201     AddOutput(hElectronPt);
202    
203     hMinElectronPt = new TH1F("Min Electron Pt","Min Electron Pt (GeV)",400,0,200.0);
204     AddOutput(hMinElectronPt);
205    
206     hSimMatchedMinElectronPt = new TH1F("Sim Matched Min Electron Pt","Sim Matched Min Electron Pt (GeV)",400,0,200.0);
207     AddOutput(hSimMatchedMinElectronPt);
208    
209     hSimMatchedMinElectronSimPt = new TH1F("Sim Matched Min Electron Sim Pt","Sim Matched Min Electron Sim Pt (GeV)",400,0,200.0);
210     AddOutput(hSimMatchedMinElectronSimPt);
211    
212     hSimMinElectronPt = new TH1F("Sim Min Electron Pt","Sim Min Electron Pt (GeV)",400,0,200.0);
213     AddOutput(hSimMinElectronPt);
214    
215     hElectronEta = new TH1F("Electron Eta","Electron Eta",200,-5.0,5.0);
216     AddOutput(hElectronEta);
217    
218     hEPairMass = new TH1F("Electron Pair Invariant Mass","Electron Pair Invariant Mass",200,0.0,10);
219     AddOutput(hEPairMass);
220    
221     hEPairDeltaPhi = new TH1F("Electron Pair Delta Phi","Electron Pair Delta Phi",200,-4.0,4.0);
222     AddOutput(hEPairDeltaPhi);
223    
224     hGenNumDaughters = new TH1F("Number of Decay daughters - gen level","Number of Decay daughters - gen level",10,-0.5,9.5);
225     AddOutput(hGenNumDaughters);
226    
227     hGenDaughterPt = new TH1F("Pt of decay daugthers - gen level","Pt of decay daugthers - gen level",400,0,200.0);
228     AddOutput(hGenDaughterPt);
229    
230     hGenDecayRadius = new TH1F("Decay vertex radius - gen level","Decay vertex radius - gen level",800,0,200.0);
231     AddOutput(hGenDecayRadius);
232    
233     hSimPt = new TH1F("Pt - sim level","Pt - sim level",400,0,200.0);
234     AddOutput(hSimPt);
235    
236     hSimConvRadius = new TH1F("Sim Photon Conversion Radius","Sim Photon Conversion Radius",800,0,200.0);
237     AddOutput(hSimConvRadius);
238    
239     // hTrackD0 = new TH1F("general track D0","general track D0",400,0,200.0);
240     // AddOutput(hTrackD0);
241    
242     hTrackSimMatchType = new TH1F("Conversion Electron matched sim pdg","Conversion Electron matched sim pdg",10001,-5000.5,5000.5);
243     AddOutput(hTrackSimMatchType);
244    
245     hParentSimMatchType = new TH1F("Conversion Parent matched sim pdg","Conversion Parent matched sim pdg",10001,-5000.5,5000.5);
246     AddOutput(hParentSimMatchType);
247    
248     hSimMatchedConvRadius = new TH1F("Sim Matched Photon Conversion Radius","Sim Matched Photon Conversion Radius",800,0,200.0);
249     AddOutput(hSimMatchedConvRadius);
250    
251     hSimMatchedConvProb = new TH1F("Sim Matched Conversion Vertex fit probability", "Sim Matched Vertex Fit Probability",200,0.0,1.0);
252     AddOutput(hSimMatchedConvProb);
253    
254     hSimMatchedEPairMass = new TH1F("Sim Matched Electron Pair Invariant Mass","Sim Matched Electron Pair Invariant Mass",200,0.0,10);
255     AddOutput(hSimMatchedEPairMass);
256    
257     hSimMatchedEPairDeltaPhi = new TH1F("Sim Matched Electron Pair Delta Phi","Sim Matched Electron Pair Delta Phi",200,-4.0,4.0);
258     AddOutput(hSimMatchedEPairDeltaPhi);
259    
260     hSimMatchedSimConvRadius = new TH1F("Sim Matched Photon Sim Conversion Radius","Sim Matched Photon Conversion Sim Radius",800,0,200.0);
261     AddOutput(hSimMatchedSimConvRadius);
262    
263     hSimMatchedConvResolution = new TH1F("Sim Matched Photon Conversion Radius Resolution","Sim Matched Photon Conversion Radius Resolution",300,-30.0,30.0);
264     AddOutput(hSimMatchedConvResolution);
265    
266     hSimMatchedConvPhiRes = new TH1F("Sim Matched Photon Conversion Phi Resolution","Sim Matched Photon Conversion Phi Resolution",1000,-3.5,3.5);
267     AddOutput(hSimMatchedConvPhiRes);
268    
269     hSimMatchedConvEOverP = new TH1F("Sim Matched Conversion E over P", "Sim Matched Conversion E over P",200,0.0,50.0);
270     AddOutput(hSimMatchedConvEOverP);
271    
272     hSimMatchedElectronPt = new TH1F("Sim Matched Electron Pt","Sim Matched Electron Pt (GeV)",400,0,200.0);
273     AddOutput(hSimMatchedElectronPt);
274    
275     hSimMatchedGammaPt = new TH1F("Sim Matched Photon Pt","Sim Matched Photon Pt (GeV)",400,0,200.0);
276     AddOutput(hSimMatchedGammaPt);
277    
278     hSimMatchedGammaEta = new TH1F("Sim Matched Photon Eta","Sim Matched Photon Eta",200,-5.0,5.0);
279     AddOutput(hSimMatchedGammaEta);
280    
281     hSimMatchedSimGammaPt = new TH1F("Sim Matched Sim Photon Pt","Sim Matched Sim Photon Pt (GeV)",400,0,200.0);
282     AddOutput(hSimMatchedSimGammaPt);
283    
284     hSimMatchedSimGammaEta = new TH1F("Sim Matched Sim Photon Eta","Sim Matched Sim Photon Eta",200,-5.0,5.0);
285     AddOutput(hSimMatchedSimGammaEta);
286    
287     hTrackChi2 = new TH1F("Conversion Track RChi squared", "Track RChi Squared",200,0.0,10.0);
288     AddOutput(hTrackChi2);
289    
290     hTrackProb = new TH1F("Conversion Track fit probability", "Track Fit Probability",200,0.0,1.0);
291     AddOutput(hTrackProb);
292    
293     hTrackNHits = new TH1F("Conversion Track NHits", "Track NHits",37,-0.5,36.5);
294     AddOutput(hTrackNHits);
295    
296     hTrackNHitsProb = new TH2F("Track NHits-RChi2","Track NHits-RChi2", 37,-0.5,36.5,50,0.0,10.0);
297     AddOutput(hTrackNHitsProb);
298    
299     hTrackD0 = new TH1F("Conversion track D0","Conversion track D0",100,-5.0,5.0);
300     AddOutput(hTrackD0);
301    
302     hUnMatchedTrackChi2 = new TH1F("UnMatched Conversion Track RChi squared", "UnMatched Track RChi Squared",200,0.0,10.0);
303     AddOutput(hUnMatchedTrackChi2);
304    
305     hUnMatchedTrackProb = new TH1F("UnMatched Conversion Track fit probability", "UnMatched Track Fit Probability",200,0.0,1.0);
306     AddOutput(hUnMatchedTrackProb);
307    
308     hUnMatchedTrackNHits = new TH1F("UnMatched Conversion Track NHits", "UnMatched Track NHits",37,-0.5,36.5);
309     AddOutput(hUnMatchedTrackNHits);
310    
311     hUnMatchedTrackNHitsProb = new TH2F("UnMatched Track NHits-RChi2","UnMatched Track NHits-RChi2", 37,-0.5,36.5,50,0.0,10.0);
312     AddOutput(hUnMatchedTrackNHitsProb);
313    
314     hUnMatchedTrackD0 = new TH1F("UnMatched Conversion track D0","UnMatched Conversion track D0",100,-5.0,5.0);
315     AddOutput(hUnMatchedTrackD0);
316    
317     hSimMatchedTrackChi2 = new TH1F("SimMatched Conversion Track RChi squared", "SimMatched Track RChi Squared",200,0.0,10.0);
318     AddOutput(hSimMatchedTrackChi2);
319    
320     hSimMatchedTrackProb = new TH1F("SimMatched Conversion Track fit probability", "SimMatched Track Fit Probability",200,0.0,1.0);
321     AddOutput(hSimMatchedTrackProb);
322    
323     hSimMatchedTrackNHits = new TH1F("SimMatched Conversion Track NHits", "SimMatched Track NHits",37,-0.5,36.5);
324     AddOutput(hSimMatchedTrackNHits);
325    
326     hSimMatchedTrackNHitsProb = new TH2F("SimMatched Track NHits-RChi2","SimMatched Track NHits-RChi2", 37,-0.5,36.5,50,0.0,10.0);
327     AddOutput(hSimMatchedTrackNHitsProb);
328    
329     hSimMatchedTrackD0 = new TH1F("SimMatched Conversion track D0","SimMatched Conversion track D0",100,-5.0,5.0);
330     AddOutput(hSimMatchedTrackD0);
331    
332     hLxy = new TH1F("Conversion Lxy","Conversion Lxy",240,-30.0,30.0);
333     AddOutput(hLxy);
334    
335     hLxyOverLxyErr = new TH1F("Conversion Lxy/LxyErr","Conversion Lxy/LxyErr",200,-100.0,100.0);
336     AddOutput(hLxyOverLxyErr);
337    
338     hLz = new TH1F("Conversion Lz","Conversion Lz",200,-50.0,50.0);
339     AddOutput(hLz);
340    
341     hLzOverLzErr = new TH1F("Conversion Lz/LzErr","Conversion Lz/LzErr",200,-100.0,100.0);
342     AddOutput(hLzOverLzErr);
343    
344     hDxy = new TH1F("Conversion Dxy","Conversion Dxy",200,-5.0,5.0);
345     AddOutput(hDxy);
346    
347     hSimMatchedLxy = new TH1F("SimMatched Conversion Lxy","SimMatched Conversion Lxy",100,-30.0,30.0);
348     AddOutput(hSimMatchedLxy);
349    
350     hSimMatchedLz = new TH1F("SimMatched Conversion Lz","SimMatched Conversion Lz",200,-50.0,50.0);
351     AddOutput(hSimMatchedLz);
352    
353     hSimMatchedDxy = new TH1F("SimMatched Conversion Dxy","SimMatched Conversion Dxy",200,-5.0,5.0);
354     AddOutput(hSimMatchedDxy);
355    
356     hNTracks = new TH1F("Number of Tracks in the event", "Number of tracks in the event", 401, -0.5,400.5);
357     AddOutput(hNTracks);
358    
359     hSimMatchedNTracks = new TH1F("SimMatched Number of Tracks in the event", "SimMatched Number of tracks in the event", 401, -0.5,400.5);
360     AddOutput(hSimMatchedNTracks);
361    
362     hIsolation = new TH1F("Track Isolation of Conversion", "Track Isolation of Conversion", 201, -0.5,200.5);
363     AddOutput(hIsolation);
364    
365     hSimMatchedIsolation = new TH1F("SimMatched Track Isolation of Conversion", "SimMatched Track Isolation of Conversion", 201, -0.5,200.5);
366     AddOutput(hSimMatchedIsolation);
367    
368     hNConversions = new TH1F("Number of Conversions", "Number of Conversions",10,-0.5,10.5);
369     AddOutput(hNConversions);
370    
371     hDoubleConvMass = new TH1F("Double Conversion Mass", "Double Conversion Mass", 1000, 0.0, 10.0);
372     AddOutput(hDoubleConvMass);
373    
374     hConvGammaMass = new TH1F("Conversion plus Photon Mass", "Conversion plus Photon Mass", 1000, 0.0, 10.0);
375     AddOutput(hConvGammaMass);
376    
377     hPiPiMass = new TH1F("Conversion two pion Mass", "Conversion two pion Mass", 1000,0.0,10.0);
378     AddOutput(hPiPiMass);
379    
380     fTimer.Start(1e8);
381    
382     }
383    
384     //__________________________________________________________________________________________________
385     void MvfConversions::Process()
386     {
387     // Process entries of the tree. For this module, we just load the branch and fill the histograms.
388     // --> Why is this done on the basis of the name? should be the pointer!
389    
390     // BitMask64 testMask;
391     // testMask.SetBit(Track::TIB1S);
392     // testMask.SetBit(Track::TIB2S);
393     // testMask.SetBit(Track::TID1S);
394     // testMask.SetBit(Track::TID2S);
395     // testMask.SetBit(Track::TID3S);
396     // testMask.SetBit(Track::TOB1S);
397     // testMask.SetBit(Track::TOB2S);
398     // testMask.SetBit(Track::TEC1S);
399     // testMask.SetBit(Track::TEC2S);
400     // testMask.SetBit(Track::TEC3S);
401     // testMask.SetBit(Track::TEC4S);
402     // testMask.SetBit(Track::TEC5S);
403     // testMask.SetBit(Track::TEC6S);
404     // testMask.SetBit(Track::TEC7S);
405     // testMask.SetBit(Track::TEC8S);
406     // testMask.SetBit(Track::TEC9S);
407     //
408     // const Long64_t *maskVal = reinterpret_cast<const Long64_t*>(testMask.Bits());
409     //
410     // printf("HitMaskVal = %lli\n",*maskVal);
411     //
412     // Track testTrack;
413     // if (testMask == testTrack.StereoLayers())
414     // printf("stereo mask match\n");
415     // else
416     // printf("stereo mask mismatch\n");
417     //
418    
419     if (fComputeEff) {
420     LoadBranch(fMCPartName);
421     for (UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
422     MCParticle* p = fMCParticles->At(i);
423     UInt_t nFailed = FailedSimCuts(p);
424     if (nFailed<=1) {
425     if (nFailed==0 || p->Pt() < fPtMin)
426     hSimPt->Fill(p->Pt());
427     if ( nFailed==0 || !PassRho(p->DecayVertex().Rho()) ) {
428     hSimConvRadius->Fill(p->DecayVertex().Rho());
429     hSimConvPosition->Fill(p->DecayVertex().X(),p->DecayVertex().Y());
430     }
431     Double_t minPt=999;
432     for (UInt_t j=0; j<p->NDaughters(); ++j) {
433     const MCParticle *d = p->Daughter(j);
434     if (TMath::Abs(d->PdgId())==11) {
435     if (d->Pt()<minPt)
436     minPt = d->Pt();
437     }
438     }
439     if ( nFailed==0 || minPt<fElectronPtMin )
440     hSimMinElectronPt->Fill(minPt);
441     }
442     }
443     }
444    
445     // Track* trackTest = new Track();
446     // Electron* electronTest = new Electron();
447     // electronTest->SetTrackerTrk(trackTest);
448     //
449     // Track *trackCopy = new Track(*trackTest);
450     // Electron* electronCopy = new Electron(*electronTest);
451     //
452     // const Track *electronTrack = electronTest->TrackerTrk();
453     // const Track *electronCopyTrack = electronCopy->TrackerTrk();
454     //
455     // Electron *secondElectron = new Electron();
456     // secondElectron->SetTrackerTrk(trackCopy);
457     //
458     // const Track *secondElectronTrack = secondElectron->TrackerTrk();
459     //
460     // if (electronTrack==trackTest)
461     // printf ("electronTrack==trackTest\n");
462     //
463     // if (electronTrack==trackCopy)
464     // printf("electronTrack==trackCopy\n");
465     //
466     // if (electronCopyTrack==trackTest)
467     // printf("electronCopyTrack==trackTest\n");
468     //
469     //
470     // if (electronCopyTrack==trackCopy)
471     // printf("electronCopyTrack==trackCopy\n");
472     //
473     // if (secondElectronTrack==trackTest)
474     // printf("secondElectronTrack==trackTest\n");
475     //
476     // if (secondElectronTrack==trackCopy)
477     // printf("secondElectronTrack==trackCopy\n");
478    
479     LoadBranch(fMvfConvName);
480     ObjArray<DecayParticle> goodConversions;
481     ObjArray<Electron> goodElectrons;
482     UInt_t nConversions = 0;
483     for (UInt_t i=0; i<fMvfConversions->GetEntries(); ++i) {
484     DecayParticle* c = fMvfConversions->At(i);
485     UInt_t nFailed = FailedCuts(c);
486    
487     //make N-2 plots for decay length
488     if (nFailed<=2) {
489     UInt_t nAllowedFails=0;
490     if (!PassRho(c->Position().Rho()))
491     nAllowedFails++;
492     if ( c->Lxy() < fLxyMin || c->Lz() < fLzMin )
493     nAllowedFails++;
494    
495     if ( (nFailed-nAllowedFails)==0 ) {
496     hLxy->Fill(c->Lxy());
497     hLxyOverLxyErr->Fill(c->Lxy()/c->LxyError());
498     hLzOverLzErr->Fill(c->Lz()/c->LzError());
499     hLz->Fill(c->Lz());
500     }
501    
502     }
503    
504     //make N-1 plots
505     if (nFailed <= 1) {
506     const MCParticle *simPhoton = SimMatch(c);
507     UInt_t nSimFailed=0;
508     if (simPhoton)
509     nSimFailed = FailedSimCuts(simPhoton);
510     if (nSimFailed>1)
511     simPhoton=0;
512    
513    
514     if (nFailed==0 || c->Pt()<fPtMin) {
515     hGammaPt->Fill(c->Pt());
516     if (simPhoton)
517     if (nSimFailed==0 || simPhoton->Pt()<fPtMin) {
518     hSimMatchedGammaPt->Fill(c->Pt());
519     hSimMatchedSimGammaPt->Fill(simPhoton->Pt());
520     }
521     }
522     if (nFailed==0 || TMath::Abs(c->Eta())>fEtaMax) {
523     hGammaEta->Fill(c->Eta());
524     if (simPhoton)
525     if (nSimFailed==0 || TMath::Abs(simPhoton->Eta())>fEtaMax) {
526     hSimMatchedGammaEta->Fill(c->Eta());
527     hSimMatchedSimGammaEta->Fill(simPhoton->Eta());
528     }
529     }
530     if ( nFailed==0 || !PassRho(c->Position().Rho()) ) {
531     hConversionRadius->Fill(c->Position().Rho());
532     hConversionRPhi->Fill(c->Position().X(), c->Position().Y());
533     hConversionRZ->Fill(c->Position().Z(), c->Position().Rho()*c->Position().Y()/TMath::Abs(c->Position().Y()));
534     if (simPhoton)
535     if ( nSimFailed==0 || !PassRho(simPhoton->DecayVertex().Rho()) ) {
536     hSimMatchedConvRadius->Fill(c->Position().Rho());
537     hSimMatchedSimConvRadius->Fill(simPhoton->DecayVertex().Rho());
538     }
539    
540     }
541     if (nFailed==0 || c->Prob() < fProbMin) {
542     hConvProb->Fill(c->Prob());
543     hConvChi2->Fill(c->Chi2());
544     if (simPhoton)
545     if( nSimFailed==0)
546     hSimMatchedConvProb->Fill(c->Prob());
547     }
548     if ( nFailed==0 ) {
549     goodConversions.Add(c);
550     ++nConversions;
551     //fill photon histograms
552     hConversionZ->Fill(c->Position().Z());
553     hConvDCotTheta->Fill(DCotTheta(c));
554     hGammaMass->Fill(c->Mass());
555     hDxy->Fill(c->Dxy());
556     LoadBranch(fTrackName);
557     hNTracks->Fill(NTracks(fTracks));
558     Double_t isolation = TrackPtIsolation(c,fIsoRadius);
559     hIsolation->Fill(isolation);
560     Double_t minElectronPt = c->Daughter(0)->Pt();
561     const Particle *minPtElectron = c->Daughter(0);
562     for (UInt_t j=0; j<c->NDaughters(); ++j) {
563     const Particle* d = c->Daughter(j);
564     hElectronPt->Fill(d->Pt());
565     hElectronEta->Fill(d->Eta());
566     if (d->Pt() < minElectronPt) {
567     minElectronPt = d->Pt();
568     minPtElectron = d;
569     }
570     const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(d);
571     if (dc) {
572     const Track* t = dc->Trk();
573     hTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
574     hTrackProb->Fill(t->Prob());
575     hTrackNHits->Fill(t->NHits());
576     hTrackNHitsProb->Fill(t->NHits(),t->RChi2());
577     hTrackD0->Fill(t->D0());
578     // LoadBranch(fElectronName);
579     // Electron *e = MatchingElectron(dc,fElectrons);
580     // if (e) {
581     // //printf("Matching Electron added\n");
582     // goodElectrons.Add(e);
583     // }
584     // else
585     // ;//printf("No matching electron found\n");
586     }
587     }
588     hMinElectronPt->Fill(minElectronPt);
589    
590     if (simPhoton && nSimFailed==0) {
591    
592     //if (c->Position().Rho() < fRhoMax)
593     hSimMatchedGammaMass->Fill(c->Mass());
594     hSimMatchedConvResolution->Fill(c->Position().Rho() - simPhoton->DecayVertex().Rho());
595     hSimMatchedConvPhiRes->Fill(c->Position().Phi() - simPhoton->DecayVertex().Phi());
596     hSimMatchedLxy->Fill(c->Lxy());
597     hSimMatchedLz->Fill(c->Lz());
598     hSimMatchedDxy->Fill(c->Dxy());
599     hSimMatchedNTracks->Fill(NTracks(fTracks));
600     hSimMatchedIsolation->Fill(isolation);
601     hSimMatchedMinElectronPt->Fill(minElectronPt);
602     for (UInt_t j=0; j<c->NDaughters(); ++j) {
603     const Particle* d = c->Daughter(j);
604     const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(d);
605     if (dc) {
606     const Track* t = dc->Trk();
607     hSimMatchedTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
608     hSimMatchedTrackProb->Fill(t->Prob());
609     hSimMatchedTrackNHits->Fill(t->NHits());
610     hSimMatchedTrackNHitsProb->Fill(t->NHits(),t->RChi2());
611     hSimMatchedTrackD0->Fill(t->D0());
612     if (d==minPtElectron)
613     hSimMatchedMinElectronSimPt->Fill(t->MCPart()->Pt());
614     }
615     }
616     }
617     }
618     }
619    
620     // else if (!simPhoton) {
621     // //hConvDCotThetaPreCut->Fill(DCotTheta(c));
622     // // Bool_t toFill = true;
623     // // if (TMath::Abs(DCotTheta(c))<0.01)
624     // // for (UInt_t j=0; j<c->NDaughters(); ++j) {
625     // // const Particle* d = c->Daughter(j);
626     // // const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(d);
627     // // if (dc) {
628     // // const MCParticle *dcmc = dc->Trk()->MCPart();
629     // // if (dcmc) {
630     // // ;//printf("Daughter pdg = %i, mother pdg = %i\n",dcmc->PdgId(),dcmc->DistinctMother()->PdgId());
631     // // //if (dcmc->DistinctMother()->PdgId()==22 || TMath::Abs(dcmc->DistinctMother()->PdgId())==3122)
632     // // //toFill=false;
633     // // }
634     // // }
635     // // }
636     // //if (toFill)
637     // hConvDCotThetaPreCut->Fill(DCotTheta(c));
638     // hSimMatchedEPairDeltaPhi->Fill(DPhi(c));
639     // hSimMatchedConvChi2->Fill(c->Chi2()/c->Ndof());
640     // }
641     // else {
642     // for (UInt_t j=0; j<c->NDaughters(); ++j) {
643     // const Particle* d = c->Daughter(j);
644     // const ChargedParticle* dc = dynamic_cast<const ChargedParticle*>(d);
645     // if (dc) {
646     // const Track* t = dc->Trk();
647     // hUnMatchedTrackChi2->Fill(t->Chi2());
648     // hUnMatchedTrackProb->Fill(t->Prob());
649     // hUnMatchedTrackNHits->Fill(t->NHits());
650     // hUnMatchedTrackNHitsProb->Fill(t->NHits(),t->Prob());
651     // }
652     // }
653     //
654     // }
655     // }
656    
657    
658     }
659     hNConversions->Fill(nConversions);
660    
661     // LoadBranch(fPhotonName);
662     for (UInt_t i=0; i<goodConversions.GetEntries(); i++) {
663     DecayParticle *conv1 = goodConversions.At(i);
664     for (UInt_t j=i+1; j<goodConversions.GetEntries(); j++) {
665     DecayParticle *conv2 = goodConversions.At(j);
666     if (!conv2->HasCommonDaughter(conv1)) {
667     CompositeParticle pi0;
668     pi0.AddDaughter(conv1);
669     pi0.AddDaughter(conv2);
670     hDoubleConvMass->Fill(pi0.Mass());
671     }
672     }
673     // for (UInt_t j=0; j<fPhotons->GetEntries(); j++) {
674     // Photon *photon = fPhotons->At(j);
675     // if (PassPhotonCuts(photon)) {
676     // CompositeParticle pi0;
677     // pi0.AddDaughter(conv1);
678     // pi0.AddDaughter(photon);
679     // hConvGammaMass->Fill(pi0.Mass());
680     // }
681     // }
682     }
683    
684     }
685    
686     //__________________________________________________________________________________________________
687     void MvfConversions::SlaveTerminate()
688     {
689     // Run finishing code on the computer (slave) that did the analysis. For this module, we dont do
690     // anything here.
691     }
692    
693     //__________________________________________________________________________________________________
694     void MvfConversions::Terminate()
695     {
696    
697     fTimer.Stop();
698     printf("Total Analysis Time = %f\n",fTimer.CpuTime());
699    
700    
701     TCanvas* c1 = new TCanvas();
702     hConversionRadius->Draw();
703    
704     TCanvas* c2 = new TCanvas();
705     hConversionRPhi->Draw("col");
706     //c2->SetLogz();
707    
708     // Run finishing code on the client computer. For this module, we dont do anything here.
709     }
710    
711     UInt_t MvfConversions::FailedCuts(const DecayParticle* c) {
712    
713    
714     //if (p->GetVertex()->Prob() < 0.005)
715     // return false;
716     UInt_t nFailed = 0;
717    
718     if ( c->NDaughters() != 2)
719     nFailed++;
720    
721     if ( c->Pt() < fPtMin )
722     nFailed++;
723    
724     if ( !PassRho(c->Position().Rho()) )
725     nFailed++;
726    
727     if ( TMath::Abs(c->Eta()) > fEtaMax )
728     nFailed++;
729    
730    
731     if ( c->Lxy() < fLxyMin || c->Lz() < fLzMin )
732     nFailed++;
733    
734     if ( (c->Lxy()/c->LxyError()) < fLxyOverLxyErrMin )
735     nFailed++;
736    
737     if ( (c->Lz()/c->LzError()) < fLzOverLzErrMin )
738     nFailed++;
739    
740     if ( TMath::Abs(c->Dxy()) > fAbsDxyMax )
741     nFailed++;
742    
743     if (c->Mass() > fMassMax)
744     nFailed++;
745    
746     if (nFailed>=3)
747     return nFailed;
748    
749     if ( c->Charge() != 0 )
750     nFailed++;
751    
752     if (nFailed>=3)
753     return nFailed;
754    
755     Bool_t failedElectrons=false;
756     for (UInt_t i=0; i<c->NDaughters(); ++i) {
757     const DaughterData* d = c->DaughterDat(i);
758     if (!PassElectronCuts(d))
759     failedElectrons=true;
760     }
761     if (failedElectrons)
762     nFailed++;
763    
764     Double_t isolation = TrackPtIsolation(c,fIsoRadius);
765    
766     if (isolation > fIsoMax)
767     nFailed++;
768    
769     if ( c->Prob() < fProbMin )
770     nFailed++;
771    
772     return nFailed;
773     // LoadBranch(fMvfConvUnconstrainedName);
774     // const DecayParticle *unconstrained = MatchingConversion(c, fMvfConversionsUnconstrained);
775     //
776     // if (!unconstrained)
777     // nFailed++;
778     //
779     // if ( TwoPionMass(unconstrained) > 0.4 )
780     // nFailed++;
781     //hConvDCotTheta->Fill(dCotTheta);
782    
783     }
784    
785     Bool_t MvfConversions::PassConvCuts(const Conversion* p) {
786     if (p->NDaughters() != 2)
787     return false;
788    
789     Double_t convRadius = p->DecayVertex().Rho();
790     if (convRadius < 2.0)
791     //if (convRadius < 2.0 || convRadius > 20.0)
792     //if (convRadius < 20.0)
793     return false;
794    
795     const Electron* pElectron1 = (Electron*)p->Daughter(0);
796     const Electron* pElectron2 = (Electron*)p->Daughter(1);
797    
798    
799     //Double_t deltaPhi = TMath::ACos((pElectron1->Px()*pElectron2->Px() + pElectron1->Py()*pElectron2->Py() + pElectron1->Pz()*pElectron2->Pz())/(pElectron1->Mom().P()*pElectron2->Mom().P()));
800    
801     //if (deltaPhi>0.5)
802     // return false;
803     // if (fabs(p->DCotTheta())>0.2)
804     if (fabs(p->DCotTheta())>0.75)
805     return false;
806    
807     if (p->Charge()!=0)
808     return false;
809    
810    
811     /* for (Int_t i=0; i<p->NDaughters(); i++) {
812     const Electron* e = p->Daughter(i);
813     if (!PassElectronCuts(e))
814     return false;
815     } */
816     //if (p->Mass()<0.6)
817     // return false;
818    
819     //if (p->GetVertex().Prob() < 0.2)// || p->GetVertex().Prob() > 0.9)
820     // return false;
821    
822     return true;
823     }
824    
825     Bool_t MvfConversions::PassElectronCuts(const DaughterData* d) {
826     //if (p->Pt() < 5.0)
827     // return false;
828    
829     if (d->Pt() < fElectronPtMin)
830     return false;
831    
832     if (TMath::Abs(d->Eta()) > fElectronEtaMax)
833     return false;
834    
835     const StableData *s = dynamic_cast<const StableData*>(d);
836    
837     if (!s)
838     return false;
839    
840     if (s->NMissedHits() > fMissedHitsMax)
841     return false;
842    
843     if (s->NWrongHits() > fWrongHitsMax)
844     return false;
845    
846     const ChargedParticle* c = dynamic_cast<const ChargedParticle*>(s->Original());
847    
848     if (!c)
849     return false;
850    
851     const Track* t = c->Trk();
852    
853     if (!t)
854     return false;
855    
856     if (!PassTrackCuts(t))
857     return false;
858    
859     return true;
860     }
861    
862     Bool_t MvfConversions::PassTrackCuts(const Track* t) {
863    
864     // if ( t->Prob()<fTrackProbMin && t->NHits()<fNHitsMin )
865     if (t->NHits()<fNHitsMin)
866     return false;
867    
868     if (t->Prob()<fTrackProbMin)
869     return false;
870    
871     if (fExcludePXB1 && t->Hit(Track::PXB1))
872     return false;
873    
874     // if (t->NStereoHits() < 2)
875     // return false;
876    
877     return true;
878    
879     }
880    
881     UInt_t MvfConversions::FailedSimCuts(const MCParticle* p) {
882    
883     UInt_t nFailed = 0;
884    
885     if (p->PdgId()!=22)
886     nFailed++;
887     if (TMath::Abs(p->Eta())>fEtaMax)
888     nFailed++;
889     //if (p->Pt()<5.0 || p->Pt()>25.0)
890     //if (p->Pt()<25.0)
891     if (p->Pt()<fPtMin)
892     nFailed++;
893    
894     Double_t simRad = p->DecayVertex().Rho();
895     //if (simRad<2.0 || simRad>128.0)
896     //if (simRad<2.0 || simRad>20.0)
897     //if (simRad<20.0 || simRad>128.0)
898     if ( !PassRho(simRad) )
899     nFailed++;
900    
901     if (nFailed>=2)
902     return nFailed;
903    
904     Int_t nEPlus = 0;
905     Int_t nEMinus = 0;
906     Bool_t failedElectronPt=false;
907     Bool_t failedElectronEta=false;
908     for (UInt_t j=0; j<p->NDaughters(); j++) {
909     const MCParticle* pDaughter = p->Daughter(j);
910     if (pDaughter->PdgId()==11)
911     nEPlus++;
912     if (pDaughter->PdgId()==-11)
913     nEMinus++;
914     if (TMath::Abs(pDaughter->PdgId())==11) {
915     if (pDaughter->Pt() < fElectronPtMin)
916     failedElectronPt = true;
917     if (TMath::Abs(pDaughter->Eta()) > fElectronEtaMax)
918     failedElectronEta=true;
919     }
920     }
921     if (failedElectronPt)
922     nFailed++;
923     if (failedElectronEta)
924     nFailed++;
925    
926     if (nEPlus!=1 || nEMinus!=1)
927     nFailed++;
928    
929     return nFailed;
930     }
931    
932     const MCParticle* MvfConversions::SimMatch(const DecayParticle* p) {
933     if ( p->NDaughters()!=2 )
934     return 0;
935    
936     const ChargedParticle *electron1 = dynamic_cast<const ChargedParticle*>(p->Daughter(0));
937     const ChargedParticle *electron2 = dynamic_cast<const ChargedParticle*>(p->Daughter(1));
938    
939     if (!electron1 || !electron2)
940     return 0;
941    
942     const MCParticle *simElectron1 = electron1->Trk()->MCPart();
943     const MCParticle *simElectron2 = electron2->Trk()->MCPart();
944    
945    
946     if (simElectron1) {
947     hTrackSimMatchType->Fill(simElectron1->PdgId());
948     if (simElectron1->HasMother())
949     hParentSimMatchType->Fill(simElectron1->Mother()->PdgId());
950     }
951    
952     if (simElectron2) {
953     hTrackSimMatchType->Fill(simElectron2->PdgId());
954     if (simElectron2->HasMother())
955     hParentSimMatchType->Fill(simElectron2->Mother()->PdgId());
956     }
957    
958    
959     if (!simElectron1) {
960     const Track *t = electron1->Trk();
961     hUnMatchedTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
962     hUnMatchedTrackProb->Fill(t->Prob());
963     hUnMatchedTrackNHits->Fill(t->NHits());
964     hUnMatchedTrackNHitsProb->Fill(t->NHits(),t->RChi2());
965     hUnMatchedTrackD0->Fill(t->D0());
966     }
967    
968     if (!simElectron2) {
969     const Track *t = electron2->Trk();
970     hUnMatchedTrackChi2->Fill(t->Chi2()/((Double_t)t->Ndof()));
971     hUnMatchedTrackProb->Fill(t->Prob());
972     hUnMatchedTrackNHits->Fill(t->NHits());
973     hUnMatchedTrackNHitsProb->Fill(t->NHits(),t->RChi2());
974     hUnMatchedTrackD0->Fill(t->D0());
975     }
976    
977     if (!simElectron1 || !simElectron2) {
978     //printf("unmatched electron\n");
979     return 0;
980     }
981    
982    
983     if ( TMath::Abs(simElectron1->PdgId())!=11 || TMath::Abs(simElectron2->PdgId())!=11 ) {
984     //printf("not electrons\n");
985     return 0;
986     }
987    
988     const MCParticle *simPhoton = simElectron1->DistinctMother();
989    
990     if (!simPhoton) {
991     // printf("no photon\n");
992     // hParentSimMatchType->Fill(0);
993     return 0;
994     }
995    
996     if (simElectron2->DistinctMother()!=simPhoton) {
997     //printf("different mothers\n");
998     // hParentSimMatchType->Fill(0);
999     return 0;
1000     }
1001    
1002     if (simPhoton->PdgId()!=22) {
1003     //printf("not a photon\n");
1004     return 0;
1005     }
1006    
1007     // printf("found common mother with pdg=%i, daughter pdgs: %i, %i\n", simPhoton->PdgId(), simElectron1->PdgId(),simElectron2->PdgId());
1008    
1009     // hParentSimMatchType->Fill(simPhoton->PdgId());
1010    
1011     return simPhoton;
1012    
1013    
1014     }
1015    
1016     UInt_t MvfConversions::NTracks(const TrackCol *col)
1017     {
1018     UInt_t ntracks=0;
1019     for (UInt_t i=0; i<col->GetEntries(); ++i) {
1020     const Track *t = col->At(i);
1021     if ( PassTrackCuts(t) )
1022     ntracks++;
1023     }
1024    
1025     return ntracks;
1026     }
1027    
1028     Double_t MvfConversions::TrackPtIsolation(const DecayParticle *p, Double_t r)
1029     {
1030     TObjArray conversionTracks;
1031     for (UInt_t i=0; i<p->NDaughters(); ++i) {
1032     const ChargedParticle* d = dynamic_cast<const ChargedParticle*>(p->Daughter(i));
1033     if (d) {
1034     const Track *t = d->Trk();
1035     if (t)
1036     conversionTracks.Add((TObject*)t);
1037     }
1038     }
1039    
1040    
1041     LoadBranch(fTrackName);
1042     Double_t sumPt=0.0;
1043     for (UInt_t i=0; i<fTracks->GetEntries(); ++i) {
1044     const Track *t = fTracks->At(i);
1045     if (conversionTracks.IndexOf(t)==-1) {
1046     Double_t deltaR = MathUtils::DeltaR(p->Phi(),p->Eta(),t->Phi(),t->Eta());
1047     if (deltaR<r)
1048     sumPt = sumPt + 1.0;//sumPt += t->Pt();
1049     }
1050     }
1051    
1052     return sumPt;
1053    
1054     }
1055    
1056     Bool_t MvfConversions::PassPhotonCuts(const Photon *p)
1057     {
1058     if (p->IsConverted())
1059     return false;
1060    
1061     return true;
1062     }
1063    
1064     Double_t MvfConversions::DCotTheta(const DecayParticle *c)
1065     {
1066     if (c->NDaughters()!=2)
1067     return 0.0;
1068    
1069     Double_t theta1 = c->DaughterDat(0)->Theta();
1070     Double_t theta2 = c->DaughterDat(1)->Theta();
1071    
1072     Double_t dCotTheta = 1./TMath::Tan(theta1) - 1./TMath::Tan(theta2);
1073     //Double_t dCotTheta = c->DaughterDat(0)->Pt() - c->DaughterDat(1)->Pt();
1074    
1075     if (c->DaughterDat(0)->Charge()==1)
1076     return dCotTheta;
1077     else
1078     return (-dCotTheta);
1079     }
1080    
1081     Double_t MvfConversions::DPhi(const DecayParticle *c)
1082     {
1083     if (c->NDaughters()!=2)
1084     return 0.0;
1085    
1086     ThreeVector mom1 = ((const StableData*)c->DaughterDat(0))->ThreeMom();
1087     ThreeVector mom2 = ((const StableData*)c->DaughterDat(1))->ThreeMom();
1088    
1089     Double_t dPhi = TMath::ACos(mom1.Dot(mom2)/(mom1.R()*mom2.R()));
1090    
1091     return dPhi;
1092     }
1093    
1094     Double_t MvfConversions::TwoPionMass(const DecayParticle *c)
1095     {
1096     if (c->NDaughters()!=2)
1097     return 0.0;
1098    
1099     StableParticle *pi1 = new StableParticle(211, (Track*)((ChargedParticle*)c->Daughter(0))->Trk());
1100     StableParticle *pi2 = new StableParticle(211, (Track*)((ChargedParticle*)c->Daughter(1))->Trk());
1101    
1102     StableData *pi1d = new StableData(pi1, ((StableData*)c->DaughterDat(0))->ThreeMom());
1103     StableData *pi2d = new StableData(pi2, ((StableData*)c->DaughterDat(1))->ThreeMom());
1104    
1105     CompositeParticle *meson = new CompositeParticle();
1106     meson->AddDaughter(pi1d);
1107     meson->AddDaughter(pi2d);
1108    
1109     Double_t mesonMass = meson->Mass();
1110    
1111     delete meson;
1112     delete pi1d;
1113     delete pi2d;
1114     delete pi1;
1115     delete pi2;
1116    
1117     return mesonMass;
1118     }
1119    
1120     const DecayParticle *MvfConversions::MatchingConversion(const DecayParticle *c, const DecayParticleCol *col) const
1121     {
1122     for (UInt_t i=0; i<col->GetEntries(); ++i) {
1123     const DecayParticle *p = col->At(i);
1124     if ( p->HasSameDaughters(c) )
1125     return c;
1126     }
1127    
1128     return 0;
1129     }
1130    
1131     Electron *MvfConversions::MatchingElectron(const ChargedParticle *c, ElectronCol *col) const
1132     {
1133     Electron *match=0;
1134     Double_t dRMin=0;
1135     for (UInt_t i=0; i<col->GetEntries(); ++i) {
1136     Electron *e = col->At(i);
1137     Double_t dR = MathUtils::DeltaR(c->Mom(), e->Mom());
1138     if ( dR<0.1 && (!match || dR<dRMin) ) {
1139     dRMin = dR;
1140     match = e;
1141     }
1142     // if ( c->TrackerTrk() == e->TrackerTrk() )
1143     // return e;
1144     }
1145    
1146     return match;
1147     }
1148    
1149     void MvfConversions::AddRhoRange(Double_t lower, Double_t upper)
1150     {
1151     fRhoLbs.push_back(lower);
1152     fRhoUbs.push_back(upper);
1153     }
1154    
1155     Bool_t MvfConversions::PassRho(Double_t rho)
1156     {
1157     for (UInt_t i=0; i<fRhoLbs.size(); ++i) {
1158     if ( rho>fRhoLbs.at(i) && rho<fRhoUbs.at(i) )
1159     return true;
1160     }
1161    
1162     return false;
1163     }