Uniform random run number generation spanning the target dataset. In real life, use the PileupReweightingTool instead!
56{
59 bool debug =
false,
fast =
false, cmdline_error =
false;
61 {
62 if(
string(argv[i]) ==
"--debug")
debug =
true;
63 if(
string(argv[i]) ==
"--fast")
fast =
true;
65 else cmdline_error = true;
66 }
67 if(!filename || cmdline_error)
68 {
70 Error(
MSGSOURCE,
" Usage: %s [--debug] [--fast] [DxAOD file name]", argv[0]);
71 return 1;
72 }
73 #ifdef XAOD_STANDALONE
75 TFile*
file = TFile::Open(filename,
"READ");
77 {
79 return 2;
80 }
83 StatusCode::enableFailure();
84 #else
87 TString
file(filename);
88 #endif
89 event.readFrom(
file).ignore();
90 Long64_t
entries =
event.getEntries();
93
94
96 if(trigConfTool.initialize() != StatusCode::SUCCESS)
97 {
99 return 3;
100 }
102 trigDecTool.setProperty("ConfigTool", trigConfTool.getHandle()).ignore();
103 trigDecTool.setProperty("TrigDecisionKey", "xTrigDecision").ignore();
104 if(trigDecTool.initialize() != StatusCode::SUCCESS)
105 {
106 Error(
MSGSOURCE,
"Unable to initialize the trigger matching tool!");
107 return 3;
108 }
110 trigMatchTool.setProperty("TrigDecisionTool", trigDecTool.getHandle()).ignore();
111 if(trigMatchTool.initialize() != StatusCode::SUCCESS)
112 {
113 Error(
MSGSOURCE,
"Unable to initialize the trigger matching tool!");
114 return 3;
115 }
116
117
118
121 const char* triggers2015 =
122 "mu20_iloose_L1MU15_OR_mu50"
123 "|| mu18_mu8noL1"
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"
129 "|| mu22_mu8noL1"
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();
134 if(
debug) myTool.setProperty(
"OutputLevel", MSG::DEBUG).ignore();
135 if(myTool.initialize() != StatusCode::SUCCESS)
136 {
138 return 3;
139 }
140
143 const unsigned periodRuns[] = {
144 276073, 278727, 279932, 280423, 281130, 282625,
145 296939, 300345, 301912, 302737, 303638, 303943, 305291, 307124,
146 305359, 309311, 310015
147 };
148 std::uniform_int_distribution<unsigned> uniformPdf(0,
149 sizeof(periodRuns)/sizeof(*periodRuns) - 1);
150 std::default_random_engine randomEngine;
151
154
155
156
159 double nSuitableEvents = 0., nMatched = 0.;
162 {
163 event.getEntry(entry);
164
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();
173 for(auto electron : *electrons)
174 {
175 if(!
electron->caloCluster())
continue;
176 float eta = fabs(
electron->caloCluster()->etaBE(2));
178 if(pt<10e3f || eta>=2.47) continue;
179 if(!
truthType.isAvailable(*electron))
continue;
182 if(t!=2 || !(o==10 || (o>=12 && o<=22) || o==43)) continue;
183 myTriggeringElectrons.push_back(electron);
184 }
185
186 vector<const xAOD::Muon*> myTriggeringMuons;
188 event.retrieve(muons,"Muons").ignore();
189 for(auto muon : *muons)
190 {
192 if(pt<10e3f || fabs(
muon->eta())>=2.5)
continue;
193 auto mt =
muon->muonType();
194 if(mt!=xAOD::Muon::Combined && mt!=xAOD::Muon::MuonStandAlone) continue;
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);
201 }
203 if(myTriggeringElectrons.size()+myTriggeringMuons.size() < 1) continue;
204 nSuitableEvents += 1;
205
206 bool matched = false;
207 if(myTool->checkTriggerMatching(matched, myTriggeringElectrons, myTriggeringMuons) !=
CP::CorrectionCode::Ok)
208 {
209 Error(
MSGSOURCE,
"trigger matching could not be checked, interrupting execution");
211 break;
212 }
213
214 if(matched) nMatched += 1;
215 }
216
217 if(errors < nSuitableEvents)
218 {
219 Info(
MSGSOURCE,
"Fraction of trigger-matched events: %f (over %ld events)",
220 nMatched / nSuitableEvents, long(nSuitableEvents));
221 }
222
223 #ifndef XAOD_STANDALONE
225 #endif
227}
Scalar eta() const
pseudorapidity method
@ Ok
The correction was done successfully.
Helper class to provide constant type-safe access to aux data.
Helper class to provide type-safe access to aux data.
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 truthOrigin(const U &p)
int truthType(const U &p)
Error
The different types of error that can be flagged in the L1TopoRDO.
IAppMgrUI * Init(const char *options="POOLRootAccess/basic.opts")
Bootstraps (creates and configures) the Gaudi Application with the provided options file.
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".