ATLAS Offline Software
ElectronEfficiencyHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
10 // Get type and charge of the truth electron
11 // made them static so they can be used by analyses to do truth matches
13 
15 {
16 
17  // Define an AsgMessaging instance
18  static const asg::AsgMessaging msg("ElectronEfficiencyHelpers");
19 
20  static const SG::ConstAccessor<int> firstEgMotherPdgIdAcc("firstEgMotherPdgId");
21  if ( !(firstEgMotherPdgIdAcc.isAvailable(ele)) ) {
22  msg.msg(MSG::ERROR) << "Link not available for firstEgMotherPdgId...BAD!!!" << endmsg;
23  msg.msg(MSG::ERROR) << "Need to have present: ( !(ele.isAvailable<int>('firstEgMotherPdgId')) )" << endmsg;
25  }
26 
27  truthcharge = (-1)*firstEgMotherPdgIdAcc(ele);
28  // Make truthcharge -1, 0, +1
29  truthcharge = (0 < truthcharge) - (truthcharge < 0);
30 
32 
33 }
34 
35 
37 {
38 
39  // good ele => (firstEgMotherPdgId) == 11
40  // this is the case for type 2,3 and 4 electrons, so is not a real truth match!!!
41  // but we believe that it doesn't hurt to apply scale factors for all these cases
42  goodEle = false;
43  int firstEgPdgId = -9999;
44 
45  // Define an AsgMessaging instance
46  static const asg::AsgMessaging msg("ElectronEfficiencyHelpers");
47 
48  static const SG::ConstAccessor<int> firstEgMotherPdgIdAcc("firstEgMotherPdgId");
49  if ( !(firstEgMotherPdgIdAcc.isAvailable(ele)) ) {
50  msg.msg(MSG::ERROR) << "firstEgMotherPdgId IS NOT AVAILABLE!!" << endmsg;
52  }
53  else {
54 
55  firstEgPdgId = firstEgMotherPdgIdAcc(ele);
56 
57  if ( std::abs(firstEgPdgId) != 11) {
58 
59  goodEle = false;
61 
62  }
63  else {
64 
65  goodEle = true;
67 
68  }
69  }
70 
72 }
73 
SG::ConstAccessor< int >
AsgMessaging.h
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
ElectronEfficiencyHelpers::isGoodEle
CP::CorrectionCode isGoodEle(const xAOD::Electron &ele, bool &goodEle)
Return true if it's good ele for charge flip measurements.
Definition: ElectronEfficiencyHelpers.cxx:36
xAOD::Electron_v1
Definition: Electron_v1.h:34
ElectronEfficiencyHelpers::getEleTruthCharge
CP::CorrectionCode getEleTruthCharge(const xAOD::Electron &ele, int &truthcharge)
Get the charge of the original electron.
Definition: ElectronEfficiencyHelpers.cxx:14
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
ElectronEfficiencyHelpers.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7