56{
57 if(argc < 2){
58 std::cerr << "No input file specified! Exiting." << std::endl;
59 return EXIT_FAILURE;
60 }
61
62 TString fileNameFullPath =
argv[1];
64
65#ifdef XAOD_STANDALONE
67
68
69 TFile *
inFile = TFile::Open(fileName,
"READ");
70 if(!inFile){
71 std::cerr << "Invalid root file! Exiting." << std::endl;
72 return EXIT_FAILURE;
73 }
74
75
76 TString
sample =
"tree_NoSys";
77
78 std::cout <<
"Running sample: " <<
sample << std::endl;
79
80
82
83
84 std::vector<std::string> ff_file = { "FakeBkgTools/testValuesFF.root" };
85
86 ANA_CHECK( ffTool->setProperty(
"InputFiles", ff_file) );
87 ANA_CHECK( ffTool->setProperty(
"EnergyUnit",
"GeV") );
88 ANA_CHECK( ffTool->setProperty(
"SkipUncertainties",
true) );
89 ANA_CHECK( ffTool->setProperty(
"OutputLevel", MSG::FATAL) );
90
91
92
93 float convertToMeV = 1000.;
94
95
97 TChain*
chain =
new TChain(
"chain");
99
101
102 for(TString
dataset : datasets){
104 }
105
111
127
143
159
161
162
163
164 chain->SetBranchStatus(
"*",1);
165
166 TFile* outFile_nominal = new TFile("antiIDTimesFF_"+sample+"_nominal.root","RECREATE");
167 TTree* outTree_nominal =
chain->CloneTree(0);
168 outTree_nominal->SetTitle("fakes");
169 outTree_nominal->SetName("fakes");
170
171
172
175
176
177 std::unique_ptr<xAOD::EventInfo> eventInfo = std::make_unique<xAOD::EventInfo>();
178 std::unique_ptr<xAOD::EventAuxInfo> eventAuxInfo = std::make_unique<xAOD::EventAuxInfo>();
179
180 eventInfo->setStore(eventAuxInfo.get());
183
184
185
187
190
191
192 int nEventsProcessed(0);
193 int nEventsPassed(0);
194
197 std::cout << "processed " << nEventsProcessed << " events" << std::endl;
198 ++nEventsProcessed;
199
200 int getEntry =
chain->GetEntry(i);
201 if(getEntry < 1){
202 std::cerr << "GetEntry() error!! Either an I/O issue, or an invalid entry. Aborting." << std::endl;
203 abort();
204 }
205
206
207 runNumberDecor(*eventInfo) = 507;
208
209 std::vector<float> lepPt = {lep1Pt, lep2Pt, lep3Pt};
210 std::vector<float> lepEta = {lep1Eta, lep2Eta, lep3Eta};
211 std::vector<float> lepPhi = {lep1Phi, lep2Phi, lep3Phi};
212 std::vector<float> lepD0Sig = {lep1D0Sig, lep2D0Sig, lep3D0Sig};
213 std::vector<float> lepZ0SinTheta = {lep1Z0SinTheta, lep2Z0SinTheta, lep3Z0SinTheta};
214 std::vector<int> lepFlavor = {lep1Flavor, lep2Flavor, lep3Flavor};
215 std::vector<int> lepCharge = {lep1Charge, lep2Charge, lep3Charge};
216 std::vector<int> lepPassOR = {lep1PassOR, lep2PassOR, lep3PassOR};
217 std::vector<int> lepPassBL = {lep1PassBL, lep2PassBL, lep3PassBL};
218 std::vector<int> lepLoose = {lep1Loose, lep2Loose, lep3Loose};
219 std::vector<int> lepMedium = {lep1Medium, lep2Medium, lep3Medium};
220 std::vector<int> lepSignal = {lep1Signal, lep2Signal, lep3Signal};
221 std::vector<int> lepTruthMatched = {lep1TruthMatched, lep2TruthMatched, lep3TruthMatched};
222
224 FFWeight = 1;
225 nLep_antiID = 0;
226 lep1AntiID = 0;
227 lep2AntiID = 0;
228 lep3AntiID = 0;
229
230
231 int nTotalLeps = 3;
232
233
234
235 std::vector<int> lepPassSigID(nTotalLeps, 0);
236 std::vector<int> lepPassAntiID(nTotalLeps, 0);
237
238
239 for(auto part : particles){
241 }
243
244
245 for(
int i = 0;
i < nTotalLeps; ++
i){
246
247 bool passesSignal = false;
248 bool passesAntiID = false;
250
251
252 if( (lepFlavor).at(i) == 1 ){
253
254
255
256 passesSignal = (lepSignal).at(i);
257 passesAntiID = !(lepSignal).at(i);
258
259
260
261 lepPassSigID.at(i) = passesSignal;
262 lepPassAntiID.at(i) = passesAntiID;
263
265 }
266 else if( (lepFlavor).at(i) == 2){
267
268
269
270 passesSignal = (lepSignal).at(i);
271 passesAntiID = !(lepSignal).at(i);
272
273
274
275 lepPassSigID.at(i) = passesSignal;
276 lepPassAntiID.at(i) = passesAntiID;
277
279 }
280
281
282 if(!passesSignal && !passesAntiID) continue;
283
284
285
289 particle->setPtEtaPhi(lepPt.at(i)*convertToMeV,lepEta.at(i),lepPhi.at(i));
290 particle->setCharge(lepCharge.at(i));
291 tightDecor(*particle) = passesSignal;
293 }
297 particle->setP4(lepPt.at(i)*convertToMeV,lepEta.at(i),lepPhi.at(i));
298 particle->setCharge(lepCharge.at(i));
299 tightDecor(*particle) = passesSignal;
301 }
302 else{
303 std::cerr << "invalid lepton type!" << std::endl;
304 continue;
305 }
306
307
308
309 if(passesAntiID){
310
311 ++nLep_signal;
312 ++nLep_antiID;
313
314 if(i == 0){
315 lep1Signal = 1;
316 lep1AntiID = 1;
317 }
318 else if(i == 1){
319 lep2Signal = 1;
320 lep2AntiID = 1;
321 }
322 else if(i == 2){
323 lep3Signal = 1;
324 lep3AntiID = 1;
325 }
326 }
327
328 }
329
330
331 if(nLep_antiID == 0) continue;
332
333
334 float fbtWeight;
337
338
339
340
341 FFWeight = fbtWeight;
342 std::cout << "nLep_antiID " << nLep_antiID << std::endl;
343 std::cout << "FFWeight " << FFWeight << std::endl;
344
345
346 outTree_nominal->Fill();
347
348
349 ++nEventsPassed;
350
351 }
352
353 std::cout << "nEventsProcessed is " << nEventsProcessed << " and nEventsPassed is " << nEventsPassed << std::endl;
354
355 outFile_nominal->Write();
356
358 delete ffTool;
359 delete outFile_nominal;
360 delete tStore;
361 delete tEvent;
362
363#endif
364
365 return EXIT_SUCCESS;
366}
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Helper class to provide type-safe access to aux data.
Class providing the definition of the 4-vector interface.
Tool for accessing xAOD files outside of Athena.
A relatively simple transient store for objects created in analysis.
#define READ_TREE_ADDRESSES(typeName, name)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
ObjectType
Type of objects that have a representation in the xAOD EDM.
@ Other
An object not falling into any of the other categories.
@ Muon
The object is a muon.
@ Electron
The object is an electron.
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.