1 |
bendavid |
1.3 |
// $Id: PhotonTools.cc,v 1.2 2011/04/14 22:05:42 bendavid Exp $
|
2 |
bendavid |
1.1 |
|
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 |
bendavid |
1.3 |
Double_t rhosmallest = 999.;
|
92 |
bendavid |
1.1 |
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 |
bendavid |
1.3 |
Double_t rho = c->Position().Rho();
|
97 |
|
|
if (dr<dRMin && rho<rhosmallest && c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
|
98 |
bendavid |
1.1 |
Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
|
99 |
|
|
Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
|
100 |
|
|
if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
|
101 |
bendavid |
1.3 |
rhosmallest = rho;
|
102 |
bendavid |
1.1 |
match = c;
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
return match;
|
109 |
|
|
|
110 |
|
|
}
|
111 |
|
|
|
112 |
bendavid |
1.2 |
//--------------------------------------------------------------------------------------------------
|
113 |
|
|
const DecayParticle *PhotonTools::MatchedConversion(const Track *t, const DecayParticleCol *conversions,
|
114 |
|
|
const BaseVertex *vtx, Int_t nWrongHitsMax, Double_t probMin,
|
115 |
|
|
Double_t lxyMin) {
|
116 |
|
|
|
117 |
|
|
for (UInt_t i=0; i<conversions->GetEntries(); ++i) {
|
118 |
|
|
const DecayParticle *c = conversions->At(i);
|
119 |
|
|
if (c->Prob()>probMin && c->LxyCorrected(vtx)>lxyMin) {
|
120 |
|
|
Int_t nhb1 = dynamic_cast<const StableData*>(c->DaughterDat(0))->NHitsBeforeVtx();
|
121 |
|
|
Int_t nhb2 = dynamic_cast<const StableData*>(c->DaughterDat(1))->NHitsBeforeVtx();
|
122 |
|
|
if (TMath::Max(nhb1,nhb2)<=nWrongHitsMax) {
|
123 |
|
|
const Track *ct1 = dynamic_cast<const ChargedParticle*>(c->Daughter(0))->Trk();
|
124 |
|
|
const Track *ct2 = dynamic_cast<const ChargedParticle*>(c->Daughter(1))->Trk();
|
125 |
|
|
if (t==ct1 || t==ct2) return c;
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
return 0;
|
132 |
|
|
|
133 |
|
|
}
|
134 |
|
|
|
135 |
bendavid |
1.1 |
PhotonTools::DiphotonR9EtaCats PhotonTools::DiphotonR9EtaCat(const Photon *p1, const Photon *p2) {
|
136 |
|
|
|
137 |
|
|
if (p1->IsEB() && p2->IsEB()) {
|
138 |
|
|
if (p1->R9()>0.93 && p2->R9()>0.93) return kCat1;
|
139 |
|
|
else return kCat2;
|
140 |
|
|
|
141 |
|
|
}
|
142 |
|
|
else {
|
143 |
|
|
if (p1->R9()>0.93 && p2->R9()>0.93) return kCat3;
|
144 |
|
|
else return kCat4;
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
PhotonTools::DiphotonR9EtaConversionCats PhotonTools::DiphotonR9EtaConversionCat(const Photon *p1, const Photon *p2, const DecayParticleCol *conversions, const BaseVertex *v) {
|
150 |
|
|
|
151 |
|
|
const DecayParticle *conv1 = MatchedConversion(p1, conversions, v);
|
152 |
|
|
const DecayParticle *conv2 = MatchedConversion(p2, conversions, v);
|
153 |
|
|
|
154 |
|
|
if (p1->IsEB() && p2->IsEB()) {
|
155 |
|
|
if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat1;
|
156 |
|
|
else if (conv1||conv2) return kNewCat2;
|
157 |
|
|
else return kNewCat3;
|
158 |
|
|
|
159 |
|
|
}
|
160 |
|
|
else {
|
161 |
|
|
if (p1->R9()>0.93 && p2->R9()>0.93) return kNewCat4;
|
162 |
|
|
else if (conv1||conv2) return kNewCat5;
|
163 |
|
|
else return kNewCat6;
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
} |