ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/PhotonTools.cc
Revision: 1.1
Committed: Tue Apr 12 22:14:21 2011 UTC (14 years ago) by bendavid
Content type: text/plain
Branch: MAIN
Log Message:
Add PhotonTools with conversion id, trigger matching and diphoton categories, add functionality to PhotonIdMod

File Contents

# User Rev Content
1 bendavid 1.1 // $Id: PhotonTools.cc,v 1.24 2011/03/21 12:25:36 ceballos Exp $
2    
3     #include "MitPhysics/Utils/interface/PhotonTools.h"
4     #include "MitPhysics/Utils/interface/ElectronTools.h"
5     #include "MitAna/DataTree/interface/StableData.h"
6     #include <TFile.h>
7    
8     ClassImp(mithep::PhotonTools)
9    
10     using namespace mithep;
11    
12     //--------------------------------------------------------------------------------------------------
13     PhotonTools::PhotonTools()
14     {
15     // Constructor.
16     }
17    
18     //--------------------------------------------------------------------------------------------------
19     Bool_t PhotonTools::PassConversionId(const Photon *p, const DecayParticle *c) {
20    
21     if (!c) return kTRUE;
22    
23     ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
24     Double_t deta = c->Eta()-dirconvsc.Eta();
25     Double_t dphi = MathUtils::DeltaPhi(c->Phi(),dirconvsc.Phi());
26     Double_t eoverp = p->SCluster()->Energy()/c->P();
27    
28     if (p->IsEB() && eoverp>2.0) return kFALSE;
29     if (p->IsEE() && eoverp>3.0) return kFALSE;
30    
31     if (p->IsEE() && TMath::Abs(deta)>0.01) return kFALSE;
32     if (p->IsEE() && TMath::Abs(dphi)>0.01) return kFALSE;
33    
34     return kTRUE;
35    
36     }
37    
38     //--------------------------------------------------------------------------------------------------
39     Bool_t PhotonTools::PassElectronVeto(const Photon *p, const ElectronCol *els) {
40    
41     Bool_t pass = kTRUE;
42     for (UInt_t i=0; i<els->GetEntries(); ++i) {
43     const Electron *e = els->At(i);
44     if (e->SCluster()==p->SCluster() && e->GsfTrk()->NExpectedHitsInner()==0) {
45     pass = kFALSE;
46     }
47     }
48    
49     return pass;
50     }
51    
52     //--------------------------------------------------------------------------------------------------
53     Bool_t PhotonTools::PassElectronVetoConvRecovery(const Photon *p, const ElectronCol *els, const DecayParticleCol *conversions, const BaseVertex *v) {
54    
55     Bool_t pass = kTRUE;
56     for (UInt_t i=0; i<els->GetEntries(); ++i) {
57     const Electron *e = els->At(i);
58     if (e->SCluster()==p->SCluster() && e->GsfTrk()->NExpectedHitsInner()==0 && ElectronTools::PassConversionFilter(e, conversions,
59     v, 0, 1e-6, 2.0, kFALSE, kFALSE) ) {
60     pass = kFALSE;
61     }
62     }
63    
64     return pass;
65     }
66    
67     //--------------------------------------------------------------------------------------------------
68     Bool_t PhotonTools::PassTriggerMatching(const Photon *p, const TriggerObjectCol *trigobjs)
69     {
70    
71     for (UInt_t i=0; i<trigobjs->GetEntries(); ++i) {
72     const TriggerObject *trigobj = trigobjs->At(i);
73     if (trigobj->TriggerType()==TriggerObject::TriggerCluster || trigobj->TriggerType()==TriggerObject::TriggerElectron || trigobj->TriggerType()==TriggerObject::TriggerPhoton) {
74     if (MathUtils::DeltaR(p->SCluster(),trigobj)<0.3) {
75     return kTRUE;
76     }
77     }
78     }
79    
80     return kFALSE;
81    
82    
83     }
84    
85     //--------------------------------------------------------------------------------------------------
86     const DecayParticle *PhotonTools::MatchedConversion(const Photon *p, const DecayParticleCol *conversions,
87     const BaseVertex *vtx, Int_t nWrongHitsMax, Double_t probMin,
88     Double_t lxyMin, Double_t dRMin) {
89    
90     const DecayParticle *match = 0;
91     Double_t drsmallest = 999.;
92     for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
93     const DecayParticle *c = conversions->At(i);
94     ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
95     Double_t dr = MathUtils::DeltaR(*c,dirconvsc);
96     if (dr<dRMin && dr<drsmallest && c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
97     Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
98     Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
99     if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
100     drsmallest = dr;
101     match = c;
102     }
103     }
104    
105     }
106    
107     return match;
108    
109     }
110    
111     PhotonTools::DiphotonR9EtaCats PhotonTools::DiphotonR9EtaCat(const Photon *p1, const Photon *p2) {
112    
113     if (p1->IsEB() && p2->IsEB()) {
114     if (p1->R9()>0.93 && p2->R9()>0.93) return kCat1;
115     else return kCat2;
116    
117     }
118     else {
119     if (p1->R9()>0.93 && p2->R9()>0.93) return kCat3;
120     else return kCat4;
121     }
122    
123     }
124    
125     PhotonTools::DiphotonR9EtaConversionCats PhotonTools::DiphotonR9EtaConversionCat(const Photon *p1, const Photon *p2, const DecayParticleCol *conversions, const BaseVertex *v) {
126    
127     const DecayParticle *conv1 = MatchedConversion(p1, conversions, v);
128     const DecayParticle *conv2 = MatchedConversion(p2, conversions, v);
129    
130     if (p1->IsEB() && p2->IsEB()) {
131     if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat1;
132     else if (conv1||conv2) return kNewCat2;
133     else return kNewCat3;
134    
135     }
136     else {
137     if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat4;
138     else if (conv1||conv2) return kNewCat5;
139     else return kNewCat6;
140     }
141    
142     }