ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
ElectronPhotonID
EGammaVariableCorrection
util
testIsoCorrection.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
10
11
// ROOT includes
12
#include "TFile.h"
13
#include "TString.h"
14
15
//EDM includes
16
#include "
xAODEgamma/PhotonContainer.h
"
17
#include "
xAODEgamma/PhotonAuxContainer.h
"
18
#include "
xAODEgamma/Photon.h
"
19
20
// must be changed to not be a relative path!
21
#include "
EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h
"
22
//
23
#include "
AsgMessaging/AsgMessaging.h
"
24
25
//infrastructure includes
26
#ifdef ROOTCORE
27
#include "
xAODRootAccess/TEvent.h
"
28
#include "
xAODRootAccess/TStore.h
"
29
#endif
//ROOTCORE
30
#include "
IsolationCorrections/IsolationCorrectionTool.h
"
31
#include "
xAODCore/ShallowCopy.h
"
32
33
//main test code
34
35
int
main
(
int
argc,
char
* argv[])
36
{
37
using namespace
asg::msgUserCode;
38
// The application's name:
39
const
char
*
APP_NAME
= argv[0];
40
// Check if we received a file name:
41
if
(argc < 2)
42
{
43
ANA_MSG_ERROR
(
"No file name received!"
);
44
ANA_MSG_ERROR
(
" Usage: %s [xAOD file name] %d Num of events to process %d (0 photons , 1 electrons)"
);
45
return
EXIT_FAILURE;
46
}
47
48
//open input file
49
const
TString fileName = argv[1];
50
ANA_MSG_INFO
(
APP_NAME
<<
" Opening file: "
<< fileName.Data());
51
std::unique_ptr<TFile> inputFile(TFile::Open(fileName,
"READ"
));
52
ANA_CHECK
(inputFile.get());
53
54
// Create a TEvent object (persistent store)
55
xAOD::TEvent
pers(
xAOD::TEvent::kClassAccess
);
56
// Create a TStore object (transient store)
57
xAOD::TStore
trans;
58
ANA_CHECK
(pers.
readFrom
(inputFile.get()));
59
60
ANA_MSG_INFO
(
"Number of events in the file: "
<< pers.
getEntries
());
61
62
// Decide how many events to run over:
63
Long64_t
entries
= pers.
getEntries
();
64
if
(argc > 2)
65
{
66
const
Long64_t userInputEntries = atoll(argv[2]);
67
if
(userInputEntries <
entries
)
68
{
69
entries
= userInputEntries;
70
}
71
}
72
73
//initialise the tool
74
ElectronPhotonVariableCorrectionBase
fudgeTool(
"fudgeTool"
);
75
ANA_CHECK
(fudgeTool.setProperty(
"ConfigFile"
,
"EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase_ExampleIsoCorrectionConf.conf"
));
76
ANA_CHECK
(fudgeTool.
initialize
());
77
78
//crosscheck with isolationcorrectiontool
79
// check these StatusCodes once update to a newer AnalysisBase version (not 21.2.56, probably > 21.2.94)
80
CP::IsolationCorrectionTool
isoCorrToolFull(
"isoCorrToolFull"
);
81
ANA_CHECK
(isoCorrToolFull.setProperty(
"Apply_etaEDPar_mc_correction"
,
true
));
82
ANA_CHECK
(isoCorrToolFull.setProperty(
"Apply_etaEDParPU_correction"
,
true
));
83
ANA_CHECK
(isoCorrToolFull.
initialize
());
84
85
CP::IsolationCorrectionTool
isoCorrToolStep(
"isoCorrToolStep"
);
86
ANA_CHECK
(isoCorrToolStep.setProperty(
"Apply_etaEDPar_mc_correction"
,
false
));
87
ANA_CHECK
(isoCorrToolStep.setProperty(
"Apply_etaEDParPU_correction"
,
true
));
88
ANA_CHECK
(isoCorrToolStep.
initialize
());
89
90
static
const
SG::ConstAccessor<float>
topoEtCone40OriginalAcc(
"topoetcone40_original"
);
91
static
const
SG::ConstAccessor<float>
topoEtCone40Acc(
"topoetcone40"
);
92
93
//loop over the events
94
for
(Long64_t entry = 0; entry <
entries
; entry++)
95
{
96
//get entry
97
pers.
getEntry
(entry);
98
ANA_MSG_INFO
(
"============================"
);
99
ANA_MSG_INFO
(
"Event: "
<< entry);
100
101
//get photon container
102
const
xAOD::PhotonContainer
* photons;
103
ANA_CHECK
(pers.
retrieve
(photons,
"Photons"
));
104
xAOD::ShallowCopyResult_t<xAOD::PhotonContainer>
photons_isocorr =
xAOD::shallowCopy
( *photons );
105
xAOD::ShallowCopyResult_t<xAOD::PhotonContainer>
photons_fudge =
xAOD::shallowCopy
( *photons );
106
107
//loop over photon container
108
for
(
unsigned
int
idx = 0; idx < photons->
size
(); idx++)
109
{
110
ANA_MSG_INFO
(
"---------------------------"
);
111
ANA_MSG_INFO
(
"Photon: "
<< idx);
112
ANA_CHECK
(isoCorrToolFull.
applyCorrection
(*(photons_isocorr.first->at(idx))));
113
ANA_CHECK
(isoCorrToolStep.
applyCorrection
(*(photons_fudge.first->at(idx))));
114
ANA_CHECK
(fudgeTool.
applyCorrection
(*(photons_fudge.first->at(idx))));
115
ANA_MSG_INFO
(
"topoetcone40 fudge before applyCorrection: "
<< topoEtCone40OriginalAcc(*photons_fudge.first->at(idx)));
116
ANA_MSG_INFO
(
"topoetcone40 fudge after applyCorrection : "
<< topoEtCone40Acc(*photons_fudge.first->at(idx)));
117
ANA_MSG_INFO
(
"topoetcone40 with IsolationCorrectionTool : "
<< topoEtCone40Acc(*photons_isocorr.first->at(idx)));
118
}
// loop over photon container
119
}
// loop over events
120
121
return
0;
122
}
AsgMessaging.h
APP_NAME
#define APP_NAME
Definition
BoostedXbbTag.cxx:25
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
TEvent.h
ElectronPhotonVariableCorrectionBase.h
PhotonContainer.h
Photon.h
IsolationCorrectionTool.h
PhotonAuxContainer.h
ShallowCopy.h
TStore.h
CP::IsolationCorrectionTool
Definition
IsolationCorrectionTool.h:27
CP::IsolationCorrectionTool::initialize
virtual StatusCode initialize() override final
Definition
IsolationCorrectionTool.cxx:47
CP::IsolationCorrectionTool::applyCorrection
virtual CP::CorrectionCode applyCorrection(xAOD::Egamma &) override final
Definition
IsolationCorrectionTool.cxx:210
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ElectronPhotonVariableCorrectionBase
Class to correct electron and photon MC variables.
Definition
ElectronPhotonVariableCorrectionBase.h:43
ElectronPhotonVariableCorrectionBase::applyCorrection
const CP::CorrectionCode applyCorrection(xAOD::Photon &photon) const
Apply the correction given in the conf file to the passed photon.
Definition
ElectronPhotonVariableCorrectionBase.cxx:202
ElectronPhotonVariableCorrectionBase::initialize
virtual StatusCode initialize() override
Initialize the class instance.
Definition
ElectronPhotonVariableCorrectionBase.cxx:47
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
xAOD::Event::retrieve
StatusCode retrieve(const T *&obj, const std::string &key)
Retrieve either an input or an output object from the event.
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:59
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:73
xAOD::TEvent::getEntry
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0) override
Function loading a given entry of the input TTree.
Definition
Control/xAODRootAccess/Root/TEvent.cxx:680
xAOD::TEvent::readFrom
StatusCode readFrom(::TFile &inFile) override
Set up the reading of an input file from TFile This method implements the interface from Event.
Definition
Control/xAODRootAccess/Root/TEvent.cxx:111
xAOD::TEvent::getEntries
::Long64_t getEntries() const override
Get how many entries are available from the current input file(s).
Definition
Control/xAODRootAccess/Root/TEvent.cxx:651
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition
TStore.h:45
main
int main()
Definition
hello.cxx:18
entries
double entries
Definition
listroot.cxx:49
xAOD::ShallowCopyResult_t
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition
ShallowCopy.h:68
xAOD::PhotonContainer
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/PhotonContainer.h:17
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
Generated on
for ATLAS Offline Software by
1.17.0