20 #ifdef XAOD_STANDALONE
47 #define MSGSOURCE "Example 5b"
56 bool debug =
false, cmdline_error =
false, toys =
false;
60 else if(
string(
argv[
i]) ==
"--toys") toys =
true;
62 else cmdline_error =
true;
70 #ifdef XAOD_STANDALONE
80 StatusCode::enableFailure();
86 event.readFrom(
file).ignore();
87 Long64_t
entries =
event.getEntries();
92 Info(
MSGSOURCE,
"Configuring the photon CP tools");
94 ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonEffTools;
96 ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonSFTools;
98 std::map<string,string> legsPerTool;
101 vector<asg::AnaToolHandle<IAsgPhotonEfficiencyCorrectionTool>> factory;
103 vector<std::array<string,2>> toolConfigs = {
105 {
"g35_loose, g35_medium_L1EM20VH",
"DI_PH_2015_g35_loose_2016_g35_loose_2017_g35_medium_L1EM20VH_2018_g35_medium_L1EM20VH"},
106 {
"g25_loose, g25_medium_L1EM20VH",
"DI_PH_2015_g25_loose_2016_g25_loose_2017_g25_medium_L1EM20VH_2018_g25_medium_L1EM20VH"}
109 const char* mapPath =
"PhotonEfficiencyCorrection/2015_2018/"
110 "rel21.2/Summer2018_Rec_v1/map1.txt";
111 for(
auto&
cfg : toolConfigs)
114 string name =
"AsgPhotonEfficiencyCorrectionTool/"
115 + ((j?
"PhTrigEff_" :
"PhTrigSF_")
117 auto t = factory.emplace(factory.end(),
name);
118 t->setProperty(
"MapFilePath", mapPath).ignore();
119 t->setProperty(
"TriggerKey",
string(j?
"":
"Eff_") +
cfg[cKEY]).
ignore();
120 t->setProperty(
"IsoKey",
"Loose").ignore();
122 if(
t->initialize() != StatusCode::SUCCESS)
128 auto& handles = (j? photonSFTools : photonEffTools);
129 handles.push_back(
t->getHandle());
132 name = handles[handles.size()-1].name();
133 legsPerTool[
name] =
cfg[cLEGS];
138 Info(
MSGSOURCE,
"Configuring the global trigger SF tool");
140 myTool.
setProperty(
"PhotonEfficiencyTools", photonEffTools).ignore();
141 myTool.
setProperty(
"PhotonScaleFactorTools", photonSFTools).ignore();
142 myTool.
setProperty(
"TriggerCombination2015",
"g35_loose_g25_loose").ignore();
143 myTool.
setProperty(
"TriggerCombination2016",
"g35_loose_g25_loose").ignore();
144 myTool.
setProperty(
"TriggerCombination2017",
"g35_medium_g25_medium_L12EM20VH").ignore();
145 myTool.
setProperty(
"TriggerCombination2018",
"g35_medium_g25_medium_L12EM20VH").ignore();
146 myTool.
setProperty(
"ListOfLegsPerTool", legsPerTool).ignore();
149 if(toys) myTool.
setProperty(
"NumberOfToys", 1000).ignore();
150 if(myTool.
initialize() != StatusCode::SUCCESS)
158 const unsigned periodRuns[] = {
160 276262, 278727, 279932, 280423, 281130, 282625,
162 297730, 300345, 301912, 302737, 303638, 303943, 305291, 307124,
163 305359, 309311, 310015,
165 325713, 329385, 330857, 332720, 334842, 336497, 336832, 338183,
167 348885, 349534, 350310, 352274, 354107, 354826, 355261, 355331,
168 355529, 357050, 359191
170 std::uniform_int_distribution<unsigned> uniformPdf(0,
171 sizeof(periodRuns)/
sizeof(*periodRuns) - 1);
172 std::default_random_engine randomEngine;
176 Info(
MSGSOURCE,
"Starting the event loop");
178 double nSuitableEvents = 0., sumW = 0.;
183 event.getEntry(
entry);
187 event.retrieve(eventInfo,
"EventInfo").ignore();
188 unsigned runNumber = periodRuns[uniformPdf(randomEngine)];
189 RandomRunNumberDec(*eventInfo) =
runNumber;
191 vector<const xAOD::Photon*> myTriggeringPhotons;
193 event.retrieve(photons,
"Photons").ignore();
195 for(
auto photon : *photons)
197 if(!
photon->caloCluster())
continue;
198 float eta = fabs(
photon->caloCluster()->etaBE(2));
200 if(pt<10e3f || eta>=2.37 || (
eta>1.37 &&
eta<1.52))
continue;
204 if(
pt < 26e3f)
continue;
205 myTriggeringPhotons.push_back(
photon);
206 if(
pt > 36e3f) ++n36;
210 if(myTriggeringPhotons.size()<2 || n36<1)
continue;
217 nSuitableEvents += 1;
222 Warning(
MSGSOURCE,
"Scale factor evaluation failed");
231 Info(
MSGSOURCE,
"Average scale factor: %f (over %ld events)",
232 sumW / nSuitableEvents,
long(nSuitableEvents));
233 #ifndef XAOD_STANDALONE