ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/PhotonTools.cc
Revision: 1.4
Committed: Wed Jun 1 18:11:52 2011 UTC (13 years, 11 months ago) by fabstoec
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_023, Mit_022a, Mit_022
Changes since 1.3: +25 -2 lines
Log Message:
CiC BaseLine Selection

File Contents

# Content
1 // $Id: PhotonTools.cc,v 1.3 2011/04/21 15:07:40 bendavid 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 Double_t PhotonTools::ElectronVetoCiC(const Photon *p, const ElectronCol *els) {
54
55 for (UInt_t i=0; i<els->GetEntries(); ++i) {
56 const Electron *e = els->At(i);
57 if (e->SCluster()==p->SCluster() && e->GsfTrk()->NExpectedHitsInner()==0)
58 return sqrt(pow(e->DeltaEtaSuperClusterTrackAtVtx(),2)+pow(e->DeltaPhiSuperClusterTrackAtVtx(),2));
59 }
60
61 return -100.;
62 }
63
64
65 //--------------------------------------------------------------------------------------------------
66 Bool_t PhotonTools::PassElectronVetoConvRecovery(const Photon *p, const ElectronCol *els, const DecayParticleCol *conversions, const BaseVertex *v) {
67
68 Bool_t pass = kTRUE;
69 for (UInt_t i=0; i<els->GetEntries(); ++i) {
70 const Electron *e = els->At(i);
71 if (e->SCluster()==p->SCluster() && e->GsfTrk()->NExpectedHitsInner()==0 && ElectronTools::PassConversionFilter(e, conversions,
72 v, 0, 1e-6, 2.0, kFALSE, kFALSE) ) {
73 pass = kFALSE;
74 }
75 }
76
77 return pass;
78 }
79
80 //--------------------------------------------------------------------------------------------------
81 Bool_t PhotonTools::PassTriggerMatching(const Photon *p, const TriggerObjectCol *trigobjs)
82 {
83
84 for (UInt_t i=0; i<trigobjs->GetEntries(); ++i) {
85 const TriggerObject *trigobj = trigobjs->At(i);
86 if (trigobj->TriggerType()==TriggerObject::TriggerCluster || trigobj->TriggerType()==TriggerObject::TriggerElectron || trigobj->TriggerType()==TriggerObject::TriggerPhoton) {
87 if (MathUtils::DeltaR(p->SCluster(),trigobj)<0.3) {
88 return kTRUE;
89 }
90 }
91 }
92
93 return kFALSE;
94
95
96 }
97
98 //--------------------------------------------------------------------------------------------------
99 const DecayParticle *PhotonTools::MatchedConversion(const Photon *p, const DecayParticleCol *conversions,
100 const BaseVertex *vtx, Int_t nWrongHitsMax, Double_t probMin,
101 Double_t lxyMin, Double_t dRMin) {
102
103 const DecayParticle *match = 0;
104 Double_t rhosmallest = 999.;
105 for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
106 const DecayParticle *c = conversions->At(i);
107 ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
108 Double_t dr = MathUtils::DeltaR(*c,dirconvsc);
109 Double_t rho = c->Position().Rho();
110 if (dr<dRMin && rho<rhosmallest && c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
111 Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
112 Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
113 if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
114 rhosmallest = rho;
115 match = c;
116 }
117 }
118
119 }
120
121 return match;
122
123 }
124
125 //--------------------------------------------------------------------------------------------------
126 const DecayParticle *PhotonTools::MatchedConversion(const Track *t, const DecayParticleCol *conversions,
127 const BaseVertex *vtx, Int_t nWrongHitsMax, Double_t probMin,
128 Double_t lxyMin) {
129
130 for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
131 const DecayParticle *c = conversions->At(i);
132 if (c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
133 Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
134 Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
135 if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
136 const Track *ct1 = dynamic_cast<const ChargedParticle*>(c->Daughter(0))->Trk();
137 const Track *ct2 = dynamic_cast<const ChargedParticle*>(c->Daughter(1))->Trk();
138 if (t==ct1 || t==ct2) return c;
139 }
140 }
141
142 }
143
144 return 0;
145
146 }
147
148 PhotonTools::DiphotonR9EtaCats PhotonTools::DiphotonR9EtaCat(const Photon *p1, const Photon *p2) {
149
150 if (p1->IsEB() && p2->IsEB()) {
151 if (p1->R9()>0.93 && p2->R9()>0.93) return kCat1;
152 else return kCat2;
153
154 }
155 else {
156 if (p1->R9()>0.93 && p2->R9()>0.93) return kCat3;
157 else return kCat4;
158 }
159
160 }
161
162 PhotonTools::DiphotonR9EtaConversionCats PhotonTools::DiphotonR9EtaConversionCat(const Photon *p1, const Photon *p2, const DecayParticleCol *conversions, const BaseVertex *v) {
163
164 const DecayParticle *conv1 = MatchedConversion(p1, conversions, v);
165 const DecayParticle *conv2 = MatchedConversion(p2, conversions, v);
166
167 if (p1->IsEB() && p2->IsEB()) {
168 if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat1;
169 else if (conv1||conv2) return kNewCat2;
170 else return kNewCat3;
171
172 }
173 else {
174 if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat4;
175 else if (conv1||conv2) return kNewCat5;
176 else return kNewCat6;
177 }
178
179 }
180
181 PhotonTools::CiCBaseLineCats PhotonTools::CiCBaseLineCat(const Photon *p) {
182 if( p->IsEB() ) {
183 if ( p->R9() > 0.94 ) return kCiCCat1;
184 else return kCiCCat2;
185 } else {
186 if ( p->R9() > 0.94 ) return kCiCCat3;
187 else return kCiCCat4;
188 }
189 }