ATLAS Offline Software
Loading...
Searching...
No Matches
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
#define endmsg
Helper class to provide constant type-safe access to aux data.
Return value from object correction CP tools.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Class mimicking the AthMessaging class from the offline software.
CP::CorrectionCode getEleTruthCharge(const xAOD::Electron &ele, int &truthcharge)
Get the charge of the original electron.
CP::CorrectionCode isGoodEle(const xAOD::Electron &ele, bool &goodEle)
Return true if it's good ele for charge flip measurements.
Electron_v1 Electron
Definition of the current "egamma version".
MsgStream & msg
Definition testRead.cxx:32