ATLAS Offline Software
Loading...
Searching...
No Matches
TrigElectron.cxx
Go to the documentation of this file.
1// -*- C++ -*-
2
3/*
4 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5*/
6
7
41#include "CaloGeoHelpers/CaloSampling.h"
44
47 P4PtEtaPhiM(0, 0, 0, ParticleConstants::electronMassInMeV),
49 m_roiWord(0),
50 m_valid(false),
51 m_tr_Algo(TrigInDetTrack::NULLID),
52 m_tr_Zvtx(0),
57 m_etoverpt(0),
58 m_cl_eta(0),
59 m_cl_phi(0),
60 m_cl_Rcore(0),
61 m_cl_Eratio(0),
62 m_cl_EThad(0),
63 // m_cl_energy(0),
68{
69 m_cluster.reset();
70 m_track.reset();
71}
72
83TrigElectron::TrigElectron(unsigned int roi, // roi word
84 float trkEtaAtCalo, float trkPhiAtCalo, float EToverPT, // track-cluster match variables
85 const TrigEMClusterContainer* cl_coll, unsigned int cl_index, // links to track and cluster
86 const TrigInDetTrackCollection* tr_coll, unsigned int tr_index)
87 : P4PtEtaPhiM(0,0,0,ParticleConstants::electronMassInMeV),
89 m_roiWord(roi),
90 m_valid(true),
91 m_tr_Zvtx(0),
96 m_etoverpt(EToverPT),
97 m_cl_eta(0),
98 m_cl_phi(0),
99 m_cl_Rcore(0),
100 m_cl_Eratio(0),
101 m_cl_EThad(0),
102 // m_cl_energy(0),
107{
108
119
120 // track variables
121 if (tr_coll != NULL && tr_coll->size() > tr_index) {
122
129 m_track.toIndexedElement(*tr_coll, tr_index);
130 if (!m_track.isValid()) {
131 m_track.reset();
132 m_valid = false;
133 }
134
136 const TrigInDetTrack* tr_ptr = (*tr_coll)[tr_index];
137
138 // get track author and nr. trt hits from track
139 m_tr_Algo = tr_ptr->algorithmId();
140 m_tr_nr_trt_hits = tr_ptr->NStrawHits();
141 m_tr_nr_trt_hithresh_hits = tr_ptr->NTRHits();
142
146 if ( tr_ptr->param() != NULL ) {
147 m_tr_Zvtx = tr_ptr->param()->z0();
148 this->setEta(tr_ptr->param()->eta()); // set to track eta
149 this->setPhi(tr_ptr->param()->phi0()); // set to track phi
150 } else {
151 m_valid = false;
152 }
153
154 } else {
155 m_tr_Algo = TrigInDetTrack::NULLID;
156 m_tr_Zvtx = 0;
157 m_valid = false;
158 }
159
160 // calorimeter variables
161 if (cl_coll != NULL && cl_coll->size() > cl_index) {
162
169 m_cluster.toIndexedElement(*cl_coll, cl_index);
170 if (!m_cluster.isValid()) {
171 m_cluster.reset();
172 m_valid = false;
173 }
174
176 const TrigEMCluster* cl_ptr = (*cl_coll)[cl_index];
177
180 this->setPt(cl_ptr->et()); // set to cluster ET
181
183 // eta-phi of cluster
184 m_cl_eta = cl_ptr->eta();
185 m_cl_phi = cl_ptr->phi();
186
187 // EThad
188 if (m_cl_eta != 0) {
189 m_cl_EThad = cl_ptr->ehad1()/cosh(fabs(m_cl_eta)); // Ehad1/cosh(fabs(eta) */
190 } else {
191 m_cl_EThad = cl_ptr->ehad1(); // Ehad1 (=EThad1)
192 }
193
194 // Rcore (test for positive energy to avoid zeros)
195 if (cl_ptr->e277() != 0) { // (VD) before it was '>'
196 m_cl_Rcore = cl_ptr->e237()/cl_ptr->e277();
197 } else {
198 m_cl_Rcore = 0;
199 m_valid = false;
200 }
201
202 // Eratio (test for positive energy to avoid zeros)
203 if (cl_ptr->emaxs1()+cl_ptr->e2tsts1() > 0) {
204 m_cl_Eratio = (cl_ptr->emaxs1()-cl_ptr->e2tsts1()) / (cl_ptr->emaxs1()+cl_ptr->e2tsts1());
205 } else {
206 m_cl_Eratio = 0;
207 m_valid = false;
208 }
209
210 // energy and energy fraction per sample
211 float tmp_cl_energy = cl_ptr->energy();
212 if (fabs(tmp_cl_energy) > 0.00001) { // avoid floating-point exceptions
213 m_cl_e_frac_S0 = ( cl_ptr->energy(CaloSampling::PreSamplerB) + cl_ptr->energy(CaloSampling::PreSamplerE)) / tmp_cl_energy;
214 m_cl_e_frac_S1 = ( cl_ptr->energy(CaloSampling::EMB1) + cl_ptr->energy(CaloSampling::EME1)) / tmp_cl_energy;
215 m_cl_e_frac_S2 = ( cl_ptr->energy(CaloSampling::EMB2) + cl_ptr->energy(CaloSampling::EME2)) / tmp_cl_energy;
216 m_cl_e_frac_S3 = ( cl_ptr->energy(CaloSampling::EMB3) + cl_ptr->energy(CaloSampling::EME3)) / tmp_cl_energy;
217 }
218
219 } else {
220 m_cl_eta = 0;
221 m_cl_phi = 0;
222 m_cl_Rcore = 0;
223 m_cl_Eratio = 0;
224 m_cl_EThad = 0;
225 m_valid = false;
226 // m_cl_energy = 0;
227 m_cl_e_frac_S0 = 0;
228 m_cl_e_frac_S1 = 0;
229 m_cl_e_frac_S2 = 0;
230 m_cl_e_frac_S3 = 0;
231 }
232}
233
234
237 float eta,
238 float phi,
239
240 // roi word
241 unsigned int roi,
242 bool valid,
243
244 // track-cluster match variables
245 float trkEtaAtCalo,
246 float trkPhiAtCalo,
247 float EToverPT,
248
249 // Cluster
251 float caloEta,
252 float caloPhi,
253 float Rcore,
254 float Eratio,
255 float EThad,
256 float F0,
257 float F1,
258 float F2,
259 float F3,
260
261 // Track
264 float Zvtx,
265 int nTRTHits,
267 : P4PtEtaPhiM(pt,eta,phi,ParticleConstants::electronMassInMeV),
268 m_roiWord(roi),
269 m_valid(valid),
276 m_etoverpt(EToverPT),
288{
289}
290
291
292// accessor to get pointer to cluster (TrigEMCluster)
294{
295 if (m_cluster.isValid()) {
296 return (*m_cluster);
297 } else {
298 return NULL;
299 }
300}
301
302
303// accessor to get pointer to track (TrigInDetTrack)
305{
306 if (m_track.isValid()) {
307 return (*m_track); // note: TrigInDetTrackContainer is a vector<TrigInDetTrack*>
308 } else {
309 return NULL;
310 }
311}
312
313// comparison operators
316// TEMPORARY: should fix it to allow proper comparison after re-running
317bool operator==( const TrigElectron& te1, const TrigElectron& te2 ) {
318 return ( te1.isValid() && te2.isValid()
319 && te1.cluster() == te2.cluster() && te1.track() == te2.track());
320}
321
322
328void diff( const TrigElectron& te1, const TrigElectron& te2, std::map< std::string, double >& v_diff ) {
329
330 v_diff["RoI"] = te1.roiId() - te2.roiId();
331 v_diff["Charge"] = std::abs( te1.charge() - te2.charge() );
332 v_diff["Eta"] = fabs( te1.eta() - te2.eta() );
333 double d_phi = fabs( te1.phi() - te2.phi() );
334 v_diff["Phi"] = (d_phi < M_PI ? d_phi : 2*M_PI - d_phi);
335 v_diff["Pt"] = 2 * fabs( (fabs(te1.pt()) - fabs(te2.pt())) / (fabs(te1.pt())+fabs(te2.pt())) );
336 v_diff["Zvtx"] = fabs( te1.Zvtx() - te2.Zvtx() );
337 v_diff["trkEtaEtCalo"] = fabs( te1.trkEtaAtCalo() - te2.trkEtaAtCalo() );
338 double d_phi_extrapol = fabs( te1.trkPhiAtCalo() - te2.trkPhiAtCalo() );
339 v_diff["trkPhiEtCalo"] = (d_phi_extrapol < M_PI ? d_phi_extrapol : 2*M_PI - d_phi_extrapol);
340 v_diff["TRThits"] = abs(te1.nTRTHits() - te2.nTRTHits());
341 v_diff["TRThitsHiThres"] = abs(te1.nTRTHiThresholdHits() - te2.nTRTHiThresholdHits());
342 // v_diff["E"] = fabs(te1.E() - te2.E());
343 v_diff["F0"] = fabs(te1.F0() - te2.F0());
344 v_diff["F1"] = fabs(te1.F1() - te2.F1());
345 v_diff["F2"] = fabs(te1.F2() - te2.F2());
346 v_diff["F3"] = fabs(te1.F3() - te2.F3());
347
348 return;
349}
350
351
352// print TrigElectron quantities
353MsgStream& operator<< ( MsgStream& msg, const TrigElectron& te ) {
354 return ( msg << "TrigElectron " << (te.isValid() ? "(valid)" : "(not valid)")
355 << ": RoI = " << te.roiId() << "; Q = " << te.charge()
356 << "; Et/Pt = " << te.EtOverPt() << "; Pt = " << te.pt()
357 << "; TRT hits = " << te.nTRTHits() << "; TRT HiThreshold hits = " << te.nTRTHiThresholdHits()
358 << "; trkPt = " << te.trkPt() << " +- " << te.err_Pt()
359 << "; eta = " << te.eta() << " +- " << te.err_eta()
360 << "; phi = " << te.phi() << " +- " << te.err_phi()
361 << "; Zvt = " << te.Zvtx() << " +- " << te.err_Zvtx()
362 << "; DeltaEta1 = " << te.DeltaEta1() << "; DeltaPhi2 = " << te.DeltaPhi2()
363 // << "; E = "<<te.E()
364 <<"; F0 = "<<te.F0()<<"; F1 = "<<te.F1()<<"; F2 = "<<te.F2()<<"; F3 = "<<te.F3() );
365}
#define M_PI
if(febId1==febId2)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
MsgStream & operator<<(MsgStream &msg, const TrigElectron &te)
bool operator==(const TrigElectron &te1, const TrigElectron &te2)
Two TrigElectron are the same if they have the same cluster and the same track (and if valid,...
void diff(const TrigElectron &te1, const TrigElectron &te2, std::map< std::string, double > &v_diff)
Function compares two objects and returns "semi verbose" output in the form of map v_diff where varai...
size_type size() const noexcept
Returns the number of elements in the collection.
P4PtEtaPhiM(const double pt, const double eta, const double phi, const double m)
constructor with all data members
Definition P4PtEtaPhiM.h:29
virtual double pt() const
get pt data member
virtual double eta() const
get eta data member
virtual double phi() const
get phi data member
Class with calibrated variables for egamma clustering.
float m_tr_eta_at_calo
Track/Cluster matching quantities: eta and phi of track extrapolated to the calorimeter face.
bool isValid() const
accessor to get TrigElectron valid flag
TrigInDetTrack::AlgoId trackAlgo() const
accessors to return the tracking quantities
float m_cl_Eratio
Energy ratio in highest and 2nd highest strip pairs in 1st LAr sampling; Eratio = EmaxS1-E2ndS1 / Ema...
float m_cl_EThad
ET in first hadronic sampling: EThad=Ehad1/cosh(fabs(eta)
const TrigInDetTrack * track() const
accessor to get pointer to track (TrigInDetTrack)
float F0() const
accessors for calibrated energy fractions in each sampling - to reject noise
int m_tr_nr_trt_hits
number of TRT hits and high-threshold hits
float m_tr_Zvtx
Z of the track at closest approach (perigee) to the Z axis (maybe later to the beam?...
float caloEta() const
accessors to get cluster eta and phi (note baseclass eta and phi come from track)
float EtOverPt() const
accessor to ratio of cluster Et to track Pt
float Rcore() const
accessors for shower shape quantities
float m_cl_eta
Calorimeter quantities: Cluster eta and phi.
float trkPt() const
accessor to get pT of electron candidate track
TrigInDetTrack::AlgoId m_tr_Algo
Tracking quantities: ID of the tracking algorithm that produced the track in this electron.
unsigned int m_roiWord
roi word unique to L1 RoI (note: different from HLT RoI id)
float m_cl_Rcore
Energy ratio in 3x7 and 7x7 cells in 2nd LAr sampling; Rcore = e237/e277.
const TrigEMCluster * cluster() const
accessor to get pointer to cluster (TrigEMCluster)
ElementLink< TrigInDetTrackCollection > m_track
bool m_valid
To certify "good" TrigElectrons: used to be necessary for studies; now basically always true for elec...
int charge() const
accessor to return the track charge (sign of TrigInDetTrack pT)
ElementLink< TrigEMClusterContainer > m_cluster
ElementLinks to the track and calorimeter cluster in electron candidate.
float m_etoverpt
Ratio of cluster transverse energy to track transv.momentum.
float trkEtaAtCalo() const
accessor to get eta and phi of electron candidate track extrapolated the calorimeter
TrigElectron()
constructors; note: default constructor needed by POOL
float m_cl_e_frac_S0
Calibrated overall and per-sampling energy - to be used for cuts.
float err_Pt() const
accessors to get uncertainty in track parameters: Pt, eta, phi and Z of track perigee (Zvtx)
represents a LVL2 ID track
MsgStream & msg
Definition testRead.cxx:32