CMS 3D CMS Logo

EgHLTOffEgSel.cc
Go to the documentation of this file.
1 #include <cmath>
2 
4 
8 
10 
11 using namespace egHLT;
12 
13 void OffEgSel::setup(const edm::ParameterSet& iConfig) {
16 }
17 
18 int OffEgSel::getCutCode(const OffEle& ele, int cutMask) const {
19  if (std::fabs(ele.detEta()) < 1.5)
20  return getCutCode(ele, ebCutValues_, cutMask);
21  else
22  return getCutCode(ele, eeCutValues_, cutMask);
23 }
24 
25 int OffEgSel::getCutCode(const OffEle& ele, const EgCutValues& cuts, int cutMask) {
26  int cutCode = 0x0;
27  //kinematic cuts
28  if (ele.et() < cuts.minEt)
29  cutCode |= EgCutCodes::ET;
30  if (std::fabs(ele.etaSC()) < cuts.minEta || std::fabs(ele.etaSC()) > cuts.maxEta)
31  cutCode |= EgCutCodes::DETETA;
32  if (ele.isGap())
33  cutCode |= EgCutCodes::CRACK;
34  //track cuts
35  if (std::fabs(ele.dEtaIn()) > cuts.maxDEtaIn)
36  cutCode |= EgCutCodes::DETAIN;
37  if (std::fabs(ele.dPhiIn()) > cuts.maxDPhiIn)
38  cutCode |= EgCutCodes::DPHIIN;
39  if (ele.invEInvP() > cuts.maxInvEInvP)
40  cutCode |= EgCutCodes::INVEINVP;
41  //supercluster cuts
42  if (ele.hOverE() > cuts.maxHadem && ele.hOverE() * ele.caloEnergy() > cuts.maxHadEnergy)
43  cutCode |= EgCutCodes::HADEM;
44  if (ele.sigmaIEtaIEta() > cuts.maxSigmaIEtaIEta)
45  cutCode |= EgCutCodes::SIGMAIETAIETA;
46  if (ele.sigmaEtaEta() > cuts.maxSigmaEtaEta)
47  cutCode |= EgCutCodes::SIGMAETAETA;
48  //---Morse-------
49  //if(ele.r9()<cuts.minR9) cutCode |= EgCutCodes::R9;
50  if (ele.r9() < cuts.minR9)
51  cutCode |= EgCutCodes::MINR9;
52  if (ele.r9() > cuts.maxR9)
53  cutCode |= EgCutCodes::MAXR9;
54  //----------------
55 
56  //std isolation cuts
57  if (ele.isolEm() > (cuts.isolEmConstTerm +
58  cuts.isolEmGradTerm * (ele.et() < cuts.isolEmGradStart ? 0. : (ele.et() - cuts.isolEmGradStart))))
59  cutCode |= EgCutCodes::ISOLEM;
60  if (ele.isolHad() >
61  (cuts.isolHadConstTerm +
62  cuts.isolHadGradTerm * (ele.et() < cuts.isolHadGradStart ? 0. : (ele.et() - cuts.isolHadGradStart))))
63  cutCode |= EgCutCodes::ISOLHAD;
64  if (ele.isolPtTrks() >
65  (cuts.isolPtTrksConstTerm +
66  cuts.isolPtTrksGradTerm * (ele.et() < cuts.isolPtTrksGradStart ? 0. : (ele.et() - cuts.isolPtTrksGradStart))))
67  cutCode |= EgCutCodes::ISOLPTTRKS;
68  //ele Nr trks not defined, assume it passes
69  //hlt isolation cuts
70  if (ele.et() <=
71  0.) { //even it if et<=0, we give it a shot at passing isolation. Note this should be an impossible case
72  if (ele.hltIsolTrksEle() > cuts.maxHLTIsolTrksEle)
73  cutCode |= EgCutCodes::HLTISOLTRKSELE;
74  if (ele.hltIsolTrksPho() > cuts.maxHLTIsolTrksPho)
75  cutCode |= EgCutCodes::HLTISOLTRKSPHO;
76  if (ele.hltIsolHad() > cuts.maxHLTIsolHad)
77  cutCode |= EgCutCodes::HLTISOLHAD;
78  if (ele.hltIsolEm() > cuts.maxHLTIsolEm)
79  cutCode |= EgCutCodes::HLTISOLEM;
80  } else {
81  if (ele.hltIsolTrksEle() > cuts.maxHLTIsolTrksEle &&
82  ele.hltIsolTrksEle() / ele.et() > cuts.maxHLTIsolTrksEleOverPt &&
83  ele.hltIsolTrksEle() / ele.et() / ele.et() > cuts.maxHLTIsolTrksEleOverPt2)
84  cutCode |= EgCutCodes::HLTISOLTRKSELE;
85  if (ele.hltIsolTrksPho() > cuts.maxHLTIsolTrksPho &&
86  ele.hltIsolTrksPho() / ele.et() > cuts.maxHLTIsolTrksPhoOverPt &&
87  ele.hltIsolTrksPho() / ele.et() / ele.et() > cuts.maxHLTIsolTrksPhoOverPt2)
88  cutCode |= EgCutCodes::HLTISOLTRKSPHO;
89  if (ele.hltIsolHad() > cuts.maxHLTIsolHad && ele.hltIsolHad() / ele.et() > cuts.maxHLTIsolHadOverEt &&
90  ele.hltIsolHad() / ele.et() / ele.et() > cuts.maxHLTIsolHadOverEt2)
91  cutCode |= EgCutCodes::HLTISOLHAD;
92  if (ele.hltIsolEm() > cuts.maxHLTIsolEm && ele.hltIsolEm() / ele.et() > cuts.maxHLTIsolEmOverEt &&
93  ele.hltIsolEm() / ele.et() / ele.et() > cuts.maxHLTIsolEmOverEt2)
94  cutCode |= EgCutCodes::HLTISOLEM;
95  }
96 
97  //cuts on CTF track, HLT tracking doesnt handle poor quaility tracks
98  if (ele.validCTFTrack()) {
99  if (!(ele.ctfTrkOuterRadius() >= cuts.minCTFTrkOuterRadius && //note I'm NOTing the result of the AND
100  ele.ctfTrkInnerRadius() <= cuts.maxCTFTrkInnerRadius &&
101 
102  ele.ctfTrkHitsFound() >= cuts.minNrCTFTrkHits && ele.ctfTrkHitsLost() <= cuts.maxNrCTFTrkHitsLost))
103  cutCode |= EgCutCodes::CTFTRACK; //the next line can also set this bit
104  if (cuts.requirePixelHitsIfOuterInOuter) {
105  DetId innerDetId(ele.ctfTrack()->extra()->innerDetId());
106  DetId outerDetId(ele.ctfTrack()->extra()->outerDetId());
107 
108  if (outerDetId.subdetId() >= 5 && innerDetId.subdetId() >= 3)
109  cutCode |= EgCutCodes::CTFTRACK; //1,2 = pixel, 3,4,5,6 sistrip
110  }
111  // std::cout <<"eta "<<ele.detEta()<<" max inner "<<cuts.maxCTFTrkInnerRadius<<" inner "<<ele.ctfTrkInnerRadius()<<std::endl;
112  } else
113  cutCode |= EgCutCodes::CTFTRACK;
114 
115  if (std::fabs(ele.hltDEtaIn()) > cuts.maxHLTDEtaIn)
116  cutCode |= EgCutCodes::HLTDETAIN;
117  if (std::fabs(ele.hltDPhiIn()) > cuts.maxHLTDPhiIn)
118  cutCode |= EgCutCodes::HLTDPHIIN;
119  if (std::fabs(ele.hltInvEInvP()) > cuts.maxHLTInvEInvP)
120  cutCode |= EgCutCodes::HLTINVEINVP;
121 
122  return (cutCode & cuts.cutMask & cutMask);
123 }
124 
125 int OffEgSel::getCutCode(const OffPho& pho, int cutMask) const {
126  if (std::fabs(pho.detEta()) < 1.5)
127  return getCutCode(pho, ebCutValues_, cutMask);
128  else
129  return getCutCode(pho, eeCutValues_, cutMask);
130 }
131 
132 //photons automatically fail any track cut
133 int OffEgSel::getCutCode(const OffPho& pho, const EgCutValues& cuts, int cutMask) {
134  int cutCode = 0x0;
135  //kinematic cuts
136  if (pho.et() < cuts.minEt)
137  cutCode |= EgCutCodes::ET;
138  if (std::fabs(pho.etaSC()) < cuts.minEta || std::fabs(pho.etaSC()) > cuts.maxEta)
139  cutCode |= EgCutCodes::DETETA;
140  if (pho.isGap())
141  cutCode |= EgCutCodes::CRACK;
142  //track cuts (all fail)
143  cutCode |= EgCutCodes::DETAIN;
144  cutCode |= EgCutCodes::DPHIIN;
145  cutCode |= EgCutCodes::INVEINVP;
146  //supercluster cuts
147  if (pho.hOverE() > cuts.maxHadem && pho.hOverE() * pho.energy() > cuts.maxHadEnergy)
148  cutCode |= EgCutCodes::HADEM;
149  if (pho.sigmaIEtaIEta() > cuts.maxSigmaIEtaIEta)
150  cutCode |= EgCutCodes::SIGMAIETAIETA;
151  if (pho.sigmaEtaEta() > cuts.maxSigmaEtaEta)
152  cutCode |= EgCutCodes::SIGMAETAETA;
153  //----Morse--------
154  //if(pho.r9()<cuts.minR9) cutCode |= EgCutCodes::R9;
155  if (pho.r9() < cuts.minR9)
156  cutCode |= EgCutCodes::MINR9;
157  if (pho.r9() > cuts.maxR9)
158  cutCode |= EgCutCodes::MAXR9;
159  //----------------
160  //std isolation cuts
161  if (pho.isolEm() > (cuts.isolEmConstTerm +
162  cuts.isolEmGradTerm * (pho.et() < cuts.isolEmGradStart ? 0. : (pho.et() - cuts.isolEmGradStart))))
163  cutCode |= EgCutCodes::ISOLEM;
164  if (pho.isolHad() >
165  (cuts.isolHadConstTerm +
166  cuts.isolHadGradTerm * (pho.et() < cuts.isolHadGradStart ? 0. : (pho.et() - cuts.isolHadGradStart))))
167  cutCode |= EgCutCodes::ISOLHAD;
168  if (pho.isolPtTrks() >
169  (cuts.isolPtTrksConstTerm +
170  cuts.isolPtTrksGradTerm * (pho.et() < cuts.isolPtTrksGradStart ? 0. : (pho.et() - cuts.isolPtTrksGradStart))))
171  cutCode |= EgCutCodes::ISOLPTTRKS;
172  if (pho.isolNrTrks() > cuts.isolNrTrksConstTerm)
173  cutCode |= EgCutCodes::ISOLNRTRKS;
174 
175  //hlt isolation cuts
176  cutCode |= EgCutCodes::HLTISOLTRKSELE; //automatically fails ele track isolation
177  if (pho.et() <=
178  0.) { //even it if et<=0, we give it a shot at passing isolation. Note this should be an impossible case
179  if (pho.hltIsolTrks() > cuts.maxHLTIsolTrksPho)
180  cutCode |= EgCutCodes::HLTISOLTRKSPHO;
181  if (pho.hltIsolHad() > cuts.maxHLTIsolHad)
182  cutCode |= EgCutCodes::HLTISOLHAD;
183  if (pho.hltIsolEm() > cuts.maxHLTIsolEm)
184  cutCode |= EgCutCodes::HLTISOLEM;
185  } else {
186  if (pho.hltIsolTrks() > cuts.maxHLTIsolTrksPho && pho.hltIsolTrks() / pho.et() > cuts.maxHLTIsolTrksPhoOverPt &&
187  pho.hltIsolTrks() / pho.et() / pho.et() > cuts.maxHLTIsolTrksPhoOverPt2)
188  cutCode |= EgCutCodes::HLTISOLTRKSPHO;
189  if (pho.hltIsolHad() > cuts.maxHLTIsolHad && pho.hltIsolHad() / pho.et() > cuts.maxHLTIsolHadOverEt &&
190  pho.hltIsolHad() / pho.et() / pho.et() > cuts.maxHLTIsolHadOverEt2)
191  cutCode |= EgCutCodes::HLTISOLHAD;
192  if (pho.hltIsolEm() > cuts.maxHLTIsolEm && pho.hltIsolEm() / pho.et() > cuts.maxHLTIsolEmOverEt &&
193  pho.hltIsolEm() / pho.et() / pho.et() > cuts.maxHLTIsolEmOverEt2)
194  cutCode |= EgCutCodes::HLTISOLEM;
195  }
196 
197  //track cuts, photon will automatically fail them (for now)
198  cutCode |= EgCutCodes::CTFTRACK;
199  cutCode |= EgCutCodes::HLTDETAIN;
200  cutCode |= EgCutCodes::HLTDPHIIN;
201  cutCode |= EgCutCodes::HLTINVEINVP;
202 
203  return (cutCode & cuts.cutMask & cutMask);
204 }
float energy() const
Definition: EgHLTOffPho.h:106
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
float detEta() const
Definition: EgHLTOffEle.h:134
float hltDPhiIn() const
Definition: EgHLTOffEle.h:192
float hltInvEInvP() const
Definition: EgHLTOffEle.h:193
float isolHad() const
Definition: EgHLTOffEle.h:180
float sigmaIEtaIEta() const
Definition: EgHLTOffPho.h:125
float sigmaEtaEta() const
Definition: EgHLTOffEle.cc:7
EgCutValues eeCutValues_
Definition: EgHLTOffEgSel.h:27
float caloEnergy() const
Definition: EgHLTOffEle.h:132
float hOverE() const
Definition: EgHLTOffPho.h:121
float ctfTrkInnerRadius() const
Definition: EgHLTOffEle.h:221
float hltIsolTrksEle() const
Definition: EgHLTOffEle.h:185
float hltIsolEm() const
Definition: EgHLTOffEle.h:188
float etaSC() const
Definition: EgHLTOffPho.h:112
int ctfTrkHitsLost() const
Definition: EgHLTOffEle.h:224
float sigmaEtaEta() const
Definition: EgHLTOffPho.cc:7
float hltIsolHad() const
Definition: EgHLTOffEle.h:187
float isolPtTrks() const
Definition: EgHLTOffEle.h:183
float sigmaIEtaIEta() const
Definition: EgHLTOffEle.h:162
int isolNrTrks() const
Definition: EgHLTOffPho.h:135
void setup(const edm::ParameterSet &)
void setup(const edm::ParameterSet &iConfig)
float r9() const
Definition: EgHLTOffEle.h:168
float isolHad() const
Definition: EgHLTOffPho.h:134
float r9() const
Definition: EgHLTOffPho.h:130
float etaSC() const
Definition: EgHLTOffEle.h:133
int ctfTrkHitsFound() const
Definition: EgHLTOffEle.h:223
bool isGap() const
Definition: EgHLTOffEle.h:141
float invEInvP() const
Definition: EgHLTOffEle.h:171
float hltIsolEm() const
Definition: EgHLTOffPho.h:139
Definition: DetId.h:17
float isolEm() const
Definition: EgHLTOffEle.h:179
float hOverE() const
Definition: EgHLTOffEle.h:151
float isolPtTrks() const
Definition: EgHLTOffPho.h:136
float dPhiIn() const
Definition: EgHLTOffEle.h:153
float hltDEtaIn() const
Definition: EgHLTOffEle.h:191
float et() const
Definition: EgHLTOffEle.h:124
float isolEm() const
Definition: EgHLTOffPho.h:133
bool isGap() const
Definition: EgHLTOffPho.h:118
bool validCTFTrack() const
Definition: EgHLTOffEle.h:207
float hltIsolTrksPho() const
Definition: EgHLTOffEle.h:186
float et() const
Definition: EgHLTOffPho.h:104
float dEtaIn() const
Definition: EgHLTOffEle.h:152
float hltIsolHad() const
Definition: EgHLTOffPho.h:137
float ctfTrkOuterRadius() const
Definition: EgHLTOffEle.h:222
int getCutCode(const OffEle &ele, int cutMask=~0x0) const
float hltIsolTrks() const
Definition: EgHLTOffPho.h:138
EgCutValues ebCutValues_
Definition: EgHLTOffEgSel.h:26
reco::TrackRef ctfTrack() const
Definition: EgHLTOffEle.h:203
float detEta() const
Definition: EgHLTOffPho.h:113