35{
36 using namespace asg::msgUserCode;
37
39
40
41 if (argc < 2)
42 {
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
51 if (argc < 4)
52 {
55 }
56 else
57 {
58 int argv1 =
atoi(argv[3]);
59 if (argv1 == 0)
60 {
63 }
64 else if (argv1 == 1)
65 {
68 }
69 else
70 {
71 ANA_MSG_ERROR (
"Usage: %s [xAOD file name] %d Num of events to process %d (0 photons , 1 electrons)");
72 return EXIT_FAILURE;
73 }
74 }
75
76
79 std::unique_ptr<TFile>
inputFile(TFile::Open(fileName,
"READ"));
81
82
84
87
88 ANA_MSG_INFO(
"Number of events in the file: " << pers.getEntries());
89
90
91 Long64_t
entries = pers.getEntries();
92 if (argc > 2)
93 {
94 const Long64_t userInputEntries = atoll(argv[2]);
96 {
98 ANA_MSG_INFO(
"Running over " << userInputEntries <<
" events.");
99 }
100 }
101
102
103
104
106 {
107
108
109 std::string configFilePathConverted = "EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase_ExampleConvertedPhotonConf_Eratio.conf";
111 ANA_CHECK(CorrectConvertedPhotonTool.setProperty(
"ConfigFile",configFilePathConverted));
112 ANA_CHECK(CorrectConvertedPhotonTool.initialize());
113
114 std::string configFilePathUnconverted = "EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase_ExampleUnconvertedPhotonConf_Eratio.conf";
116 ANA_CHECK(CorrectUnconvertedPhotonTool.setProperty(
"ConfigFile",configFilePathUnconverted));
117 ANA_CHECK(CorrectUnconvertedPhotonTool.initialize());
118
119 std::string correctionVariable = CorrectConvertedPhotonTool.getCorrectionVariable();
120 ANA_MSG_INFO(
"Correcting Variable: " << correctionVariable);
121
122
124 {
125
126 pers.getEntry(entry);
129
130
132 ANA_CHECK(pers.retrieve(photons,
"Photons"));
133
134
135
136 auto photons_copy = std::make_unique<xAOD::PhotonContainer>();
137 auto photons_copy_aux = std::make_unique<xAOD::AuxContainerBase>();
138 photons_copy->setStore (photons_copy_aux.get());
139
140
141 for (auto photon : *photons) {
142
144 photons_copy->push_back (photon_copy);
146 }
147
148
149
150 for (unsigned int photon_itr = 0; photon_itr < photons_copy->size(); photon_itr++)
151 {
155
156
158 {
160 ANA_CHECK(CorrectConvertedPhotonTool.applyCorrection(*photon));
161 }
162 else
163 {
165 ANA_CHECK(CorrectUnconvertedPhotonTool.applyCorrection(*photon));
166 }
167
168
171
172
173 ANA_MSG_INFO(
"Original value: " << VariableToCorrect(*photon));
174 ANA_MSG_INFO(
"Corrected value: " << CorrectedVariable(*photon));
175
176 }
177 }
178 }
179
180
181
182
184 {
185 std::string configFilePath = "EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase_ExampleElectronConf_Eratio.conf";
187 ANA_CHECK(CorrectElectronTool.setProperty(
"ConfigFile",configFilePath));
188 ANA_CHECK(CorrectElectronTool.initialize());
189
190 std::string correctionVariable = CorrectElectronTool.getCorrectionVariable();
191 ANA_MSG_INFO(
"Correcting Variable: " << correctionVariable);
192
193
195 {
196
197 pers.getEntry(entry);
200
201
203 ANA_CHECK(pers.retrieve(electrons,
"Electrons"));
204
205
206
207 auto electrons_copy = std::make_unique<xAOD::ElectronContainer>();
208 auto electrons_copy_aux = std::make_unique<xAOD::AuxContainerBase>();
209 electrons_copy->setStore (electrons_copy_aux.get());
210
211
212 for (auto electron : *electrons) {
213
215 electrons_copy->push_back (electron_copy);
217 }
218
219
220
221 for (unsigned int electron_itr = 0; electron_itr < electrons_copy->size(); electron_itr++)
222 {
226
227
228 ANA_CHECK(CorrectElectronTool.applyCorrection(*electron));
229
230
233
234
235 ANA_MSG_INFO(
"Original value: " << VariableToCorrect(*electron));
236 ANA_MSG_INFO(
"Corrected value: " << CorrectedVariable(*electron));
237
238 }
239 }
240 }
241
242 return 0;
243}
bool isElectron(const T &p)
bool isPhoton(const T &p)
Class to correct electron and photon MC variables.
SG::Accessor< T, ALLOC > Accessor
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
A relatively simple transient store for objects created in analysis.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".