ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonTreeWriter.cc
Revision: 1.20
Committed: Sun May 27 16:09:57 2012 UTC (12 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.19: +368 -71 lines
Log Message:
add optional filling of detailed cluster arrays and optimization of tree writing

File Contents

# User Rev Content
1 bendavid 1.1 #include "MitPhysics/Mods/interface/PhotonTreeWriter.h"
2     #include "MitAna/DataTree/interface/PhotonCol.h"
3     #include "MitAna/DataTree/interface/PFCandidateCol.h"
4     #include "MitAna/DataTree/interface/StableData.h"
5     #include "MitAna/DataTree/interface/StableParticle.h"
6 bendavid 1.2 #include "MitAna/DataTree/interface/PFMet.h"
7 bendavid 1.1 #include "MitPhysics/Init/interface/ModNames.h"
8     #include "MitPhysics/Utils/interface/IsolationTools.h"
9     #include "MitPhysics/Utils/interface/PhotonTools.h"
10     #include "MitPhysics/Utils/interface/VertexTools.h"
11 fabstoec 1.16 #include "MitPhysics/Utils/interface/PFMetCorrectionTools.h"
12     #include "MitAna/DataTree/interface/PFJetCol.h"
13     #include "MitAna/DataTree/interface/GenJetCol.h"
14 bendavid 1.1 #include "TDataMember.h"
15 bendavid 1.20 #include "TFile.h"
16 bendavid 1.1 #include <TNtuple.h>
17     #include <TRandom3.h>
18     #include <TSystem.h>
19    
20     using namespace mithep;
21    
22     ClassImp(mithep::PhotonTreeWriter)
23 bendavid 1.20 templateClassImp(mithep::PhotonTreeWriterPhoton)
24 bendavid 1.1 ClassImp(mithep::PhotonTreeWriterDiphotonEvent)
25    
26     //--------------------------------------------------------------------------------------------------
27     PhotonTreeWriter::PhotonTreeWriter(const char *name, const char *title) :
28     // Base Module...
29 paus 1.12 BaseMod (name,title),
30 bendavid 1.1 // define all the Branches to load
31 paus 1.12 fPhotonBranchName (Names::gkPhotonBrn),
32 bendavid 1.20 fPFPhotonName ("PFPhotons"),
33 paus 1.12 fElectronName (Names::gkElectronBrn),
34     fGoodElectronName (Names::gkElectronBrn),
35     fConversionName (Names::gkMvfConversionBrn),
36     fTrackBranchName (Names::gkTrackBrn),
37     fPileUpDenName (Names::gkPileupEnergyDensityBrn),
38     fPVName (Names::gkPVBeamSpotBrn),
39     fBeamspotName (Names::gkBeamSpotBrn),
40     fPFCandName (Names::gkPFCandidatesBrn),
41     fMCParticleName (Names::gkMCPartBrn),
42     fPileUpName (Names::gkPileupInfoBrn),
43     fSuperClusterName ("PFSuperClusters"),
44     fPFMetName ("PFMet"),
45     fPFJetName (Names::gkPFJetBrn),
46 fabstoec 1.19 funcorrPFJetName ("AKt5PFJets"),
47 fabstoec 1.17 fGenJetName ("AKT5GenJets"),
48 fabstoec 1.13 fLeptonTagElectronsName ("HggLeptonTagElectrons"),
49     fLeptonTagMuonsName ("HggLeptonTagMuons"),
50    
51 paus 1.12 fIsData (false),
52     fPhotonsFromBranch (kTRUE),
53     fPVFromBranch (kTRUE),
54     fGoodElectronsFromBranch(kTRUE),
55     fPFJetsFromBranch (kTRUE),
56 bendavid 1.1 // ----------------------------------------
57     // collections....
58 paus 1.12 fPhotons (0),
59 bendavid 1.20 fPFPhotons (0),
60 paus 1.12 fElectrons (0),
61     fConversions (0),
62     fTracks (0),
63     fPileUpDen (0),
64     fPV (0),
65     fBeamspot (0),
66     fPFCands (0),
67     fMCParticles (0),
68     fPileUp (0),
69     fSuperClusters (0),
70     fPFJets (0),
71 fabstoec 1.16 fGenJets (0),
72     funcorrPFJets (0),
73 fabstoec 1.13
74     fLeptonTagElectrons (0),
75     fLeptonTagMuons (0),
76    
77 paus 1.12 fLoopOnGoodElectrons (kFALSE),
78     fApplyElectronVeto (kTRUE),
79     fWriteDiphotonTree (kTRUE),
80     fWriteSingleTree (kTRUE),
81 bendavid 1.20 fEnablePFPhotons (kTRUE),
82 paus 1.12 fExcludeSinglePrompt (kFALSE),
83     fExcludeDoublePrompt (kFALSE),
84     fEnableJets (kFALSE),
85 fabstoec 1.13 fApplyLeptonTag (kFALSE),
86 fabstoec 1.15 fApplyBTag (kFALSE),
87 fabstoec 1.17 fApplyPFMetCorrections (kFALSE),
88 bendavid 1.20 fFillClusterArrays (kFALSE),
89 paus 1.12 fPhFixDataFile (gSystem->Getenv("CMSSW_BASE") +
90     TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat")),
91     fTupleName ("hPhotonTree")
92 bendavid 1.1 {
93 paus 1.12 // Constructor
94 bendavid 1.1 }
95    
96 paus 1.12 PhotonTreeWriter::~PhotonTreeWriter()
97     {
98     // Destructor
99 bendavid 1.1 }
100    
101     //--------------------------------------------------------------------------------------------------
102     void PhotonTreeWriter::Process()
103     {
104     // ------------------------------------------------------------
105     // Process entries of the tree.
106     LoadEventObject(fPhotonBranchName, fPhotons);
107 paus 1.12 LoadEventObject(fGoodElectronName, fGoodElectrons);
108 fabstoec 1.13
109     // lepton tag collections
110     if( fApplyLeptonTag ) {
111     LoadEventObject(fLeptonTagElectronsName, fLeptonTagElectrons);
112     LoadEventObject(fLeptonTagMuonsName, fLeptonTagMuons);
113     }
114    
115 bendavid 1.2 const BaseCollection *egcol = 0;
116 paus 1.12 if (fLoopOnGoodElectrons)
117 bendavid 1.2 egcol = fGoodElectrons;
118 paus 1.12 else
119 bendavid 1.2 egcol = fPhotons;
120 paus 1.12 if (egcol->GetEntries()<1)
121     return;
122 bendavid 1.20
123     if (fEnablePFPhotons) LoadEventObject(fPFPhotonName, fPFPhotons);
124 bendavid 1.1 LoadEventObject(fElectronName, fElectrons);
125     LoadEventObject(fConversionName, fConversions);
126     LoadEventObject(fTrackBranchName, fTracks);
127     LoadEventObject(fPileUpDenName, fPileUpDen);
128     LoadEventObject(fPVName, fPV);
129     LoadEventObject(fBeamspotName, fBeamspot);
130     LoadEventObject(fPFCandName, fPFCands);
131 bendavid 1.2 LoadEventObject(fSuperClusterName, fSuperClusters);
132 paus 1.12 LoadEventObject(fPFMetName, fPFMet);
133 fabstoec 1.16 if (fEnableJets){
134 paus 1.12 LoadEventObject(fPFJetName, fPFJets);
135 fabstoec 1.19 //LoadEventObject(funcorrPFJetName, funcorrPFJets);
136 fabstoec 1.16 LoadBranch(funcorrPFJetName);
137 fabstoec 1.19 // if(!fIsData) LoadEventObject(fGenJetName, fGenJets);
138 fabstoec 1.16 }
139 bendavid 1.1 // ------------------------------------------------------------
140     // load event based information
141 paus 1.12 Int_t _numPU = -1.; // some sensible default values....
142 bendavid 1.1 Int_t _numPUminus = -1.; // some sensible default values....
143 paus 1.12 Int_t _numPUplus = -1.; // some sensible default values....
144 bendavid 1.1
145 paus 1.12 Float_t rho = -99.;
146 bendavid 1.1 if( fPileUpDen->GetEntries() > 0 )
147 paus 1.12 rho = (Double_t) fPileUpDen->At(0)->RhoRandomLowEta();
148 bendavid 1.1
149     const BaseVertex *bsp = dynamic_cast<const BaseVertex*>(fBeamspot->At(0));
150 bendavid 1.20
151 bendavid 1.1 if( !fIsData ) {
152     LoadBranch(fMCParticleName);
153     LoadBranch(fPileUpName);
154 fabstoec 1.19 if (fEnableJets) LoadEventObject(fGenJetName, fGenJets);
155     } else fGenJets = NULL;
156 bendavid 1.1
157     if( !fIsData ) {
158     for (UInt_t i=0; i<fPileUp->GetEntries(); ++i) {
159     const PileupInfo *puinfo = fPileUp->At(i);
160     if (puinfo->GetBunchCrossing()==0) _numPU = puinfo->GetPU_NumInteractions();
161     else if (puinfo->GetBunchCrossing() == -1) _numPUminus = puinfo->GetPU_NumInteractions();
162     else if (puinfo->GetBunchCrossing() == 1) _numPUplus = puinfo->GetPU_NumInteractions();
163     }
164     }
165    
166     // in case of a MC event, try to find Higgs and Higgs decay Z poisition
167 paus 1.12 Float_t _pth = -100.;
168     Float_t _decayZ = -100.;
169 bendavid 1.1 Float_t _genmass = -100.;
170 paus 1.12 if (!fIsData)
171     FindHiggsPtAndZ(_pth, _decayZ, _genmass);
172 bendavid 1.1
173 fabstoec 1.19
174     Double_t _spfMet = fPFMet->At(0)->SumEt();
175 fabstoec 1.13 fDiphotonEvent->leptonTag = -1; // disabled
176    
177 bendavid 1.20 fDiphotonEvent->rho = fPileUpDen->At(0)->RhoKt6PFJets();
178     fDiphotonEvent->rho25 = fPileUpDen->At(0)->RhoRandomLowEta();
179     fDiphotonEvent->rhoold = fPileUpDen->At(0)->Rho();
180 bendavid 1.1 fDiphotonEvent->genHiggspt = _pth;
181     fDiphotonEvent->genHiggsZ = _decayZ;
182     fDiphotonEvent->genmass = _genmass;
183     fDiphotonEvent->gencostheta = -99.;
184     fDiphotonEvent->nVtx = fPV->GetEntries();
185 bendavid 1.2 fDiphotonEvent->bsX = fBeamspot->At(0)->X();
186     fDiphotonEvent->bsY = fBeamspot->At(0)->Y();
187     fDiphotonEvent->bsZ = fBeamspot->At(0)->Z();
188 bendavid 1.7 fDiphotonEvent->bsSigmaZ = fBeamspot->At(0)->SigmaZ();
189 bendavid 1.2 fDiphotonEvent->vtxX = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->X() : -99.;
190     fDiphotonEvent->vtxY = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Y() : -99.;
191 bendavid 1.1 fDiphotonEvent->vtxZ = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Z() : -99.;
192     fDiphotonEvent->numPU = _numPU;
193     fDiphotonEvent->numPUminus = _numPUminus;
194     fDiphotonEvent->numPUplus = _numPUplus;
195     fDiphotonEvent->mass = -99.;
196     fDiphotonEvent->ptgg = -99.;
197     fDiphotonEvent->costheta = -99.;
198 bendavid 1.2 fDiphotonEvent->mt = -99.;
199     fDiphotonEvent->cosphimet = -99.;
200     fDiphotonEvent->mtele = -99.;
201     fDiphotonEvent->cosphimetele = -99.;
202 bendavid 1.1 fDiphotonEvent->evt = GetEventHeader()->EvtNum();
203     fDiphotonEvent->run = GetEventHeader()->RunNum();
204     fDiphotonEvent->lumi = GetEventHeader()->LumiSec();
205     fDiphotonEvent->evtcat = -99;
206 bendavid 1.2 fDiphotonEvent->nobj = fPhotons->GetEntries();
207     fDiphotonEvent->pfmet = fPFMet->At(0)->Pt();
208     fDiphotonEvent->pfmetphi = fPFMet->At(0)->Phi();
209     fDiphotonEvent->pfmetx = fPFMet->At(0)->Px();
210     fDiphotonEvent->pfmety = fPFMet->At(0)->Py();
211 fabstoec 1.19 fDiphotonEvent->spfMet = _spfMet;
212 bendavid 1.1 fDiphotonEvent->masscor = -99.;
213     fDiphotonEvent->masscorerr = -99.;
214 bendavid 1.2 fDiphotonEvent->masscorele = -99.;
215     fDiphotonEvent->masscoreleerr = -99.;
216     fDiphotonEvent->ismc = GetEventHeader()->IsMC();
217    
218 bendavid 1.5 //jets
219     const Jet *jet1 = 0;
220     const Jet *jet2 = 0;
221     const Jet *jetcentral = 0;
222    
223     fDiphotonEvent->jet1pt = -99.;
224     fDiphotonEvent->jet1eta = -99.;
225     fDiphotonEvent->jet1phi = -99.;
226     fDiphotonEvent->jet1mass = -99.;
227     fDiphotonEvent->jet2pt = -99.;
228     fDiphotonEvent->jet2eta = -99.;
229     fDiphotonEvent->jet2phi = -99.;
230     fDiphotonEvent->jet2mass = -99.;
231     fDiphotonEvent->jetcentralpt = -99.;
232     fDiphotonEvent->jetcentraleta = -99.;
233     fDiphotonEvent->jetcentralphi = -99.;
234     fDiphotonEvent->jetcentralmass = -99.;
235     fDiphotonEvent->dijetpt = -99.;
236     fDiphotonEvent->dijeteta = -99.;
237     fDiphotonEvent->dijetphi = -99.;
238     fDiphotonEvent->dijetmass = -99.;
239     fDiphotonEvent->jetetaplus = -99.;
240     fDiphotonEvent->jetetaminus = -99.;
241     fDiphotonEvent->zeppenfeld = -99.;
242     fDiphotonEvent->dphidijetgg = -99.;
243    
244 fabstoec 1.19 //uncorrected jets
245     // const Jet *uncorrjet1 = 0;
246     // const Jet *uncorrjet2 = 0;
247     // const Jet *uncorrjetcentral = 0;
248    
249     // fDiphotonEvent->uncorrjet1pt = -99.;
250     // fDiphotonEvent->uncorrjet1eta = -99.;
251     // fDiphotonEvent->uncorrjet1phi = -99.;
252     // fDiphotonEvent->uncorrjet1mass = -99.;
253     // fDiphotonEvent->uncorrjet2pt = -99.;
254     // fDiphotonEvent->uncorrjet2eta = -99.;
255     // fDiphotonEvent->uncorrjet2phi = -99.;
256     // fDiphotonEvent->uncorrjet2mass = -99.;
257     // fDiphotonEvent->uncorrjetcentralpt = -99.;
258     // fDiphotonEvent->uncorrjetcentraleta = -99.;
259     // fDiphotonEvent->uncorrjetcentralphi = -99.;
260     // fDiphotonEvent->uncorrjetcentralmass = -99.;
261     // fDiphotonEvent->diuncorrjetpt = -99.;
262     // fDiphotonEvent->diuncorrjeteta = -99.;
263     // fDiphotonEvent->diuncorrjetphi = -99.;
264     // fDiphotonEvent->diuncorrjetmass = -99.;
265    
266    
267    
268 bendavid 1.1 Int_t nhitsbeforevtxmax = 1;
269 paus 1.12 if (!fApplyElectronVeto)
270     nhitsbeforevtxmax = 999;
271 bendavid 1.1
272 bendavid 1.2 if (egcol->GetEntries()>=2) {
273     const Particle *p1 = 0;
274     const Particle *p2 = 0;
275     const Photon *phHard = 0;
276     const Photon *phSoft = 0;
277     const Electron *ele1 = 0;
278     const Electron *ele2 = 0;
279     const SuperCluster *sc1 = 0;
280     const SuperCluster *sc2 = 0;
281    
282     if (fLoopOnGoodElectrons) {
283     ele1 = fGoodElectrons->At(0);
284     ele2 = fGoodElectrons->At(1);
285     p1 = ele1;
286     p2 = ele2;
287     sc1 = ele1->SCluster();
288     sc2 = ele2->SCluster();
289     phHard = PhotonTools::MatchedPhoton(ele1,fPhotons);
290     phSoft = PhotonTools::MatchedPhoton(ele2,fPhotons);
291     }
292     else {
293     phHard = fPhotons->At(0);
294     phSoft = fPhotons->At(1);
295     p1 = phHard;
296     p2 = phSoft;
297     sc1 = phHard->SCluster();
298     sc2 = phSoft->SCluster();
299     ele1 = PhotonTools::MatchedElectron(phHard,fGoodElectrons);
300     ele2 = PhotonTools::MatchedElectron(phSoft,fGoodElectrons);
301 bendavid 1.1 }
302    
303 paus 1.12 const DecayParticle *conv1 = PhotonTools::MatchedConversion(sc1,fConversions,bsp,
304     nhitsbeforevtxmax);
305     const DecayParticle *conv2 = PhotonTools::MatchedConversion(sc2,fConversions,bsp,
306     nhitsbeforevtxmax);
307 bendavid 1.2
308 bendavid 1.20 const SuperCluster *pfsc1 = PhotonTools::MatchedPFSC(sc1,fPFPhotons, fElectrons);
309     const SuperCluster *pfsc2 = PhotonTools::MatchedPFSC(sc2,fPFPhotons, fElectrons);
310 bendavid 1.1
311     const MCParticle *phgen1 = 0;
312     const MCParticle *phgen2 = 0;
313 paus 1.12 if (!fIsData) {
314 bendavid 1.6 phgen1 = PhotonTools::MatchMC(p1,fMCParticles,!fApplyElectronVeto);
315     phgen2 = PhotonTools::MatchMC(p2,fMCParticles,!fApplyElectronVeto);
316 bendavid 1.2 }
317    
318 paus 1.12 if (fExcludeSinglePrompt && (phgen1 || phgen2))
319     return;
320     if (fExcludeDoublePrompt && (phgen1 && phgen2))
321     return;
322 bendavid 1.2
323     if (!fLoopOnGoodElectrons && phHard->HasPV()) {
324     fDiphotonEvent->vtxX = phHard->PV()->X();
325     fDiphotonEvent->vtxY = phHard->PV()->Y();
326     fDiphotonEvent->vtxZ = phHard->PV()->Z();
327 bendavid 1.4 fDiphotonEvent->vtxprob = phHard->VtxProb();
328 bendavid 1.2 }
329    
330 fabstoec 1.15 // fill Btag information... set to true if One jet fullfills
331 fabstoec 1.19 fDiphotonEvent -> btagJet1 = -1.;
332     fDiphotonEvent -> btagJet1Pt = -99.;
333     fDiphotonEvent -> btagJet1Eta = -99.;
334    
335     fDiphotonEvent -> btagJet2 = -1.;
336     fDiphotonEvent -> btagJet2Pt = -99.;
337     fDiphotonEvent -> btagJet2Eta = -99.;
338 fabstoec 1.18
339 fabstoec 1.15 if( fApplyBTag && fEnableJets ) {
340     float highTag = 0.;
341     float highJetPt = 0.;
342     float highJetEta = 0.;
343 fabstoec 1.19
344     float trailTag = 0.;
345 fabstoec 1.18 float trailJetPt = 0.;
346     float trailJetEta = 0.;
347 fabstoec 1.19
348 fabstoec 1.15 for (UInt_t ijet=0; ijet<fPFJets->GetEntries();++ijet) {
349     const Jet *jet = fPFJets->At(ijet);
350     if( jet->Pt() < 20. || jet->AbsEta() > 2.4 ) continue;
351     if ( jet->CombinedSecondaryVertexBJetTagsDisc() > highTag ) {
352 fabstoec 1.19
353     trailTag = highTag;
354     trailJetPt = highJetPt;
355 fabstoec 1.18 trailJetEta = highJetEta;
356 fabstoec 1.19
357 fabstoec 1.15 highTag = jet->CombinedSecondaryVertexBJetTagsDisc();
358     highJetPt = jet->Pt();
359     highJetEta = jet->Eta();
360 fabstoec 1.19
361 fabstoec 1.18 } else if ( jet->CombinedSecondaryVertexBJetTagsDisc() > trailTag ) {
362 fabstoec 1.19
363 fabstoec 1.18 trailTag = jet->CombinedSecondaryVertexBJetTagsDisc();
364     trailJetPt = jet->Pt();
365     trailJetEta = jet->Eta();
366 fabstoec 1.15 }
367     }
368 fabstoec 1.18 fDiphotonEvent -> btagJet1 = highTag;
369     fDiphotonEvent -> btagJet1Pt = highJetPt;
370 fabstoec 1.19 fDiphotonEvent -> btagJet1Eta = highJetEta;
371    
372     fDiphotonEvent -> btagJet1 = trailTag;
373     fDiphotonEvent -> btagJet1Pt = trailJetPt;
374     fDiphotonEvent -> btagJet1Eta = trailJetEta;
375    
376 fabstoec 1.15 }
377    
378 bendavid 1.5 //fill jet variables
379     if (fEnableJets) {
380     for (UInt_t ijet=0; ijet<fPFJets->GetEntries();++ijet) {
381     const Jet *jet = fPFJets->At(ijet);
382 bendavid 1.8 if (jet->AbsEta()<4.7 && MathUtils::DeltaR(jet,p1)>0.5 && MathUtils::DeltaR(jet,p2)>0.5) {
383 bendavid 1.5 if (!jet1) jet1 = jet;
384     else if (!jet2) jet2 = jet;
385     else if (!jetcentral && 0) jetcentral = jet;
386     }
387     if (jet1&&jet2&&jetcentral) break;
388 fabstoec 1.19 }
389 bendavid 1.5 }
390    
391     if (jet1) {
392     fDiphotonEvent->jet1pt = jet1->Pt();
393     fDiphotonEvent->jet1eta = jet1->Eta();
394     fDiphotonEvent->jet1phi = jet1->Phi();
395     fDiphotonEvent->jet1mass = jet1->Mass();
396     }
397    
398     if (jet2) {
399     fDiphotonEvent->jet2pt = jet2->Pt();
400     fDiphotonEvent->jet2eta = jet2->Eta();
401     fDiphotonEvent->jet2phi = jet2->Phi();
402     fDiphotonEvent->jet2mass = jet2->Mass();
403     }
404    
405     if (jetcentral) {
406     fDiphotonEvent->jetcentralpt = jetcentral->Pt();
407     fDiphotonEvent->jetcentraleta = jetcentral->Eta();
408     fDiphotonEvent->jetcentralphi = jetcentral->Phi();
409     fDiphotonEvent->jetcentralmass = jetcentral->Mass();
410     }
411    
412     if (jet1&&jet2){
413     FourVectorM momjj = (jet1->Mom() + jet2->Mom());
414    
415     fDiphotonEvent->dijetpt = momjj.Pt();
416     fDiphotonEvent->dijeteta = momjj.Eta();
417     fDiphotonEvent->dijetphi = momjj.Phi();
418     fDiphotonEvent->dijetmass = momjj.M();
419    
420     if (jet1->Eta()>jet2->Eta()) {
421     fDiphotonEvent->jetetaplus = jet1->Eta();
422     fDiphotonEvent->jetetaminus = jet2->Eta();
423     }
424     else {
425     fDiphotonEvent->jetetaplus = jet2->Eta();
426     fDiphotonEvent->jetetaminus = jet1->Eta();
427     }
428     }
429    
430 fabstoec 1.16 //added gen. info of whether a lep. or nutrino is from W or Z --Heng 02/14/2012 12:30 EST
431     Double_t _fromZ = -99;
432     Double_t _fromW = -99;
433     Float_t _zpt = -99;
434     Float_t _zEta = -99;
435     Float_t _allZpt = -99;
436     Float_t _allZEta = -99;
437    
438     if( !fIsData ){
439    
440     // loop over all GEN particles and look for nutrinos whoes mother is Z
441     for(UInt_t j=0; j<fMCParticles->GetEntries(); ++j) {
442     const MCParticle* p = fMCParticles->At(j);
443     if( p->AbsPdgId()==23 ||p->AbsPdgId()==32 || p->AbsPdgId()==33 ) {
444     _allZpt=p->Pt();
445     _allZEta=p->Eta();
446     if (p->HasDaughter(12,kFALSE) || p->HasDaughter(14,kFALSE) || p->HasDaughter(16,kFALSE) ||p->HasDaughter(18,kFALSE) ) {
447     _fromZ=1;
448     _zpt=p->Pt();
449     _zEta=p->Eta();
450     }
451     }
452     else _fromW=1;
453     }
454     }
455    
456     fDiphotonEvent->fromZ = _fromZ;
457     fDiphotonEvent->fromW = _fromW;
458     fDiphotonEvent->zpt = _zpt;
459     fDiphotonEvent->zEta = _zEta;
460     fDiphotonEvent->allZpt = _allZpt;
461     fDiphotonEvent->allZEta = _allZEta;
462    
463     Double_t _dphiMetgg = -99;
464     Double_t _cosdphiMetgg = -99;
465     Double_t _dphiPhPh = -99;
466 bendavid 1.4 Double_t _mass = -99.;
467     Double_t _masserr = -99.;
468     Double_t _masserrsmeared = -99.;
469     Double_t _masserrwrongvtx = -99.;
470     Double_t _masserrsmearedwrongvtx = -99.;
471     Double_t _ptgg = -99.;
472 bendavid 1.5 Double_t _etagg = -99.;
473     Double_t _phigg = -99.;
474 bendavid 1.4 Double_t _costheta = -99.;
475 bendavid 1.2 PhotonTools::DiphotonR9EtaPtCats _evtcat = PhotonTools::kOctCat0;
476     if (phHard && phSoft) {
477 fabstoec 1.16 _dphiMetgg = MathUtils::DeltaPhi((phHard->Mom()+phSoft->Mom()).Phi(),fPFMet->At(0)->Phi());
478     _cosdphiMetgg = TMath::Cos(_dphiMetgg);
479     _dphiPhPh = MathUtils::DeltaPhi((phHard->Mom()).Phi(),(phSoft->Mom()).Phi());
480 bendavid 1.2 _mass = (phHard->Mom()+phSoft->Mom()).M();
481     _masserr = 0.5*_mass*TMath::Sqrt(phHard->EnergyErr()*phHard->EnergyErr()/phHard->E()/phHard->E() + phSoft->EnergyErr()*phSoft->EnergyErr()/phSoft->E()/phSoft->E());
482     _masserrsmeared = 0.5*_mass*TMath::Sqrt(phHard->EnergyErrSmeared()*phHard->EnergyErrSmeared()/phHard->E()/phHard->E() + phSoft->EnergyErrSmeared()*phSoft->EnergyErrSmeared()/phSoft->E()/phSoft->E());
483     _ptgg = (phHard->Mom()+phSoft->Mom()).Pt();
484 bendavid 1.5 _etagg = (phHard->Mom()+phSoft->Mom()).Eta();
485     _phigg = (phHard->Mom()+phSoft->Mom()).Phi();
486 bendavid 1.2 _costheta = ThreeVector(phHard->Mom()).Unit().Dot(ThreeVector(phSoft->Mom()).Unit());
487     _evtcat = PhotonTools::DiphotonR9EtaPtCat(phHard,phSoft);
488 bendavid 1.4
489 bendavid 1.5 const Double_t dz = sqrt(2.0)*5.8;
490 paus 1.12 Double_t deltamvtx = _mass*VertexTools::DeltaMassVtx(phHard->CaloPos().X(),
491     phHard->CaloPos().Y(),
492     phHard->CaloPos().Z(),
493     phSoft->CaloPos().X(),
494     phSoft->CaloPos().Y(),
495     phSoft->CaloPos().Z(),
496     fDiphotonEvent->vtxX,
497     fDiphotonEvent->vtxY,
498     fDiphotonEvent->vtxZ,
499     dz);
500 bendavid 1.5 fDiphotonEvent->deltamvtx = deltamvtx;
501    
502 paus 1.12 _masserrwrongvtx = TMath::Sqrt(_masserr*_masserr + deltamvtx*deltamvtx);
503 bendavid 1.4 _masserrsmearedwrongvtx = TMath::Sqrt(_masserrsmeared*_masserrsmeared + deltamvtx*deltamvtx);
504    
505 bendavid 1.5 if (jet1 && jet2) {
506     fDiphotonEvent->zeppenfeld = TMath::Abs(_etagg - 0.5*(jet1->Eta()+jet2->Eta()));
507     fDiphotonEvent->dphidijetgg = MathUtils::DeltaPhi( (jet1->Mom()+jet2->Mom()).Phi(), _phigg );
508     }
509 bendavid 1.4
510 bendavid 1.20 PFJetOArr pfjets;
511     for (UInt_t ijet=0; ijet<fPFJets->GetEntries(); ++ijet) {
512     const PFJet *pfjet = dynamic_cast<const PFJet*>(fPFJets->At(ijet));
513     if (pfjet && MathUtils::DeltaR(*pfjet,*phHard)>0.3 && MathUtils::DeltaR(*pfjet,*phSoft)>0.3) pfjets.Add(pfjet);
514     }
515    
516     PFCandidateOArr pfcands;
517     for (UInt_t icand=0; icand<fPFCands->GetEntries(); ++icand) {
518     const PFCandidate *pfcand = fPFCands->At(icand);
519     if (MathUtils::DeltaR(*pfcand,*phHard)>0.1 && MathUtils::DeltaR(*pfcand,*phSoft)>0.1) pfcands.Add(pfcand);
520     }
521    
522     const Vertex *firstvtx = fPV->At(0);
523     const Vertex *selvtx = fPV->At(0);
524    
525     if (!fLoopOnGoodElectrons && phHard->HasPV()) {
526     selvtx = phHard->PV();
527     }
528    
529    
530     {
531     Met mmet = fMVAMet.GetMet( false,
532     0.,0.,0.,
533     fPFMet->At(0),
534     &pfcands,selvtx,fPV, fPileUpDen->At(0)->Rho(),
535     &pfjets,
536     int(fPV->GetEntries()),
537     kFALSE);
538    
539     TMatrixD *metcov = fMVAMet.GetMetCovariance();
540    
541     ThreeVector fullmet(mmet.Px() - phHard->Px() - phSoft->Px(),
542     mmet.Py() - phHard->Py() - phSoft->Py(),
543     0.);
544    
545     ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > mcov;
546     mcov(0,0) = (*metcov)(0,0);
547     mcov(0,1) = (*metcov)(0,1);
548     mcov(1,0) = (*metcov)(1,0);
549     mcov(1,1) = (*metcov)(1,1);
550     ROOT::Math::SVector<double,2> vmet;
551     vmet(0) = fullmet.X();
552     vmet(1) = fullmet.Y();
553     mcov.Invert();
554     Double_t metsig = sqrt(ROOT::Math::Similarity(mcov,vmet));
555    
556     fDiphotonEvent->mvametsel = fullmet.Rho();
557     fDiphotonEvent->mvametselphi = fullmet.Phi();
558     fDiphotonEvent->mvametselx = fullmet.X();
559     fDiphotonEvent->mvametsely = fullmet.Y();
560     fDiphotonEvent->mvametselsig = metsig;
561     }
562    
563     {
564     Met mmet = fMVAMet.GetMet( false,
565     0.,0.,0.,
566     fPFMet->At(0),
567     &pfcands,firstvtx,fPV, fPileUpDen->At(0)->Rho(),
568     &pfjets,
569     int(fPV->GetEntries()),
570     kFALSE);
571    
572     TMatrixD *metcov = fMVAMet.GetMetCovariance();
573    
574     ThreeVector fullmet(mmet.Px() - phHard->Px() - phSoft->Px(),
575     mmet.Py() - phHard->Py() - phSoft->Py(),
576     0.);
577    
578     ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > mcov;
579     mcov(0,0) = (*metcov)(0,0);
580     mcov(0,1) = (*metcov)(0,1);
581     mcov(1,0) = (*metcov)(1,0);
582     mcov(1,1) = (*metcov)(1,1);
583     ROOT::Math::SVector<double,2> vmet;
584     vmet(0) = fullmet.X();
585     vmet(1) = fullmet.Y();
586     mcov.Invert();
587     Double_t metsig = sqrt(ROOT::Math::Similarity(mcov,vmet));
588    
589     fDiphotonEvent->mvametfirst = fullmet.Rho();
590     fDiphotonEvent->mvametfirstphi = fullmet.Phi();
591     fDiphotonEvent->mvametfirstx = fullmet.X();
592     fDiphotonEvent->mvametfirsty = fullmet.Y();
593     fDiphotonEvent->mvametfirstsig = metsig;
594     }
595    
596 bendavid 1.2 }
597 fabstoec 1.19
598     fDiphotonEvent->corrpfmet = -99.;
599     fDiphotonEvent->corrpfmetphi = -99.;
600     fDiphotonEvent->corrpfmetx = -99.;
601     fDiphotonEvent->corrpfmety = -99.;
602    
603     Met *corrMet =NULL;
604 bendavid 1.2
605 fabstoec 1.19 if (fApplyPFMetCorrections){
606     corrMet = new Met(fPFMet->At(0)->Px(),fPFMet->At(0)->Py());
607 fabstoec 1.17
608 fabstoec 1.19 if (!fIsData){
609 fabstoec 1.17 PFMetCorrectionTools::correctMet(corrMet,phHard,phSoft,1,1,funcorrPFJets,fGenJets,fPFJets);
610 fabstoec 1.19 PFMetCorrectionTools::shiftMet(corrMet,fIsData,_spfMet);
611     }
612     else {
613     PFMetCorrectionTools::shiftMet(corrMet,fIsData,_spfMet);
614     PFMetCorrectionTools::correctMet(corrMet,phHard,phSoft,0,1,funcorrPFJets,fGenJets,fPFJets);
615     }
616    
617     fDiphotonEvent->corrpfmet = corrMet->Pt();
618     fDiphotonEvent->corrpfmetphi = corrMet->Phi();
619     fDiphotonEvent->corrpfmetx = corrMet->Px();
620     fDiphotonEvent->corrpfmety = corrMet->Py();
621 fabstoec 1.17
622 fabstoec 1.19 delete corrMet;
623 fabstoec 1.17 }
624 fabstoec 1.16
625 bendavid 1.2 Float_t _massele = -99.;
626     Float_t _ptee = -99.;
627     Float_t _costhetaele = -99.;
628     if (ele1 && ele2) {
629     _massele = (ele1->Mom()+ele2->Mom()).M();
630     _ptee = (ele1->Mom()+ele2->Mom()).Pt();
631     _costhetaele = ThreeVector(ele1->Mom()).Unit().Dot(ThreeVector(ele2->Mom()).Unit());
632 bendavid 1.1 }
633    
634     Float_t _gencostheta = -99.;
635     if (phgen1 && phgen2) {
636     _gencostheta = ThreeVector(phgen1->Mom()).Unit().Dot(ThreeVector(phgen2->Mom()).Unit());
637     }
638    
639     fDiphotonEvent->gencostheta = _gencostheta;
640 fabstoec 1.16 fDiphotonEvent->dphiMetgg = _dphiMetgg;
641     fDiphotonEvent->cosdphiMetgg = _cosdphiMetgg;
642     fDiphotonEvent->dphiPhPh = _dphiPhPh;
643 bendavid 1.1 fDiphotonEvent->mass = _mass;
644 bendavid 1.2 fDiphotonEvent->masserr = _masserr;
645     fDiphotonEvent->masserrsmeared = _masserrsmeared;
646 bendavid 1.4 fDiphotonEvent->masserrwrongvtx = _masserrwrongvtx;
647     fDiphotonEvent->masserrsmearedwrongvtx = _masserrsmearedwrongvtx;
648 bendavid 1.1 fDiphotonEvent->ptgg = _ptgg;
649 bendavid 1.5 fDiphotonEvent->etagg = _etagg;
650     fDiphotonEvent->phigg = _phigg;
651 bendavid 1.2 fDiphotonEvent->costheta = _costheta;;
652     fDiphotonEvent->massele = _massele;
653     fDiphotonEvent->ptee = _ptee;
654     fDiphotonEvent->costhetaele = _costhetaele;
655     fDiphotonEvent->evtcat = _evtcat;
656 bendavid 1.1
657 bendavid 1.20 fDiphotonEvent->photons[0].SetVars(phHard,conv1,ele1,pfsc1,phgen1,fPhfixph,fPhfixele,fTracks,fPV,rho,fFillClusterArrays,fElectrons,fApplyElectronVeto);
658     fDiphotonEvent->photons[1].SetVars(phSoft,conv2,ele2,pfsc2,phgen2,fPhfixph,fPhfixele,fTracks,fPV,rho,fFillClusterArrays,fElectrons,fApplyElectronVeto);
659 bendavid 1.1
660     Float_t ph1ecor = fDiphotonEvent->photons[0].Ecor();
661     Float_t ph1ecorerr = fDiphotonEvent->photons[0].Ecorerr();
662     Float_t ph2ecor = fDiphotonEvent->photons[1].Ecor();
663     Float_t ph2ecorerr = fDiphotonEvent->photons[1].Ecorerr();
664 bendavid 1.2
665     Float_t ph1ecorele = fDiphotonEvent->photons[0].Ecorele();
666     Float_t ph1ecoreleerr = fDiphotonEvent->photons[0].Ecoreleerr();
667     Float_t ph2ecorele = fDiphotonEvent->photons[1].Ecorele();
668     Float_t ph2ecoreleerr = fDiphotonEvent->photons[1].Ecoreleerr();
669    
670 bendavid 1.1
671 paus 1.12 fDiphotonEvent->masscor = TMath::Sqrt(2.0*ph1ecor*ph2ecor*(1.0-fDiphotonEvent->costheta));
672     fDiphotonEvent->masscorerr = 0.5*fDiphotonEvent->masscor*
673     TMath::Sqrt(ph1ecorerr*ph1ecorerr/ph1ecor/ph1ecor + ph2ecorerr*ph2ecorerr/ph2ecor/ph2ecor);
674    
675     fDiphotonEvent->masscorele = TMath::Sqrt(2.0*ph1ecorele*ph2ecorele*
676     (1.0-fDiphotonEvent->costheta));
677     fDiphotonEvent->masscoreleerr = 0.5*fDiphotonEvent->masscorele*
678     TMath::Sqrt(ph1ecoreleerr*ph1ecoreleerr/ph1ecorele/ph1ecorele +
679     ph2ecoreleerr*ph2ecoreleerr/ph2ecorele/ph2ecorele);
680 bendavid 1.2
681 paus 1.12 //printf("r9 = %5f, photon sigieie = %5f, seed sigieie = %5f\n",phHard->R9(),
682     // phHard->CoviEtaiEta(),sqrt(phHard->SCluster()->Seed()->CoviEtaiEta()));
683 fabstoec 1.13
684 fabstoec 1.14 // MuonStuff
685     fDiphotonEvent-> muonPt = -99.;
686     fDiphotonEvent-> muonEta = -99.;
687     fDiphotonEvent-> muDR1 = -99.;
688     fDiphotonEvent-> muDR2 = -99.;
689     fDiphotonEvent-> muIso1 = -99.;
690     fDiphotonEvent-> muIso2 = -99.;
691     fDiphotonEvent-> muIso3 = -99.;
692     fDiphotonEvent-> muIso4 = -99.;
693     fDiphotonEvent-> muD0 = -99.;
694     fDiphotonEvent-> muDZ = -99.;
695     fDiphotonEvent-> muChi2 = -99.;
696     fDiphotonEvent-> muNhits = -99;
697     fDiphotonEvent-> muNpixhits = -99;
698     fDiphotonEvent-> muNegs = -99;
699     fDiphotonEvent-> muNMatch = -99;
700    
701     // Electron Stuff
702     fDiphotonEvent-> elePt = -99.;
703     fDiphotonEvent-> eleEta = -99.;
704     fDiphotonEvent-> eleSCEta = -99.;
705     fDiphotonEvent-> eleIso1 = -99.;
706     fDiphotonEvent-> eleIso2 = -99.;
707     fDiphotonEvent-> eleIso3 = -99.;
708     fDiphotonEvent-> eleIso4 = -99.;
709     fDiphotonEvent-> eleDist = -99.;
710     fDiphotonEvent-> eleDcot = -99.;
711     fDiphotonEvent-> eleCoviee = -99.;
712     fDiphotonEvent-> eleDphiin = -99.;
713     fDiphotonEvent-> eleDetain = -99.;
714     fDiphotonEvent-> eleDR1 = -99.;
715     fDiphotonEvent-> eleDR2 = -99.;
716     fDiphotonEvent-> eleMass1 = -99.;
717     fDiphotonEvent-> eleMass2 = -99.;
718     fDiphotonEvent-> eleNinnerHits = -99;
719    
720 fabstoec 1.13 if( fApplyLeptonTag ) {
721     // perform lepton tagging
722     // the diphoton event record will have one more entry; i.e. leptonTag
723     // leptonTag = -1 -> lepton-taggng was swicthed off
724     // = 0 -> event tagged as 'non-lepton-event'
725     // = +1 -> event tagged as muon-event
726     // = +2 -> event tagged as electron-event
727     fDiphotonEvent->leptonTag = 0;
728    
729     if ( fLeptonTagMuons->GetEntries() > 0 ) {
730 fabstoec 1.14
731 fabstoec 1.13 // need to have dR > 1 for with respect to both photons
732     for(UInt_t iMuon = 0; iMuon <fLeptonTagMuons->GetEntries(); ++iMuon) {
733     if(MathUtils::DeltaR(fLeptonTagMuons->At(iMuon),phHard) < 1.) continue;
734     if(MathUtils::DeltaR(fLeptonTagMuons->At(iMuon),phSoft) < 1.) continue;
735    
736     fDiphotonEvent->leptonTag = 1;
737 fabstoec 1.14
738     fDiphotonEvent-> muonPt = fLeptonTagMuons->At(iMuon)->Pt();
739     fDiphotonEvent-> muonEta = fLeptonTagMuons->At(iMuon)->Eta();
740     fDiphotonEvent-> muDR1 = MathUtils::DeltaR(fLeptonTagMuons->At(iMuon),phHard);
741     fDiphotonEvent-> muDR2 = MathUtils::DeltaR(fLeptonTagMuons->At(iMuon),phSoft);
742     fDiphotonEvent-> muIso1 = (fLeptonTagMuons->At(iMuon)->IsoR03SumPt() + fLeptonTagMuons->At(iMuon)->IsoR03EmEt() + fLeptonTagMuons->At(iMuon)->IsoR03HadEt() - fPileUpDen->At(0)->RhoRandomLowEta() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(iMuon)->Pt();
743     fDiphotonEvent-> muIso2 = (fLeptonTagMuons->At(iMuon)->IsoR03SumPt() + fLeptonTagMuons->At(iMuon)->IsoR03EmEt() + fLeptonTagMuons->At(iMuon)->IsoR03HadEt() - fPileUpDen->At(0)->RhoRandom() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(iMuon)->Pt();
744     fDiphotonEvent-> muIso3 = (fLeptonTagMuons->At(iMuon)->IsoR03SumPt() + fLeptonTagMuons->At(iMuon)->IsoR03EmEt() + fLeptonTagMuons->At(iMuon)->IsoR03HadEt() - fPileUpDen->At(0)->RhoLowEta() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(iMuon)->Pt();
745     fDiphotonEvent-> muIso4 = (fLeptonTagMuons->At(iMuon)->IsoR03SumPt() + fLeptonTagMuons->At(iMuon)->IsoR03EmEt() + fLeptonTagMuons->At(iMuon)->IsoR03HadEt() - fPileUpDen->At(0)->Rho() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(iMuon)->Pt();
746     fDiphotonEvent-> muD0 = TMath::Abs(fLeptonTagMuons->At(iMuon)->BestTrk()->D0Corrected(*fPV->At(0)));
747     fDiphotonEvent-> muDZ = TMath::Abs(fLeptonTagMuons->At(iMuon)->BestTrk()->DzCorrected(*fPV->At(0)));
748     fDiphotonEvent-> muChi2 = fLeptonTagMuons->At(iMuon)->GlobalTrk()->Chi2()/fLeptonTagMuons->At(iMuon)->GlobalTrk()->Ndof();
749    
750     fDiphotonEvent-> muNhits = fLeptonTagMuons->At(iMuon)->BestTrk()->NHits();
751     fDiphotonEvent-> muNpixhits = fLeptonTagMuons->At(iMuon)->BestTrk()->NPixelHits();
752     fDiphotonEvent-> muNegs = fLeptonTagMuons->At(iMuon)->NSegments();
753     fDiphotonEvent-> muNMatch = fLeptonTagMuons->At(iMuon)->NMatches();
754    
755 fabstoec 1.13 break;
756     }
757     }
758     if ( fDiphotonEvent->leptonTag < 1 && fLeptonTagElectrons->GetEntries() > 0 ) {
759     for(UInt_t iEle = 0; iEle < fLeptonTagElectrons->GetEntries(); ++iEle) {
760     if(MathUtils::DeltaR(fLeptonTagElectrons->At(iEle),phHard) < 1.) continue;
761     if(MathUtils::DeltaR(fLeptonTagElectrons->At(iEle),phSoft) < 1.) continue;
762    
763     // here we also check the mass ....
764     if ( TMath::Abs( (phHard->Mom()+fLeptonTagElectrons->At(iEle)->Mom()).M()-91.19 ) < 5. ) continue;
765     if ( TMath::Abs( (phSoft->Mom()+fLeptonTagElectrons->At(iEle)->Mom()).M()-91.19 ) < 5. ) continue;
766    
767     fDiphotonEvent->leptonTag = 2;
768 fabstoec 1.14
769     fDiphotonEvent-> elePt = fLeptonTagElectrons->At(iEle)->Pt();
770     fDiphotonEvent-> eleEta = fLeptonTagElectrons->At(iEle)->Eta();
771     fDiphotonEvent-> eleSCEta = fLeptonTagElectrons->At(iEle)->SCluster()->Eta();
772     fDiphotonEvent-> eleIso1 = (fLeptonTagElectrons->At(iEle)->TrackIsolationDr03() + fLeptonTagElectrons->At(iEle)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(iEle)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoRandomLowEta() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
773     fDiphotonEvent-> eleIso2 = (fLeptonTagElectrons->At(iEle)->TrackIsolationDr03() + fLeptonTagElectrons->At(iEle)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(iEle)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoRandom() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
774     fDiphotonEvent-> eleIso3 = (fLeptonTagElectrons->At(iEle)->TrackIsolationDr03() + fLeptonTagElectrons->At(iEle)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(iEle)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoLowEta() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
775     fDiphotonEvent-> eleIso4 = (fLeptonTagElectrons->At(iEle)->TrackIsolationDr03() + fLeptonTagElectrons->At(iEle)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(iEle)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->Rho() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
776     fDiphotonEvent-> eleDist = fLeptonTagElectrons->At(iEle)->ConvPartnerDist();
777     fDiphotonEvent-> eleDcot = fLeptonTagElectrons->At(iEle)->ConvPartnerDCotTheta();
778     fDiphotonEvent-> eleCoviee = fLeptonTagElectrons->At(iEle)->CoviEtaiEta();
779     fDiphotonEvent-> eleDphiin = TMath::Abs(fLeptonTagElectrons->At(iEle)->DeltaPhiSuperClusterTrackAtVtx());
780     fDiphotonEvent-> eleDetain = TMath::Abs(fLeptonTagElectrons->At(iEle)->DeltaEtaSuperClusterTrackAtVtx());
781     fDiphotonEvent-> eleDR1 = MathUtils::DeltaR(fLeptonTagElectrons->At(iEle),phHard);
782     fDiphotonEvent-> eleDR2 = MathUtils::DeltaR(fLeptonTagElectrons->At(iEle),phSoft);
783     fDiphotonEvent-> eleMass1 = (phHard->Mom()+fLeptonTagElectrons->At(iEle)->Mom()).M();
784     fDiphotonEvent-> eleMass2 = (phSoft->Mom()+fLeptonTagElectrons->At(iEle)->Mom()).M();
785     fDiphotonEvent-> eleNinnerHits = fLeptonTagElectrons->At(iEle)->Trk()->NExpectedHitsInner();
786    
787 fabstoec 1.13 break;
788     }
789     }
790     }
791    
792 paus 1.12 if (fWriteDiphotonTree)
793     hCiCTuple->Fill();
794 bendavid 1.1 }
795    
796 paus 1.12 if (!fWriteSingleTree)
797     return;
798 bendavid 1.1
799 bendavid 1.2 for (UInt_t iph = 0; iph<egcol->GetEntries(); ++iph) {
800     const Particle *p = 0;
801     const Photon *ph = 0;
802     const Electron *ele = 0;
803     const SuperCluster *sc = 0;
804     if (fLoopOnGoodElectrons) {
805     ele = fGoodElectrons->At(iph);
806     p = ele;
807     sc = ele->SCluster();
808     ph = PhotonTools::MatchedPhoton(ele,fPhotons);
809     }
810     else {
811     ph = fPhotons->At(iph);
812     p = ph;
813     sc = ph->SCluster();
814     ele = PhotonTools::MatchedElectron(ph,fGoodElectrons);
815     }
816    
817 paus 1.12 const DecayParticle *conv = PhotonTools::MatchedConversion(sc,fConversions,bsp,
818     nhitsbeforevtxmax);
819 bendavid 1.20 const SuperCluster *pfsc = PhotonTools::MatchedPFSC(sc,fPFPhotons, fElectrons);
820    
821 bendavid 1.2 if (!fLoopOnGoodElectrons && ph->HasPV()) {
822 bendavid 1.1 fDiphotonEvent->vtxZ = ph->PV()->Z();
823     }
824    
825     const MCParticle *phgen = 0;
826     if( !fIsData ) {
827 bendavid 1.6 phgen = PhotonTools::MatchMC(p,fMCParticles,!fApplyElectronVeto);
828 bendavid 1.1 }
829    
830 bendavid 1.2 if (fExcludeSinglePrompt && phgen) return;
831    
832     fDiphotonEvent->mt = -99.;
833     fDiphotonEvent->cosphimet = -99.;
834     fDiphotonEvent->mtele = -99.;
835     fDiphotonEvent->cosphimetele = -99.;
836    
837     if (ph) {
838     fDiphotonEvent->cosphimet = TMath::Cos(ph->Phi()-fPFMet->At(0)->Phi());
839 paus 1.12 fDiphotonEvent->mt = TMath::Sqrt(2.0*fPFMet->At(0)->Pt()*ph->Pt()*
840     (1.0-fDiphotonEvent->cosphimet));
841 bendavid 1.2 }
842 bendavid 1.1
843 bendavid 1.2 if (ele) {
844     fDiphotonEvent->cosphimetele = TMath::Cos(ele->Phi()-fPFMet->At(0)->Phi());
845 paus 1.12 fDiphotonEvent->mtele = TMath::Sqrt(2.0*fPFMet->At(0)->Pt()*ele->Pt()*
846     (1.0-fDiphotonEvent->cosphimetele));
847 bendavid 1.2 }
848    
849 bendavid 1.20 fSinglePhoton->SetVars(ph,conv,ele,pfsc,phgen,fPhfixph,fPhfixele,fTracks,fPV,rho,fFillClusterArrays,
850 paus 1.12 fElectrons,fApplyElectronVeto);
851 bendavid 1.1 hCiCTupleSingle->Fill();
852     }
853 fabstoec 1.16
854    
855    
856 bendavid 1.1
857     return;
858     }
859    
860     //--------------------------------------------------------------------------------------------------
861     void PhotonTreeWriter::SlaveBegin()
862     {
863     // Run startup code on the computer (slave) doing the actual analysis. Here,
864     // we just request the photon collection branch.
865    
866 fabstoec 1.13 if( fApplyLeptonTag ) {
867     ReqEventObject(fLeptonTagElectronsName, fLeptonTagElectrons, false);
868     ReqEventObject(fLeptonTagMuonsName, fLeptonTagMuons, false);
869     }
870    
871 paus 1.12 ReqEventObject(fPhotonBranchName,fPhotons, fPhotonsFromBranch);
872 bendavid 1.20 if (fEnablePFPhotons) ReqEventObject(fPFPhotonName,fPFPhotons, true);
873 paus 1.12 ReqEventObject(fTrackBranchName, fTracks, true);
874     ReqEventObject(fElectronName, fElectrons, true);
875     ReqEventObject(fGoodElectronName,fGoodElectrons,fGoodElectronsFromBranch);
876     ReqEventObject(fPileUpDenName, fPileUpDen, true);
877     ReqEventObject(fPVName, fPV, fPVFromBranch);
878     ReqEventObject(fConversionName, fConversions, true);
879     ReqEventObject(fBeamspotName, fBeamspot, true);
880     ReqEventObject(fPFCandName, fPFCands, true);
881     ReqEventObject(fSuperClusterName,fSuperClusters,true);
882     ReqEventObject(fPFMetName, fPFMet, true);
883 fabstoec 1.16 if (fEnableJets){
884     ReqEventObject(fPFJetName, fPFJets, fPFJetsFromBranch);
885     ReqBranch(funcorrPFJetName, funcorrPFJets);
886 fabstoec 1.19 // if (!fIsData) ReqEventObject(fGenJetName, fGenJets, true);
887 fabstoec 1.16 }
888 bendavid 1.1 if (!fIsData) {
889 paus 1.12 ReqBranch(fPileUpName, fPileUp);
890     ReqBranch(fMCParticleName, fMCParticles);
891 fabstoec 1.19 if (fEnableJets) ReqEventObject(fGenJetName, fGenJets, true);
892 bendavid 1.1 }
893 bendavid 1.6 if (fIsData) {
894 paus 1.12 fPhFixDataFile = gSystem->Getenv("CMSSW_BASE") +
895     TString("/src/MitPhysics/data/PhotonFixGRPV22.dat");
896 bendavid 1.6 }
897     else {
898 paus 1.12 fPhFixDataFile = gSystem->Getenv("CMSSW_BASE") +
899     TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat");
900 bendavid 1.6 }
901 bendavid 1.1
902 bendavid 1.2 fPhfixph.initialise("4_2",std::string(fPhFixDataFile));
903     fPhfixele.initialise("4_2e",std::string(fPhFixDataFile));
904    
905 bendavid 1.20 // fMVAMet.Initialize(TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))),
906     // TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))),
907     // TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")),
908     // TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmet_42.root"))),
909     // TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphi_42.root"))),
910     // TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu1_42.root"))),
911     // TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu2_42.root")))
912     // );
913    
914     fMVAMet.Initialize(TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))),
915     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))),
916     TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")),
917     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmet_52.root"))),
918     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphi_52.root"))),
919     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu1cov_52.root"))),
920     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu2cov_52.root")))
921     );
922    
923 bendavid 1.1 fDiphotonEvent = new PhotonTreeWriterDiphotonEvent;
924 bendavid 1.20 fSinglePhoton = new PhotonTreeWriterPhoton<16>;
925 bendavid 1.1
926 bendavid 1.20 TFile *ftmp = TFile::Open(TString::Format("%s_tmp.root",GetName()),"RECREATE");
927    
928     if (fWriteDiphotonTree) {
929 paus 1.12 hCiCTuple = new TTree(fTupleName.Data(),fTupleName.Data());
930 bendavid 1.20 hCiCTuple->SetAutoSave(300e9);
931     }
932 bendavid 1.1 TString singlename = fTupleName + TString("Single");
933 bendavid 1.20 if (fWriteSingleTree) {
934 paus 1.12 hCiCTupleSingle = new TTree(singlename,singlename);
935 bendavid 1.20 hCiCTupleSingle->SetAutoSave(300e9);
936     }
937    
938 bendavid 1.1 //make flattish tree from classes so we don't have to rely on dictionaries for reading later
939     TClass *eclass = TClass::GetClass("mithep::PhotonTreeWriterDiphotonEvent");
940 bendavid 1.20 TClass *pclass = TClass::GetClass("mithep::PhotonTreeWriterPhoton<16>");
941 paus 1.12 TList *elist = eclass->GetListOfDataMembers();
942     TList *plist = pclass->GetListOfDataMembers();
943 bendavid 1.1
944     for (int i=0; i<elist->GetEntries(); ++i) {
945     const TDataMember *tdm = static_cast<const TDataMember*>(elist->At(i));
946 bendavid 1.20 if (!(tdm->IsBasic() && tdm->IsPersistent())) continue;
947 bendavid 1.1 TString typestring;
948 bendavid 1.20 if (TString(tdm->GetTypeName()).BeginsWith("Char_t")) typestring = "B";
949     else if (TString(tdm->GetTypeName()).BeginsWith("UChar_t")) typestring = "b";
950     else if (TString(tdm->GetTypeName()).BeginsWith("Short_t")) typestring = "S";
951     else if (TString(tdm->GetTypeName()).BeginsWith("UShort_t")) typestring = "s";
952     else if (TString(tdm->GetTypeName()).BeginsWith("Int_t")) typestring = "I";
953     else if (TString(tdm->GetTypeName()).BeginsWith("UInt_t")) typestring = "i";
954     else if (TString(tdm->GetTypeName()).BeginsWith("Float_t")) typestring = "F";
955     else if (TString(tdm->GetTypeName()).BeginsWith("Double_t")) typestring = "D";
956     else if (TString(tdm->GetTypeName()).BeginsWith("Long64_t")) typestring = "L";
957     else if (TString(tdm->GetTypeName()).BeginsWith("ULong64_t")) typestring = "l";
958     else if (TString(tdm->GetTypeName()).BeginsWith("Bool_t")) typestring = "O";
959     else continue;
960 bendavid 1.1 //printf("%s %s: %i\n",tdm->GetTypeName(),tdm->GetName(),int(tdm->GetOffset()));
961     Char_t *addr = (Char_t*)fDiphotonEvent;
962     assert(sizeof(Char_t)==1);
963 bendavid 1.20 if (fWriteDiphotonTree) hCiCTuple->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data()));
964     if (fWriteSingleTree) hCiCTupleSingle->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data()));
965 bendavid 1.1 }
966    
967     for (int iph=0; iph<2; ++iph) {
968     for (int i=0; i<plist->GetEntries(); ++i) {
969     const TDataMember *tdm = static_cast<const TDataMember*>(plist->At(i));
970 bendavid 1.20 if (!(tdm->IsBasic() && tdm->IsPersistent())) continue;
971 bendavid 1.1 TString typestring;
972 bendavid 1.20 if (TString(tdm->GetTypeName()).BeginsWith("Char_t")) typestring = "B";
973     else if (TString(tdm->GetTypeName()).BeginsWith("UChar_t")) typestring = "b";
974     else if (TString(tdm->GetTypeName()).BeginsWith("Short_t")) typestring = "S";
975     else if (TString(tdm->GetTypeName()).BeginsWith("UShort_t")) typestring = "s";
976     else if (TString(tdm->GetTypeName()).BeginsWith("Int_t")) typestring = "I";
977     else if (TString(tdm->GetTypeName()).BeginsWith("UInt_t")) typestring = "i";
978     else if (TString(tdm->GetTypeName()).BeginsWith("Float_t")) typestring = "F";
979     else if (TString(tdm->GetTypeName()).BeginsWith("Double_t")) typestring = "D";
980     else if (TString(tdm->GetTypeName()).BeginsWith("Long64_t")) typestring = "L";
981     else if (TString(tdm->GetTypeName()).BeginsWith("ULong64_t")) typestring = "l";
982     else if (TString(tdm->GetTypeName()).BeginsWith("Bool_t")) typestring = "O";
983     else continue;
984 bendavid 1.1 //printf("%s\n",tdm->GetTypeName());
985     TString varname = TString::Format("ph%d.%s",iph+1,tdm->GetName());
986 bendavid 1.20 if (tdm->GetArrayDim()==1) {
987     varname = TString::Format("%s[%i]",varname.Data(),tdm->GetMaxIndex(0));
988     }
989    
990     //printf("typename = %s, arraydim = %i, arraysize = %i,varname = %s\n", tdm->GetTypeName(), tdm->GetArrayDim(), tdm->GetMaxIndex(0), varname.Data());
991 bendavid 1.1
992     Char_t *addr = (Char_t*)&fDiphotonEvent->photons[iph];
993     assert(sizeof(Char_t)==1);
994 bendavid 1.20 if (fWriteDiphotonTree) hCiCTuple->Branch(varname,addr+tdm->GetOffset(),TString::Format("%s/%s",varname.Data(),typestring.Data()));
995 bendavid 1.1
996     if (iph==0) {
997     TString singlename = TString::Format("ph.%s",tdm->GetName());
998 bendavid 1.20 if (tdm->GetArrayDim()==1) {
999     singlename = TString::Format("%s[%i]",singlename.Data(),tdm->GetMaxIndex(0));
1000     }
1001 bendavid 1.1 Char_t *addrsingle = (Char_t*)fSinglePhoton;
1002 bendavid 1.20 if (fWriteSingleTree) hCiCTupleSingle->Branch(singlename,addrsingle+tdm->GetOffset(),TString::Format("%s/%s",singlename.Data(),typestring.Data()));
1003 bendavid 1.1 }
1004     }
1005     }
1006 paus 1.12
1007     if (fWriteDiphotonTree)
1008     AddOutput(hCiCTuple);
1009     if (fWriteSingleTree)
1010     AddOutput(hCiCTupleSingle);
1011 bendavid 1.1 }
1012    
1013     // ----------------------------------------------------------------------------------------
1014     // some helpfer functions....
1015 paus 1.12 void PhotonTreeWriter::FindHiggsPtAndZ(Float_t& pt, Float_t& decayZ, Float_t& mass)
1016     {
1017     pt = -999.;
1018 bendavid 1.1 decayZ = -999.;
1019 paus 1.12 mass = -999.;
1020 bendavid 1.1
1021     // loop over all GEN particles and look for status 1 photons
1022     for(UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
1023     const MCParticle* p = fMCParticles->At(i);
1024 paus 1.12 if (p->Is(MCParticle::kH) || (!fApplyElectronVeto &&
1025     (p->AbsPdgId()==23 || p->AbsPdgId()==24))) {
1026     pt = p->Pt();
1027 bendavid 1.1 decayZ = p->DecayVertex().Z();
1028 paus 1.12 mass = p->Mass();
1029 bendavid 1.1 break;
1030     }
1031     }
1032    
1033     return;
1034     }
1035    
1036    
1037 paus 1.12 Float_t PhotonTreeWriter::GetEventCat(PhotonTools::CiCBaseLineCats cat1,
1038     PhotonTools::CiCBaseLineCats cat2) {
1039 bendavid 1.1
1040 paus 1.12 bool ph1IsEB = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat2);
1041     bool ph2IsEB = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat2);
1042 bendavid 1.1
1043     bool ph1IsHR9 = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat3);
1044     bool ph2IsHR9 = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat3);
1045    
1046     if( ph1IsEB && ph2IsEB )
1047     return ( ph1IsHR9 && ph2IsHR9 ? 0. : 1.);
1048    
1049     return ( ph1IsHR9 && ph2IsHR9 ? 2. : 3.);
1050     }
1051    
1052 bendavid 1.20 template <int NClus>
1053     void PhotonTreeWriterPhoton<NClus>::SetVars(const Photon *p, const DecayParticle *c, const Electron *ele,
1054 paus 1.12 const SuperCluster *pfsc, const MCParticle *m,
1055     PhotonFix &phfixph, PhotonFix &phfixele,
1056     const TrackCol* trackCol,const VertexCol* vtxCol,Double_t rho,
1057 bendavid 1.20 Bool_t fillclusterarrays,
1058 paus 1.12 const ElectronCol* els, Bool_t applyElectronVeto) {
1059    
1060     const SuperCluster *s = 0;
1061     if (p)
1062     s = p->SCluster();
1063     else
1064     s = ele->SCluster();
1065     const BasicCluster *b = s->Seed();
1066     const BasicCluster *b2 = 0;
1067     Double_t ebcmax = -99.;
1068     for (UInt_t i=0; i<s->ClusterSize(); ++i) {
1069     const BasicCluster *bc = s->Cluster(i);
1070     if (bc->Energy() > ebcmax && bc !=b) {
1071     b2 = bc;
1072     ebcmax = bc->Energy();
1073     }
1074     }
1075 bendavid 1.2
1076 paus 1.12 const BasicCluster *bclast = 0;
1077     Double_t ebcmin = 1e6;
1078     for (UInt_t i=0; i<s->ClusterSize(); ++i) {
1079     const BasicCluster *bc = s->Cluster(i);
1080     if (bc->Energy() < ebcmin && bc !=b) {
1081     bclast = bc;
1082     ebcmin = bc->Energy();
1083     }
1084     }
1085 bendavid 1.5
1086 paus 1.12 const BasicCluster *bclast2 = 0;
1087     ebcmin = 1e6;
1088     for (UInt_t i=0; i<s->ClusterSize(); ++i) {
1089     const BasicCluster *bc = s->Cluster(i);
1090     if (bc->Energy() < ebcmin && bc !=b && bc!=bclast) {
1091     bclast2 = bc;
1092     ebcmin = bc->Energy();
1093     }
1094     }
1095 bendavid 1.5
1096 paus 1.12 if (p) {
1097     hasphoton = kTRUE;
1098     e = p->E();
1099     pt = p->Pt();
1100     eta = p->Eta();
1101     phi = p->Phi();
1102     r9 = p->R9();
1103     e3x3 = p->E33();
1104     e5x5 = p->E55();
1105     hovere = p->HadOverEm();
1106 bendavid 1.20 hoveretower = p->HadOverEmTow();
1107 paus 1.12 sigietaieta = p->CoviEtaiEta();
1108     phcat = PhotonTools::CiCBaseLineCat(p);
1109     eerr = p->EnergyErr();
1110     eerrsmeared = p->EnergyErrSmeared();
1111     esmearing = p->EnergySmearing();
1112     idmva = p->IdMva();
1113     hcalisodr03 = p->HcalTowerSumEtDr03();
1114     ecalisodr03 = p->EcalRecHitIsoDr03();
1115     trkisohollowdr03 = p->HollowConeTrkIsoDr03();
1116     hcalisodr04 = p->HcalTowerSumEtDr04();
1117     ecalisodr04 = p->EcalRecHitIsoDr04();
1118     trkisohollowdr04 = p->HollowConeTrkIsoDr04();
1119    
1120    
1121     const Vertex *vtx = vtxCol->At(0);
1122     if (p->HasPV()) vtx = p->PV();
1123    
1124     UInt_t wVtxInd = 0;
1125    
1126     trackiso1 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0,
1127     trackCol, NULL, NULL,
1128     (!applyElectronVeto ? els : NULL) );
1129     //Question Ming:whyfPV->At(0) instead of selected vertex using ranking method?
1130 bendavid 1.2
1131 paus 1.12 // track iso worst vtx
1132     trackiso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0,
1133     trackCol, &wVtxInd,vtxCol,
1134     (!applyElectronVeto ? els : NULL) );
1135     combiso1 = ecalisodr03+hcalisodr04+trackiso1 - 0.17*rho;
1136     combiso2 = ecalisodr04+hcalisodr04+trackiso2 - 0.52*rho;
1137     }
1138     else {
1139     hasphoton = kFALSE;
1140     e = -99.;
1141     pt = -99.;
1142     eta = -99.;
1143     phi = -99.;
1144     r9 = b->E3x3()/s->RawEnergy();
1145     e3x3 = b->E3x3();
1146     e5x5 = b->E5x5();
1147     hovere = ele->HadronicOverEm();
1148     sigietaieta = ele->CoviEtaiEta();
1149     phcat = -99;
1150     eerr = -99.;
1151     eerrsmeared = -99.;
1152     esmearing = 0.;
1153     idmva = -99.;
1154     hcalisodr03 = -99;
1155     ecalisodr03 = -99;
1156     trkisohollowdr03 = -99;
1157     hcalisodr04 = -99;
1158     ecalisodr04 = -99;
1159     trkisohollowdr04 = -99;
1160     trackiso1 = -99.;
1161     trackiso2 = -99.;
1162     combiso1 = -99.;
1163     combiso2 = -99.;
1164     }
1165    
1166     sce = s->Energy();
1167     scrawe = s->RawEnergy();
1168     scpse = s->PreshowerEnergy();
1169 bendavid 1.20 scpssigmaxx = s->PsEffWidthSigmaXX();
1170     scpssigmayy = s->PsEffWidthSigmaYY();
1171 paus 1.12 sceta = s->Eta();
1172     scphi = s->Phi();
1173     scnclusters = s->ClusterSize();
1174     scnhits = s->NHits();
1175     scetawidth = -99.;
1176     scphiwidth = -99.;
1177     if (p) {
1178     scetawidth = p->EtaWidth();
1179     scphiwidth = p->PhiWidth();
1180     }
1181     else {
1182     scetawidth = s->EtaWidth();
1183     scphiwidth = s->PhiWidth();
1184     }
1185     isbarrel = (s->AbsEta()<1.5);
1186     isr9reco = (isbarrel && r9>0.94) || (!isbarrel && r9>0.95);
1187     isr9cat = (r9>0.94);
1188    
1189     eseed = b->Energy();
1190     etaseed = b->Eta();
1191     phiseed = b->Phi();
1192     ietaseed = b->IEta();
1193     iphiseed = b->IPhi();
1194     ixseed = b->IX();
1195     iyseed = b->IY();
1196     etacryseed = b->EtaCry();
1197     phicryseed = b->PhiCry();
1198     xcryseed = b->XCry();
1199     ycryseed = b->YCry();
1200     thetaaxisseed = b->ThetaAxis();
1201     phiaxisseed = b->PhiAxis();
1202     sigietaietaseed = TMath::Sqrt(b->CoviEtaiEta());
1203     sigiphiphiseed = TMath::Sqrt(b->CoviPhiiPhi());
1204     if (isnan(sigiphiphiseed)) sigiphiphiseed = -99.;
1205     covietaiphiseed = b->CoviEtaiPhi();
1206     if (isnan(covietaiphiseed)) covietaiphiseed = -99.;
1207     e3x3seed = b->E3x3();
1208     e5x5seed = b->E5x5();
1209     emaxseed = b->EMax();
1210     e2ndseed = b->E2nd();
1211     etopseed = b->ETop();
1212     ebottomseed = b->EBottom();
1213     eleftseed = b->ELeft();
1214     erightseed = b->ERight();
1215     e1x3seed = b->E1x3();
1216     e3x1seed = b->E3x1();
1217     e1x5seed = b->E1x5();
1218     e2x2seed = b->E2x2();
1219     e4x4seed = b->E4x4();
1220     e2x5maxseed = b->E2x5Max();
1221     e2x5topseed = b->E2x5Top();
1222     e2x5bottomseed = b->E2x5Bottom();
1223     e2x5leftseed = b->E2x5Left();
1224     e2x5rightseed = b->E2x5Right();
1225     xseedseed = b->Pos().X();
1226     yseedseed = b->Pos().Y();
1227     zseedseed = b->Pos().Z();
1228     nhitsseed = b->NHits();
1229    
1230     if (b2) {
1231     ebc2 = b2->Energy();
1232     etabc2 = b2->Eta();
1233     phibc2 = b2->Phi();
1234     ietabc2 = b2->IEta();
1235     iphibc2 = b2->IPhi();
1236     ixbc2 = b2->IX();
1237     iybc2 = b2->IY();
1238     etacrybc2 = b2->EtaCry();
1239     phicrybc2 = b2->PhiCry();
1240     xcrybc2 = b2->XCry();
1241     ycrybc2 = b2->YCry();
1242     thetaaxisbc2 = b2->ThetaAxis();
1243     phiaxisbc2 = b2->PhiAxis();
1244     sigietaietabc2 = TMath::Sqrt(b2->CoviEtaiEta());
1245     sigiphiphibc2 = TMath::Sqrt(b2->CoviPhiiPhi());
1246     if (isnan(sigiphiphibc2)) sigiphiphibc2 = -99.;
1247     covietaiphibc2 = b2->CoviEtaiPhi();
1248     if (isnan(covietaiphibc2)) covietaiphibc2 = -99.;
1249     e3x3bc2 = b2->E3x3();
1250     e5x5bc2 = b2->E5x5();
1251     emaxbc2 = b2->EMax();
1252     e2ndbc2 = b2->E2nd();
1253     etopbc2 = b2->ETop();
1254     ebottombc2 = b2->EBottom();
1255     eleftbc2 = b2->ELeft();
1256     erightbc2 = b2->ERight();
1257     e1x3bc2 = b2->E1x3();
1258     e3x1bc2 = b2->E3x1();
1259     e1x5bc2 = b2->E1x5();
1260     e2x2bc2 = b2->E2x2();
1261     e4x4bc2 = b2->E4x4();
1262     e2x5maxbc2 = b2->E2x5Max();
1263     e2x5topbc2 = b2->E2x5Top();
1264     e2x5bottombc2 = b2->E2x5Bottom();
1265     e2x5leftbc2 = b2->E2x5Left();
1266     e2x5rightbc2 = b2->E2x5Right();
1267     xbc2bc2 = b2->Pos().X();
1268     ybc2bc2 = b2->Pos().Y();
1269     zbc2bc2 = b2->Pos().Z();
1270     nhitsbc2= b2->NHits();
1271     }
1272     else {
1273     ebc2 = 0;
1274     etabc2 = 0;
1275     phibc2 = 0;
1276     ietabc2 = 0;
1277     iphibc2 = 0;
1278     ixbc2 = 0;
1279     iybc2 = 0;
1280     etacrybc2 = 0;
1281     phicrybc2 = 0;
1282     xcrybc2 = 0;
1283     ycrybc2 = 0;
1284     thetaaxisbc2 = 0;
1285     phiaxisbc2 = 0;
1286     sigietaietabc2 = 0;
1287     sigiphiphibc2 = 0;
1288     covietaiphibc2 = 0;
1289     e3x3bc2 = 0;
1290     e5x5bc2 = 0;
1291     emaxbc2 = 0;
1292     e2ndbc2 = 0;
1293     etopbc2 = 0;
1294     ebottombc2 = 0;
1295     eleftbc2 = 0;
1296     erightbc2 = 0;
1297     e1x3bc2 = 0;
1298     e3x1bc2 = 0;
1299     e1x5bc2 = 0;
1300     e2x2bc2 = 0;
1301     e4x4bc2 = 0;
1302     e2x5maxbc2 = 0;
1303     e2x5topbc2 = 0;
1304     e2x5bottombc2 = 0;
1305     e2x5leftbc2 = 0;
1306     e2x5rightbc2 = 0;
1307     xbc2bc2 = 0;
1308     ybc2bc2 = 0;
1309     zbc2bc2 = 0;
1310     nhitsbc2 = 0;
1311     }
1312 bendavid 1.5
1313 paus 1.12 if (bclast) {
1314     ebclast = bclast->Energy();
1315     etabclast = bclast->Eta();
1316     phibclast = bclast->Phi();
1317     ietabclast = bclast->IEta();
1318     iphibclast = bclast->IPhi();
1319     ixbclast = bclast->IX();
1320     iybclast = bclast->IY();
1321     etacrybclast = bclast->EtaCry();
1322     phicrybclast = bclast->PhiCry();
1323     xcrybclast = bclast->XCry();
1324     ycrybclast = bclast->YCry();
1325     thetaaxisbclast = bclast->ThetaAxis();
1326     phiaxisbclast = bclast->PhiAxis();
1327     sigietaietabclast = TMath::Sqrt(bclast->CoviEtaiEta());
1328     sigiphiphibclast = TMath::Sqrt(bclast->CoviPhiiPhi());
1329     if (isnan(sigiphiphibclast)) sigiphiphibclast = -99.;
1330     covietaiphibclast = bclast->CoviEtaiPhi();
1331     if (isnan(covietaiphibclast)) covietaiphibclast = -99.;
1332     e3x3bclast = bclast->E3x3();
1333     nhitsbclast = bclast->NHits();
1334     }
1335     else {
1336     ebclast = 0;
1337     etabclast = 0;
1338     phibclast = 0;
1339     ietabclast = 0;
1340     iphibclast = 0;
1341     ixbclast = 0;
1342     iybclast = 0;
1343     etacrybclast = 0;
1344     phicrybclast = 0;
1345     xcrybclast = 0;
1346     ycrybclast = 0;
1347     thetaaxisbclast = 0;
1348     phiaxisbclast = 0;
1349     sigietaietabclast = 0;
1350     sigiphiphibclast = 0;
1351     covietaiphibclast = 0;
1352     e3x3bclast = 0;
1353     nhitsbclast = 0;
1354     }
1355 bendavid 1.5
1356 paus 1.12 if (bclast2) {
1357     ebclast2 = bclast2->Energy();
1358     etabclast2 = bclast2->Eta();
1359     phibclast2 = bclast2->Phi();
1360     ietabclast2 = bclast2->IEta();
1361     iphibclast2 = bclast2->IPhi();
1362     ixbclast2 = bclast2->IX();
1363     iybclast2 = bclast2->IY();
1364     etacrybclast2 = bclast2->EtaCry();
1365     phicrybclast2 = bclast2->PhiCry();
1366     xcrybclast2 = bclast2->XCry();
1367     ycrybclast2 = bclast2->YCry();
1368     thetaaxisbclast2 = bclast2->ThetaAxis();
1369     phiaxisbclast2 = bclast2->PhiAxis();
1370     sigietaietabclast2 = TMath::Sqrt(bclast2->CoviEtaiEta());
1371     sigiphiphibclast2 = TMath::Sqrt(bclast2->CoviPhiiPhi());
1372     if (isnan(sigiphiphibclast2)) sigiphiphibclast2 = -99.;
1373     covietaiphibclast2 = bclast2->CoviEtaiPhi();
1374     if (isnan(covietaiphibclast2)) covietaiphibclast2 = -99.;
1375     e3x3bclast2 = bclast2->E3x3();
1376     nhitsbclast2 = bclast2->NHits();
1377     }
1378     else {
1379     ebclast2 = 0;
1380     etabclast2 = 0;
1381     phibclast2 = 0;
1382     ietabclast2 = 0;
1383     iphibclast2 = 0;
1384     ixbclast2 = 0;
1385     iybclast2 = 0;
1386     etacrybclast2 = 0;
1387     phicrybclast2 = 0;
1388     xcrybclast2 = 0;
1389     ycrybclast2 = 0;
1390     thetaaxisbclast2 = 0;
1391     phiaxisbclast2 = 0;
1392     sigietaietabclast2 = 0;
1393     sigiphiphibclast2 = 0;
1394     covietaiphibclast2 = 0;
1395     e3x3bclast2 = 0;
1396     nhitsbclast2 = 0;
1397     }
1398 bendavid 1.5
1399 bendavid 1.20 for (UInt_t iclus=0; iclus<NClus; ++iclus) {
1400     if (fillclusterarrays && iclus < s->ClusterSize() ) {
1401     const BasicCluster *ib =s->Cluster(iclus);
1402    
1403     ebcs[iclus] = ib->Energy();
1404     etabcs[iclus] = ib->Eta();
1405     phibcs[iclus] = ib->Phi();
1406     ietabcs[iclus] = ib->IEta();
1407     iphibcs[iclus] = ib->IPhi();
1408     ixbcs[iclus] = ib->IX();
1409     iybcs[iclus] = ib->IY();
1410     etacrybcs[iclus] = ib->EtaCry();
1411     phicrybcs[iclus] = ib->PhiCry();
1412     xcrybcs[iclus] = ib->XCry();
1413     ycrybcs[iclus] = ib->YCry();
1414     sigietaietabcs[iclus] = TMath::Sqrt(ib->CoviEtaiEta());
1415     sigiphiphibcs[iclus] = TMath::Sqrt(ib->CoviPhiiPhi());
1416     covietaiphibcs[iclus] = ib->CoviEtaiPhi();
1417     sigetaetabcs[iclus] = TMath::Sqrt(ib->CovEtaEta());
1418     sigphiphibcs[iclus] = TMath::Sqrt(ib->CovPhiPhi());
1419     covetaphibcs[iclus] = ib->CovEtaPhi();
1420     e3x3bcs[iclus] = ib->E3x3();
1421     e5x5bcs[iclus] = ib->E5x5();
1422     emaxbcs[iclus] = ib->EMax();
1423     e2ndbcs[iclus] = ib->E2nd();
1424     etopbcs[iclus] = ib->ETop();
1425     ebottombcs[iclus] = ib->EBottom();
1426     eleftbcs[iclus] = ib->ELeft();
1427     erightbcs[iclus] = ib->ERight();
1428     e1x3bcs[iclus] = ib->E1x3();
1429     e3x1bcs[iclus] = ib->E3x1();
1430     e1x5bcs[iclus] = ib->E1x5();
1431     e2x2bcs[iclus] = ib->E2x2();
1432     e4x4bcs[iclus] = ib->E4x4();
1433     e2x5maxbcs[iclus] = ib->E2x5Max();
1434     e2x5topbcs[iclus] = ib->E2x5Top();
1435     e2x5bottombcs[iclus] = ib->E2x5Bottom();
1436     e2x5leftbcs[iclus] = ib->E2x5Left();
1437     e2x5rightbcs[iclus] = ib->E2x5Right();
1438     nhitsbcs[iclus]= ib->NHits();
1439     }
1440     else {
1441     ebcs[iclus] = -999;
1442     etabcs[iclus] = -999;
1443     phibcs[iclus] = -999;
1444     ietabcs[iclus] = -999;
1445     iphibcs[iclus] = -999;
1446     ixbcs[iclus] = -999;
1447     iybcs[iclus] = -999;
1448     etacrybcs[iclus] = -999;
1449     phicrybcs[iclus] = -999;
1450     xcrybcs[iclus] = -999;
1451     ycrybcs[iclus] = -999;
1452     sigietaietabcs[iclus] = -999;
1453     sigiphiphibcs[iclus] = -999;
1454     covietaiphibcs[iclus] = -999;
1455     sigetaetabcs[iclus] = -999;
1456     sigphiphibcs[iclus] = -999;
1457     covetaphibcs[iclus] = -999;
1458     e3x3bcs[iclus] = -999;
1459     e5x5bcs[iclus] = -999;
1460     emaxbcs[iclus] = -999;
1461     e2ndbcs[iclus] = -999;
1462     etopbcs[iclus] = -999;
1463     ebottombcs[iclus] = -999;
1464     eleftbcs[iclus] = -999;
1465     erightbcs[iclus] = -999;
1466     e1x3bcs[iclus] = -999;
1467     e3x1bcs[iclus] = -999;
1468     e1x5bcs[iclus] = -999;
1469     e2x2bcs[iclus] = -999;
1470     e4x4bcs[iclus] = -999;
1471     e2x5maxbcs[iclus] = -999;
1472     e2x5topbcs[iclus] = -999;
1473     e2x5bottombcs[iclus] = -999;
1474     e2x5leftbcs[iclus] = -999;
1475     e2x5rightbcs[iclus] = -999;
1476     nhitsbcs[iclus] = -999;
1477     }
1478     }
1479    
1480     for (UInt_t iclus=0; iclus<NClus; ++iclus) {
1481     if (fillclusterarrays && pfsc && iclus < pfsc->ClusterSize() ) {
1482     const BasicCluster *ib =pfsc->Cluster(iclus);
1483    
1484     epfbcs[iclus] = ib->Energy();
1485     etapfbcs[iclus] = ib->Eta();
1486     phipfbcs[iclus] = ib->Phi();
1487     ietapfbcs[iclus] = ib->IEta();
1488     iphipfbcs[iclus] = ib->IPhi();
1489     ixpfbcs[iclus] = ib->IX();
1490     iypfbcs[iclus] = ib->IY();
1491     etacrypfbcs[iclus] = ib->EtaCry();
1492     phicrypfbcs[iclus] = ib->PhiCry();
1493     xcrypfbcs[iclus] = ib->XCry();
1494     ycrypfbcs[iclus] = ib->YCry();
1495     sigietaietapfbcs[iclus] = TMath::Sqrt(ib->CoviEtaiEta());
1496     sigiphiphipfbcs[iclus] = TMath::Sqrt(ib->CoviPhiiPhi());
1497     covietaiphipfbcs[iclus] = ib->CoviEtaiPhi();
1498     sigetaetapfbcs[iclus] = TMath::Sqrt(ib->CovEtaEta());
1499     sigphiphipfbcs[iclus] = TMath::Sqrt(ib->CovPhiPhi());
1500     covetaphipfbcs[iclus] = ib->CovEtaPhi();
1501     e3x3pfbcs[iclus] = ib->E3x3();
1502     e5x5pfbcs[iclus] = ib->E5x5();
1503     emaxpfbcs[iclus] = ib->EMax();
1504     e2ndpfbcs[iclus] = ib->E2nd();
1505     etoppfbcs[iclus] = ib->ETop();
1506     ebottompfbcs[iclus] = ib->EBottom();
1507     eleftpfbcs[iclus] = ib->ELeft();
1508     erightpfbcs[iclus] = ib->ERight();
1509     e1x3pfbcs[iclus] = ib->E1x3();
1510     e3x1pfbcs[iclus] = ib->E3x1();
1511     e1x5pfbcs[iclus] = ib->E1x5();
1512     e2x2pfbcs[iclus] = ib->E2x2();
1513     e4x4pfbcs[iclus] = ib->E4x4();
1514     e2x5maxpfbcs[iclus] = ib->E2x5Max();
1515     e2x5toppfbcs[iclus] = ib->E2x5Top();
1516     e2x5bottompfbcs[iclus] = ib->E2x5Bottom();
1517     e2x5leftpfbcs[iclus] = ib->E2x5Left();
1518     e2x5rightpfbcs[iclus] = ib->E2x5Right();
1519     nhitspfbcs[iclus]= ib->NHits();
1520     }
1521     else {
1522     epfbcs[iclus] = -999;
1523     etapfbcs[iclus] = -999;
1524     phipfbcs[iclus] = -999;
1525     ietapfbcs[iclus] = -999;
1526     iphipfbcs[iclus] = -999;
1527     ixpfbcs[iclus] = -999;
1528     iypfbcs[iclus] = -999;
1529     etacrypfbcs[iclus] = -999;
1530     phicrypfbcs[iclus] = -999;
1531     xcrypfbcs[iclus] = -999;
1532     ycrypfbcs[iclus] = -999;
1533     sigietaietapfbcs[iclus] = -999;
1534     sigiphiphipfbcs[iclus] = -999;
1535     covietaiphipfbcs[iclus] = -999;
1536     sigetaetapfbcs[iclus] = -999;
1537     sigphiphipfbcs[iclus] = -999;
1538     covetaphipfbcs[iclus] = -999;
1539     e3x3pfbcs[iclus] = -999;
1540     e5x5pfbcs[iclus] = -999;
1541     emaxpfbcs[iclus] = -999;
1542     e2ndpfbcs[iclus] = -999;
1543     etoppfbcs[iclus] = -999;
1544     ebottompfbcs[iclus] = -999;
1545     eleftpfbcs[iclus] = -999;
1546     erightpfbcs[iclus] = -999;
1547     e1x3pfbcs[iclus] = -999;
1548     e3x1pfbcs[iclus] = -999;
1549     e1x5pfbcs[iclus] = -999;
1550     e2x2pfbcs[iclus] = -999;
1551     e4x4pfbcs[iclus] = -999;
1552     e2x5maxpfbcs[iclus] = -999;
1553     e2x5toppfbcs[iclus] = -999;
1554     e2x5bottompfbcs[iclus] = -999;
1555     e2x5leftpfbcs[iclus] = -999;
1556     e2x5rightpfbcs[iclus] = -999;
1557     nhitspfbcs[iclus] = -999;
1558     }
1559     }
1560    
1561     for (UInt_t iclus=0; iclus<100; ++iclus) {
1562     if (fillclusterarrays && pfsc && iclus < pfsc->NPsClusts() ) {
1563     const PsCluster *ib = pfsc->PsClust(iclus);
1564    
1565     epsc[iclus] = ib->Energy();
1566     etapsc[iclus] = ib->Eta();
1567     phipsc[iclus] = ib->Phi();
1568     planepsc[iclus] = ib->PsPlane();
1569     }
1570     else {
1571     epsc[iclus] = -999;
1572     etapsc[iclus] = -999;
1573     phipsc[iclus] = -999;
1574     planepsc[iclus] = 0;
1575     }
1576     }
1577    
1578 paus 1.12 //initialize photon energy corrections if needed
1579     /*if (!PhotonFix::initialised()) {
1580     PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));
1581     }*/
1582    
1583     phfixph.setup(e,sceta,scphi,r9);
1584     phfixele.setup(e,sceta,scphi,r9);
1585    
1586     const Float_t dval = -99.;
1587     ecor = phfixph.fixedEnergy();
1588     ecorerr = phfixph.sigmaEnergy();
1589     ecorele = phfixele.fixedEnergy();
1590     ecoreleerr = phfixele.sigmaEnergy();
1591     if (phfixph.isbarrel()) {
1592     etac = phfixph.etaC();
1593     etas = phfixph.etaS();
1594     etam = phfixph.etaM();
1595     phic = phfixph.phiC();
1596     phis = phfixph.phiS();
1597     phim = phfixph.phiM();
1598     xz = dval;
1599     xc = dval;
1600     xs = dval;
1601     xm = dval;
1602     yz = dval;
1603     yc = dval;
1604     ys = dval;
1605     ym = dval;
1606     }
1607     else {
1608     etac = dval;
1609     etas = dval;
1610     etam = dval;
1611     phic = dval;
1612     phis = dval;
1613     phim = dval;
1614     xz = phfixph.xZ();
1615     xc = phfixph.xC();
1616     xs = phfixph.xS();
1617     xm = phfixph.xM();
1618     yz = phfixph.yZ();
1619     yc = phfixph.yC();
1620     ys = phfixph.yS();
1621     ym = phfixph.yM();
1622     }
1623    
1624     if (c) {
1625     hasconversion = kTRUE;
1626     convp = c->P();
1627     convpt = c->Pt();
1628     conveta = c->Eta();
1629     convphi = c->Phi();
1630     ThreeVector dirconvsc = ThreeVector(s->Point()) - c->Position();
1631     convdeta = c->Eta() - dirconvsc.Eta();
1632     convdphi = MathUtils::DeltaPhi(c->Phi(),dirconvsc.Phi());
1633     convvtxrho = c->Position().Rho();
1634     convvtxz = c->Position().Z();
1635     convvtxphi = c->Position().Phi();
1636    
1637     const StableData *leadsd = dynamic_cast<const StableData*>(c->DaughterDat(0));
1638     const StableData *trailsd = dynamic_cast<const StableData*>(c->DaughterDat(1));
1639     if (leadsd->Pt()<trailsd->Pt()) {
1640     const StableData *sdtmp = leadsd;
1641     leadsd = trailsd;
1642     trailsd = sdtmp;
1643     }
1644    
1645     const Track *leadtrack = dynamic_cast<const StableParticle*>(leadsd->Original())->Trk();
1646     const Track *trailtrack = dynamic_cast<const StableParticle*>(trailsd->Original())->Trk();
1647    
1648     convleadpt = leadsd->Pt();
1649     convtrailpt = trailsd->Pt();
1650     convleadtrackpt = leadtrack->Pt();
1651     convleadtrackalgo = leadtrack->Algo();
1652     if (convleadtrackalgo==29) convleadtrackalgos=2; //gsf track
1653     else if (convleadtrackalgo==15 ||convleadtrackalgo==16) convleadtrackalgos=1; //ecal-seeded track
1654     else convleadtrackalgos = 0; //std iterative track
1655     convleadtrackcharge = leadtrack->Charge();
1656     convtrailtrackpt = trailtrack->Pt();
1657     convtrailtrackalgo = trailtrack->Algo();
1658     if (convtrailtrackalgo==29) convtrailtrackalgos=2; //gsf track
1659     else if (convtrailtrackalgo==15 ||convtrailtrackalgo==16) convtrailtrackalgos=1; //ecal-seeded track
1660     else convtrailtrackalgos = 0; //std iterative track
1661     trailtrackcharge = trailtrack->Charge();
1662     }
1663     else {
1664     hasconversion = kFALSE;
1665     convp = -99.;
1666     convpt = -99.;
1667     conveta = -99.;
1668     convphi = -99.;
1669     convdeta = -99.;
1670     convdphi = -99.;
1671     convvtxrho = -99.;
1672     convvtxz = -999.;
1673     convvtxphi = -99.;
1674     convleadpt = -99.;
1675     convtrailpt = -99.;
1676     convleadtrackpt = -99.;
1677     convleadtrackalgo = -99;
1678     convleadtrackalgos = -99;
1679     convleadtrackcharge = 0;
1680     convtrailtrackpt = -99.;
1681     convtrailtrackalgo = -99;
1682     convtrailtrackalgos = -99;
1683     trailtrackcharge = 0;
1684     }
1685    
1686     //electron quantities
1687     if (ele) {
1688     haselectron = kTRUE;
1689     eleisecaldriven = ele->IsEcalDriven();
1690     eleistrackerdriven = ele->IsTrackerDriven();
1691     elee = ele->E();
1692     elept = ele->Pt();
1693     eleeta = ele->Eta();
1694     elephi = ele->Phi();
1695     elecharge = ele->Charge();
1696     elefbrem = ele->FBrem();
1697     eledeta = ele->DeltaEtaSuperClusterTrackAtVtx();
1698     eledphi = ele->DeltaPhiSuperClusterTrackAtVtx();
1699     elep = s->Energy()/ele->ESuperClusterOverP();
1700     elepin = ele->PIn();
1701     elepout = ele->POut();
1702     }
1703     else {
1704     haselectron = kFALSE;
1705     eleisecaldriven = kFALSE;
1706     eleistrackerdriven = kFALSE;
1707     elee = -99.;
1708     elept = -99.;
1709     eleeta = -99.;
1710     elephi = -99.;
1711     elecharge = -99;
1712     elefbrem = -99.;
1713     eledeta = -99.;
1714     eledphi = -99.;
1715     elep = -99.;
1716     elepin = -99.;
1717     elepout = -99.;
1718     }
1719    
1720     //pf supercluster quantities
1721     if (pfsc) {
1722     haspfsc = kTRUE;
1723     pfsce = pfsc->Energy();
1724     pfscrawe = pfsc->RawEnergy();
1725     pfsceta = pfsc->Eta();
1726     pfscphi = pfsc->Phi();
1727 bendavid 1.20 pfscnclusters = pfsc->NClusters();
1728     pfscnhits = pfsc->NHits();
1729     pfscetawidth = pfsc->EtaWidth();
1730     pfscphiwidth = pfsc->PhiWidth();
1731     pfscnpsclusters = pfsc->NPsClusts();
1732 paus 1.12 }
1733     else {
1734     haspfsc = kFALSE;
1735     pfsce = -99.;
1736     pfscrawe = -99.;
1737     pfsceta = -99.;
1738     pfscphi = -99.;
1739 bendavid 1.20 pfscnclusters = 0;
1740     pfscnhits = 0;
1741     pfscetawidth = -99.;
1742     pfscphiwidth = -99.;
1743     pfscnpsclusters = 0;
1744 paus 1.12 }
1745    
1746     genz = -99.;
1747     if (m) {
1748     ispromptgen = kTRUE;
1749     gene = m->E();
1750     genpt = m->Pt();
1751     geneta = m->Eta();
1752     genphi = m->Phi();
1753     const MCParticle *mm = m->DistinctMother();
1754     if (mm) genz = mm->DecayVertex().Z();
1755     pdgid = m->PdgId();
1756     if (mm) motherpdgid = mm->PdgId();
1757     else motherpdgid = -99;
1758     }
1759     else {
1760     ispromptgen = kFALSE;
1761     gene = -99.;
1762     genpt = -99.;
1763     geneta = -99.;
1764     genphi = -99.;
1765     pdgid = -99;
1766     motherpdgid = -99;
1767     }
1768 bendavid 1.1 }