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 
24 
27 
28 namespace egHLT {
29  class OffEle {
30  public:
31  //helper struct to store the isolations
32  struct IsolData {
33  float em;
34  float hadDepth1;
35  float hadDepth2;
36  float ptTrks;
37  int nrTrks;
38  //possibly going to move these to hlt data
39  float hltHad;
40  float hltTrksEle;
41  float hltTrksPho;
42  float hltEm;
43  };
44 
45  public:
46  //helper struct to store the cluster shapes
47  struct ClusShapeData {
48  float sigmaEtaEta;
50  float sigmaPhiPhi;
52  float e1x5Over5x5;
54  float r9;
55  };
56 
57  public:
58  //helper struct to store reco approximations of variables made by HLT - and HLT p4 to get eta,phi
59  struct HLTData {
60  float dEtaIn;
61  float dPhiIn;
62  float invEInvP;
63  //math::XYZTLorentzVector p4;
64  float HLTeta;
65  float HLTphi;
66  float HLTenergy;
67  };
68 
69  public:
70  //helper struct to store event-wide variables
71  struct EventData {
72  int NVertex;
73  };
74 
75  private:
76  const reco::GsfElectron* gsfEle_; //pointers to the underlying electron (we do not own this)
77 
82 
83  //these are bit-packed words telling me which cuts the electron fail (ie 0x0 is passed all cuts)
84  int cutCode_;
86  //the idea is that these are user definable cuts meant to be idenital to the specified trigger
87  //it is probably clear to the reader that I havent decided on the most efficient way to do this
88  std::vector<std::pair<TrigCodes::TrigBitSet, int> >
89  trigCutsCutCodes_; //unsorted vector (may sort if have performance issues)
90 
91  //and these are the trigger bits stored
92  //note that the trigger bits are defined at the begining of each job
93  //and do not necessaryly map between jobs
95 
96  public:
98  const ClusShapeData& shapeData,
99  const IsolData& isolData,
100  const HLTData& hltData,
101  const EventData& eventData)
102  : gsfEle_(&ele),
103  clusShapeData_(shapeData),
104  isolData_(isolData),
105  hltData_(hltData),
106  eventData_(eventData),
109  ~OffEle() = default;
110 
111  //modifiers
112  int NVertex() const { return eventData_.NVertex; }
113  void setCutCode(int code) { cutCode_ = code; }
114  void setLooseCutCode(int code) { looseCutCode_ = code; }
115  //slightly inefficient way, think I can afford it and its a lot easier to just make the sorted vector outside the class
116  void setTrigCutsCutCodes(const std::vector<std::pair<TrigCodes::TrigBitSet, int> >& trigCutsCutCodes) {
117  trigCutsCutCodes_ = trigCutsCutCodes;
118  }
120 
121  const reco::GsfElectron* gsfEle() const { return gsfEle_; }
122 
123  //kinematic and geometric methods
124  float et() const { return gsfEle_->et(); }
125  // float et()const{return etSC();}
126  float energy() const { return gsfEle_->energy(); }
127  float eta() const { return gsfEle_->eta(); }
128  float phi() const { return gsfEle_->phi(); }
129  float etSC() const {
130  return gsfEle_->superCluster()->position().rho() / gsfEle_->superCluster()->position().r() * caloEnergy();
131  }
132  float caloEnergy() const { return gsfEle_->caloEnergy(); }
133  float etaSC() const { return gsfEle_->superCluster()->eta(); }
134  float detEta() const { return etaSC(); }
135  float phiSC() const { return gsfEle_->superCluster()->phi(); }
136  float zVtx() const { return gsfEle_->TrackPositionAtVtx().z(); }
137  const math::XYZTLorentzVector& p4() const { return gsfEle_->p4(); }
138 
139  //classification (couldnt they have just named it 'type')
140  int classification() const { return gsfEle_->classification(); }
141  bool isGap() const { return gsfEle_->isEBGap() || gsfEle_->isEEGap() || gsfEle_->isEBEEGap(); }
142 
143  //track methods
144  int charge() const { return gsfEle_->charge(); }
145  float pVtx() const { return gsfEle_->trackMomentumAtVtx().R(); }
146  float pCalo() const { return gsfEle_->trackMomentumAtCalo().R(); }
147  float ptVtx() const { return gsfEle_->trackMomentumAtVtx().rho(); }
148  float ptCalo() const { return gsfEle_->trackMomentumAtCalo().rho(); }
149 
150  //abreviations of overly long GsfElectron methods, I'm sorry but if you cant figure out what hOverE() means, you shouldnt be using this class
151  float hOverE() const { return gsfEle_->hadronicOverEm(); }
152  float dEtaIn() const { return gsfEle_->deltaEtaSuperClusterTrackAtVtx(); }
153  float dPhiIn() const { return gsfEle_->deltaPhiSuperClusterTrackAtVtx(); }
154  float dPhiOut() const { return gsfEle_->deltaPhiSeedClusterTrackAtCalo(); }
155  float dEtaOut() const { return gsfEle_->deltaEtaSeedClusterTrackAtCalo(); }
156  float epIn() const { return gsfEle_->eSuperClusterOverP(); }
157  float epOut() const { return gsfEle_->eSeedClusterOverPout(); }
158 
159  //variables with no direct method
160  float sigmaEtaEta() const;
161  float sigmaEtaEtaUnCorr() const { return clusShapeData_.sigmaEtaEta; }
162  float sigmaIEtaIEta() const { return clusShapeData_.sigmaIEtaIEta; }
163  float sigmaPhiPhi() const { return clusShapeData_.sigmaPhiPhi; }
164  //float sigmaIPhiIPhi()const{return clusShapeData_.sigmaIPhiIPhi;}
165  float e2x5MaxOver5x5() const { return clusShapeData_.e2x5MaxOver5x5; }
166  float e1x5Over5x5() const { return clusShapeData_.e1x5Over5x5; }
167 
168  float r9() const { return clusShapeData_.r9; }
169  //float sigmaPhiPhi()const{return clusShape_!=NULL ? sqrt(clusShape_->covPhiPhi()) : 999;}
170  float bremFrac() const { return (pVtx() - pCalo()) / pVtx(); }
171  float invEInvP() const {
172  return gsfEle_->caloEnergy() != 0 && gsfEle_->trackMomentumAtVtx().R() != 0.
173  ? 1. / gsfEle_->caloEnergy() - 1. / gsfEle_->trackMomentumAtVtx().R()
174  : -999;
175  }
176  //float e9OverE25()const{return clusShape_!=NULL ? clusShape_->e3x3()/clusShape_->e5x5() : -999;}
177 
178  //isolation
179  float isolEm() const { return isolData_.em; }
180  float isolHad() const { return isolHadDepth1() + isolHadDepth2(); }
181  float isolHadDepth1() const { return isolData_.hadDepth1; }
182  float isolHadDepth2() const { return isolData_.hadDepth2; }
183  float isolPtTrks() const { return isolData_.ptTrks; }
184  int isolNrTrks() const { return isolData_.nrTrks; }
185  float hltIsolTrksEle() const { return isolData_.hltTrksEle; }
186  float hltIsolTrksPho() const { return isolData_.hltTrksPho; }
187  float hltIsolHad() const { return isolData_.hltHad; }
188  float hltIsolEm() const { return isolData_.hltEm; }
189 
190  //some hlt id variables (note these are reco approximations)
191  float hltDEtaIn() const { return hltData_.dEtaIn; }
192  float hltDPhiIn() const { return hltData_.dPhiIn; }
193  float hltInvEInvP() const { return hltData_.invEInvP; }
194  //hlt position - not a reco approximation, taken from triggerobject
195  //const math::XYZTLorentzVector& HLTp4()const{return hltData_.p4;}
196  float hltPhi() const { return hltData_.HLTphi; }
197  float hltEta() const { return hltData_.HLTeta; }
198  float hltEnergy() const { return hltData_.HLTenergy; }
199  //Diference between HLT Et and reco SC Et
200  float DeltaE() const { return (hltEnergy() - caloEnergy()); }
201 
202  //ctf track accessor and validatity checker
204  return gsfEle_->closestCtfTrackRef();
205  } //in theory lightweight (if they follow good design),return by value
206  //track is only valid if it exists and track extra exists (track extra is only stored in reco)
207  bool validCTFTrack() const {
209  }
210 
211  //ctf track varibles, used as hlt uses this algo
212  float ctfTrkP() const { return validCTFTrack() ? ctfTrack()->p() : -999.; }
213  float ctfTrkPt() const { return validCTFTrack() ? ctfTrack()->pt() : -999.; }
214  float ctfTrkEta() const { return validCTFTrack() ? ctfTrack()->eta() : -999.; }
215  float ctfTrkChi2() const { return validCTFTrack() ? ctfTrack()->chi2() : 999.; }
216  float ctfTrkNDof() const {
217  return validCTFTrack() ? ctfTrack()->ndof() : 999.;
218  } //this will give chi2/ndof a valid value, perhaps rethink
219  float ctfTrkPtOuter() const { return validCTFTrack() ? ctfTrack()->outerMomentum().Perp2() : -999.; }
220  float ctfTrkPtInner() const { return validCTFTrack() ? ctfTrack()->innerMomentum().Perp2() : -999.; }
221  float ctfTrkInnerRadius() const { return validCTFTrack() ? ctfTrack()->innerPosition().Rho() : 999.; }
222  float ctfTrkOuterRadius() const { return validCTFTrack() ? ctfTrack()->outerPosition().Rho() : -999.; }
223  int ctfTrkHitsFound() const { return validCTFTrack() ? static_cast<int>(ctfTrack()->found()) : -999; }
224  int ctfTrkHitsLost() const { return validCTFTrack() ? static_cast<int>(ctfTrack()->lost()) : -999; }
225  int ctfTrkNrHits() const { return validCTFTrack() ? static_cast<int>(ctfTrack()->recHitsSize()) : -999; }
226 
227  //selection cuts
228  int cutCode() const { return cutCode_; }
229  int looseCutCode() const { return looseCutCode_; }
230 
231  //trigger codes are just used as a unique identifier of the trigger, it is an error to specify more than a single bit
232  //the idea here is to allow an arbitary number of electron triggers
234  //trigger
236  };
237 
238 } // namespace egHLT
239 
240 #endif
bool isEBGap() const
Definition: GsfElectron.h:332
float phi() const
Definition: EgHLTOffEle.h:128
float detEta() const
Definition: EgHLTOffEle.h:134
float hltDPhiIn() const
Definition: EgHLTOffEle.h:192
OffEle(const reco::GsfElectron &ele, const ClusShapeData &shapeData, const IsolData &isolData, const HLTData &hltData, const EventData &eventData)
Definition: EgHLTOffEle.h:97
float hltInvEInvP() const
Definition: EgHLTOffEle.h:193
float sigmaPhiPhi() const
Definition: EgHLTOffEle.h:163
float deltaPhiSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:229
float isolHad() const
Definition: EgHLTOffEle.h:180
int looseCutCode() const
Definition: EgHLTOffEle.h:229
EventData eventData_
Definition: EgHLTOffEle.h:81
float ctfTrkPt() const
Definition: EgHLTOffEle.h:213
float sigmaEtaEta() const
Definition: EgHLTOffEle.cc:7
void setLooseCutCode(int code)
Definition: EgHLTOffEle.h:114
int isolNrTrks() const
Definition: EgHLTOffEle.h:184
float hltEta() const
Definition: EgHLTOffEle.h:197
int ctfTrkNrHits() const
Definition: EgHLTOffEle.h:225
float dEtaOut() const
Definition: EgHLTOffEle.h:155
float ctfTrkPtOuter() const
Definition: EgHLTOffEle.h:219
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:232
float caloEnergy() const
Definition: EgHLTOffEle.h:132
const reco::GsfElectron * gsfEle_
Definition: EgHLTOffEle.h:76
float ctfTrkInnerRadius() const
Definition: EgHLTOffEle.h:221
int cutCode() const
Definition: EgHLTOffEle.h:228
float hltIsolTrksEle() const
Definition: EgHLTOffEle.h:185
float hltIsolEm() const
Definition: EgHLTOffEle.h:188
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float DeltaE() const
Definition: EgHLTOffEle.h:200
Classification classification() const
Definition: GsfElectron.h:805
float pVtx() const
Definition: EgHLTOffEle.h:145
math::XYZVectorF trackMomentumAtCalo() const
Definition: GsfElectron.h:269
float eSeedClusterOverPout() const
Definition: GsfElectron.h:223
TrigCodes::TrigBitSet trigBits() const
Definition: EgHLTOffEle.h:235
int ctfTrkHitsLost() const
Definition: EgHLTOffEle.h:224
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
float hltIsolHad() const
Definition: EgHLTOffEle.h:187
float isolPtTrks() const
Definition: EgHLTOffEle.h:183
float caloEnergy() const
Definition: GsfElectron.h:899
float sigmaIEtaIEta() const
Definition: EgHLTOffEle.h:162
HLTData hltData_
Definition: EgHLTOffEle.h:80
float isolHadDepth2() const
Definition: EgHLTOffEle.h:182
int NVertex() const
Definition: EgHLTOffEle.h:112
bool isEBEEGap() const
Definition: GsfElectron.h:331
float pCalo() const
Definition: EgHLTOffEle.h:146
int charge() const
Definition: EgHLTOffEle.h:144
const reco::GsfElectron * gsfEle() const
Definition: EgHLTOffEle.h:121
float r9() const
Definition: EgHLTOffEle.h:168
float dPhiOut() const
Definition: EgHLTOffEle.h:154
float etaSC() const
Definition: EgHLTOffEle.h:133
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
float e2x5MaxOver5x5() const
Definition: EgHLTOffEle.h:165
int ctfTrkHitsFound() const
Definition: EgHLTOffEle.h:223
bool isGap() const
Definition: EgHLTOffEle.h:141
float invEInvP() const
Definition: EgHLTOffEle.h:171
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
void setCutCode(int code)
Definition: EgHLTOffEle.h:113
float etSC() const
Definition: EgHLTOffEle.h:129
math::XYZPointF TrackPositionAtVtx() const
Definition: GsfElectron.h:281
float ptCalo() const
Definition: EgHLTOffEle.h:148
float e1x5Over5x5() const
Definition: EgHLTOffEle.h:166
float eta() const
Definition: EgHLTOffEle.h:127
float ptVtx() const
Definition: EgHLTOffEle.h:147
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
TrigCodes::TrigBitSet trigBits_
Definition: EgHLTOffEle.h:94
float hltEnergy() const
Definition: EgHLTOffEle.h:198
float hltPhi() const
Definition: EgHLTOffEle.h:196
float ctfTrkChi2() const
Definition: EgHLTOffEle.h:215
float isolEm() const
Definition: EgHLTOffEle.h:179
float hOverE() const
Definition: EgHLTOffEle.h:151
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
float isolHadDepth1() const
Definition: EgHLTOffEle.h:181
float dPhiIn() const
Definition: EgHLTOffEle.h:153
float ctfTrkPtInner() const
Definition: EgHLTOffEle.h:220
const math::XYZTLorentzVector & p4() const
Definition: EgHLTOffEle.h:137
ClusShapeData clusShapeData_
Definition: EgHLTOffEle.h:78
float hltDEtaIn() const
Definition: EgHLTOffEle.h:191
float ctfTrkNDof() const
Definition: EgHLTOffEle.h:216
float et() const
Definition: EgHLTOffEle.h:124
float phiSC() const
Definition: EgHLTOffEle.h:135
float epOut() const
Definition: EgHLTOffEle.h:157
void setTrigCutsCutCodes(const std::vector< std::pair< TrigCodes::TrigBitSet, int > > &trigCutsCutCodes)
Definition: EgHLTOffEle.h:116
int classification() const
Definition: EgHLTOffEle.h:140
bool validCTFTrack() const
Definition: EgHLTOffEle.h:207
IsolData isolData_
Definition: EgHLTOffEle.h:79
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
float energy() const
Definition: EgHLTOffEle.h:126
int trigCutsCutCode(const TrigCodes::TrigBitSet &trigger) const
Definition: EgHLTOffEle.cc:19
~OffEle()=default
double et() const final
transverse energy
float hltIsolTrksPho() const
Definition: EgHLTOffEle.h:186
float dEtaIn() const
Definition: EgHLTOffEle.h:152
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
float epIn() const
Definition: EgHLTOffEle.h:156
float ctfTrkOuterRadius() const
Definition: EgHLTOffEle.h:222
float ctfTrkEta() const
Definition: EgHLTOffEle.h:214
float zVtx() const
Definition: EgHLTOffEle.h:136
double phi() const final
momentum azimuthal angle
bool isEEGap() const
Definition: GsfElectron.h:335
std::vector< std::pair< TrigCodes::TrigBitSet, int > > trigCutsCutCodes_
Definition: EgHLTOffEle.h:89
std::bitset< maxNrBits_ > TrigBitSet
reco::TrackRef ctfTrack() const
Definition: EgHLTOffEle.h:203
float hadronicOverEm() const
Definition: GsfElectron.h:500
float bremFrac() const
Definition: EgHLTOffEle.h:170
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
void setTrigBits(TrigCodes::TrigBitSet bits)
Definition: EgHLTOffEle.h:119
int charge() const final
electric charge
float sigmaEtaEtaUnCorr() const
Definition: EgHLTOffEle.h:161
double energy() const final
energy
double eta() const final
momentum pseudorapidity
float ctfTrkP() const
Definition: EgHLTOffEle.h:212