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> |
7 |
> |
#include <bitset> |
8 |
|
using namespace std; |
9 |
|
|
10 |
|
// |
11 |
< |
// ROOT headers |
11 |
> |
// root headers |
12 |
|
// |
13 |
< |
#include <TROOT.h> // access to gROOT, entry point to ROOT system |
14 |
< |
#include <TSystem.h> // interface to OS |
15 |
< |
#include <TFile.h> // file handle class |
16 |
< |
#include <TNtuple.h> |
17 |
< |
#include <TTree.h> // class to access ntuples |
18 |
< |
#include <TChain.h> // |
19 |
< |
#include <TBranch.h> // class to access branches in TTree |
20 |
< |
#include <TClonesArray.h> // ROOT array class |
21 |
< |
#include <TCanvas.h> // class for drawing |
22 |
< |
#include <TH1F.h> // 1D histograms |
23 |
< |
#include <TBenchmark.h> // class to track macro running statistics |
24 |
< |
#include <TLorentzVector.h> // 4-vector class |
25 |
< |
#include <TVector3.h> // 3D vector class |
13 |
> |
#include <TFile.h> |
14 |
> |
#include <TTree.h> |
15 |
> |
#include <TChain.h> |
16 |
> |
#include <TBranch.h> |
17 |
> |
#include <TClonesArray.h> |
18 |
> |
|
19 |
> |
|
20 |
> |
// |
21 |
> |
// TMVA |
22 |
> |
// |
23 |
> |
#include "TMVA/Reader.h" |
24 |
> |
#include "TMVA/Tools.h" |
25 |
> |
#include "TMVA/Config.h" |
26 |
> |
#include "TMVA/MethodBDT.h" |
27 |
|
|
28 |
|
// |
29 |
|
// ntuple format headers |
30 |
|
// |
31 |
< |
#include "HiggsAnaDefs.hh" |
32 |
< |
#include "TEventInfo.hh" |
33 |
< |
#include "TElectron.hh" |
34 |
< |
#include "TMuon.hh" |
35 |
< |
#include "TJet.hh" |
36 |
< |
#include "SiMVAElectronSelection.h" |
37 |
< |
#include "RunLumiRangeMap.h" |
31 |
> |
#include "EventHeader.h" |
32 |
> |
#include "Electron.h" |
33 |
> |
#include "Muon.h" |
34 |
> |
#include "Vertex.h" |
35 |
> |
#include "PFCandidate.h" |
36 |
> |
#include "PFCandidateCol.h" |
37 |
> |
#include "TriggerMask.h" |
38 |
> |
#include "TriggerTable.h" |
39 |
> |
#include "Names.h" |
40 |
> |
#include "BaseMod.h" |
41 |
|
|
42 |
|
// |
43 |
< |
// utility headers |
43 |
> |
// our headers |
44 |
|
// |
45 |
|
#include "ParseArgs.h" |
46 |
+ |
#include "MuonSelection.h" |
47 |
+ |
#include "ElectronSelection.h" |
48 |
+ |
#include "IsolationSelection.h" |
49 |
+ |
|
50 |
+ |
//#include "Selection.h" |
51 |
+ |
#include "ReferenceSelection.h" |
52 |
+ |
|
53 |
+ |
#include "TriggerUtils.h" |
54 |
+ |
#include "PassHLT.h" |
55 |
+ |
#include "Angles.h" |
56 |
+ |
#include "KinematicsStruct.h" |
57 |
+ |
#include "InfoStruct.h" |
58 |
+ |
//#include "GenInfoStruct.h" |
59 |
+ |
#include "WeightStruct.h" |
60 |
+ |
#include "GlobalDataAndFuncs.h" |
61 |
+ |
|
62 |
+ |
#include "AngleTuple.h" |
63 |
+ |
#include "FOTuple.h" |
64 |
+ |
|
65 |
|
#include "SampleWeight.h" |
66 |
< |
#include "Selection.h" |
67 |
< |
#include "HZZCiCElectronSelection.h" |
68 |
< |
#include "HZZLikelihoodElectronSelection.h" |
69 |
< |
#include "HZZBDTElectronSelection.h" |
70 |
< |
#include "SampleWeight.h" |
66 |
> |
#include "EfficiencyWeightsInterface.h" |
67 |
> |
|
68 |
> |
#ifndef CMSSW_BASE |
69 |
> |
#define CMSSW_BASE "../" |
70 |
> |
#endif |
71 |
> |
|
72 |
> |
using namespace mithep; |
73 |
|
|
74 |
< |
//#define BDTFAIL_THEIR_EVENTS |
75 |
< |
//#define THEIR_EVENTS |
74 |
> |
#include "SimpleLepton.h" |
75 |
> |
vector<SimpleLepton> failedLeptons; // for fake estimation |
76 |
> |
|
77 |
> |
//---------------------------------------------------------------------------- |
78 |
> |
bool setPV(ControlFlags,const mithep::Array<mithep::Vertex>*, mithep::Vertex& ); |
79 |
> |
//---------------------------------------------------------------------------- |
80 |
|
|
81 |
|
//=== MAIN ================================================================================================= |
82 |
|
int main(int argc, char** argv) |
83 |
|
{ |
84 |
< |
|
84 |
> |
string cmsswpath(CMSSW_BASE); |
85 |
> |
cmsswpath.append("/src"); |
86 |
> |
std::bitset<1024> triggerBits; |
87 |
|
vector<vector<string> > inputFiles; |
88 |
|
inputFiles.push_back(vector<string>()); |
89 |
+ |
map<string,double> entrymap; // number of unskimmed entries in each file |
90 |
|
|
91 |
|
// |
92 |
|
// args |
93 |
|
//-------------------------------------------------------------------------------------------------------------- |
94 |
|
ControlFlags ctrl; |
95 |
|
parse_args( argc, argv, ctrl ); |
96 |
< |
if( ctrl.inputfile.empty() || |
97 |
< |
ctrl.inputfile.empty() ) { |
98 |
< |
cerr << "usage: applySelection.exe <flags> " << endl; |
99 |
< |
cerr << "\tmandoatory flags : " << endl; |
100 |
< |
cerr << "\t--inputfile | file containing a list of ntuples to run over" << endl; |
101 |
< |
cerr << "\t--outputfile | file to store selected evet" << endl; |
102 |
< |
return 1; |
103 |
< |
} |
96 |
> |
if( ctrl.inputfiles.empty() &&ctrl.inputfile.empty() ) |
97 |
> |
{ |
98 |
> |
cerr << "usage: applySelection.exe <flags> " << endl; |
99 |
> |
cerr << "\tmandoatory flags : " << endl; |
100 |
> |
cerr << "\t--inputfiles | file containing a list of ntuples to run over" << endl; |
101 |
> |
cerr << "\t--inputfile | a file to run over" << endl; |
102 |
> |
cerr << "\t--outputfile | file to store selected evet" << endl; |
103 |
> |
return 1; |
104 |
> |
} |
105 |
|
ctrl.dump(); |
106 |
|
|
107 |
< |
map<string,double> entrymap; // number of unskimmed entries in each file |
107 |
> |
|
108 |
|
|
109 |
|
// |
110 |
|
// File I/O |
111 |
|
//-------------------------------------------------------------------------------------------------------------- |
112 |
|
TChain * chain = new TChain("Events"); |
113 |
< |
ifstream f(ctrl.inputfile.c_str()); |
113 |
> |
TChain * hltchain = new TChain("HLT"); |
114 |
> |
|
115 |
|
string fname; |
116 |
< |
while (f >> fname) { |
117 |
< |
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines |
118 |
< |
cout << "adding inputfile : " << fname.c_str() << endl; |
119 |
< |
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str()); |
120 |
< |
chain->AddFile(fname.c_str()); |
116 |
> |
if( !ctrl.inputfiles.empty() ) { |
117 |
> |
ifstream f(ctrl.inputfiles.c_str()); |
118 |
> |
while (f >> fname) { |
119 |
> |
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines |
120 |
> |
cout << "adding inputfile : " << fname.c_str() << endl; |
121 |
> |
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str()); |
122 |
> |
chain->AddFile(fname.c_str()); |
123 |
> |
hltchain->AddFile(fname.c_str()); |
124 |
> |
} |
125 |
> |
} else { |
126 |
> |
cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl; |
127 |
> |
entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str()); |
128 |
> |
chain->AddFile(ctrl.inputfile.c_str()); |
129 |
> |
hltchain->AddFile(ctrl.inputfile.c_str()); |
130 |
|
} |
131 |
|
|
132 |
+ |
const char * ofname; |
133 |
+ |
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
134 |
+ |
ofname = ctrl.outputfile.c_str(); |
135 |
+ |
} else { |
136 |
+ |
ofname = "tmp.root"; |
137 |
+ |
} |
138 |
|
// table of cross section values |
139 |
< |
SimpleTable xstab("./data/xs.dat"); |
139 |
> |
string xspath = (cmsswpath+string("/MitPhysics/data/xs.dat")); |
140 |
> |
cout << "xspath: " << xspath.c_str() << endl; |
141 |
> |
SimpleTable xstab(xspath.c_str()); |
142 |
> |
|
143 |
|
|
144 |
|
// |
145 |
|
// Setup |
146 |
|
//-------------------------------------------------------------------------------------------------------------- |
147 |
< |
TH1F * h_evt = new TH1F("hevt", "hevt", 2, 0, 2 ); |
148 |
< |
TH1F * h_evtfail = new TH1F("hevtfail", "hevtfail", 1024, 0, 1024 ); |
149 |
< |
// TNtuple * passtuple = new TNtuple( "passtuple", "passtuple", "run:evt:lumi:channel:mZ1:mZ2:m4l:pt4l:w" ); |
150 |
< |
TTree * passtuple = new TTree("passtuple", "passtuple" ); |
151 |
< |
unsigned run, evt, lumi, channel; |
105 |
< |
float mZ1, mZ2, m4l, pt4l; |
106 |
< |
double w; |
107 |
< |
passtuple->Branch("run", &run); |
108 |
< |
passtuple->Branch("evt", &evt); |
109 |
< |
passtuple->Branch("lumi", &lumi); |
110 |
< |
passtuple->Branch("mZ1", &mZ1); |
111 |
< |
passtuple->Branch("mZ2", &mZ2); |
112 |
< |
passtuple->Branch("m4l", &m4l); |
113 |
< |
passtuple->Branch("pt4l", &pt4l); |
114 |
< |
passtuple->Branch("w", &w); |
115 |
< |
initCiCSelection(); |
116 |
< |
if(ctrl.eleSele=="lik") initLikSelection(); |
117 |
< |
if(ctrl.eleSele=="bdt") initBDTSelection(); |
118 |
< |
if(ctrl.eleSele=="si" ) initSiMVAElectronSelection(); |
119 |
< |
initRunLumiRangeMap(); |
147 |
> |
Angles angles; |
148 |
> |
KinematicsStruct kinematics; |
149 |
> |
InfoStruct evtinfo; |
150 |
> |
WeightStruct weights; |
151 |
> |
// GenInfoStruct geninfo; |
152 |
|
|
153 |
< |
// |
154 |
< |
// Loop |
155 |
< |
//-------------------------------------------------------------------------------------------------------------- |
153 |
> |
|
154 |
> |
AngleTuple nt( (const char*)ofname, (const char*)"zznt"); |
155 |
> |
nt.makeAngleBranch(angles); |
156 |
> |
nt.makeKinematicsBranch(kinematics); |
157 |
> |
nt.makeInfoBranch(evtinfo); |
158 |
> |
FOTuple foTree( nt.getFile(), (const char*)"fo"); |
159 |
> |
foTree.makeSimpleLeptonBranch(failedLeptons); |
160 |
> |
|
161 |
> |
TH1F * h_w_hpt; |
162 |
> |
if(ctrl.mc) { |
163 |
> |
nt.makeWeightBranch(weights); |
164 |
> |
// nt.makeGenInfoBranch(geninfo); |
165 |
> |
initEfficiencyWeights(); |
166 |
> |
/* |
167 |
> |
// Higgs only, pt reweighting |
168 |
> |
if( ctrl.mH <= 140 ) { |
169 |
> |
char wptname[256]; |
170 |
> |
sprintf( wptname, "/data/blue/pharris/Flat/ntupler/root/weight_ptH_%i.root", ctrl.mH ); |
171 |
> |
TFile * f_hpt = new TFile(wptname); |
172 |
> |
f_hpt->Print(); |
173 |
> |
sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH); |
174 |
> |
h_w_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
175 |
> |
h_w_hpt->Print(); |
176 |
> |
} |
177 |
> |
*/ |
178 |
> |
} else { |
179 |
> |
initRunLumiRangeMap(); |
180 |
> |
} |
181 |
> |
|
182 |
> |
// initMuonIDMVA(); |
183 |
> |
initMuonIsoMVA(); |
184 |
> |
initElectronIDMVA(); |
185 |
> |
initElectronIsoMVA(); |
186 |
> |
initTrigger(); |
187 |
> |
|
188 |
> |
|
189 |
> |
|
190 |
> |
//########################################################################## |
191 |
> |
// Setup tree I/O |
192 |
> |
//########################################################################## |
193 |
|
|
194 |
|
// |
195 |
|
// Access samples and fill histograms |
196 |
|
TFile *inputFile=0; |
197 |
|
TTree *eventTree=0; |
198 |
< |
|
130 |
< |
// Data structures to store info from TTrees |
131 |
< |
mithep::TEventInfo *info = new mithep::TEventInfo(); |
132 |
< |
TClonesArray *electronArr = new TClonesArray("mithep::TElectron"); |
133 |
< |
TClonesArray *muonArr = new TClonesArray("mithep::TMuon"); |
134 |
< |
|
135 |
< |
|
136 |
< |
TBranch *infoBr; |
137 |
< |
TBranch *electronBr; |
138 |
< |
TBranch *muonBr; |
139 |
< |
|
140 |
< |
// chain->SetBranchStatus("*",0); //disable all branches |
141 |
< |
// chain->SetBranchStatus("Info", 1); |
142 |
< |
// chain->SetBranchStatus("Muon", 1); |
143 |
< |
// chain->SetBranchStatus("Electron", 1); |
144 |
< |
|
145 |
< |
chain->SetBranchAddress("Info", &info); |
146 |
< |
chain->SetBranchAddress("Electron", &electronArr); |
147 |
< |
chain->SetBranchAddress("Muon", &muonArr); |
148 |
< |
|
149 |
< |
|
150 |
< |
|
151 |
< |
cout << "nEntries: " << chain->GetEntries() << endl; |
152 |
< |
for(UInt_t ientry=0; ientry<chain->GetEntries(); ientry++) { |
153 |
< |
|
154 |
< |
chain->GetEntry(ientry); |
155 |
< |
if(!(ientry%100000)) cout << "entry: " << ientry << endl; |
156 |
< |
|
157 |
< |
// get event weight for this file |
158 |
< |
double eventweight=1; |
159 |
< |
if(ctrl.mc) eventweight = getWeight(xstab,entrymap,chain); |
160 |
< |
|
161 |
< |
#ifdef THEIR_EVENTS |
162 |
< |
if( !( info->evtNum == 504867308 || |
163 |
< |
info->evtNum == 368148849 || |
164 |
< |
info->evtNum == 129514273 || |
165 |
< |
info->evtNum == 286336207 || |
166 |
< |
info->evtNum == 344708580 || |
167 |
< |
info->evtNum == 30998576 || |
168 |
< |
info->evtNum == 155679852 || |
169 |
< |
info->evtNum == 394010457 || |
170 |
< |
info->evtNum == 917379387 || |
171 |
< |
info->evtNum == 78213037 || |
172 |
< |
info->evtNum == 337493970 || |
173 |
< |
info->evtNum == 1491724484 || |
174 |
< |
info->evtNum == 480301165 || |
175 |
< |
info->evtNum == 1038911933 || |
176 |
< |
info->evtNum == 876658967 || |
177 |
< |
info->evtNum == 966824024 || |
178 |
< |
info->evtNum == 141954801 || |
179 |
< |
info->evtNum == 160966858 || |
180 |
< |
info->evtNum == 191231387 || |
181 |
< |
info->evtNum == 66033190 || |
182 |
< |
info->evtNum == 10347106 || |
183 |
< |
info->evtNum == 107360878 ) ) continue; |
184 |
< |
#endif |
185 |
< |
|
186 |
< |
|
187 |
< |
#ifdef BDTFAIL_THEIR_EVENTS |
188 |
< |
if( !( info->evtNum == 78213037 || |
189 |
< |
info->evtNum == 876658967 ) ) continue; |
190 |
< |
|
191 |
< |
#endif |
192 |
< |
|
193 |
< |
unsigned evtfail = fails_HZZ4L_selection(ctrl, info, electronArr, muonArr, eventweight, passtuple); |
194 |
< |
h_evtfail->Fill( evtfail, eventweight ); |
195 |
< |
|
196 |
< |
|
197 |
< |
} //end loop over data |
198 |
< |
|
199 |
< |
|
200 |
< |
|
201 |
< |
delete info; |
202 |
< |
delete electronArr; |
203 |
< |
delete muonArr; |
204 |
< |
|
205 |
< |
|
206 |
< |
|
207 |
< |
//-------------------------------------------------------------------------------------------------------------- |
208 |
< |
// Save Histograms; |
209 |
< |
//============================================================================================================== |
210 |
< |
const char * ofname; |
211 |
< |
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
212 |
< |
ofname = ctrl.outputfile.c_str(); |
213 |
< |
} else { |
214 |
< |
ofname = "tmp.root"; |
215 |
< |
} |
198 |
> |
string currentFile(""); |
199 |
|
|
200 |
< |
TFile *file = new TFile(ofname, "RECREATE"); |
201 |
< |
h_evt->Write(); |
202 |
< |
h_evtfail->Write(); |
203 |
< |
passtuple->Write(); |
204 |
< |
file->Close(); |
205 |
< |
delete file; |
206 |
< |
|
207 |
< |
// map<TString,TMVA::Reader*>::iterator it; |
208 |
< |
// for(it=readers.begin(); it!=readers.end(); it++) delete (*it).second; |
200 |
> |
// Data structures to store info from TTrees |
201 |
> |
mithep::EventHeader *info = new mithep::EventHeader(); |
202 |
> |
// mithep::TGenInfo *ginfo = new mithep::TGenInfo(); |
203 |
> |
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
204 |
> |
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
205 |
> |
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
206 |
> |
mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>(); |
207 |
> |
mithep::Array<mithep::PileupEnergyDensity> *puArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
208 |
> |
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
209 |
> |
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
210 |
> |
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
211 |
> |
vector<string> *hltTableStrings = new vector<string>(); |
212 |
> |
|
213 |
> |
TString fElectronName(Names::gkElectronBrn); |
214 |
> |
TString fMuonName(Names::gkMuonBrn); |
215 |
> |
TString fInfoName(Names::gkEvtHeaderBrn); |
216 |
> |
TString fPrimVtxName(Names::gkPVBrn); |
217 |
> |
TString fPFCandidateName(Names::gkPFCandidatesBrn); |
218 |
> |
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
219 |
> |
TString fTrackName(Names::gkTrackBrn); |
220 |
> |
TString fTriggerMaskName(Names::gkHltBitBrn); |
221 |
> |
TString fTriggerTableName(Names::gkHltTableBrn); |
222 |
> |
|
223 |
> |
chain->SetBranchAddress(fInfoName, &info); |
224 |
> |
chain->SetBranchAddress(fElectronName, &electronArr); |
225 |
> |
chain->SetBranchAddress(fMuonName, &muonArr); |
226 |
> |
chain->SetBranchAddress(fPrimVtxName, &vtxArr); |
227 |
> |
chain->SetBranchAddress(fPFCandidateName, &pfArr); |
228 |
> |
chain->SetBranchAddress(fPileupEnergyDensityName, &puArr); |
229 |
> |
chain->SetBranchAddress(fTrackName, &trkArr); |
230 |
> |
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
231 |
> |
cout << "hlttable: " << fTriggerTableName << endl; |
232 |
> |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
233 |
> |
|
234 |
> |
mithep::Vertex vtx; // best primary vertex in the event |
235 |
> |
|
236 |
> |
// ginfo = NULL; |
237 |
> |
// if( ctrl.mc ) { chain->SetBranchAddress("Gen", &ginfo);} |
238 |
> |
|
239 |
> |
int count=0, pass=0; |
240 |
> |
float passcorr=0., passcorr_errup=0., passcorr_errdown=0.; |
241 |
> |
float denom[3]={0.,0.,0.}; |
242 |
> |
float numer[3]={0.,0.,0.}; |
243 |
> |
float numercorr[3]={0.,0.,0.}; |
244 |
> |
|
245 |
> |
// only 1 HLT table / file ??? |
246 |
> |
hltchain->GetEntry(0); |
247 |
> |
cerr << "here... " << endl; |
248 |
> |
|
249 |
> |
int imax = chain->GetEntries(); |
250 |
> |
cout << "nEntries: " << imax << endl; |
251 |
> |
|
252 |
> |
|
253 |
> |
//########################################################################## |
254 |
> |
// Loop !!!!!!!!! should alternate events here and +1 in the training ... |
255 |
> |
//########################################################################## |
256 |
> |
for(UInt_t ientry=0; ientry<imax; ientry++) |
257 |
> |
{ |
258 |
> |
chain->GetEntry(ientry); |
259 |
> |
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
260 |
> |
|
261 |
> |
setPV( ctrl, vtxArr, vtx); |
262 |
> |
|
263 |
> |
if(ctrl.mc) { |
264 |
> |
weights.w = getWeight(xstab,entrymap,chain); |
265 |
> |
} else { |
266 |
> |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
267 |
> |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
268 |
> |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
269 |
> |
hltchain->GetEntry(0); |
270 |
> |
hltTable->Clear(); |
271 |
> |
fillTriggerBits(hltTable, hltTableStrings ); |
272 |
> |
} |
273 |
> |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
274 |
> |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
275 |
> |
} |
276 |
> |
|
277 |
> |
|
278 |
> |
// |
279 |
> |
// trigger |
280 |
> |
// |
281 |
> |
if( !ctrl.mc ) { |
282 |
> |
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
283 |
> |
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
284 |
> |
continue; |
285 |
> |
} |
286 |
> |
} |
287 |
> |
|
288 |
> |
// |
289 |
> |
// lepton/kinematic selection ... |
290 |
> |
// |
291 |
> |
EventData ret4l = |
292 |
> |
apply_HZZ4L_reference_selection(ctrl, info, |
293 |
> |
vtx, |
294 |
> |
pfArr, |
295 |
> |
puArr, |
296 |
> |
electronArr, |
297 |
> |
&electronReferencePreSelection, |
298 |
> |
&electronReferenceIDMVASelection, |
299 |
> |
&electronReferenceIsoSelection, |
300 |
> |
muonArr, |
301 |
> |
&muonReferencePreSelection, |
302 |
> |
&muonIDPFSelection, |
303 |
> |
&muonReferenceIsoSelection); |
304 |
> |
/* |
305 |
> |
apply_HZZ4L_reference_selection(ctrl, info, |
306 |
> |
vtx, |
307 |
> |
pfArr, |
308 |
> |
puArr, |
309 |
> |
electronArr, |
310 |
> |
&electronPreSelection, |
311 |
> |
&electronIDMVASelection, |
312 |
> |
&electronIsoMVASelection, |
313 |
> |
muonArr, |
314 |
> |
&muonPreSelection, |
315 |
> |
&muonIDPFSelection, |
316 |
> |
&muonIsoMVASelection); |
317 |
> |
*/ |
318 |
> |
|
319 |
> |
if( ctrl.debug ) cout << endl; |
320 |
> |
|
321 |
> |
cout << "bits: " << ret4l.status.selectionBits << endl; |
322 |
> |
|
323 |
> |
if( ret4l.status.pass() ) { |
324 |
> |
|
325 |
> |
fillAngles(ret4l,angles); |
326 |
> |
fillKinematics(ret4l,kinematics); |
327 |
> |
fillEventInfo(info,evtinfo); |
328 |
> |
//if(ctrl.mc) fillGenInfo(ginfo,geninfo); |
329 |
> |
|
330 |
> |
/* |
331 |
> |
// only for Higgs < 140 |
332 |
> |
geninfo.weight *= h_w_hpt->GetBinContent(h_w_hpt->FindBin(geninfo.pt_zz)); |
333 |
> |
angles.bdt = reader->EvaluateMVA("BDTG"); |
334 |
> |
*/ |
335 |
> |
nt.Fill(); |
336 |
> |
|
337 |
> |
cerr << "PASS:: " |
338 |
> |
<< "\trun: " << evtinfo.run |
339 |
> |
<< "\tevt: " << evtinfo.evt |
340 |
> |
<< "\tlumi: " << evtinfo.lumi |
341 |
> |
<< "\tcostheta1: " << angles.costheta1 |
342 |
> |
<< "\tcostheta2: " << angles.costheta2 |
343 |
> |
<< "\tcostheta*: " << angles.costhetastar |
344 |
> |
<< "\tbdt: " << angles.bdt |
345 |
> |
<< endl; |
346 |
> |
pass++; |
347 |
> |
// if( pass > 3 ) break; |
348 |
> |
|
349 |
> |
} else if( ret4l.status.selectionBits.test(8) ) { // save for fakes ... |
350 |
> |
cout << "failedLeptons : " << failedLeptons.size() << endl; |
351 |
> |
for( int f=0; f<failedLeptons.size(); f++ ) { |
352 |
> |
cout << "f: " << f << "\t" |
353 |
> |
<< "type: " << failedLeptons[f].type << "\t" |
354 |
> |
<< "pT: " << failedLeptons[f].vec->Pt() |
355 |
> |
<< endl; |
356 |
> |
} |
357 |
> |
cout << endl; |
358 |
> |
// foTree.Fill(); |
359 |
> |
// break; |
360 |
> |
} |
361 |
> |
} |
362 |
|
|
363 |
< |
cerr << "done!" << endl; |
363 |
> |
// foTree.getTree()->Write(); |
364 |
> |
nt.WriteClose(); |
365 |
|
} |
366 |
|
|
367 |
< |
|
368 |
< |
|
367 |
> |
//---------------------------------------------------------------------------- |
368 |
> |
// |
369 |
> |
// Get primary vertices |
370 |
> |
// Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW) |
371 |
> |
// NOTE: if no PV is found from fitting tracks, the beamspot is used |
372 |
> |
// |
373 |
> |
//---------------------------------------------------------------------------- |
374 |
> |
bool setPV(ControlFlags ctrl, |
375 |
> |
const mithep::Array<mithep::Vertex> * vtxArr, |
376 |
> |
mithep::Vertex & vtx) |
377 |
> |
//---------------------------------------------------------------------------- |
378 |
> |
{ |
379 |
> |
const Vertex *bestPV = 0; |
380 |
> |
float best_sumpt=-1; |
381 |
> |
|
382 |
> |
// good PV requirements |
383 |
> |
const UInt_t fMinNTracksFit = 0; |
384 |
> |
const Double_t fMinNdof = 4; |
385 |
> |
const Double_t fMaxAbsZ = 24; |
386 |
> |
const Double_t fMaxRho = 2; |
387 |
> |
|
388 |
> |
for(int i=0; i<vtxArr->GetEntries(); ++i) { |
389 |
> |
const Vertex *pv = (Vertex*)(vtxArr->At(i)); |
390 |
> |
if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl; |
391 |
> |
|
392 |
> |
// Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used |
393 |
> |
// if(!pv->IsValid()) continue; |
394 |
> |
if(pv->NTracksFit() < fMinNTracksFit) continue; |
395 |
> |
if(pv->Ndof() < fMinNdof) continue; |
396 |
> |
if(fabs(pv->Z()) > fMaxAbsZ) continue; |
397 |
> |
if(pv->Position().Rho() > fMaxRho) continue; |
398 |
> |
|
399 |
> |
// take the first ... |
400 |
> |
bestPV = pv; |
401 |
> |
break; |
402 |
> |
|
403 |
> |
// this never reached ... |
404 |
> |
float tmp_sumpt=0; |
405 |
> |
for( int t=0; t<pv->NTracks(); t++ ) |
406 |
> |
tmp_sumpt += pv->Trk(t)->Pt(); |
407 |
> |
|
408 |
> |
if( tmp_sumpt > best_sumpt ) { |
409 |
> |
bestPV = pv; |
410 |
> |
best_sumpt = tmp_sumpt; |
411 |
> |
if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl; |
412 |
> |
} |
413 |
> |
} |
414 |
> |
|
415 |
> |
if(!bestPV) bestPV = vtxArr->At(0); |
416 |
> |
vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z()); |
417 |
> |
vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr()); |
418 |
> |
return true; |
419 |
> |
}; |