CMS 3D CMS Logo

EgHLTOffEle.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTOFFELE
2 #define DQMOFFLINE_TRIGGER_EGHLTOFFELE
3 
4 //class: EgHLTOffEle
5 //
6 //author: Sam Harper (July 2008)
7 //
8 //
9 //aim: to allow easy access to electron ID variables
10 // currently the CMSSW electron classes are a mess with key electron selection variables not being accessable from GsfElectron
11 // this a stop gap to produce a simple electron class with all variables easily accessable via methods
12 // note as this is meant for HLT Offline DQM, I do not want the overhead of converting to pat
13 //
14 //implimentation: aims to be a wrapper for GsfElectron methods, it is hoped that in time these methods will be directly added to GsfElectron and so
15 // make this class obsolute
16 // unfortunately can not be a pure wrapper as needs to store isol and cluster shape
17 //
18 
19 
25 
28 
29 namespace egHLT {
30  class OffEle {
31 
32  public:
33  //helper struct to store the isolations
34  struct IsolData {
35  float em;
36  float hadDepth1;
37  float hadDepth2;
38  float ptTrks;
39  int nrTrks;
40  //possibly going to move these to hlt data
41  float hltHad;
42  float hltTrksEle;
43  float hltTrksPho;
44  float hltEm;
45  };
46 
47  public:
48  //helper struct to store the cluster shapes
49  struct ClusShapeData {
50  float sigmaEtaEta;
51  float sigmaIEtaIEta;
52  float sigmaPhiPhi;
53  float sigmaIPhiIPhi;
54  float e1x5Over5x5;
56  float r9;
57 
58  };
59 
60  public:
61  //helper struct to store reco approximations of variables made by HLT - and HLT p4 to get eta,phi
62  struct HLTData {
63  float dEtaIn;
64  float dPhiIn;
65  float invEInvP;
66  //math::XYZTLorentzVector p4;
67  float HLTeta;
68  float HLTphi;
69  float HLTenergy;
70  };
71 
72  public:
73  //helper struct to store event-wide variables
74  struct EventData {
75  int NVertex;
76  };
77 
78  private:
79  const reco::GsfElectron* gsfEle_; //pointers to the underlying electron (we do not own this)
80 
85 
86  //these are bit-packed words telling me which cuts the electron fail (ie 0x0 is passed all cuts)
87  int cutCode_;
89  //the idea is that these are user definable cuts meant to be idenital to the specified trigger
90  //it is probably clear to the reader that I havent decided on the most efficient way to do this
91  std::vector<std::pair<TrigCodes::TrigBitSet,int> > trigCutsCutCodes_; //unsorted vector (may sort if have performance issues)
92 
93  //and these are the trigger bits stored
94  //note that the trigger bits are defined at the begining of each job
95  //and do not necessaryly map between jobs
97 
98  public:
99 
100  OffEle(const reco::GsfElectron& ele,const ClusShapeData& shapeData,const IsolData& isolData,const HLTData& hltData,const EventData& eventData):
101  gsfEle_(&ele),clusShapeData_(shapeData),isolData_(isolData),hltData_(hltData),eventData_(eventData),
102  cutCode_(int(EgCutCodes::INVALID)),looseCutCode_(int(EgCutCodes::INVALID)){}
104 
105 
106  //modifiers
107  int NVertex()const{return eventData_.NVertex;}
108  void setCutCode(int code){cutCode_=code;}
109  void setLooseCutCode(int code){looseCutCode_=code;}
110  //slightly inefficient way, think I can afford it and its a lot easier to just make the sorted vector outside the class
111  void setTrigCutsCutCodes(const std::vector<std::pair<TrigCodes::TrigBitSet,int> >& trigCutsCutCodes){trigCutsCutCodes_=trigCutsCutCodes;}
113 
114  const reco::GsfElectron* gsfEle()const{return gsfEle_;}
115 
116  //kinematic and geometric methods
117  float et()const{return gsfEle_->et();}
118  // float et()const{return etSC();}
119  float energy()const{return gsfEle_->energy();}
120  float eta()const{return gsfEle_->eta();}
121  float phi()const{return gsfEle_->phi();}
122  float etSC()const{return gsfEle_->superCluster()->position().rho()/gsfEle_->superCluster()->position().r()*caloEnergy();}
123  float caloEnergy()const{return gsfEle_->caloEnergy();}
124  float etaSC()const{return gsfEle_->superCluster()->eta();}
125  float detEta()const{return etaSC();}
126  float phiSC()const{return gsfEle_->superCluster()->phi();}
127  float zVtx()const{return gsfEle_->TrackPositionAtVtx().z();}
128  const math::XYZTLorentzVector& p4()const{return gsfEle_->p4();}
129 
130  //classification (couldnt they have just named it 'type')
131  int classification()const{return gsfEle_->classification();}
132  bool isGap()const{return gsfEle_->isEBGap() || gsfEle_->isEEGap() || gsfEle_->isEBEEGap();}
133 
134  //track methods
135  int charge()const{return gsfEle_->charge();}
136  float pVtx()const{return gsfEle_->trackMomentumAtVtx().R();}
137  float pCalo()const{return gsfEle_->trackMomentumAtCalo().R();}
138  float ptVtx()const{return gsfEle_->trackMomentumAtVtx().rho();}
139  float ptCalo()const{return gsfEle_->trackMomentumAtCalo().rho();}
140 
141 
142  //abreviations of overly long GsfElectron methods, I'm sorry but if you cant figure out what hOverE() means, you shouldnt be using this class
143  float hOverE()const{return gsfEle_->hadronicOverEm();}
144  float dEtaIn()const{return gsfEle_->deltaEtaSuperClusterTrackAtVtx();}
145  float dPhiIn()const{return gsfEle_->deltaPhiSuperClusterTrackAtVtx();}
146  float dPhiOut()const{return gsfEle_->deltaPhiSeedClusterTrackAtCalo();}
147  float dEtaOut()const{return gsfEle_->deltaEtaSeedClusterTrackAtCalo();}
148  float epIn()const{return gsfEle_->eSuperClusterOverP();}
149  float epOut()const{return gsfEle_->eSeedClusterOverPout();}
150 
151  //variables with no direct method
152  float sigmaEtaEta()const;
153  float sigmaEtaEtaUnCorr()const{return clusShapeData_.sigmaEtaEta;}
154  float sigmaIEtaIEta()const{return clusShapeData_.sigmaIEtaIEta;}
155  float sigmaPhiPhi()const{return clusShapeData_.sigmaPhiPhi;}
156  //float sigmaIPhiIPhi()const{return clusShapeData_.sigmaIPhiIPhi;}
157  float e2x5MaxOver5x5()const{return clusShapeData_.e2x5MaxOver5x5;}
158  float e1x5Over5x5()const{return clusShapeData_.e1x5Over5x5;}
159 
160  float r9()const{return clusShapeData_.r9;}
161  //float sigmaPhiPhi()const{return clusShape_!=NULL ? sqrt(clusShape_->covPhiPhi()) : 999;}
162  float bremFrac()const{return (pVtx()-pCalo())/pVtx();}
163  float invEInvP()const{return gsfEle_->caloEnergy()!=0 && gsfEle_->trackMomentumAtVtx().R()!=0. ? 1./gsfEle_->caloEnergy() - 1./gsfEle_->trackMomentumAtVtx().R() : -999;}
164  //float e9OverE25()const{return clusShape_!=NULL ? clusShape_->e3x3()/clusShape_->e5x5() : -999;}
165 
166  //isolation
167  float isolEm()const{return isolData_.em;}
168  float isolHad()const{return isolHadDepth1()+isolHadDepth2();}
169  float isolHadDepth1()const{return isolData_.hadDepth1;}
170  float isolHadDepth2()const{return isolData_.hadDepth2;}
171  float isolPtTrks()const{return isolData_.ptTrks;}
172  int isolNrTrks()const{return isolData_.nrTrks;}
173  float hltIsolTrksEle()const{return isolData_.hltTrksEle;}
174  float hltIsolTrksPho()const{return isolData_.hltTrksPho;}
175  float hltIsolHad()const{return isolData_.hltHad;}
176  float hltIsolEm()const{return isolData_.hltEm;}
177 
178  //some hlt id variables (note these are reco approximations)
179  float hltDEtaIn()const{return hltData_.dEtaIn;}
180  float hltDPhiIn()const{return hltData_.dPhiIn;}
181  float hltInvEInvP()const{return hltData_.invEInvP;}
182  //hlt position - not a reco approximation, taken from triggerobject
183  //const math::XYZTLorentzVector& HLTp4()const{return hltData_.p4;}
184  float hltPhi()const{return hltData_.HLTphi;}
185  float hltEta()const{return hltData_.HLTeta;}
186  float hltEnergy()const{return hltData_.HLTenergy;}
187  //Diference between HLT Et and reco SC Et
188  float DeltaE()const{return (hltEnergy() - caloEnergy());}
189 
190  //ctf track accessor and validatity checker
191  reco::TrackRef ctfTrack()const{return gsfEle_->closestCtfTrackRef();} //in theory lightweight (if they follow good design),return by value
192  //track is only valid if it exists and track extra exists (track extra is only stored in reco)
193  bool validCTFTrack()const{return gsfEle_->closestCtfTrackRef().isNonnull() && gsfEle_->closestCtfTrackRef()->extra().isNonnull();}
194 
195 
196  //ctf track varibles, used as hlt uses this algo
197  float ctfTrkP()const{return validCTFTrack() ? ctfTrack()->p() : -999.;}
198  float ctfTrkPt()const{return validCTFTrack() ? ctfTrack()->pt() : -999.;}
199  float ctfTrkEta()const{return validCTFTrack() ? ctfTrack()->eta() : -999.;}
200  float ctfTrkChi2()const{return validCTFTrack() ? ctfTrack()->chi2() : 999.;}
201  float ctfTrkNDof()const{return validCTFTrack() ? ctfTrack()->ndof() : 999.;} //this will give chi2/ndof a valid value, perhaps rethink
202  float ctfTrkPtOuter()const{return validCTFTrack() ? ctfTrack()->outerMomentum().Perp2() : -999.;}
203  float ctfTrkPtInner()const{return validCTFTrack() ? ctfTrack()->innerMomentum().Perp2() : -999.;}
204  float ctfTrkInnerRadius()const{return validCTFTrack() ? ctfTrack()->innerPosition().Rho() : 999.;}
205  float ctfTrkOuterRadius()const{return validCTFTrack() ? ctfTrack()->outerPosition().Rho() : -999.;}
206  int ctfTrkHitsFound()const{return validCTFTrack() ? static_cast<int>(ctfTrack()->found()) : -999;}
207  int ctfTrkHitsLost()const{return validCTFTrack() ? static_cast<int>(ctfTrack()->lost()) : -999;}
208  int ctfTrkNrHits()const{return validCTFTrack() ? static_cast<int>(ctfTrack()->recHitsSize()) : -999;}
209 
210  //selection cuts
211  int cutCode()const{return cutCode_;}
212  int looseCutCode()const{return looseCutCode_;}
213 
214 
215  //trigger codes are just used as a unique identifier of the trigger, it is an error to specify more than a single bit
216  //the idea here is to allow an arbitary number of electron triggers
218  //trigger
220 
221 
222  };
223 
224 }
225 
226 
227 
228 #endif
bool isEEGap() const
Definition: GsfElectron.h:359
float e2x5MaxOver5x5() const
Definition: EgHLTOffEle.h:157
OffEle(const reco::GsfElectron &ele, const ClusShapeData &shapeData, const IsolData &isolData, const HLTData &hltData, const EventData &eventData)
Definition: EgHLTOffEle.h:100
float eta() const
Definition: EgHLTOffEle.h:120
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
int ctfTrkHitsFound() const
Definition: EgHLTOffEle.h:206
reco::TrackRef ctfTrack() const
Definition: EgHLTOffEle.h:191
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:225
float eSuperClusterOverP() const
Definition: GsfElectron.h:245
EventData eventData_
Definition: EgHLTOffEle.h:84
int looseCutCode() const
Definition: EgHLTOffEle.h:212
bool isEBEEGap() const
Definition: GsfElectron.h:355
float detEta() const
Definition: EgHLTOffEle.h:125
virtual double eta() const final
momentum pseudorapidity
TrigCodes::TrigBitSet trigBits() const
Definition: EgHLTOffEle.h:219
void setLooseCutCode(int code)
Definition: EgHLTOffEle.h:109
float caloEnergy() const
Definition: EgHLTOffEle.h:123
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
float pVtx() const
Definition: EgHLTOffEle.h:136
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:291
float ctfTrkEta() const
Definition: EgHLTOffEle.h:199
float epIn() const
Definition: EgHLTOffEle.h:148
int ctfTrkNrHits() const
Definition: EgHLTOffEle.h:208
float r9() const
Definition: EgHLTOffEle.h:160
float invEInvP() const
Definition: EgHLTOffEle.h:163
float et() const
Definition: EgHLTOffEle.h:117
float ctfTrkInnerRadius() const
Definition: EgHLTOffEle.h:204
const reco::GsfElectron * gsfEle_
Definition: EgHLTOffEle.h:79
float sigmaEtaEtaUnCorr() const
Definition: EgHLTOffEle.h:153
bool validCTFTrack() const
Definition: EgHLTOffEle.h:193
float dPhiIn() const
Definition: EgHLTOffEle.h:145
float zVtx() const
Definition: EgHLTOffEle.h:127
float isolHadDepth1() const
Definition: EgHLTOffEle.h:169
math::XYZPointF TrackPositionAtVtx() const
Definition: GsfElectron.h:302
float hltEnergy() const
Definition: EgHLTOffEle.h:186
float sigmaPhiPhi() const
Definition: EgHLTOffEle.h:155
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:201
virtual double phi() const final
momentum azimuthal angle
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
int charge() const
Definition: EgHLTOffEle.h:135
float hltDPhiIn() const
Definition: EgHLTOffEle.h:180
virtual double et() const final
transverse energy
float isolEm() const
Definition: EgHLTOffEle.h:167
math::XYZVectorF trackMomentumAtCalo() const
Definition: GsfElectron.h:292
float ctfTrkP() const
Definition: EgHLTOffEle.h:197
float hltInvEInvP() const
Definition: EgHLTOffEle.h:181
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:249
float hadronicOverEm() const
Definition: GsfElectron.h:487
float bremFrac() const
Definition: EgHLTOffEle.h:162
float dEtaOut() const
Definition: EgHLTOffEle.h:147
float dEtaIn() const
Definition: EgHLTOffEle.h:144
float deltaPhiSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:253
HLTData hltData_
Definition: EgHLTOffEle.h:83
float phi() const
Definition: EgHLTOffEle.h:121
float hltEta() const
Definition: EgHLTOffEle.h:185
float ctfTrkPtOuter() const
Definition: EgHLTOffEle.h:202
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:184
float etaSC() const
Definition: EgHLTOffEle.h:124
float DeltaE() const
Definition: EgHLTOffEle.h:188
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:252
virtual double energy() const final
energy
bool isGap() const
Definition: EgHLTOffEle.h:132
float sigmaIEtaIEta() const
Definition: EgHLTOffEle.h:154
std::vector< std::pair< TrigCodes::TrigBitSet, int > > trigCutsCutCodes_
Definition: EgHLTOffEle.h:91
float eSeedClusterOverPout() const
Definition: GsfElectron.h:247
float sigmaEtaEta() const
Definition: EgHLTOffEle.cc:5
void setCutCode(int code)
Definition: EgHLTOffEle.h:108
float hltPhi() const
Definition: EgHLTOffEle.h:184
float hltIsolHad() const
Definition: EgHLTOffEle.h:175
int classification() const
Definition: EgHLTOffEle.h:131
TrigCodes::TrigBitSet trigBits_
Definition: EgHLTOffEle.h:96
bool isEBGap() const
Definition: GsfElectron.h:356
int cutCode() const
Definition: EgHLTOffEle.h:211
int ctfTrkHitsLost() const
Definition: EgHLTOffEle.h:207
float epOut() const
Definition: EgHLTOffEle.h:149
float energy() const
Definition: EgHLTOffEle.h:119
ClusShapeData clusShapeData_
Definition: EgHLTOffEle.h:81
Classification classification() const
Definition: GsfElectron.h:746
float ptVtx() const
Definition: EgHLTOffEle.h:138
float isolHadDepth2() const
Definition: EgHLTOffEle.h:170
float hltIsolTrksPho() const
Definition: EgHLTOffEle.h:174
float etSC() const
Definition: EgHLTOffEle.h:122
float ctfTrkPt() const
Definition: EgHLTOffEle.h:198
float isolPtTrks() const
Definition: EgHLTOffEle.h:171
float ctfTrkChi2() const
Definition: EgHLTOffEle.h:200
float ctfTrkOuterRadius() const
Definition: EgHLTOffEle.h:205
float hltIsolTrksEle() const
Definition: EgHLTOffEle.h:173
void setTrigCutsCutCodes(const std::vector< std::pair< TrigCodes::TrigBitSet, int > > &trigCutsCutCodes)
Definition: EgHLTOffEle.h:111
float hltDEtaIn() const
Definition: EgHLTOffEle.h:179
IsolData isolData_
Definition: EgHLTOffEle.h:82
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:250
float ctfTrkNDof() const
Definition: EgHLTOffEle.h:201
float ptCalo() const
Definition: EgHLTOffEle.h:139
int trigCutsCutCode(const TrigCodes::TrigBitSet &trigger) const
Definition: EgHLTOffEle.cc:18
float ctfTrkPtInner() const
Definition: EgHLTOffEle.h:203
const reco::GsfElectron * gsfEle() const
Definition: EgHLTOffEle.h:114
const math::XYZTLorentzVector & p4() const
Definition: EgHLTOffEle.h:128
float e1x5Over5x5() const
Definition: EgHLTOffEle.h:158
int NVertex() const
Definition: EgHLTOffEle.h:107
float dPhiOut() const
Definition: EgHLTOffEle.h:146
float hOverE() const
Definition: EgHLTOffEle.h:143
float phiSC() const
Definition: EgHLTOffEle.h:126
float caloEnergy() const
Definition: GsfElectron.h:840
float isolHad() const
Definition: EgHLTOffEle.h:168
int isolNrTrks() const
Definition: EgHLTOffEle.h:172
float pCalo() const
Definition: EgHLTOffEle.h:137
float hltIsolEm() const
Definition: EgHLTOffEle.h:176
void setTrigBits(TrigCodes::TrigBitSet bits)
Definition: EgHLTOffEle.h:112
std::bitset< maxNrBits_ > TrigBitSet