Uniform random run number generation spanning the target dataset. In real life, use the PileupReweightingTool instead!
59 bool debug =
false,
fast =
false, cmdline_error =
false;
63 if(
string(
argv[
i]) ==
"--fast")
fast =
true;
65 else cmdline_error =
true;
73 #ifdef XAOD_STANDALONE
83 StatusCode::enableFailure();
89 event.readFrom(
file).ignore();
90 Long64_t
entries =
event.getEntries();
96 if(trigConfTool.initialize() != StatusCode::SUCCESS)
102 trigDecTool.setProperty(
"ConfigTool", trigConfTool.getHandle()).ignore();
103 trigDecTool.setProperty(
"TrigDecisionKey",
"xTrigDecision").ignore();
104 if(trigDecTool.initialize() != StatusCode::SUCCESS)
106 Error(
MSGSOURCE,
"Unable to initialize the trigger matching tool!");
110 trigMatchTool.setProperty(
"TrigDecisionTool", trigDecTool.getHandle()).ignore();
111 if(trigMatchTool.initialize() != StatusCode::SUCCESS)
113 Error(
MSGSOURCE,
"Unable to initialize the trigger matching tool!");
121 const char* triggers2015 =
122 "mu20_iloose_L1MU15_OR_mu50"
124 "|| e24_lhmedium_L1EM20VH_OR_e60_lhmedium_OR_e120_lhloose"
125 "|| 2e12_lhloose_L12EM10VH";
126 myTool.setProperty(
"TriggerCombination2015", triggers2015).ignore();
127 const char* triggers2016 =
128 "mu26_ivarmedium_OR_mu50"
130 "|| e26_lhtight_nod0_ivarloose_OR_e60_lhmedium_nod0_OR_e140_lhloose_nod0"
131 "|| 2e17_lhvloose_nod0";
132 myTool.setProperty(
"TriggerCombination2016", triggers2016).ignore();
133 myTool.setProperty(
"TriggerMatchingTool", trigMatchTool.getHandle()).ignore();
135 if(myTool.initialize() != StatusCode::SUCCESS)
143 const unsigned periodRuns[] = {
144 276073, 278727, 279932, 280423, 281130, 282625,
145 296939, 300345, 301912, 302737, 303638, 303943, 305291, 307124,
146 305359, 309311, 310015
148 std::uniform_int_distribution<unsigned> uniformPdf(0,
149 sizeof(periodRuns)/
sizeof(*periodRuns) - 1);
150 std::default_random_engine randomEngine;
159 double nSuitableEvents = 0., nMatched = 0.;
163 event.getEntry(
entry);
167 event.retrieve(eventInfo,
"EventInfo").ignore();
168 unsigned runNumber = periodRuns[uniformPdf(randomEngine)];
169 RandomRunNumberDec(*eventInfo) =
runNumber;
170 vector<const xAOD::Electron*> myTriggeringElectrons;
172 event.retrieve(
electrons,
"Electrons").ignore();
175 if(!
electron->caloCluster())
continue;
176 float eta = fabs(
electron->caloCluster()->etaBE(2));
178 if(pt<10e3f || eta>=2.47)
continue;
182 if(
t!=2 || !(o==10 || (o>=12 && o<=22) || o==43))
continue;
183 myTriggeringElectrons.push_back(
electron);
186 vector<const xAOD::Muon*> myTriggeringMuons;
188 event.retrieve(muons,
"Muons").ignore();
189 for(
auto muon : *muons)
192 if(
pt<10e3f || fabs(
muon->eta())>=2.5)
continue;
193 auto mt =
muon->muonType();
195 auto& mtp = *(
muon->primaryTrackParticle());
196 if(!
truthType.isAvailable(mtp))
continue;
199 if(
t!=6 || !(o==10 || (o>=12 && o<=22) || o==43))
continue;
200 myTriggeringMuons.push_back(
muon);
203 if(myTriggeringElectrons.size()+myTriggeringMuons.size() < 1)
continue;
204 nSuitableEvents += 1;
209 Error(
MSGSOURCE,
"trigger matching could not be checked, interrupting execution");
217 if(
errors < nSuitableEvents)
219 Info(
MSGSOURCE,
"Fraction of trigger-matched events: %f (over %ld events)",
220 nMatched / nSuitableEvents,
long(nSuitableEvents));
223 #ifndef XAOD_STANDALONE