1 |
khahn |
1.1 |
//
|
2 |
|
|
// System headers
|
3 |
|
|
//
|
4 |
|
|
#include <vector> // STL vector class
|
5 |
|
|
#include <iostream> // standard I/O
|
6 |
|
|
#include <iomanip> // functions to format standard I/O
|
7 |
|
|
#include <fstream> // functions for file I/O
|
8 |
|
|
#include <string> // C++ string class
|
9 |
|
|
#include <sstream> // class for parsing strings
|
10 |
|
|
#include <assert.h>
|
11 |
|
|
#include <stdlib.h>
|
12 |
|
|
#include <getopt.h>
|
13 |
|
|
using namespace std;
|
14 |
|
|
|
15 |
|
|
//
|
16 |
|
|
// ROOT headers
|
17 |
|
|
//
|
18 |
|
|
#include <TROOT.h> // access to gROOT, entry point to ROOT system
|
19 |
|
|
#include <TSystem.h> // interface to OS
|
20 |
|
|
#include <TFile.h> // file handle class
|
21 |
|
|
#include <TNtuple.h>
|
22 |
|
|
#include <TTree.h> // class to access ntuples
|
23 |
|
|
#include <TChain.h> //
|
24 |
|
|
#include <TBranch.h> // class to access branches in TTree
|
25 |
|
|
#include <TClonesArray.h> // ROOT array class
|
26 |
|
|
#include <TCanvas.h> // class for drawing
|
27 |
|
|
#include <TH1F.h> // 1D histograms
|
28 |
|
|
#include <TBenchmark.h> // class to track macro running statistics
|
29 |
|
|
#include <TLorentzVector.h> // 4-vector class
|
30 |
|
|
#include <TVector3.h> // 3D vector class
|
31 |
|
|
|
32 |
|
|
//
|
33 |
|
|
// ntuple format headers
|
34 |
|
|
//
|
35 |
|
|
#include "EWKAnaDefs.hh"
|
36 |
|
|
#include "TEventInfo.hh"
|
37 |
|
|
#include "TElectron.hh"
|
38 |
|
|
#include "TMuon.hh"
|
39 |
|
|
#include "TJet.hh"
|
40 |
|
|
#include "RunLumiRangeMap.h"
|
41 |
|
|
|
42 |
|
|
//
|
43 |
|
|
// utility headers
|
44 |
|
|
//
|
45 |
|
|
#include "ParseArgs.h"
|
46 |
|
|
#include "Selection.h"
|
47 |
|
|
#include "HZZCiCElectronSelection.h"
|
48 |
|
|
|
49 |
|
|
//#define THEIR_EVENTS
|
50 |
|
|
|
51 |
|
|
//=== MAIN =================================================================================================
|
52 |
|
|
int main(int argc, char** argv)
|
53 |
|
|
{
|
54 |
|
|
|
55 |
|
|
vector<vector<string> > inputFiles;
|
56 |
|
|
inputFiles.push_back(vector<string>());
|
57 |
|
|
|
58 |
|
|
//
|
59 |
|
|
// args
|
60 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
61 |
|
|
ControlFlags ctrl;
|
62 |
|
|
parse_args( argc, argv, ctrl );
|
63 |
|
|
if( ctrl.inputfile.empty() ||
|
64 |
|
|
ctrl.inputfile.empty() ) {
|
65 |
|
|
cerr << "usage: applySelection.exe <flags> " << endl;
|
66 |
|
|
cerr << "\tmandoatory flags : " << endl;
|
67 |
|
|
cerr << "\t--inputfile | file containing a list of ntuples to run over" << endl;
|
68 |
|
|
cerr << "\t--outputfile | file to store selected evet" << endl;
|
69 |
|
|
return 1;
|
70 |
|
|
}
|
71 |
|
|
ctrl.dump();
|
72 |
|
|
|
73 |
|
|
//
|
74 |
|
|
// File I/O
|
75 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
76 |
|
|
TChain * chain = new TChain("Events");
|
77 |
|
|
ifstream f(ctrl.inputfile.c_str());
|
78 |
|
|
string fname;
|
79 |
|
|
while (f >> fname) {
|
80 |
|
|
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines
|
81 |
|
|
cout << "adding inputfile : " << fname.c_str() << endl;
|
82 |
|
|
chain->AddFile(fname.c_str());
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
//
|
86 |
|
|
// Setup
|
87 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
88 |
|
|
TH1F * h_evt = new TH1F("hevt", "hevt", 2, 0, 2 );
|
89 |
|
|
TH1F * h_evtfail = new TH1F("hevtfail", "hevtfail", 100, 0, 100 );
|
90 |
|
|
TNtuple * passtuple = new TNtuple( "passtuple", "passtuple", "run:evt:lumi:channel:mZ1:mZ2:m4l:pt4l:w" );
|
91 |
|
|
initCiCSelection();
|
92 |
|
|
initRunLumiRangeMap();
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
//
|
96 |
|
|
// Loop
|
97 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
98 |
|
|
|
99 |
|
|
//
|
100 |
|
|
// Access samples and fill histograms
|
101 |
|
|
TFile *inputFile=0;
|
102 |
|
|
TTree *eventTree=0;
|
103 |
|
|
|
104 |
|
|
// Data structures to store info from TTrees
|
105 |
|
|
mithep::TEventInfo *info = new mithep::TEventInfo();
|
106 |
|
|
TClonesArray *electronArr = new TClonesArray("mithep::TElectron");
|
107 |
|
|
TClonesArray *muonArr = new TClonesArray("mithep::TMuon");
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
TBranch *infoBr;
|
111 |
|
|
TBranch *electronBr;
|
112 |
|
|
TBranch *muonBr;
|
113 |
|
|
|
114 |
|
|
// chain->SetBranchStatus("*",0); //disable all branches
|
115 |
|
|
// chain->SetBranchStatus("Info", 1);
|
116 |
|
|
// chain->SetBranchStatus("Muon", 1);
|
117 |
|
|
// chain->SetBranchStatus("Electron", 1);
|
118 |
|
|
|
119 |
|
|
chain->SetBranchAddress("Info", &info);
|
120 |
|
|
chain->SetBranchAddress("Electron", &electronArr);
|
121 |
|
|
chain->SetBranchAddress("Muon", &muonArr);
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
cout << "nEntries: " << chain->GetEntries() << endl;
|
126 |
|
|
for(UInt_t ientry=0; ientry<chain->GetEntries(); ientry++) {
|
127 |
|
|
|
128 |
|
|
chain->GetEntry(ientry);
|
129 |
|
|
|
130 |
|
|
#ifdef THEIR_EVENTS
|
131 |
|
|
if( !( info->evtNum == 504867308 ||
|
132 |
|
|
info->evtNum == 368148849 ||
|
133 |
|
|
info->evtNum == 129514273 ||
|
134 |
|
|
info->evtNum == 286336207 ||
|
135 |
|
|
info->evtNum == 344708580 ||
|
136 |
|
|
info->evtNum == 30998576 ||
|
137 |
|
|
info->evtNum == 155679852 ||
|
138 |
|
|
info->evtNum == 394010457 ||
|
139 |
|
|
info->evtNum == 917379387 ||
|
140 |
|
|
info->evtNum == 78213037 ||
|
141 |
|
|
info->evtNum == 337493970 ||
|
142 |
|
|
info->evtNum == 1491724484 ||
|
143 |
|
|
info->evtNum == 480301165 ||
|
144 |
|
|
info->evtNum == 1038911933 ||
|
145 |
|
|
info->evtNum == 876658967 ||
|
146 |
|
|
info->evtNum == 966824024 ||
|
147 |
|
|
info->evtNum == 141954801 ||
|
148 |
|
|
info->evtNum == 160966858 ||
|
149 |
|
|
info->evtNum == 191231387 ||
|
150 |
|
|
info->evtNum == 66033190 ||
|
151 |
|
|
info->evtNum == 10347106 ||
|
152 |
|
|
info->evtNum == 107360878 ) ) continue;
|
153 |
|
|
#endif
|
154 |
|
|
|
155 |
|
|
unsigned evtfail = fails_HZZ4L_selection(ctrl, info, electronArr, muonArr, passtuple );
|
156 |
|
|
double eventweight = info->eventweight;
|
157 |
|
|
h_evtfail->Fill( evtfail, eventweight );
|
158 |
|
|
cout << endl << endl;
|
159 |
|
|
|
160 |
|
|
} //end loop over data
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
delete info;
|
165 |
|
|
delete electronArr;
|
166 |
|
|
delete muonArr;
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
171 |
|
|
// Save Histograms;
|
172 |
|
|
//==============================================================================================================
|
173 |
|
|
const char * ofname;
|
174 |
|
|
if( strcmp( ctrl.outputfile.c_str(), "") ) {
|
175 |
|
|
ofname = ctrl.outputfile.c_str();
|
176 |
|
|
} else {
|
177 |
|
|
ofname = "tmp.root";
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
TFile *file = new TFile(ofname, "RECREATE");
|
181 |
|
|
h_evt->Write();
|
182 |
|
|
h_evtfail->Write();
|
183 |
|
|
passtuple->Write();
|
184 |
|
|
file->Close();
|
185 |
|
|
delete file;
|
186 |
|
|
|
187 |
|
|
cerr << "done!" << endl;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|