ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/PhotonTools.cc
Revision: 1.5
Committed: Mon Jun 27 12:32:21 2011 UTC (13 years, 10 months ago) by fabstoec
Content type: text/plain
Branch: MAIN
Changes since 1.4: +159 -7 lines
Log Message:
update Photon CiC selection

File Contents

# User Rev Content
1 fabstoec 1.5 // $Id: PhotonTools.cc,v 1.4 2011/06/01 18:11:52 fabstoec Exp $
2 bendavid 1.1
3     #include "MitPhysics/Utils/interface/PhotonTools.h"
4     #include "MitPhysics/Utils/interface/ElectronTools.h"
5 fabstoec 1.5 #include "MitPhysics/Utils/interface/IsolationTools.h"
6 bendavid 1.1 #include "MitAna/DataTree/interface/StableData.h"
7     #include <TFile.h>
8    
9     ClassImp(mithep::PhotonTools)
10    
11     using namespace mithep;
12    
13     //--------------------------------------------------------------------------------------------------
14     PhotonTools::PhotonTools()
15     {
16     // Constructor.
17     }
18    
19     //--------------------------------------------------------------------------------------------------
20     Bool_t PhotonTools::PassConversionId(const Photon *p, const DecayParticle *c) {
21    
22     if (!c) return kTRUE;
23    
24     ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
25     Double_t deta = c->Eta()-dirconvsc.Eta();
26     Double_t dphi = MathUtils::DeltaPhi(c->Phi(),dirconvsc.Phi());
27     Double_t eoverp = p->SCluster()->Energy()/c->P();
28    
29     if (p->IsEB() && eoverp>2.0) return kFALSE;
30     if (p->IsEE() && eoverp>3.0) return kFALSE;
31    
32     if (p->IsEE() && TMath::Abs(deta)>0.01) return kFALSE;
33     if (p->IsEE() && TMath::Abs(dphi)>0.01) return kFALSE;
34    
35     return kTRUE;
36    
37     }
38    
39     //--------------------------------------------------------------------------------------------------
40     Bool_t PhotonTools::PassElectronVeto(const Photon *p, const ElectronCol *els) {
41    
42     Bool_t pass = kTRUE;
43     for (UInt_t i=0; i<els->GetEntries(); ++i) {
44     const Electron *e = els->At(i);
45     if (e->SCluster()==p->SCluster() && e->GsfTrk()->NExpectedHitsInner()==0) {
46     pass = kFALSE;
47     }
48     }
49    
50     return pass;
51     }
52    
53     //--------------------------------------------------------------------------------------------------
54 fabstoec 1.4 Double_t PhotonTools::ElectronVetoCiC(const Photon *p, const ElectronCol *els) {
55    
56     for (UInt_t i=0; i<els->GetEntries(); ++i) {
57     const Electron *e = els->At(i);
58 fabstoec 1.5 if (e->SCluster()==p->SCluster() ) {
59     //if( e->GsfTrk()->NExpectedHitsInner()==0 && e->GsfTrk()->Pt() > 2.5 ) {
60     if( e->GsfTrk()->NExpectedHitsInner()==0 ) {
61     double dEta = e->DeltaEtaSuperClusterTrackAtVtx();
62     double dPhi = e->DeltaPhiSuperClusterTrackAtVtx();
63     double dR = TMath::Sqrt(dEta*dEta+dPhi*dPhi);
64     return dR;
65     }
66     }
67     }
68     return 99.;
69 fabstoec 1.4 }
70    
71     //--------------------------------------------------------------------------------------------------
72 bendavid 1.1 Bool_t PhotonTools::PassElectronVetoConvRecovery(const Photon *p, const ElectronCol *els, const DecayParticleCol *conversions, const BaseVertex *v) {
73    
74     Bool_t pass = kTRUE;
75     for (UInt_t i=0; i<els->GetEntries(); ++i) {
76     const Electron *e = els->At(i);
77     if (e->SCluster()==p->SCluster() && e->GsfTrk()->NExpectedHitsInner()==0 && ElectronTools::PassConversionFilter(e, conversions,
78     v, 0, 1e-6, 2.0, kFALSE, kFALSE) ) {
79     pass = kFALSE;
80     }
81     }
82    
83     return pass;
84     }
85    
86     //--------------------------------------------------------------------------------------------------
87     Bool_t PhotonTools::PassTriggerMatching(const Photon *p, const TriggerObjectCol *trigobjs)
88     {
89    
90     for (UInt_t i=0; i<trigobjs->GetEntries(); ++i) {
91     const TriggerObject *trigobj = trigobjs->At(i);
92     if (trigobj->TriggerType()==TriggerObject::TriggerCluster || trigobj->TriggerType()==TriggerObject::TriggerElectron || trigobj->TriggerType()==TriggerObject::TriggerPhoton) {
93     if (MathUtils::DeltaR(p->SCluster(),trigobj)<0.3) {
94     return kTRUE;
95     }
96     }
97     }
98    
99     return kFALSE;
100    
101    
102     }
103    
104     //--------------------------------------------------------------------------------------------------
105     const DecayParticle *PhotonTools::MatchedConversion(const Photon *p, const DecayParticleCol *conversions,
106     const BaseVertex *vtx, Int_t nWrongHitsMax, Double_t probMin,
107     Double_t lxyMin, Double_t dRMin) {
108    
109     const DecayParticle *match = 0;
110 bendavid 1.3 Double_t rhosmallest = 999.;
111 bendavid 1.1 for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
112     const DecayParticle *c = conversions->At(i);
113     ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
114     Double_t dr = MathUtils::DeltaR(*c,dirconvsc);
115 bendavid 1.3 Double_t rho = c->Position().Rho();
116     if (dr<dRMin && rho<rhosmallest && c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
117 bendavid 1.1 Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
118     Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
119     if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
120 bendavid 1.3 rhosmallest = rho;
121 bendavid 1.1 match = c;
122     }
123     }
124    
125     }
126    
127     return match;
128    
129     }
130    
131 bendavid 1.2 //--------------------------------------------------------------------------------------------------
132     const DecayParticle *PhotonTools::MatchedConversion(const Track *t, const DecayParticleCol *conversions,
133     const BaseVertex *vtx, Int_t nWrongHitsMax, Double_t probMin,
134     Double_t lxyMin) {
135    
136     for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
137     const DecayParticle *c = conversions->At(i);
138     if (c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
139     Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
140     Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
141     if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
142     const Track *ct1 = dynamic_cast<const ChargedParticle*>(c->Daughter(0))->Trk();
143     const Track *ct2 = dynamic_cast<const ChargedParticle*>(c->Daughter(1))->Trk();
144     if (t==ct1 || t==ct2) return c;
145     }
146     }
147    
148     }
149    
150     return 0;
151    
152     }
153    
154 bendavid 1.1 PhotonTools::DiphotonR9EtaCats PhotonTools::DiphotonR9EtaCat(const Photon *p1, const Photon *p2) {
155    
156     if (p1->IsEB() && p2->IsEB()) {
157     if (p1->R9()>0.93 && p2->R9()>0.93) return kCat1;
158     else return kCat2;
159    
160     }
161     else {
162     if (p1->R9()>0.93 && p2->R9()>0.93) return kCat3;
163     else return kCat4;
164     }
165    
166     }
167    
168     PhotonTools::DiphotonR9EtaConversionCats PhotonTools::DiphotonR9EtaConversionCat(const Photon *p1, const Photon *p2, const DecayParticleCol *conversions, const BaseVertex *v) {
169    
170     const DecayParticle *conv1 = MatchedConversion(p1, conversions, v);
171     const DecayParticle *conv2 = MatchedConversion(p2, conversions, v);
172    
173     if (p1->IsEB() && p2->IsEB()) {
174     if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat1;
175     else if (conv1||conv2) return kNewCat2;
176     else return kNewCat3;
177    
178     }
179     else {
180     if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat4;
181     else if (conv1||conv2) return kNewCat5;
182     else return kNewCat6;
183     }
184    
185 fabstoec 1.4 }
186    
187     PhotonTools::CiCBaseLineCats PhotonTools::CiCBaseLineCat(const Photon *p) {
188     if( p->IsEB() ) {
189     if ( p->R9() > 0.94 ) return kCiCCat1;
190     else return kCiCCat2;
191     } else {
192     if ( p->R9() > 0.94 ) return kCiCCat3;
193     else return kCiCCat4;
194     }
195     }
196 fabstoec 1.5
197     //--------------------------------------------------------------------------------------------------
198     const DecayParticle *PhotonTools::MatchedCiCConversion(const Photon *p, const DecayParticleCol *conversions,
199     Double_t dPhiMin,
200     Double_t dEtaMin) {
201    
202    
203    
204     const DecayParticle *match = 0;
205     Double_t rhosmallest = 999.;
206     for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
207     const DecayParticle *c = conversions->At(i);
208     ThreeVector dirconvsc = ThreeVector(p->SCluster()->Point()) - c->Position();
209     Double_t dphi = MathUtils::DeltaPhi(*c,dirconvsc);
210     Double_t deta = c->Eta()-dirconvsc.Eta();
211     Double_t rho = c->Position().Rho();
212     if (dphi<dPhiMin && TMath::Abs(deta)<dEtaMin && rho<rhosmallest) {
213     rhosmallest = rho;
214     match = c;
215     }
216    
217     }
218    
219     return match;
220    
221     }
222    
223     bool PhotonTools::PassCiCSelection(Photon* ph, const Vertex* vtx,
224     const TrackCol* trackCol,
225     const ElectronCol* eleCol,
226     const VertexCol* vtxCol,
227     double rho, double ptmin,
228     bool print, float* kin) {
229    
230     // these values are taken from the H2GGlobe code... (actually from Marco/s mail)
231     float cic4_allcuts_temp_sublead[] = {
232     3.8, 2.2, 1.77, 1.29,
233     11.7, 3.4, 3.9, 1.84,
234     3.5, 2.2, 2.3, 1.45,
235     0.0106, 0.0097, 0.028, 0.027,
236     0.082, 0.062, 0.065, 0.048,
237     0.94, 0.36, 0.94, 0.32,
238     1., 0.062, 0.97, 0.97,
239     1.5, 1.5, 1.5, 1.5 }; // the last line is PixelmatchVeto and un-used
240    
241     // cut on Et instead of Pt???
242     Bool_t isbarrel = ph->SCluster()->AbsEta()<1.5;
243    
244     // compute all relevant observables first
245     double ecalIso3 = ph->EcalRecHitIsoDr03();
246     double ecalIso4 = ph->EcalRecHitIsoDr04();
247     double hcalIso4 = ph->HcalTowerSumEtDr04();
248    
249     unsigned int wVtxInd = 0;
250    
251     double trackIso1 = IsolationTools::CiCTrackIsolation(ph, vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol);
252    
253     // track iso only
254     double trackIso3 = IsolationTools::CiCTrackIsolation(ph, vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol);
255    
256     // track iso worst vtx
257     double trackIso2 = IsolationTools::CiCTrackIsolation(ph, vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd, vtxCol);
258    
259     double combIso1 = ecalIso3+hcalIso4+trackIso1 - 0.17*rho;
260     double combIso2 = ecalIso4+hcalIso4+trackIso2 - 0.52*rho;
261    
262     double tIso1 = (combIso1) *50./ph->Et();
263     double tIso2 = (combIso2) *50./(ph->MomVtx(vtxCol->At(wVtxInd)->Position()).Pt());
264     //double tIso2 = (combIso2) *50./ph->Et();
265     double tIso3 = (trackIso3)*50./ph->Et();
266    
267     double covIEtaIEta =ph->CoviEtaiEta();
268     double HoE = ph->HadOverEm();
269    
270     double R9 = ph->R9();
271    
272     double dRTrack = PhotonTools::ElectronVetoCiC(ph, eleCol);
273    
274     // check which category it is ...
275     int _tCat = 1;
276     if ( !isbarrel ) _tCat = 3;
277     if ( R9 < 0.94 ) _tCat++;
278    
279     if(print) {
280     std::cout<<" -------------------------- "<<std::endl;
281     std::cout<<" photon Et = "<<ph->Et()<<std::endl;
282     std::cout<<" Eta = "<<ph->SCluster()->Eta()<<std::endl;
283     std::cout<<" HoE = "<<HoE<<std::endl;
284     std::cout<<" R9 = "<<R9<<std::endl;
285     std::cout<<" dR = "<<dRTrack<<std::endl;
286     std::cout<<" iso1 = "<<tIso1<<std::endl;
287     std::cout<<" iso2 = "<<tIso2<<std::endl;
288     std::cout<<" iso3 = "<<tIso3<<std::endl;
289     }
290    
291     if(kin) {
292     kin[0] = tIso1;
293     kin[1] = tIso2;
294     kin[2] = tIso3;
295     kin[3] = covIEtaIEta;
296     kin[4] = HoE;
297     kin[5] = R9;
298     kin[6] = dRTrack;
299     kin[7] = (float) ph->Pt();
300     kin[8] = (float) ph->Eta();
301     kin[9] = (float) ph->Phi();
302    
303     // iso quantities separate
304     kin[10] = ecalIso3;
305     kin[11] = ecalIso4;
306     kin[12] = hcalIso4;
307     kin[13] = trackIso1;
308     kin[14] = trackIso2;
309     kin[15] = trackIso3;
310    
311     kin[16] = (float) ph->Et();
312     kin[17] = (float) ph->E();
313    
314     }
315    
316     float passCuts = 1.;
317    
318     if ( ph->Pt() <= ptmin ) passCuts = -1.;
319    
320     // not needed anymore, do in pre-selection...
321     //if ( ph->SCluster()->AbsEta()>=2.5 || (ph->SCluster()->AbsEta()>=1.4442 && ph->SCluster()->AbsEta()<=1.566)) passCuts = -1.;
322    
323     if( ! ( tIso1 < cic4_allcuts_temp_sublead[_tCat-1+0*4]
324     && tIso2 < cic4_allcuts_temp_sublead[_tCat-1+1*4]
325     && tIso3 < cic4_allcuts_temp_sublead[_tCat-1+2*4]
326     && covIEtaIEta < cic4_allcuts_temp_sublead[_tCat-1+3*4]
327     && HoE < cic4_allcuts_temp_sublead[_tCat-1+4*4]
328     && R9 > cic4_allcuts_temp_sublead[_tCat-1+5*4]
329     && dRTrack > cic4_allcuts_temp_sublead[_tCat-1+6*4] )
330     ) {
331     passCuts = -1.;
332     }
333    
334     if(kin) {
335     kin[18] = passCuts;
336     kin[19] = (float) _tCat;
337     }
338    
339     if(passCuts > 0.) return true;
340     return false;
341     }