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 "HiggsAnaDefs.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 "SampleWeight.h"
|
47 |
#include "Selection.h"
|
48 |
#include "HZZCiCElectronSelection.h"
|
49 |
#include "HZZLikelihoodElectronSelection.h"
|
50 |
#include "HZZBDTElectronSelection.h"
|
51 |
#include "SampleWeight.h"
|
52 |
|
53 |
//#define THEIR_EVENTS
|
54 |
|
55 |
//=== MAIN =================================================================================================
|
56 |
int main(int argc, char** argv)
|
57 |
{
|
58 |
|
59 |
vector<vector<string> > inputFiles;
|
60 |
inputFiles.push_back(vector<string>());
|
61 |
|
62 |
//
|
63 |
// args
|
64 |
//--------------------------------------------------------------------------------------------------------------
|
65 |
ControlFlags ctrl;
|
66 |
parse_args( argc, argv, ctrl );
|
67 |
if( ctrl.inputfile.empty() ||
|
68 |
ctrl.inputfile.empty() ) {
|
69 |
cerr << "usage: applySelection.exe <flags> " << endl;
|
70 |
cerr << "\tmandoatory flags : " << endl;
|
71 |
cerr << "\t--inputfile | file containing a list of ntuples to run over" << endl;
|
72 |
cerr << "\t--outputfile | file to store selected evet" << endl;
|
73 |
return 1;
|
74 |
}
|
75 |
ctrl.dump();
|
76 |
|
77 |
map<string,double> entrymap; // number of unskimmed entries in each file
|
78 |
|
79 |
//
|
80 |
// File I/O
|
81 |
//--------------------------------------------------------------------------------------------------------------
|
82 |
TChain * chain = new TChain("Events");
|
83 |
ifstream f(ctrl.inputfile.c_str());
|
84 |
string fname;
|
85 |
while (f >> fname) {
|
86 |
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines
|
87 |
cout << "adding inputfile : " << fname.c_str() << endl;
|
88 |
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str());
|
89 |
chain->AddFile(fname.c_str());
|
90 |
}
|
91 |
|
92 |
// table of cross section values
|
93 |
SimpleTable xstab("./data/xs.dat");
|
94 |
|
95 |
//
|
96 |
// Setup
|
97 |
//--------------------------------------------------------------------------------------------------------------
|
98 |
TH1F * h_evt = new TH1F("hevt", "hevt", 2, 0, 2 );
|
99 |
TH1F * h_evtfail = new TH1F("hevtfail", "hevtfail", 1024, 0, 1024 );
|
100 |
// TNtuple * passtuple = new TNtuple( "passtuple", "passtuple", "run:evt:lumi:channel:mZ1:mZ2:m4l:pt4l:w" );
|
101 |
TTree * passtuple = new TTree("passtuple", "passtuple" );
|
102 |
unsigned run, evt, lumi, channel;
|
103 |
float mZ1, mZ2, m4l, pt4l, w;
|
104 |
passtuple->Branch("run", &run);
|
105 |
passtuple->Branch("evt", &evt);
|
106 |
passtuple->Branch("lumi", &lumi);
|
107 |
passtuple->Branch("mZ1", &mZ1);
|
108 |
passtuple->Branch("mZ2", &mZ2);
|
109 |
passtuple->Branch("m4l", &m4l);
|
110 |
passtuple->Branch("pt4l", &pt4l);
|
111 |
passtuple->Branch("w", &w);
|
112 |
initCiCSelection();
|
113 |
if(ctrl.eleSele=="lik") initLikSelection();
|
114 |
if(ctrl.eleSele=="bdt") initBDTSelection();
|
115 |
initRunLumiRangeMap();
|
116 |
|
117 |
//
|
118 |
// Loop
|
119 |
//--------------------------------------------------------------------------------------------------------------
|
120 |
|
121 |
//
|
122 |
// Access samples and fill histograms
|
123 |
TFile *inputFile=0;
|
124 |
TTree *eventTree=0;
|
125 |
|
126 |
// Data structures to store info from TTrees
|
127 |
mithep::TEventInfo *info = new mithep::TEventInfo();
|
128 |
TClonesArray *electronArr = new TClonesArray("mithep::TElectron");
|
129 |
TClonesArray *muonArr = new TClonesArray("mithep::TMuon");
|
130 |
|
131 |
|
132 |
TBranch *infoBr;
|
133 |
TBranch *electronBr;
|
134 |
TBranch *muonBr;
|
135 |
|
136 |
// chain->SetBranchStatus("*",0); //disable all branches
|
137 |
// chain->SetBranchStatus("Info", 1);
|
138 |
// chain->SetBranchStatus("Muon", 1);
|
139 |
// chain->SetBranchStatus("Electron", 1);
|
140 |
|
141 |
chain->SetBranchAddress("Info", &info);
|
142 |
chain->SetBranchAddress("Electron", &electronArr);
|
143 |
chain->SetBranchAddress("Muon", &muonArr);
|
144 |
|
145 |
|
146 |
|
147 |
cout << "nEntries: " << chain->GetEntries() << endl;
|
148 |
for(UInt_t ientry=0; ientry<chain->GetEntries(); ientry++) {
|
149 |
|
150 |
chain->GetEntry(ientry);
|
151 |
if(!(ientry%100000)) cout << "entry: " << ientry << endl;
|
152 |
|
153 |
// get event weight for this file
|
154 |
double eventweight=1;
|
155 |
if(ctrl.mc) eventweight = getWeight(xstab,entrymap,chain);
|
156 |
|
157 |
#ifdef THEIR_EVENTS
|
158 |
if( !( info->evtNum == 504867308 ||
|
159 |
info->evtNum == 368148849 ||
|
160 |
info->evtNum == 129514273 ||
|
161 |
info->evtNum == 286336207 ||
|
162 |
info->evtNum == 344708580 ||
|
163 |
info->evtNum == 30998576 ||
|
164 |
info->evtNum == 155679852 ||
|
165 |
info->evtNum == 394010457 ||
|
166 |
info->evtNum == 917379387 ||
|
167 |
info->evtNum == 78213037 ||
|
168 |
info->evtNum == 337493970 ||
|
169 |
info->evtNum == 1491724484 ||
|
170 |
info->evtNum == 480301165 ||
|
171 |
info->evtNum == 1038911933 ||
|
172 |
info->evtNum == 876658967 ||
|
173 |
info->evtNum == 966824024 ||
|
174 |
info->evtNum == 141954801 ||
|
175 |
info->evtNum == 160966858 ||
|
176 |
info->evtNum == 191231387 ||
|
177 |
info->evtNum == 66033190 ||
|
178 |
info->evtNum == 10347106 ||
|
179 |
info->evtNum == 107360878 ) ) continue;
|
180 |
#endif
|
181 |
|
182 |
unsigned evtfail = fails_HZZ4L_selection(ctrl, info, electronArr, muonArr, eventweight, passtuple);
|
183 |
h_evtfail->Fill( evtfail, eventweight );
|
184 |
if( ctrl.debug ) cout << endl << endl;
|
185 |
|
186 |
} //end loop over data
|
187 |
|
188 |
|
189 |
|
190 |
delete info;
|
191 |
delete electronArr;
|
192 |
delete muonArr;
|
193 |
|
194 |
|
195 |
|
196 |
//--------------------------------------------------------------------------------------------------------------
|
197 |
// Save Histograms;
|
198 |
//==============================================================================================================
|
199 |
const char * ofname;
|
200 |
if( strcmp( ctrl.outputfile.c_str(), "") ) {
|
201 |
ofname = ctrl.outputfile.c_str();
|
202 |
} else {
|
203 |
ofname = "tmp.root";
|
204 |
}
|
205 |
|
206 |
TFile *file = new TFile(ofname, "RECREATE");
|
207 |
h_evt->Write();
|
208 |
h_evtfail->Write();
|
209 |
passtuple->Write();
|
210 |
file->Close();
|
211 |
delete file;
|
212 |
|
213 |
// map<TString,TMVA::Reader*>::iterator it;
|
214 |
// for(it=readers.begin(); it!=readers.end(); it++) delete (*it).second;
|
215 |
|
216 |
cerr << "done!" << endl;
|
217 |
}
|
218 |
|
219 |
|
220 |
|