ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaEmulationPrecisionElectronHypoTool.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
5#include "GaudiKernel/SystemOfUnits.h"
6
7
8using namespace Trig;
9
10//**********************************************************************
11
15
16
17
18//=================================================================
19
25
27
29 bool &pass) const
30{
31 pass=false;
32
33 if( !input.roi ) return false;
34
35 if( input.electrons.empty() ) return false;
36
37 if (m_acceptAll){
38 pass=true;
39 return true;
40 }
41
42 for ( const auto& el : input.electrons )
43 {
44 if( decide( input, el ) ){
45 pass=true;
46 return true;
47 }
48 }
49 return false;
50
51}
52
53
54//=================================================================
55
56
58 const xAOD::Electron *el
59 ) const
60
61{
62 const TrigRoiDescriptor *roi = input.roi;
63
64 // when leaving scope it will ship data to monTool
65 unsigned PassedCuts = 0; //got called (data in place)
66
67
68 if ( std::abs( roi->eta() ) > 2.6 ) {
69 ATH_MSG_DEBUG( "REJECT The electron had eta coordinates beyond the EM fiducial volume : " << roi->eta() << "; stop the chain now" );
70 return false;
71 }
72
73 ATH_MSG_DEBUG( "RoI ID = " << roi->roiId() << ": Eta = " << roi->eta() << ", Phi = " << roi->phi() );
74
75 // fill local variables for RoI reference position
76 double etaRef = roi->eta();
77 double phiRef = roi->phi();
78 ATH_MSG_DEBUG("etaRef: "<<etaRef);
79 // correct phi the to right range ( probably not needed anymore )
80 if ( std::abs( phiRef ) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
81
82
83 ATH_MSG_DEBUG("Electron : et " << el->pt() << " eta = " << el->eta() << " phi = " << el->phi());
84
85 auto pClus = el->caloCluster();
86
87 if(!pClus){
88 ATH_MSG_DEBUG("No calo cluster for this electron");
89 return false;
90 }
91
92 float absEta = std::abs( pClus->eta() );
93
94 ATH_MSG_DEBUG("absEta: "<<absEta);
95
96 const int cutIndex = findCutIndex( absEta );
97
98
99
100
101 float dEta = pClus->eta() - etaRef;
102 // Deal with angle diferences greater than Pi
103 float dPhi = std::abs( pClus->phi() - phiRef );
104 dPhi = ( dPhi < M_PI ? dPhi : 2*M_PI - dPhi ); // TB why only <
105 float ET = pClus->et();
106
107
108 // eta range
109 if( absEta > 2.47 ){
110 ATH_MSG_DEBUG( "Electron : " << absEta << " outside eta range ");
111 return false;
112 }
113
114 PassedCuts = PassedCuts + 1; // passed eta cut
115
116
117 // apply cuts: DeltaEta( clus-ROI )
118 ATH_MSG_DEBUG( "Electron : eta=" << pClus->eta() << " roi eta=" << etaRef << " DeltaEta=" << dEta
119 << " cut: <" << m_detacluster );
120
121 if ( std::abs( pClus->eta() - etaRef ) > m_detacluster ) {
122 ATH_MSG_DEBUG("REJECT Electron a cut failed");
123 return false;
124 }
125 PassedCuts = PassedCuts + 1; //Deta
126
127 // DeltaPhi( clus-ROI )
128 ATH_MSG_DEBUG( ": phi=" << pClus->phi() << " roi phi="<< phiRef << " DeltaPhi="<< dPhi << " cut: <" << m_dphicluster );
129
130 if( dPhi > m_dphicluster ) {
131 ATH_MSG_DEBUG("REJECT Clsuter dPhi cut failed");
132 return false;
133 }
134 PassedCuts = PassedCuts + 1; //DPhi
135
136
137
138 // eta range
139 if ( cutIndex == -1 ) { // VD
140 ATH_MSG_DEBUG( "Electron : " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
141 return false;
142 } else {
143 ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex );
144 }
145 PassedCuts = PassedCuts + 1; // passed eta cut
146
147 // ET_em
148 ATH_MSG_DEBUG( "Electron: ET_em=" << ET << " cut: >" << m_eTthr[cutIndex] );
149 if ( ET < m_eTthr[cutIndex] ) {
150 ATH_MSG_DEBUG("REJECT et cut failed");
151 return false;
152 }
153 PassedCuts = PassedCuts + 1; // ET_em
154 if(m_doNoPid) return true;
155
156
157
158 // d0 for LRT
159 if (m_d0 and m_d0>0.)
160 {
161 float trk_d0 = std::abs(el->trackParticle()->d0());
162 ATH_MSG_DEBUG( "Electron: trk_d0=" << trk_d0 << " cut: >" << m_d0 );
163 if ( trk_d0 < m_d0 ) {
164 ATH_MSG_DEBUG("REJECT d0 cut failed");
165 return false;
166 }
167 PassedCuts = PassedCuts + 1; // d0
168 }
169
170
171 ATH_MSG_DEBUG("Average mu " << avgmu());
172
173 bool pass = input.isPassed(el , avgmu(), m_pidName);
174
175
176 float Rhad1(0), Rhad(0), Reta(0), Rphi(0), e277(0), weta2c(0), //emax2(0),
177 Eratio(0), DeltaE(0), f1(0), weta1c(0), wtot(0), fracm(0);
178 float ptcone20(999), ptcone30(999), ptcone40(999), etcone20(999), etcone30(999), etcone40(999), topoetcone20(999), topoetcone30(999), topoetcone40(999), relptcone20(999);
179
180
181 // variables based on HCAL
182 // transverse energy in 1st scintillator of hadronic calorimeter/ET
183 el->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1);
184 // transverse energy in hadronic calorimeter/ET
185 el->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad);
186
187 // variables based on S2 of EM CAL
188 // E(7*7) in 2nd sampling
189 el->showerShapeValue(e277, xAOD::EgammaParameters::e277);
190 // E(3*7)/E(7*7) in 2nd sampling
191 el->showerShapeValue(Reta, xAOD::EgammaParameters::Reta);
192 // E(3*3)/E(3*7) in 2nd sampling
193 el->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi);
194 // shower width in 2nd sampling
195 el->showerShapeValue(weta2c, xAOD::EgammaParameters::weta2);
196
197 // variables based on S1 of EM CAL
198 // fraction of energy reconstructed in the 1st sampling
199 el->showerShapeValue(f1, xAOD::EgammaParameters::f1);
200 // shower width in 3 strips in 1st sampling
201 el->showerShapeValue(weta1c, xAOD::EgammaParameters::weta1);
202 // E of 2nd max between max and min in strips [NOT USED]
203 // eg->showerShapeValue(emax2, xAOD::EgammaParameters::e2tsts1);
204 // (E of 1st max in strips-E of 2nd max)/(E of 1st max+E of 2nd max)
205 el->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio);
206 // E(2nd max)-E(min) in strips
207 el->showerShapeValue(DeltaE, xAOD::EgammaParameters::DeltaE);
208 // total shower width in 1st sampling
209 el->showerShapeValue(wtot, xAOD::EgammaParameters::wtots1);
210 // E(+/-3)-E(+/-1)/E(+/-1)
211 el->showerShapeValue(fracm, xAOD::EgammaParameters::fracs1);
212
213 el->isolationValue(ptcone20, xAOD::Iso::ptcone20);
214
215 el->isolationValue(ptcone30, xAOD::Iso::ptcone30);
216
217 el->isolationValue(ptcone40, xAOD::Iso::ptcone40);
218
219 el->isolationValue(etcone20, xAOD::Iso::etcone20);
220
221 el->isolationValue(etcone30, xAOD::Iso::etcone30);
222
223 el->isolationValue(etcone40, xAOD::Iso::etcone40);
224
225 el->isolationValue(topoetcone20, xAOD::Iso::topoetcone20);
226
227 el->isolationValue(topoetcone30, xAOD::Iso::topoetcone30);
228
229 el->isolationValue(topoetcone40, xAOD::Iso::topoetcone40);
230
231 ATH_MSG_DEBUG(" electron Cluster Et "<<ET);
232 ATH_MSG_DEBUG( " Rhad1 " << Rhad1 ) ;
233 ATH_MSG_DEBUG( " Rhad " << Rhad ) ;
234 ATH_MSG_DEBUG( " e277 " << e277 ) ;
235 ATH_MSG_DEBUG( " Reta " << Reta ) ;
236 ATH_MSG_DEBUG( " Rphi " << Rphi ) ;
237 ATH_MSG_DEBUG( " weta2c " << weta2c ) ;
238 ATH_MSG_DEBUG( " f1 " << f1 ) ;
239 ATH_MSG_DEBUG( " weta1c " << weta1c ) ;
240 ATH_MSG_DEBUG( " Eratio " << Eratio ) ;
241 ATH_MSG_DEBUG( " DeltaE " << DeltaE ) ;
242 ATH_MSG_DEBUG( " wtot " << wtot ) ;
243 ATH_MSG_DEBUG( " fracm " << fracm ) ;
244 ATH_MSG_DEBUG( " trackPT "<<el->trackParticle()->pt());
245 ATH_MSG_DEBUG( " d0 "<<el->trackParticle()->d0());
246 ATH_MSG_DEBUG( " z0 "<<el->trackParticle()->z0());
247 ATH_MSG_DEBUG( " ptcone20 " << ptcone20 ) ;
248 ATH_MSG_DEBUG( " ptcone30 " << ptcone30 ) ;
249 ATH_MSG_DEBUG( " ptcone40 " << ptcone40 ) ;
250 ATH_MSG_DEBUG( " etcone20 " << etcone20 ) ;
251 ATH_MSG_DEBUG( " etcone30 " << etcone30 ) ;
252 ATH_MSG_DEBUG( " etcone40 " << etcone40 ) ;
253 ATH_MSG_DEBUG( " topoetcone20 " << topoetcone20 ) ;
254 ATH_MSG_DEBUG( " topoetcone30 " << topoetcone30 ) ;
255 ATH_MSG_DEBUG( " topoetcone40 " << topoetcone40 ) ;
256
257 // Monitor showershapes
258 relptcone20 = ptcone20/el->pt();
259 ATH_MSG_DEBUG("relptcone20 = " <<relptcone20 );
260 ATH_MSG_DEBUG("m_RelPtConeCut = " << m_RelPtConeCut );
261
262 // Evaluating lh *after* retrieving variables for monitoing and DEBUGing purposes
263 ATH_MSG_DEBUG("AthenaLHSelectorTool: TAccept = " << pass);
264 if ( !pass ){
265 ATH_MSG_DEBUG("REJECT Likelihood failed");
266 return false;
267 } else {
268 ATH_MSG_DEBUG("ACCEPT Likelihood passed");
269 }
270
271 // Check if need to apply isolation
272 // First check logic. if cut is very negative, then no isolation cut is defined
273 // if m_RelPtConeCut <-100 then hypo is configured not to apply isolation
274 if (m_RelPtConeCut < -100){
275 ATH_MSG_DEBUG(" not applying isolation. Returning NOW");
276 ATH_MSG_DEBUG("TAccept = " << pass);
277 return true;
278 }
279 // Then, It will pass if relptcone20 is less than cut:
280 pass = (relptcone20 < m_RelPtConeCut);
281 //
282 // Reach this point successfully
283 ATH_MSG_DEBUG( "pass = " << pass );
284 return pass;
285
286
287
288}
289
290
292 const float absEta = std::abs(eta);
293 auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
294 if ( binIterator == m_etabin.end() ) {
295 return -1;
296 }
297 return binIterator - m_etabin.begin();
298}
299
#define M_PI
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
virtual double phi() const override final
Methods to retrieve data members.
virtual double eta() const override final
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
bool decide(const Trig::TrigData &input, const xAOD::Electron *el) const
virtual bool emulate(const TrigData &input, bool &pass) const override
==========================================================================
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< std::vector< float > > m_etabin
selection variable for PRECISION electron selection:eta bins
The common trigger namespace for trigger analysis tools.
@ wtots1
shower width is determined in a window detaxdphi = 0,0625 ×~0,2, corresponding typically to 20 strips...
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition EgammaEnums.h:81
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
Definition EgammaEnums.h:53
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
@ DeltaE
e2tsts1-emins1
@ fracs1
shower shape in the shower core : [E(+/-3)-E(+/-1)]/E(+/-1), where E(+/-n) is the energy in ± n strip...
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
@ weta1
shower width using +/-3 strips around the one with the maximal energy deposit: w3 strips = sqrt{sum(E...
Definition EgammaEnums.h:98
@ topoetcone20
Topo-cluster ET-sum.
@ etcone20
Calorimeter isolation.
@ ptcone20
Track isolation.
Electron_v1 Electron
Definition of the current "egamma version".