ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
ElectronPhotonID
ElectronEfficiencyCorrection
Root
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
5
#include "
ElectronEfficiencyCorrection/ElectronEfficiencyHelpers.h
"
6
#include "
AsgMessaging/AsgMessaging.h
"
7
#include "
AthContainers/ConstAccessor.h
"
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
14
CP::CorrectionCode
ElectronEfficiencyHelpers::getEleTruthCharge
(
const
xAOD::Electron
& ele,
int
& truthcharge )
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
;
24
return
CP::CorrectionCode::OutOfValidityRange
;
25
}
26
27
truthcharge = (-1)*firstEgMotherPdgIdAcc(ele);
28
// Make truthcharge -1, 0, +1
29
truthcharge = (0 < truthcharge) - (truthcharge < 0);
30
31
return
CP::CorrectionCode::Ok
;
32
33
}
34
35
36
CP::CorrectionCode
ElectronEfficiencyHelpers::isGoodEle
(
const
xAOD::Electron
& ele,
bool
& goodEle)
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
;
51
return
CP::CorrectionCode::OutOfValidityRange
;
52
}
53
else
{
54
55
firstEgPdgId = firstEgMotherPdgIdAcc(ele);
56
57
if
( std::abs(firstEgPdgId) != 11) {
58
59
goodEle =
false
;
60
return
CP::CorrectionCode::Ok
;
61
62
}
63
else
{
64
65
goodEle =
true
;
66
return
CP::CorrectionCode::Ok
;
67
68
}
69
}
70
71
return
CP::CorrectionCode::OutOfValidityRange
;
72
}
73
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
AsgMessaging.h
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
ElectronEfficiencyHelpers.h
CP::CorrectionCode
Return value from object correction CP tools.
Definition
CorrectionCode.h:31
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition
CorrectionCode.h:37
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition
CorrectionCode.h:38
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition
AsgMessaging.h:40
ElectronEfficiencyHelpers::getEleTruthCharge
CP::CorrectionCode getEleTruthCharge(const xAOD::Electron &ele, int &truthcharge)
Get the charge of the original electron.
Definition
ElectronEfficiencyHelpers.cxx:14
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
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0