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