ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonTreeWriter.cc
(Generate patch)

Comparing UserCode/MitPhysics/Mods/src/PhotonTreeWriter.cc (file contents):
Revision 1.1 by bendavid, Wed Aug 3 17:15:43 2011 UTC vs.
Revision 1.2 by bendavid, Thu Sep 8 15:51:23 2011 UTC

# Line 3 | Line 3
3   #include "MitAna/DataTree/interface/PFCandidateCol.h"
4   #include "MitAna/DataTree/interface/StableData.h"
5   #include "MitAna/DataTree/interface/StableParticle.h"
6 + #include "MitAna/DataTree/interface/PFMet.h"
7   #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"
10 #include "MitPhysics/Utils/interface/PhotonFix.h"
11   #include "TDataMember.h"
12   #include <TNtuple.h>
13   #include <TRandom3.h>
# Line 35 | Line 35 | PhotonTreeWriter::PhotonTreeWriter(const
35    fPVName            (Names::gkPVBeamSpotBrn),
36    fBeamspotName      (Names::gkBeamSpotBrn),
37    fPFCandName        (Names::gkPFCandidatesBrn),
38  // MC specific stuff...
38    fMCParticleName    (Names::gkMCPartBrn),
39 <  fPileUpName        (Names::gkPileupInfoBrn),
39 >  fPileUpName        (Names::gkPileupInfoBrn),  
40 >  fSuperClusterName  ("PFSuperClusters"),
41 >  fPFMetName         ("PFMet"),
42  
43    
44    fIsData            (false),
# Line 57 | Line 58 | PhotonTreeWriter::PhotonTreeWriter(const
58    fPFCands           (0),
59    fMCParticles       (0),
60    fPileUp            (0),
61 +  fSuperClusters     (0),
62  
63 +  fLoopOnGoodElectrons(kFALSE),
64    fInvertElectronVeto(kFALSE),  
65  
66    fWriteDiphotonTree(kTRUE),
67    fWriteSingleTree(kTRUE),
68 +  fExcludeSinglePrompt(kFALSE),
69 +  fExcludeDoublePrompt(kFALSE),
70 +  fPhFixDataFile(gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat")),
71    fTupleName         ("hPhotonTree")
72  
73  
# Line 78 | Line 84 | void PhotonTreeWriter::Process()
84   {
85    // ------------------------------------------------------------  
86    // Process entries of the tree.
87 +  
88    LoadEventObject(fPhotonBranchName,   fPhotons);
89 +  LoadEventObject(fGoodElectronName,       fGoodElectrons);
90 +  
91 +  const BaseCollection *egcol = 0;
92 +  if (fLoopOnGoodElectrons) {
93 +    egcol = fGoodElectrons;
94 +  }
95 +  else {
96 +    egcol = fPhotons;
97 +  }
98    
99 <  if (fPhotons->GetEntries()<1) return;
99 >  if (egcol->GetEntries()<1) return;
100    
101    LoadEventObject(fElectronName,       fElectrons);
86  LoadEventObject(fGoodElectronName,       fGoodElectrons);
102    LoadEventObject(fConversionName,     fConversions);
103    LoadEventObject(fTrackBranchName,    fTracks);
104    LoadEventObject(fPileUpDenName,      fPileUpDen);
105    LoadEventObject(fPVName,             fPV);    
106    LoadEventObject(fBeamspotName,       fBeamspot);
107    LoadEventObject(fPFCandName,         fPFCands);
108 +  LoadEventObject(fSuperClusterName,   fSuperClusters);
109 +  LoadEventObject(fPFMetName,   fPFMet);  
110  
111    // ------------------------------------------------------------  
112    // load event based information
# Line 129 | Line 146 | void PhotonTreeWriter::Process()
146    fDiphotonEvent->genmass = _genmass;  
147    fDiphotonEvent->gencostheta = -99.;
148    fDiphotonEvent->nVtx = fPV->GetEntries();
149 +  fDiphotonEvent->bsX = fBeamspot->At(0)->X();
150 +  fDiphotonEvent->bsY = fBeamspot->At(0)->Y();
151 +  fDiphotonEvent->bsZ = fBeamspot->At(0)->Z();
152 +  fDiphotonEvent->vtxX = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->X() : -99.;
153 +  fDiphotonEvent->vtxY = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Y() : -99.;  
154    fDiphotonEvent->vtxZ = (fDiphotonEvent->nVtx>0) ? fPV->At(0)->Z() : -99.;
155    fDiphotonEvent->numPU = _numPU;
156    fDiphotonEvent->numPUminus = _numPUminus;
# Line 136 | Line 158 | void PhotonTreeWriter::Process()
158    fDiphotonEvent->mass = -99.;
159    fDiphotonEvent->ptgg = -99.;
160    fDiphotonEvent->costheta = -99.;
161 +  fDiphotonEvent->mt = -99.;
162 +  fDiphotonEvent->cosphimet = -99.;
163 +  fDiphotonEvent->mtele = -99.;
164 +  fDiphotonEvent->cosphimetele = -99.;
165    fDiphotonEvent->evt = GetEventHeader()->EvtNum();
166    fDiphotonEvent->run = GetEventHeader()->RunNum();
167    fDiphotonEvent->lumi = GetEventHeader()->LumiSec();
168    fDiphotonEvent->evtcat = -99;
169 +  fDiphotonEvent->nobj = fPhotons->GetEntries();
170 +  fDiphotonEvent->pfmet = fPFMet->At(0)->Pt();
171 +  fDiphotonEvent->pfmetphi = fPFMet->At(0)->Phi();
172 +  fDiphotonEvent->pfmetx = fPFMet->At(0)->Px();
173 +  fDiphotonEvent->pfmety = fPFMet->At(0)->Py();
174    fDiphotonEvent->masscor = -99.;
175    fDiphotonEvent->masscorerr = -99.;
176 <
176 >  fDiphotonEvent->masscorele = -99.;
177 >  fDiphotonEvent->masscoreleerr = -99.;
178 >  fDiphotonEvent->ismc = GetEventHeader()->IsMC();
179 >  
180    Int_t nhitsbeforevtxmax = 1;
181    if (fInvertElectronVeto) nhitsbeforevtxmax = 999;  
182    
183 <  if (fPhotons->GetEntries()>=2) {
150 <    Bool_t doFill = kTRUE;
183 >  if (egcol->GetEntries()>=2) {
184      
185 <    const Photon *phHard = fPhotons->At(0);
186 <    const Photon *phSoft = fPhotons->At(1);
187 <
188 <    if (phHard->HasPV()) {
189 <      fDiphotonEvent->vtxZ = phHard->PV()->Z();
185 >    const Particle *p1 = 0;
186 >    const Particle *p2 = 0;
187 >    const Photon *phHard = 0;
188 >    const Photon *phSoft = 0;
189 >    const Electron *ele1 = 0;
190 >    const Electron *ele2 = 0;
191 >    const SuperCluster *sc1 = 0;
192 >    const SuperCluster *sc2 = 0;
193 >    
194 >    if (fLoopOnGoodElectrons) {
195 >      ele1 = fGoodElectrons->At(0);
196 >      ele2 = fGoodElectrons->At(1);
197 >      p1 = ele1;
198 >      p2 = ele2;
199 >      sc1 = ele1->SCluster();
200 >      sc2 = ele2->SCluster();
201 >      phHard = PhotonTools::MatchedPhoton(ele1,fPhotons);
202 >      phSoft = PhotonTools::MatchedPhoton(ele2,fPhotons);
203 >    }
204 >    else {
205 >      phHard = fPhotons->At(0);
206 >      phSoft = fPhotons->At(1);
207 >      p1 = phHard;
208 >      p2 = phSoft;
209 >      sc1 = phHard->SCluster();
210 >      sc2 = phSoft->SCluster();      
211 >      ele1 = PhotonTools::MatchedElectron(phHard,fGoodElectrons);
212 >      ele2 = PhotonTools::MatchedElectron(phSoft,fGoodElectrons);
213      }
214      
215 <    Float_t _mass = ( doFill ? (phHard->Mom()+phSoft->Mom()).M()  : -100.);
216 <    Float_t _ptgg = ( doFill ? (phHard->Mom()+phSoft->Mom()).Pt() : -100.);
215 >    const DecayParticle *conv1 = PhotonTools::MatchedConversion(sc1,fConversions,bsp,nhitsbeforevtxmax);
216 >    const DecayParticle *conv2 = PhotonTools::MatchedConversion(sc2,fConversions,bsp,nhitsbeforevtxmax);
217 >    
218 >    const SuperCluster *pfsc1 = PhotonTools::MatchedSC(sc1,fSuperClusters);
219 >    const SuperCluster *pfsc2 = PhotonTools::MatchedSC(sc2,fSuperClusters);
220      
162
163    const DecayParticle *conv1 = PhotonTools::MatchedConversion(phHard,fConversions,bsp,nhitsbeforevtxmax);
164    const DecayParticle *conv2 = PhotonTools::MatchedConversion(phSoft,fConversions,bsp,nhitsbeforevtxmax);
165
221      const MCParticle *phgen1 = 0;
222      const MCParticle *phgen2 = 0;
223      if( !fIsData ) {
224 <      phgen1 = PhotonTools::MatchMC(phHard,fMCParticles,!fInvertElectronVeto);
225 <      phgen2 = PhotonTools::MatchMC(phSoft,fMCParticles,!fInvertElectronVeto);
224 >      phgen1 = PhotonTools::MatchMC(p1,fMCParticles,fInvertElectronVeto);
225 >      phgen2 = PhotonTools::MatchMC(p2,fMCParticles,fInvertElectronVeto);
226 >    }
227 >    
228 >    if (fExcludeSinglePrompt && (phgen1 || phgen2) ) return;
229 >    if (fExcludeDoublePrompt && (phgen1 && phgen2) ) return;
230 >    
231 >    if (!fLoopOnGoodElectrons && phHard->HasPV()) {
232 >      fDiphotonEvent->vtxX = phHard->PV()->X();
233 >      fDiphotonEvent->vtxY = phHard->PV()->Y();
234 >      fDiphotonEvent->vtxZ = phHard->PV()->Z();
235 >    }
236 >    
237 >    Float_t _mass = -99.;
238 >    Float_t _masserr = -99.;
239 >    Float_t _masserrsmeared = -99.;
240 >    Float_t _ptgg = -99.;
241 >    Float_t _costheta = -99.;
242 >    PhotonTools::DiphotonR9EtaPtCats _evtcat = PhotonTools::kOctCat0;
243 >    if (phHard && phSoft) {
244 >      _mass = (phHard->Mom()+phSoft->Mom()).M();
245 >      _masserr = 0.5*_mass*TMath::Sqrt(phHard->EnergyErr()*phHard->EnergyErr()/phHard->E()/phHard->E() + phSoft->EnergyErr()*phSoft->EnergyErr()/phSoft->E()/phSoft->E());
246 >      _masserrsmeared = 0.5*_mass*TMath::Sqrt(phHard->EnergyErrSmeared()*phHard->EnergyErrSmeared()/phHard->E()/phHard->E() + phSoft->EnergyErrSmeared()*phSoft->EnergyErrSmeared()/phSoft->E()/phSoft->E());
247 >      _ptgg = (phHard->Mom()+phSoft->Mom()).Pt();
248 >      _costheta = ThreeVector(phHard->Mom()).Unit().Dot(ThreeVector(phSoft->Mom()).Unit());
249 >      _evtcat = PhotonTools::DiphotonR9EtaPtCat(phHard,phSoft);
250 >    }
251 >      
252 >    
253 >    Float_t _massele = -99.;
254 >    Float_t _ptee = -99.;
255 >    Float_t _costhetaele = -99.;
256 >    if (ele1 && ele2) {
257 >      _massele = (ele1->Mom()+ele2->Mom()).M();
258 >      _ptee = (ele1->Mom()+ele2->Mom()).Pt();
259 >      _costhetaele = ThreeVector(ele1->Mom()).Unit().Dot(ThreeVector(ele2->Mom()).Unit());      
260      }
261      
262      Float_t _gencostheta = -99.;
# Line 177 | Line 266 | void PhotonTreeWriter::Process()
266    
267      fDiphotonEvent->gencostheta = _gencostheta;
268      fDiphotonEvent->mass = _mass;
269 +    fDiphotonEvent->masserr = _masserr;
270 +    fDiphotonEvent->masserrsmeared = _masserrsmeared;
271      fDiphotonEvent->ptgg = _ptgg;
272 <    fDiphotonEvent->costheta =  ThreeVector(phHard->Mom()).Unit().Dot(ThreeVector(phSoft->Mom()).Unit());
273 <    fDiphotonEvent->evtcat = PhotonTools::DiphotonR9EtaPtCat(phHard,phSoft);
272 >    fDiphotonEvent->costheta =  _costheta;;
273 >    fDiphotonEvent->massele = _massele;
274 >    fDiphotonEvent->ptee = _ptee;
275 >    fDiphotonEvent->costhetaele =  _costhetaele;    
276 >    fDiphotonEvent->evtcat = _evtcat;
277  
278 <    fDiphotonEvent->photons[0].SetVars(phHard,conv1,phgen1);
279 <    fDiphotonEvent->photons[1].SetVars(phSoft,conv2,phgen2);
278 >    fDiphotonEvent->photons[0].SetVars(phHard,conv1,ele1,pfsc1,phgen1,fPhfixph,fPhfixele);
279 >    fDiphotonEvent->photons[1].SetVars(phSoft,conv2,ele2,pfsc2,phgen2,fPhfixph,fPhfixele);
280      
281      Float_t ph1ecor    = fDiphotonEvent->photons[0].Ecor();
282      Float_t ph1ecorerr = fDiphotonEvent->photons[0].Ecorerr();
283      Float_t ph2ecor    = fDiphotonEvent->photons[1].Ecor();
284      Float_t ph2ecorerr = fDiphotonEvent->photons[1].Ecorerr();
285 +
286 +    Float_t ph1ecorele    = fDiphotonEvent->photons[0].Ecorele();
287 +    Float_t ph1ecoreleerr = fDiphotonEvent->photons[0].Ecoreleerr();
288 +    Float_t ph2ecorele    = fDiphotonEvent->photons[1].Ecorele();
289 +    Float_t ph2ecoreleerr = fDiphotonEvent->photons[1].Ecoreleerr();
290 +    
291      
292      fDiphotonEvent->masscor = TMath::Sqrt(2.0*ph1ecor*ph2ecor*(1.0-fDiphotonEvent->costheta));
293      fDiphotonEvent->masscorerr = 0.5*fDiphotonEvent->masscor*TMath::Sqrt(ph1ecorerr*ph1ecorerr/ph1ecor/ph1ecor + ph2ecorerr*ph2ecorerr/ph2ecor/ph2ecor);
294      
295 +    fDiphotonEvent->masscorele = TMath::Sqrt(2.0*ph1ecorele*ph2ecorele*(1.0-fDiphotonEvent->costheta));
296 +    fDiphotonEvent->masscoreleerr = 0.5*fDiphotonEvent->masscorele*TMath::Sqrt(ph1ecoreleerr*ph1ecoreleerr/ph1ecorele/ph1ecorele + ph2ecoreleerr*ph2ecoreleerr/ph2ecorele/ph2ecorele);    
297 +    
298      //printf("r9 = %5f, photon sigieie = %5f, seed sigieie = %5f\n",phHard->R9(),phHard->CoviEtaiEta(),sqrt(phHard->SCluster()->Seed()->CoviEtaiEta()));
299      
300      if (fWriteDiphotonTree) hCiCTuple->Fill();  
# Line 201 | Line 304 | void PhotonTreeWriter::Process()
304    if (!fWriteSingleTree) return;
305  
306  
307 <  for (UInt_t iph = 0; iph<fPhotons->GetEntries(); ++iph) {
205 <    const Photon *ph = fPhotons->At(iph);
307 >  for (UInt_t iph = 0; iph<egcol->GetEntries(); ++iph) {
308      
309 <    if (ph->HasPV()) {
309 >    const Particle *p = 0;
310 >    const Photon *ph = 0;
311 >    const Electron *ele = 0;
312 >    const SuperCluster *sc = 0;
313 >    if (fLoopOnGoodElectrons) {
314 >      ele = fGoodElectrons->At(iph);
315 >      p = ele;
316 >      sc = ele->SCluster();
317 >      ph = PhotonTools::MatchedPhoton(ele,fPhotons);
318 >    }
319 >    else {
320 >      ph = fPhotons->At(iph);
321 >      p = ph;
322 >      sc = ph->SCluster();
323 >      ele = PhotonTools::MatchedElectron(ph,fGoodElectrons);    
324 >    }
325 >    
326 >    const DecayParticle *conv = PhotonTools::MatchedConversion(sc,fConversions,bsp,nhitsbeforevtxmax);
327 >    const SuperCluster *pfsc = PhotonTools::MatchedSC(sc,fSuperClusters);
328 >
329 >    
330 >    
331 >    if (!fLoopOnGoodElectrons && ph->HasPV()) {
332        fDiphotonEvent->vtxZ = ph->PV()->Z();
333      }
334  
335      const MCParticle *phgen = 0;
336      if( !fIsData ) {
337 <      phgen = PhotonTools::MatchMC(ph,fMCParticles,!fInvertElectronVeto);
337 >      phgen = PhotonTools::MatchMC(p,fMCParticles,fInvertElectronVeto);
338      }
339  
340 <    const DecayParticle *conv = PhotonTools::MatchedConversion(ph,fConversions,bsp,nhitsbeforevtxmax);
340 >    if (fExcludeSinglePrompt && phgen) return;
341 >
342 >    fDiphotonEvent->mt = -99.;
343 >    fDiphotonEvent->cosphimet = -99.;
344 >    fDiphotonEvent->mtele = -99.;
345 >    fDiphotonEvent->cosphimetele = -99.;
346 >
347 >    if (ph) {
348 >      fDiphotonEvent->cosphimet = TMath::Cos(ph->Phi()-fPFMet->At(0)->Phi());
349 >      fDiphotonEvent->mt = TMath::Sqrt(2.0*fPFMet->At(0)->Pt()*ph->Pt()*(1.0-fDiphotonEvent->cosphimet));
350 >    }
351      
352 <    fSinglePhoton->SetVars(ph,conv,phgen);
352 >    if (ele) {
353 >      fDiphotonEvent->cosphimetele = TMath::Cos(ele->Phi()-fPFMet->At(0)->Phi());
354 >      fDiphotonEvent->mtele = TMath::Sqrt(2.0*fPFMet->At(0)->Pt()*ele->Pt()*(1.0-fDiphotonEvent->cosphimetele));      
355 >    }
356 >    
357 >    fSinglePhoton->SetVars(ph,conv,ele,pfsc,phgen,fPhfixph,fPhfixele);
358      hCiCTupleSingle->Fill();
359      
360    }
# Line 240 | Line 379 | void PhotonTreeWriter::SlaveBegin()
379    ReqEventObject(fConversionName,     fConversions,true);
380    ReqEventObject(fBeamspotName,       fBeamspot,   true);
381    ReqEventObject(fPFCandName,         fPFCands,    true);
382 +  ReqEventObject(fSuperClusterName,   fSuperClusters, true);
383 +  ReqEventObject(fPFMetName,   fPFMet, true);
384    
385    if (!fIsData) {
386      ReqBranch(fPileUpName,            fPileUp);
# Line 251 | Line 392 | void PhotonTreeWriter::SlaveBegin()
392    //initialize photon energy corrections
393    //PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));  
394  
395 +  fPhfixph.initialise("4_2",std::string(fPhFixDataFile));
396 +  fPhfixele.initialise("4_2e",std::string(fPhFixDataFile));
397 +  
398    fDiphotonEvent = new PhotonTreeWriterDiphotonEvent;
399    fSinglePhoton = new PhotonTreeWriterPhoton;
400  
# Line 338 | Line 482 | void PhotonTreeWriter::FindHiggsPtAndZ(F
482    // loop over all GEN particles and look for status 1 photons
483    for(UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
484      const MCParticle* p = fMCParticles->At(i);
485 <    if( p->Is(MCParticle::kH) || (!fInvertElectronVeto && p->AbsPdgId()==23) ) {
485 >    if( p->Is(MCParticle::kH) || (fInvertElectronVeto && (p->AbsPdgId()==23||p->AbsPdgId()==24) ) ) {
486        pt=p->Pt();
487        decayZ = p->DecayVertex().Z();
488        mass = p->Mass();
# Line 364 | Line 508 | Float_t PhotonTreeWriter::GetEventCat(Ph
508    return ( ph1IsHR9 && ph2IsHR9 ? 2. : 3.);
509   }
510  
511 < void PhotonTreeWriterPhoton::SetVars(const Photon *p, const DecayParticle *c, const MCParticle *m) {
512 <      e = p->E();
513 <      pt = p->Pt();
514 <      eta = p->Eta();
515 <      phi = p->Phi();
516 <      r9 = p->R9();
517 <      e3x3 = p->E33();
518 <      e5x5 = p->E55();
519 <      const SuperCluster *s = p->SCluster();
511 > void PhotonTreeWriterPhoton::SetVars(const Photon *p, const DecayParticle *c, const Electron *ele, const SuperCluster *pfsc, const MCParticle *m, PhotonFix &phfixph, PhotonFix &phfixele) {
512 >  
513 >      const SuperCluster *s = 0;
514 >      if (p) {
515 >        s = p->SCluster();
516 >      }
517 >      else {
518 >        s = ele->SCluster();
519 >      }
520 >      const BasicCluster *b = s->Seed();
521 >  
522 > //       if (p && ele) {
523 > //         printf("p    : r9 = %5f, e33 = %5f, e55 = %5f, hovere = %5f, sigieie = %5f\n",p->R9(),p->E33(),p->E55(),p->HadOverEm(),p->CoviEtaiEta());
524 > //         printf("ele/b: r9 = %5f, e33 = %5f, e55 = %5f, hovere = %5f, sigieie = %5f\n",b->E3x3()/s->RawEnergy(),b->E3x3(),b->E5x5(),ele->HadronicOverEm(),ele->CoviEtaiEta());
525 > //       }
526 >      
527 >      if (p) {
528 >        hasphoton = kTRUE;
529 >        e = p->E();
530 >        pt = p->Pt();
531 >        eta = p->Eta();
532 >        phi = p->Phi();
533 >        r9 = p->R9();
534 >        e3x3 = p->E33();
535 >        e5x5 = p->E55();
536 >        hovere = p->HadOverEm();
537 >        sigietaieta = p->CoviEtaiEta();      
538 >        phcat = PhotonTools::CiCBaseLineCat(p);
539 >        eerr = p->EnergyErr();
540 >        eerrsmeared = p->EnergyErrSmeared();
541 >      }
542 >      else {
543 >        hasphoton = kFALSE;
544 >        e = -99.;
545 >        pt = -99.;
546 >        eta = -99.;
547 >        phi = -99.;
548 >        r9 = b->E3x3()/s->RawEnergy();
549 >        e3x3 = b->E3x3();
550 >        e5x5 = b->E5x5();
551 >        hovere = ele->HadronicOverEm();
552 >        sigietaieta = ele->CoviEtaiEta();      
553 >        phcat = -99;    
554 >        eerr = -99.;
555 >        eerrsmeared = -99.;
556 >      }
557 >      
558 >      
559        sce = s->Energy();
560        scrawe = s->RawEnergy();
561        scpse = s->PreshowerEnergy();
# Line 380 | Line 563 | void PhotonTreeWriterPhoton::SetVars(con
563        scphi = s->Phi();
564        scnclusters = s->ClusterSize();
565        scnhits = s->NHits();
566 <      hovere = p->HadOverEm();
567 <      sigietaieta = p->CoviEtaiEta();
566 >      scetawidth = s->EtaWidth();
567 >      scphiwidth = s->PhiWidth();
568        isbarrel = (s->AbsEta()<1.5);
569        isr9reco = (isbarrel && r9>0.94) || (!isbarrel && r9>0.95);
570        isr9cat = (r9>0.94);
571        
389      phcat = PhotonTools::CiCBaseLineCat(p);
572        
391 /*      if (isbarrel) {
392        if (isr9cat) phcat = 1;
393        else phcat = 2;
394      }
395      else {
396        if (isr9cat) phcat = 3;
397        else phcat = 4;
398      }*/
573        
574 <      const BasicCluster *b = s->Seed();
574 >      
575        sigiphiphi = TMath::Sqrt(b->CoviPhiiPhi());
576        if (isnan(sigiphiphi)) sigiphiphi = -99.;
577        covietaiphi = b->CoviEtaiPhi();
# Line 418 | Line 592 | void PhotonTreeWriterPhoton::SetVars(con
592        e2x5bottom = b->E2x5Bottom();
593        e2x5left = b->E2x5Left();
594        e2x5right = b->E2x5Right();
595 <
595 >      eseed = b->Energy();
596 >      
597        //initialize photon energy corrections if needed
598 <      if (!PhotonFix::initialised()) {
598 >      /*if (!PhotonFix::initialised()) {
599          PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data()));  
600 <      }
600 >      }*/
601 >      
602 >
603 >      phfixph.setup(e,sceta,scphi,r9);
604 >      phfixele.setup(e,sceta,scphi,r9);      
605        
427      PhotonFix fix(e,sceta,scphi,r9);
606        const Float_t dval = -99.;
607 <      ecor = fix.fixedEnergy();
608 <      ecorerr = fix.sigmaEnergy();
609 <      if (isbarrel) {
610 <       etac = fix.etaC();
611 <       etas = fix.etaS();
612 <       etam = fix.etaM();
613 <       phic = fix.phiC();
614 <       phis = fix.phiS();
615 <       phim = fix.phiM();
607 >      ecor = phfixph.fixedEnergy();
608 >      ecorerr = phfixph.sigmaEnergy();
609 >      ecorele = phfixele.fixedEnergy();
610 >      ecoreleerr = phfixele.sigmaEnergy();
611 >      if (phfixph.isbarrel()) {
612 >       etac = phfixph.etaC();
613 >       etas = phfixph.etaS();
614 >       etam = phfixph.etaM();
615 >       phic = phfixph.phiC();
616 >       phis = phfixph.phiS();
617 >       phim = phfixph.phiM();
618         xz = dval;
619         xc = dval;
620         xs = dval;
# Line 451 | Line 631 | void PhotonTreeWriterPhoton::SetVars(con
631         phic = dval;
632         phis = dval;
633         phim = dval;
634 <       xz = fix.xZ();
635 <       xc = fix.xC();
636 <       xs = fix.xS();
637 <       xm = fix.xM();
638 <       yz = fix.yZ();
639 <       yc = fix.yC();
640 <       ys = fix.yS();
641 <       ym = fix.yM();
634 >       xz = phfixph.xZ();
635 >       xc = phfixph.xC();
636 >       xs = phfixph.xS();
637 >       xm = phfixph.xM();
638 >       yz = phfixph.yZ();
639 >       yc = phfixph.yC();
640 >       ys = phfixph.yS();
641 >       ym = phfixph.yM();
642        }  
643        
644        if (c) {
# Line 467 | Line 647 | void PhotonTreeWriterPhoton::SetVars(con
647          convpt = c->Pt();
648          conveta = c->Eta();
649          convphi = c->Phi();
650 <        ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
650 >        ThreeVector dirconvsc = ThreeVector(s->Point()) - c->Position();
651          convdeta = c->Eta() - dirconvsc.Eta();
652          convdphi = MathUtils::DeltaPhi(c->Phi(),dirconvsc.Phi());
653          convvtxrho = c->Position().Rho();
# Line 523 | Line 703 | void PhotonTreeWriterPhoton::SetVars(con
703          trailtrackcharge = 0;      
704        }
705        
706 +      //electron quantities
707 +      if (ele) {
708 +        haselectron = kTRUE;
709 +        eleisecaldriven = ele->IsEcalDriven();
710 +        eleistrackerdriven = ele->IsTrackerDriven();
711 +        elee = ele->E();
712 +        elept = ele->Pt();
713 +        eleeta = ele->Eta();
714 +        elephi = ele->Phi();
715 +        elecharge = ele->Charge();
716 +        elefbrem = ele->FBrem();
717 +        eledeta = ele->DeltaEtaSuperClusterTrackAtVtx();
718 +        eledphi = ele->DeltaPhiSuperClusterTrackAtVtx();
719 +        elep = s->Energy()/ele->ESuperClusterOverP();
720 +        elepin = ele->PIn();
721 +        elepout = ele->POut();        
722 +      }
723 +      else {
724 +        haselectron = kFALSE;
725 +        eleisecaldriven = kFALSE;
726 +        eleistrackerdriven = kFALSE;
727 +        elee = -99.;
728 +        elept = -99.;
729 +        eleeta = -99.;
730 +        elephi = -99.;
731 +        elecharge = -99;
732 +        elefbrem = -99.;
733 +        eledeta = -99.;
734 +        eledphi = -99.;
735 +        elep = -99.;
736 +        elepin = -99.;
737 +        elepout = -99.;
738 +      }
739 +      
740 +      //pf supercluster quantities
741 +      if (pfsc) {
742 +        haspfsc = kTRUE;
743 +        pfsce = pfsc->Energy();
744 +        pfscrawe = pfsc->RawEnergy();
745 +        pfsceta = pfsc->Eta();
746 +        pfscphi = pfsc->Phi();        
747 +      }
748 +      else {
749 +        haspfsc = kFALSE;
750 +        pfsce = -99.;
751 +        pfscrawe = -99.;
752 +        pfsceta = -99.;
753 +        pfscphi = -99.;
754 +      }
755 +      
756        genz = -99.;
757        if (m) {
758          ispromptgen = kTRUE;
# Line 540 | Line 770 | void PhotonTreeWriterPhoton::SetVars(con
770          geneta = -99.;
771          genphi = -99.;
772        }
773 <      
773 >            
774   }
775 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines