18 #ifdef XAOD_STANDALONE
45 #define MSGSOURCE "Example 5a"
54 bool debug =
false, cmdline_error =
false, toys =
false;
58 else if(
string(
argv[
i]) ==
"--toys") toys =
true;
60 else cmdline_error =
true;
68 #ifdef XAOD_STANDALONE
78 StatusCode::enableFailure();
84 event.readFrom(
file).ignore();
85 Long64_t
entries =
event.getEntries();
90 Info(
MSGSOURCE,
"Configuring the photon CP tools");
92 ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonEffTools;
94 ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonSFTools;
97 vector<asg::AnaToolHandle<IAsgPhotonEfficiencyCorrectionTool>> factory;
99 const char* mapPath =
"PhotonEfficiencyCorrection/2015_2018/"
100 "rel21.2/Summer2018_Rec_v1/map1.txt";
103 string name =
"AsgPhotonEfficiencyCorrectionTool/" + std::string(j?
"PhTrigEff" :
"PhTrigSF");
104 auto t = factory.emplace(factory.end(),
name);
105 t->setProperty(
"MapFilePath", mapPath).ignore();
106 t->setProperty(
"TriggerKey",
string(j?
"":
"Eff_") +
"DI_PH_2015_2016_g20_tight_2016_g22_tight_2017_2018_g20_tight_icalovloose_L1EM15VHI").ignore();
107 t->setProperty(
"IsoKey",
"Loose").ignore();
109 if(
t->initialize() != StatusCode::SUCCESS)
115 auto& handles = (j? photonSFTools : photonEffTools);
116 handles.push_back(
t->getHandle());
121 Info(
MSGSOURCE,
"Configuring the global trigger SF tool");
123 myTool.
setProperty(
"PhotonEfficiencyTools", photonEffTools).ignore();
124 myTool.
setProperty(
"PhotonScaleFactorTools", photonSFTools).ignore();
125 std::map<std::string, std::string>
triggers;
126 triggers[
"266904-302872"] =
"2g20_tight";
127 triggers[
"302919-311481"] =
"2g22_tight";
128 triggers[
"2017"] =
"2g22_tight_L12EM15VHI";
129 triggers[
"2018"] =
"2g22_tight_L12EM15VHI";
133 if(toys) myTool.
setProperty(
"NumberOfToys", 1000).ignore();
134 if(myTool.
initialize() != StatusCode::SUCCESS)
142 const unsigned periodRuns[] = {
144 276262, 278727, 279932, 280423, 281130, 282625,
146 297730, 300345, 301912, 302737, 303638, 303943, 305291, 307124,
147 305359, 309311, 310015,
149 325713, 329385, 330857, 332720, 334842, 336497, 336832, 338183,
151 348885, 349534, 350310, 352274, 354107, 354826, 355261, 355331,
152 355529, 357050, 359191
154 std::uniform_int_distribution<unsigned> uniformPdf(0,
155 sizeof(periodRuns)/
sizeof(*periodRuns) - 1);
156 std::default_random_engine randomEngine;
160 Info(
MSGSOURCE,
"Starting the event loop");
162 double nSuitableEvents = 0., sumW = 0.;
167 event.getEntry(
entry);
171 event.retrieve(eventInfo,
"EventInfo").ignore();
172 unsigned runNumber = periodRuns[uniformPdf(randomEngine)];
173 RandomRunNumberDec(*eventInfo) =
runNumber;
175 vector<const xAOD::Photon*> myTriggeringPhotons;
177 event.retrieve(photons,
"Photons").ignore();
178 for(
auto photon : *photons)
180 if(!
photon->caloCluster())
continue;
181 float eta = fabs(
photon->caloCluster()->etaBE(2));
183 if(pt<10e3f || eta>=2.37 || (
eta>1.37 &&
eta<1.52))
continue;
187 if(
pt < (
runNumber>=302919? 23e3f : 21e3f))
continue;
188 myTriggeringPhotons.push_back(
photon);
192 if(myTriggeringPhotons.size() < 2)
continue;
199 nSuitableEvents += 1;
204 Warning(
MSGSOURCE,
"Scale factor evaluation failed");
213 Info(
MSGSOURCE,
"Average scale factor: %f (over %ld events)",
214 sumW / nSuitableEvents,
long(nSuitableEvents));
215 #ifndef XAOD_STANDALONE