41 {
42
44
46
47 using namespace asg::TestxAODPhotonAlg;
49 MSG::Level mylevel = MSG::INFO;
50 setMsgLevel(mylevel);
52
53
54 if( argc < 2 ) {
57 return 1;
58 }
59
60
62
63
66 std::unique_ptr< TFile >
ifile( TFile::Open( fileName,
"READ" ) );
68
69
70
74 static_cast< int >(
event.getEntries() ) );
75
76
77
78 Long64_t
entries =
event.getEntries();
79 if( argc > 2 ) {
80 const Long64_t
e = atoll( argv[ 2 ] );
83 }
84 }
85
86
90
91 photonSF_ID.msg().setLevel( mylevel );
92 photonSF_Iso.msg().setLevel( mylevel );
93 photonSF_Trig.msg().setLevel( mylevel );
94
95
96
97 ANA_CHECK(photonSF_ID.setProperty(
"ForceDataType",1));
98
99
100 ANA_CHECK(photonSF_Iso.setProperty(
"IsoKey",
"Loose"));
101 ANA_CHECK(photonSF_Iso.setProperty(
"ForceDataType",1));
102
103
104 ANA_CHECK(photonSF_Trig.setProperty(
"IsoKey",
"Loose"));
105 ANA_CHECK(photonSF_Trig.setProperty(
"TriggerKey",
"DI_PH_2015_2016_g25_loose_2017_2018_g50_loose_L1EM20VH"));
106 ANA_CHECK(photonSF_Trig.setProperty(
"ForceDataType",1));
107
108
109 ANA_CHECK(photonSF_ID.setProperty(
"UseRandomRunNumber",
false));
110 ANA_CHECK(photonSF_ID.setProperty(
"DefaultRandomRunNumber",428648));
111 ANA_CHECK(photonSF_Iso.setProperty(
"UseRandomRunNumber",
false));
112 ANA_CHECK(photonSF_Iso.setProperty(
"DefaultRandomRunNumber",428648));
113 ANA_CHECK(photonSF_Trig.setProperty(
"UseRandomRunNumber",
false));
114 ANA_CHECK(photonSF_Trig.setProperty(
"DefaultRandomRunNumber",349534));
115
116 if(!photonSF_ID.initialize()){
117 std::cout <<"Failed to initialize the tool, check for errors"<<std::endl;
118 return 1;
119 }
120 if(!photonSF_Iso.initialize()){
121 std::cout <<"Failed to initialize the tool, check for errors"<<std::endl;
122 return 1;
123 }
124 if(!photonSF_Trig.initialize()){
125 std::cout <<"Failed to initialize the tool, check for errors"<<std::endl;
126 return 1;
127 }
128
129
130 std::vector<CP::SystematicSet> sysList;
134 std::cout << "List of recommended systematics from the registry:"<<std::endl;
135 for (
auto sysListItr = recommendedSystematics.
begin(); sysListItr != recommendedSystematics.
end(); ++sysListItr){
136 std::cout <<(*sysListItr).name()<<std::endl;
137 }
138
139
140
141
142
143 std::cout << "restructure all recommended systematic variations for the SF tool"<<std::endl;
144 std::vector<CP::SystematicSet> syst_PhotonID, syst_PhotonIso, syst_PhotonTrig;
146 {
147 syst_PhotonID.emplace_back();
148 syst_PhotonID.back().insert(SystematicsVariation);
149 }
151 {
152 syst_PhotonIso.emplace_back();
153 syst_PhotonIso.back().insert(SystematicsVariation);
154 }
156 {
157 syst_PhotonTrig.emplace_back();
158 syst_PhotonTrig.back().insert(SystematicsVariation);
159 }
160
161 for (const auto& sSystematicSet: syst_PhotonID){
162 Info(
APP_NAME,
"PhotonEfficiencyCorrectionTool ID instance has next systematic variation %s ",sSystematicSet.name().c_str());
163 }
164 for (const auto& sSystematicSet: syst_PhotonIso){
165 Info(
APP_NAME,
"PhotonEfficiencyCorrectionTool Iso instance has next systematic variation %s ",sSystematicSet.name().c_str());
166 }
167 for (const auto& sSystematicSet: syst_PhotonTrig){
168 Info(
APP_NAME,
"PhotonEfficiencyCorrectionTool Iso instance has next systematic variation %s ",sSystematicSet.name().c_str());
169 }
170
171 double efficiencyScaleFactor=0, efficiencyScaleFactorError=0;
172
173 std::cout <<
"loop on " <<
entries <<
" entries"<<std::endl;
175
176
177 event.getEntry( entry );
178
179
182
183
185
186
190
192
194 for( ; ph_itr != ph_end; ++ph_itr, ++
i ) {
196
197
198 if(ph->
pt()<10000.0)
continue;
200 if (!cluster){
202 return 1;
203 }
204 if( std::abs(cluster->
etaBE(2))>2.37)
continue;
207
208
209 ANA_CHECK(photonSF_ID.applySystematicVariation(syst_PhotonID.at(0)));
210 ANA_CHECK(photonSF_Iso.applySystematicVariation(syst_PhotonIso.at(0)));
211
212
213 ANA_CHECK(photonSF_ID.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
214 ANA_CHECK(photonSF_ID.getEfficiencyScaleFactorError(*ph,efficiencyScaleFactorError));
215 ANA_CHECK(photonSF_Trig.applySystematicVariation(syst_PhotonTrig.at(0)));
216
217 Info(
APP_NAME,
"===>>> Result ID: ScaleFactor %f, TotalUncertainty %f ",efficiencyScaleFactor,efficiencyScaleFactorError);
218
219
220 ANA_CHECK(photonSF_Iso.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
221 ANA_CHECK(photonSF_Iso.getEfficiencyScaleFactorError(*ph,efficiencyScaleFactorError));
222
223 Info(
APP_NAME,
"===>>> Result Iso: ScaleFactor %f, TotalUncertainty %f ",efficiencyScaleFactor,efficiencyScaleFactorError);
224
225
226 ANA_CHECK(photonSF_Trig.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
227 ANA_CHECK(photonSF_Trig.getEfficiencyScaleFactorError(*ph,efficiencyScaleFactorError));
228
229 Info(
APP_NAME,
"===>>> Result Trigger: ScaleFactor %f, TotalUncertainty %f ",efficiencyScaleFactor,efficiencyScaleFactorError);
230
231
232 ANA_CHECK(photonSF_ID.applyEfficiencyScaleFactor(*ph));
233 Info(
"applyEfficiencyScaleFactor()",
"===>>> new decoration: \"SF\"=%f", sfAcc(*ph));
234 ANA_CHECK(photonSF_Iso.applyEfficiencyScaleFactor(*ph));
235 Info(
"applyEfficiencyScaleFactor()",
"===>>> new decoration: \"SF\"=%f", sfAcc(*ph));
236 ANA_CHECK(photonSF_Trig.applyEfficiencyScaleFactor(*ph));
237 Info(
"applyEfficiencyScaleFactor()",
"===>>> new decoration: \"SF\"=%f", sfAcc(*ph));
238
239
240 for (const auto& sSystematicSet: syst_PhotonID){
241 ANA_CHECK(photonSF_ID.applySystematicVariation(sSystematicSet));
242 ANA_CHECK(photonSF_ID.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
243 Info(
APP_NAME,
"===>>> apply %s: ScaleFactor = %f",photonSF_ID.appliedSystematics().name().c_str(),efficiencyScaleFactor);
244 }
245 for (const auto& sSystematicSet: syst_PhotonIso){
246 ANA_CHECK(photonSF_Iso.applySystematicVariation(sSystematicSet));
247 ANA_CHECK(photonSF_Iso.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
248 Info(
APP_NAME,
"===>>> apply %s: ScaleFactor = %f",photonSF_Iso.appliedSystematics().name().c_str(),efficiencyScaleFactor);
249 }
250 for (const auto& sSystematicSet: syst_PhotonTrig){
251 ANA_CHECK(photonSF_Trig.applySystematicVariation(sSystematicSet));
252 ANA_CHECK(photonSF_Trig.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
253 Info(
APP_NAME,
"===>>> apply %s: ScaleFactor = %f",photonSF_Trig.appliedSystematics().name().c_str(),efficiencyScaleFactor);
254 }
255
256 }
257
258 }
259
260
261 return 0;
262
263}
This module implements the central registry for handling systematic uncertainties with CP tools.
const SystematicSet & recommendedSystematics() const
returns: the recommended set of systematics
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
const_iterator end() const
description: const iterator to the end of the set
const_iterator begin() const
description: const iterator to the beginning of the set
DataModel_detail::iterator< DataVector > iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Helper class to provide constant type-safe access to aux data.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
static void enableDataSubmission(::Bool_t value)
Function for turning data submission on/off.
std::vector< CP::SystematicSet > make_systematics_vector(const SystematicSet &systematics)
utility functions for working with systematics
Error
The different types of error that can be flagged in the L1TopoRDO.
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
Photon_v1 Photon
Definition of the current "egamma version".