ATLAS Offline Software
ElectronIDSelectorCore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*****************************************************************************
6  * @Project: AnalysisUtils
7  *
8  * @class ElectronIDSelectorCore
9  *
10  * @author Karsten Koeneke <karsten.koeneke@cernSPAMNOT.ch>
11  *
12  * Based on C implementation by:
13  * @author John Alison <johnda@sas.upenn.edu>
14  *
15  * @date August 2010
16  *
17  * @brief Dual use tool (athena/ARA) for specialized electron identification cuts.
18  *
19  *****************************************************************************/
20 
83 // This class's header
85 
86 // STL includes
87 #include <iostream>
88 #include <iomanip>
89 #include <cmath>
90 #include <string>
91 #include <cfloat>
92 
93 // Atlas includes
94 #include "GaudiKernel/ToolHandle.h"
96 #include "egammaEvent/Electron.h"
97 #include "egammaEvent/egamma.h"
98 #include "egammaEvent/EMShower.h"
100 #include "Particle/TrackParticle.h"
101 #include "CLHEP/Units/SystemOfUnits.h"
102 
103 
104 using CLHEP::GeV;
105 
106 
107 
108 //=============================================================================
109 // The contructor
110 //=============================================================================
112  AraToolBase(pmgr),
113  ISelectorCore(pmgr),
114  m_isEM(0),
115  m_isEM_NoConvCut(0)
116 {
117 
118  //Need a mechanism to turn on/off a cut
119  // The default values are such that the cut is effectefly turned off.
120  // Name of the EMShower container
121  declareProperty( "EMShowerContainerName", m_showerContainerName="egDetailAOD", "Name of the EMShower container" );
122  declareProperty( "isEM", m_isEMCut="", "IsEM cut selection");
123 
124 }
125 
126 
127 
128 //=============================================================================
129 // Athena initialize method
130 //=============================================================================
132 {
133  // The standard status code
134  StatusCode sc = StatusCode::SUCCESS ;
135 
136  // Set the IsEM bitmask to the wanted criteria
137  if ( m_isEMCut == "RobustLoose" )
138  {
139  // Does it pass the loose isEM with Reta and w2 removed?
140  const unsigned int CALOMIDDLE_ELECTRON_NoReta_NoW2 = 0x1 << egammaPIDObs::ClusterMiddleEnergy_Electron;
141  const unsigned int ElectronLoose_NoReta_NoW2 = CALOMIDDLE_ELECTRON_NoReta_NoW2 | egammaPIDObs::HADLEAKETA_ELECTRON;
142  m_isEM = ElectronLoose_NoReta_NoW2;
143  }
144  else if ( m_isEMCut == "RobustMedium" )
145  {
146  const unsigned int CALOMIDDLE_ELECTRON_NoReta_NoW2 = 0x1 << egammaPIDObs::ClusterMiddleEnergy_Electron;
147 
148  const unsigned int CALO_ELECTRON_NoReta_NoW2 =
151  CALOMIDDLE_ELECTRON_NoReta_NoW2 ;
152 
153  const unsigned int ElectronMedium_NOReta_NoW2 =
154  CALO_ELECTRON_NoReta_NoW2 |
157 
158  m_isEM = ElectronMedium_NOReta_NoW2;
159  }
160  else if ( m_isEMCut == "RobustTight" || m_isEMCut == "RobusterTight" )
161  {
162  const unsigned int CALOMIDDLE_ELECTRON_NoReta_NoW2 = 0x1 << egammaPIDObs::ClusterMiddleEnergy_Electron;
163 
164  const unsigned int CALO_ELECTRON_NoReta_NoW2 =
167  CALOMIDDLE_ELECTRON_NoReta_NoW2 ;
168 
169  const unsigned int ElectronTightRobust_NoReta_NoW2 =
170  CALO_ELECTRON_NoReta_NoW2 |
177 
178  m_isEM = ElectronTightRobust_NoReta_NoW2;
179 
180  // Tight without the conversion requirement
181  const unsigned int ElectronTightRobust_NoReta_NoW2_NoConvCut =
182  CALO_ELECTRON_NoReta_NoW2 |
188 
189  m_isEM_NoConvCut = ElectronTightRobust_NoReta_NoW2_NoConvCut;
190  }
191  else
192  {
193  std::cerr << "IsEM is not recognized! Please configure it properly"
194  << std::endl;
195  sc = StatusCode::FAILURE;
196  }
197 
198 
199  return sc ;
200 }
201 
202 
203 
204 
205 
206 //=============================================================================
207 // Athena finalize method
208 //=============================================================================
210 {
211  // The standard status code
212  StatusCode sc = StatusCode::SUCCESS ;
213 
214  return sc ;
215 }
216 
217 
218 
219 
220 //=============================================================================
221 // The main accept method for INavigable4Momentum
222 //=============================================================================
224 {
225  // Cast to an electron and if succesfull, perform selection
226  const Analysis::Electron* electron = dynamic_cast< const Analysis::Electron* >( part );
227  if ( !electron )
228  {
229  std::cerr << "Couldn't cast to an electron! Are you sure you are using this right?"
230  << std::endl;
231  return true;
232  }
233 
234 
235  // Does it pass the isEM with Reta and w2 removed?
236  if ( m_isEM_NoConvCut == 0 && electron->isem(m_isEM) != 0 )
237  {
238  return false;
239  }
240 
241  // Check for the b-layer requirement if RobusterTight is requested
242  if ( m_isEM_NoConvCut != 0 )
243  {
246  {
247  if ( electron->isem(m_isEM) != 0 )
248  {
249  return false;
250  }
251  }
252  else // no b-layer hit is expected; thus don't use the conversion cut
253  {
254  if ( electron->isem(m_isEM_NoConvCut) != 0 )
255  {
256  return false;
257  }
258  }
259  }
260 
261 
262  // Get the CaloCluster for this electron and make sure that we got it
263  const CaloCluster* cluster = electron->cluster();
264  if ( !cluster )
265  {
266  std::cerr << "Couldn't get the CaloCluster for this electron! Passing this electron."
267  << std::endl;
268  return true;
269  }
270 
271  // eta position in second sampling
272  double eta2 = fabs(cluster->etaBE(2));
273  // transverse energy in calorimeter (using eta position in second sampling)
274  double et = 0.;
275  if (fabs(eta2)<999.)
276  {
277  et = cosh(eta2)!=0. ? cluster->energy()/cosh(eta2) : 0.;
278  }
279 
280  // Get the absolute value of eta2
281  double absEta2 = fabs(eta2);
282 
283 
284  // retrieve shower object
285  const EMShower* shower = electron->detail<EMShower>(m_showerContainerName);
286  if ( !shower )
287  {
288  std::cerr << "Couldn't get the EMShower object for this electron! Passing this electron."
289  << std::endl;
290  return true;
291  }
292 
293 
294  // Get the W2 for this electron
295  double weta2 = shower->weta2();
296 
297  // Do the modified W2 cut
298  double w2CutValue = getW2Cut( et, absEta2 );
299  if ( weta2 > w2CutValue )
300  {
301  return false;
302  }
303 
304 
305  // E(3*7) in 2nd sampling
306  double e237 = shower->e237();
307  // E(7*7) in 2nd sampling
308  double e277 = shower->e277();
309  // Get the REta for this electron
310  double reta = e277 != 0.0 ? e237/e277 : 0.0;
311 
312  // Do the modified REta cut
313  double REtaCutValue = getREtaCut( et, absEta2 );
314  if ( reta <= REtaCutValue )
315  {
316  return false;
317  }
318 
319  return true;
320 }
321 
322 
323 
324 
325 
326 
327 
328 
329 //=============================================================================
330 // Gets the Eta bin [0-9] given the eta
331 //=============================================================================
332 unsigned int ElectronIDSelectorCore::getEtaBin(double eta) const
333 {
334  const unsigned int nEtaBins = 10;
335  const double etaBins[nEtaBins] = {0.1,0.6,0.8,1.15,1.37,1.52,1.81,2.01,2.37,2.47};
336 
337  for ( unsigned int etaBin = 0; etaBin < nEtaBins; ++etaBin )
338  {
339  if ( eta < etaBins[etaBin] )
340  {
341  return etaBin;
342  }
343  }
344 
345  return 9;
346 }
347 
348 
349 //=============================================================================
350 // Gets the Et bin [0-10] given the et (MeV)
351 //=============================================================================
352 unsigned int ElectronIDSelectorCore::getEtBin(double eT) const
353 {
354  const unsigned int nEtBins = 11;
355  const double eTBins[nEtBins] = {5*GeV,10*GeV,15*GeV,20*GeV,30*GeV,40*GeV,50*GeV,60*GeV,70*GeV,80*GeV};
356 
357  for ( unsigned int eTBin = 0; eTBin < nEtBins; ++eTBin )
358  {
359  if ( eT < eTBins[eTBin] )
360  {
361  return eTBin;
362  }
363  }
364 
365  return 10;
366 }
367 
368 
369 
370 
371 //=============================================================================
372 // Get the REta cut value for a given et and eta
373 //=============================================================================
374 double ElectronIDSelectorCore::getREtaCut( double eT, double eta ) const
375 {
376  // New values cut on ratio e237/e277 (rows are eT bins, columns are eta bins)
377  const double cutReta37[11][10] = {{ 0.700, 0.700, 0.798, 0.700, 0.700, 0.690, 0.848, 0.876, 0.870, 0.894} // < 5
378  ,{0.700, 0.700, 0.700, 0.700, 0.700, 0.715, 0.860, 0.880, 0.880, 0.880} // 5-10
379  ,{0.860, 0.860, 0.860, 0.860, 0.860, 0.730, 0.860, 0.880, 0.880, 0.880}// 10-15
380  ,{0.860, 0.860, 0.860, 0.860, 0.860, 0.740, 0.860, 0.880, 0.880, 0.880}// 15-20
381  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}// 20-30
382  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}// 30-40
383  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}// 40-50
384  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}// 50-60
385  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}// 60-70
386  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}// 70-80
387  ,{0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900, 0.900}};// 80<
388 
389  unsigned int eTBin = getEtBin(eT);
390  unsigned int etaBin = getEtaBin(eta);
391 
392  return cutReta37[eTBin][etaBin];
393 }
394 
395 
396 
397 
398 
399 //=============================================================================
400 // Get te W2 cut value for a given et and eta
401 //=============================================================================
402 double ElectronIDSelectorCore::getW2Cut( double eT, double eta ) const
403 {
404  //New values for cut on shower width in 2nd sampling (rows are eT bins, columns are eta bins)
405  const double cutWeta2[11][10] = {{ 0.014, 0.014, 0.014, 0.014, 0.014, 0.028, 0.017, 0.014, 0.014, 0.014} // < 5
406  ,{0.013, 0.013, 0.014, 0.014, 0.014, 0.026, 0.017, 0.014, 0.014, 0.014} // 5-10
407  ,{0.013, 0.013, 0.014, 0.014, 0.014, 0.025, 0.017, 0.014, 0.014, 0.014} // 10-15
408  ,{0.012, 0.012, 0.013, 0.013, 0.013, 0.025, 0.017, 0.014, 0.014, 0.014} // 15-20
409  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013} // 20-30
410  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013} // 30-40
411  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013} // 40-50
412  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013} // 50-60
413  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013} // 60-70
414  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013} // 70-80
415  ,{0.012, 0.012, 0.012, 0.013, 0.015, 0.025, 0.015, 0.013, 0.013, 0.013}};// 80<;
416 
417  unsigned int eTBin = getEtBin(eT);
418  unsigned int etaBin = getEtaBin(eta);
419 
420  return cutWeta2[eTBin][etaBin];
421 }
422 
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
ISelectorCore
Dual use tool (athena/ARA) for any cuts. This is the base class.
Definition: ISelectorCore.h:29
egammaPIDdefsObs.h
egammaPIDObs::ConversionMatch_Electron
@ ConversionMatch_Electron
matching to photon (not necessarily conversion–the name is historical)
Definition: egammaPIDdefsObs.h:136
et
Extra patterns decribing particle interation process.
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
TrackParticle.h
EMShower::e237
double e237() const
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 3x7
TCS::KFMET::nEtaBins
constexpr unsigned nEtaBins
Definition: KalmanMETCorrectionConstants.h:18
INavigable4Momentum.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
egammaPIDObs::TrackMatchEta_Electron
@ TrackMatchEta_Electron
eta difference between cluster and extrapolated track in the 1st sampling
Definition: egammaPIDdefsObs.h:176
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
egammaPIDObs::TRACKMATCHDETA_ELECTRON
const unsigned int TRACKMATCHDETA_ELECTRON
Track cluster matching in eta for electrons.
Definition: egammaPIDdefsObs.h:315
Analysis::Electron
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/Electron.h:20
ElectronIDSelectorCore::getREtaCut
double getREtaCut(double eT, double eta) const
Gets the Reta cut given eT (MeV) and eta.
Definition: ElectronIDSelectorCore.cxx:374
egamma.h
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
ElectronIDSelectorCore::finalize
virtual StatusCode finalize()
Gaudi Service Interface method implementations.
Definition: ElectronIDSelectorCore.cxx:209
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCompositeKineBase::energy
virtual double energy() const
Return energy.
Definition: CaloCompositeKineBase.h:70
EMShower
Definition: EMShower.h:24
ElectronIDSelectorCore::getEtBin
unsigned int getEtBin(double eT) const
Gets the Et bin [0-10] given the et (MeV)
Definition: ElectronIDSelectorCore.cxx:352
ElectronIDSelectorCore::m_isEM_NoConvCut
unsigned int m_isEM_NoConvCut
IsEM from the electron for robusterTight with b-layer check.
Definition: ElectronIDSelectorCore.h:94
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
ElectronIDSelectorCore.h
egammaPIDObs::ClusterMiddleEnergy_Electron
@ ClusterMiddleEnergy_Electron
energy in 2nd sampling (e.g E277>0)
Definition: egammaPIDdefsObs.h:141
egammaPIDObs::TRT_ELECTRON
const unsigned int TRT_ELECTRON
TRT hits and TR ratio for electrons.
Definition: egammaPIDdefsObs.h:338
IDTPM::eT
float eT(const U &p)
Accessor utility function for getting the value of Tranverse energy.
Definition: TrackParametersHelper.h:130
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ElectronIDSelectorCore::getEtaBin
unsigned int getEtaBin(double eta) const
Gets the Eta bin [0-9] given the eta.
Definition: ElectronIDSelectorCore.cxx:332
EMShower::e277
double e277() const
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloCluster::etaBE
double etaBE(int sampling) const
EMB/EMEC combined barycenter .
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:1199
EMShower::weta2
double weta2() const
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
egammaPIDObs::TRACKING_ELECTRON
const unsigned int TRACKING_ELECTRON
Track quality cuts for electrons.
Definition: egammaPIDdefsObs.h:311
ElectronIDSelectorCore::accept
bool accept(const INavigable4Momentum *part) const
Main method, all cuts are applied.
Definition: ElectronIDSelectorCore.cxx:223
Electron.h
egammaPIDObs::TrackA0Tight_Electron
@ TrackA0Tight_Electron
distance of closet approach for tight selection (not to be used in new ++ menus)
Definition: egammaPIDdefsObs.h:189
egammaPIDObs::TRACKINGNOBLAYER_ELECTRON
const unsigned int TRACKINGNOBLAYER_ELECTRON
Track quality cuts except b-layer for electrons.
Definition: egammaPIDdefsObs.h:302
ElectronIDSelectorCore::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations.
Definition: ElectronIDSelectorCore.cxx:131
AraToolBase::PropertyMgr
PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > > PropertyMgr
Definition: AraToolBase.h:19
EMShower.h
AraToolBase::declareProperty
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Definition: AraToolBase.h:52
egammaPIDObs::HADLEAKETA_ELECTRON
const unsigned int HADLEAKETA_ELECTRON
cuts of hadronic leakage
Definition: egammaPIDdefsObs.h:271
INavigable4Momentum
Definition: INavigable4Momentum.h:21
AraToolBase
Definition: AraToolBase.h:17
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
ElectronIDSelectorCore::m_showerContainerName
std::string m_showerContainerName
Name of the EMShower container.
Definition: ElectronIDSelectorCore.h:85
egammaPIDObs::TrackMatchEoverP_Electron
@ TrackMatchEoverP_Electron
energy-momentum match
Definition: egammaPIDdefsObs.h:180
ElectronIDSelectorCore::getW2Cut
double getW2Cut(double eT, double eta) const
Gets the w2 cut given eT (MeV) and eta.
Definition: ElectronIDSelectorCore.cxx:402
xAOD::EgammaParameters::e277
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition: EgammaEnums.h:80
ElectronIDSelectorCore::m_isEM
unsigned int m_isEM
IsEM from the electron.
Definition: ElectronIDSelectorCore.h:91
xAOD::EgammaParameters::e237
@ e237
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 3x7
Definition: EgammaEnums.h:77
egammaParameters::expectHitInBLayer
@ expectHitInBLayer
expectHitInBLayer (set to 1 if true)
Definition: egammaParamDefs.h:683
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
ElectronIDSelectorCore::ElectronIDSelectorCore
ElectronIDSelectorCore(PropertyMgr *pmgr=0)
Default contructor.
Definition: ElectronIDSelectorCore.cxx:111
egammaPIDObs::CALOSTRIPS_ELECTRON
const unsigned int CALOSTRIPS_ELECTRON
cuts in strips (with ClusterStripsDEmaxs1)
Definition: egammaPIDdefsObs.h:275
xAOD::EgammaParameters::weta2
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
Definition: EgammaEnums.h:103
ElectronIDSelectorCore::m_isEMCut
std::string m_isEMCut
IsEM cut.
Definition: ElectronIDSelectorCore.h:88