-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintEvents.cpp
More file actions
88 lines (57 loc) · 1.95 KB
/
printEvents.cpp
File metadata and controls
88 lines (57 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <TFile.h>
#include <TTree.h>
#include <TBranch.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TString.h>
#include <TCanvas.h>
#include <TEfficiency.h>
#include <TLatex.h>
#include <TStyle.h>
#include <sstream>
#include "TMVA/Tools.h"
#include "TMVA/Reader.h"
#include <Math/Math.h>
#include <TLorentzVector.h>
#include <Math/Vector3D.h>
#include <Math/DisplacementVector3D.h>
#include <Math/Vector3Dfwd.h>
#include <TBenchmark.h>
#include <iostream>
using namespace std;
void printEvents () {
gBenchmark->Start("running time");
ofstream file0;
file0.open ("events_noPU.txt");
ofstream file1;
file1.open ("events_PU.txt");
TString fileName[2] = {
"flatTree_QCD_Pt-15to7000_TuneCP5_Flat2018_13TeV_pythia8_training_noPU_EXT_sorted",
"flatTree_QCD_Pt-15to7000_TuneCP5_Flat2018_13TeV_pythia8_training_PU_EXT_sorted",
};
for (int k = 0; k < 2; k++) {
TFile *inputfile = new TFile( fileName[k] + ".root", "READ" );
cout << "Processing file " << inputfile->GetName() << "..." << endl;
//addressing branches
TTree *evt = (TTree*)inputfile->Get( "events_sorted" );
UInt_t myevtNo = 0;
evt->SetBranchAddress("evtNo", &myevtNo);
UInt_t myrunNo = 0;
evt->SetBranchAddress("runNo", &myrunNo);
UInt_t mylumiSec = 0;
evt->SetBranchAddress("lumiSec", &mylumiSec);
Long64_t nevents = evt->GetEntries();
for ( Long64_t ievent = 0; ievent < nevents; ++ievent ){
if ( !(ievent % 100 ) ) cout << "ievent = " << ievent << endl;
//get i-th entry in tree
evt->GetEntry( ievent );
if (k == 0) file0 << myrunNo << ":" << mylumiSec << ":" << myevtNo << "\n";
if (k == 1) file1 << myrunNo << ":" << mylumiSec << ":" << myevtNo << "\n";
}// end loop over events
inputfile->Close();
delete inputfile;
}//end loop over input files
file0.close();
file1.close();
gBenchmark->Show("running time");
}