11 |
|
// |
12 |
|
// root headers |
13 |
|
// |
14 |
< |
#include <TFile.h> |
14 |
> |
#include <TFile.h> |
15 |
> |
#include <TRegexp.h> |
16 |
|
#include <TTree.h> |
17 |
|
#include <TChain.h> |
18 |
|
#include <TBranch.h> |
27 |
|
#include "TMVA/Config.h" |
28 |
|
#include "TMVA/MethodBDT.h" |
29 |
|
|
30 |
+ |
#include "FactorizedJetCorrector.h" |
31 |
+ |
#include "JetCorrectorParameters.h" |
32 |
+ |
|
33 |
|
// |
34 |
|
// ntuple format headers |
35 |
|
// |
38 |
|
#include "Muon.h" |
39 |
|
#include "Vertex.h" |
40 |
|
#include "PFMet.h" |
41 |
+ |
#include "PFJetCol.h" |
42 |
|
#include "PFCandidate.h" |
43 |
|
#include "PFCandidateCol.h" |
44 |
|
#include "PileupInfoCol.h" |
51 |
|
#include "Names.h" |
52 |
|
#include "BaseMod.h" |
53 |
|
#include "TriggerObjectsTable.h" |
54 |
+ |
#include "JetIDMVA.h" |
55 |
|
|
56 |
|
// |
57 |
|
// our headers |
59 |
|
#include "ParseArgs.h" |
60 |
|
#include "MuonSelection.h" |
61 |
|
#include "ElectronSelection.h" |
62 |
+ |
#include "ElectronMomentumCorrection.h" |
63 |
+ |
#include "JetSelection.h" |
64 |
|
#include "IsolationSelection.h" |
65 |
|
#include "ReferenceSelection.h" |
66 |
+ |
#include "MuonMomentumCorrection.h" |
67 |
|
|
68 |
|
#include "TriggerUtils.h" |
69 |
|
#include "PassHLT.h" |
61 |
– |
#include "Angles.h" |
70 |
|
#include "KinematicsStruct.h" |
71 |
|
#include "InfoStruct.h" |
72 |
|
#include "GenInfoStruct.h" |
81 |
|
|
82 |
|
#include "SimpleLepton.h" |
83 |
|
|
84 |
+ |
#include "Cintex/Cintex.h" |
85 |
+ |
|
86 |
|
#ifndef CMSSW_BASE |
87 |
|
#define CMSSW_BASE "../" |
88 |
|
#endif |
100 |
|
vector<vector<unsigned> > zcutvec; |
101 |
|
vector<vector<unsigned> > zzcutvec; |
102 |
|
map<unsigned,float> evtrhoMap; |
103 |
+ |
TrigInfo ti; |
104 |
|
vector<string> cutstrs; |
105 |
< |
bool passes_HLT_MC; |
105 |
> |
bool passes_HLT; |
106 |
|
vector<bool> PFnoPUflag;; |
107 |
+ |
map<TString, map<TString,int>* > counts; |
108 |
+ |
ElectronMomentumCorrection electron_momentum_correction; |
109 |
+ |
MuCorr *muCorr; |
110 |
+ |
void addDummyZ2Lepotons(EventData &ret4l); |
111 |
+ |
void setNtupleVals(ControlFlags &ctrl, EventData &ret4l, InfoStruct &evtinfo, Angles &angles, KinematicsStruct &kine, |
112 |
+ |
JetInfoStruct &ji, WeightStruct &weights, EventHeader *info, Array<Muon> *muonArr, Array<Electron> *electronArr, Array<PFJet> *jetArr, Array<PFMet> *metArr, |
113 |
+ |
vector<SimpleLepton> &simpleLeptonJets, FactorizedJetCorrector *fJetCorrector, Array<PileupInfo> *puArr, |
114 |
+ |
Array<PileupEnergyDensity> *puDArr, JetIDMVA *fJetIDMVA, Array<Vertex> *vtxArr, bitset<1024> &triggerBits, |
115 |
+ |
TriggerTable *hltTable, Array<TriggerObject> *hltObjArr, TriggerObjectsTable *fTrigObjs, AngleTuple *nt); |
116 |
+ |
//---------------------------------------------------------------------------- |
117 |
+ |
void initRunLumiRangeMap(ControlFlags &ctrl) |
118 |
+ |
//---------------------------------------------------------------------------- |
119 |
+ |
{ |
120 |
+ |
if(ctrl.jsonFile==""){ |
121 |
+ |
cout << "WARNING: running with empty jsonFile, so setting noJSON to true" << endl; |
122 |
+ |
ctrl.noJSON = true; |
123 |
+ |
} |
124 |
+ |
rlrm.AddJSONFile(string(ctrl.jsonFile)); |
125 |
+ |
} |
126 |
|
|
127 |
|
// |
128 |
|
// prototypes |
129 |
|
//---------------------------------------------------------------------------- |
100 |
– |
void initRunLumiRangeMap(ControlFlags &ctrl); |
101 |
– |
//---------------------------------------------------------------------------- |
102 |
– |
|
130 |
|
|
131 |
|
// |
132 |
|
// MAIN |
134 |
|
int main(int argc, char** argv) |
135 |
|
//---------------------------------------------------------------------------- |
136 |
|
{ |
110 |
– |
cutstrs.push_back(string("skim0")); //0 |
111 |
– |
cutstrs.push_back(string("skim1")); //1 |
112 |
– |
cutstrs.push_back(string("skim2")); //1 |
113 |
– |
cutstrs.push_back(string("trigger")); //2 |
114 |
– |
// ------------------------------------------------- |
115 |
– |
cutstrs.push_back(string("Z candidate")); //3 |
116 |
– |
cutstrs.push_back(string("good Z1")); //4 |
117 |
– |
// ------------------------------------------------- |
118 |
– |
cutstrs.push_back(string("4l")); //5 |
119 |
– |
cutstrs.push_back(string("ZZ candidate")); //6 |
120 |
– |
cutstrs.push_back(string("good Z2")); //7 |
121 |
– |
cutstrs.push_back(string("ZZ 20/10")); //8 |
122 |
– |
cutstrs.push_back(string("resonance")); //9 |
123 |
– |
cutstrs.push_back(string("m4l>70")); //10 |
124 |
– |
cutstrs.push_back(string("m4l>100, mZ2 > 12")); //11 |
125 |
– |
|
126 |
– |
|
127 |
– |
|
137 |
|
|
138 |
+ |
vector<TString> cuts; |
139 |
+ |
cuts.push_back("start"); // NOTE: is incremented in ReferenceSelection, so if you turn on JSONS be careful |
140 |
+ |
cuts.push_back("trigger"); |
141 |
+ |
cuts.push_back("sfOsHiPt"); |
142 |
+ |
cuts.push_back("4<mZ2<120"); |
143 |
+ |
cuts.push_back("pt>20,10"); |
144 |
+ |
cuts.push_back("mll>4"); |
145 |
+ |
cuts.push_back("m4l>70"); |
146 |
+ |
cuts.push_back("mZ2>12"); |
147 |
+ |
cuts.push_back("m4l>100"); |
148 |
+ |
cuts.push_back("m4l > 100 && >= 1 jets"); |
149 |
+ |
cuts.push_back("m4l > 100 && 2 jets"); |
150 |
+ |
cuts.push_back("m4l > 100 && fisher > 0.4"); |
151 |
+ |
|
152 |
+ |
for(unsigned icut=0; icut<cuts.size(); icut++) |
153 |
+ |
counts[cuts[icut]] = new map<TString,int>; |
154 |
+ |
|
155 |
+ |
map<TString,map<TString,int>* >::iterator cit; |
156 |
+ |
for(cit=counts.begin(); cit!=counts.end(); cit++) { |
157 |
+ |
map<TString,int> *cts = (*cit).second; |
158 |
+ |
(*cts)["all"] = int(0); |
159 |
+ |
(*cts)["4e"] = int(0); |
160 |
+ |
(*cts)["4m"] = int(0); |
161 |
+ |
(*cts)["2e2m"] = int(0); |
162 |
+ |
} |
163 |
+ |
|
164 |
|
string cmsswpath(CMSSW_BASE); |
165 |
|
cmsswpath.append("/src"); |
166 |
< |
std::bitset<1024> triggerBits; |
166 |
> |
bitset<1024> triggerBits; |
167 |
|
vector<vector<string> > inputFiles; |
168 |
|
inputFiles.push_back(vector<string>()); |
169 |
|
map<string,unsigned> entrymap; // number of unskimmed entries in each file |
135 |
– |
for( int i=0; i<cutstrs.size(); i++ ) cutvec.push_back(0); |
136 |
– |
for( int i=0; i<2; i++ ) { |
137 |
– |
zcutvec.push_back(vector<unsigned>()); |
138 |
– |
for( int j=0; j<cutstrs.size(); j++ ) zcutvec[i].push_back(0); |
139 |
– |
} |
140 |
– |
for( int i=0; i<3; i++ ) { |
141 |
– |
zzcutvec.push_back(vector<unsigned>()); |
142 |
– |
for( int j=0; j<cutstrs.size(); j++ ) zzcutvec[i].push_back(0); |
143 |
– |
} |
144 |
– |
|
170 |
|
|
171 |
|
// |
172 |
|
// args |
173 |
|
//-------------------------------------------------------------------------------------------------------------- |
174 |
|
ControlFlags ctrl; |
175 |
|
parse_args( argc, argv, ctrl ); |
151 |
– |
if( ctrl.inputfiles.empty() &&ctrl.inputfile.empty() ) |
152 |
– |
{ |
153 |
– |
cerr << "usage: applySelection.exe <flags> " << endl; |
154 |
– |
cerr << "\tmandoatory flags : " << endl; |
155 |
– |
cerr << "\t--inputfiles | file containing a list of ntuples to run over" << endl; |
156 |
– |
cerr << "\t--inputfile | a file to run over" << endl; |
157 |
– |
cerr << "\t--outputfile | file to store selected evet" << endl; |
158 |
– |
return 1; |
159 |
– |
} |
176 |
|
ctrl.dump(); |
177 |
< |
|
178 |
< |
|
177 |
> |
cout << "\n\nNOTE: now setting era with arguments... double check this doesnt mess something else up\n\n" << endl; |
178 |
> |
assert(ctrl.doFSR); |
179 |
|
|
180 |
|
// |
181 |
|
// File I/O |
182 |
|
//-------------------------------------------------------------------------------------------------------------- |
183 |
|
TChain * chain = new TChain("Events"); |
184 |
|
TChain * hltchain = new TChain("HLT"); |
185 |
+ |
TChain * runchain = new TChain(Names::gkRunTreeName); |
186 |
|
|
187 |
|
string fname; |
188 |
|
unsigned total_unskimmed=0; |
189 |
|
if( !ctrl.inputfiles.empty() ) { |
190 |
|
ifstream f(ctrl.inputfiles.c_str()); |
191 |
< |
while (f >> fname) { |
191 |
> |
while (f >> fname) { |
192 |
|
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines |
193 |
+ |
//if(fname.find("/store/") != string::npos) fname = "root://eoscms//"+fname; |
194 |
|
cout << "adding inputfile : " << fname.c_str() << endl; |
195 |
|
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str()); |
196 |
< |
cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl; |
196 |
> |
cerr << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl; |
197 |
|
total_unskimmed += entrymap[string(fname.c_str())]; |
198 |
|
chain->AddFile(fname.c_str()); |
199 |
|
hltchain->AddFile(fname.c_str()); |
200 |
+ |
runchain->AddFile(fname.c_str()); |
201 |
|
} |
202 |
|
} else { |
203 |
+ |
//if(ctrl.inputfile.find("/store/") != string::npos) ctrl.inputfile = "root://eoscms//"+ctrl.inputfile; |
204 |
|
cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl; |
205 |
|
unsigned unsk_ents = unskimmedEntries(ctrl.inputfile.c_str()); |
206 |
|
entrymap[string(ctrl.inputfile.c_str())] = unsk_ents; |
207 |
< |
cout << "unskimmed entries: " << unsk_ents << endl; |
207 |
> |
cerr << "unskimmed entries: " << unsk_ents << endl; |
208 |
|
total_unskimmed += unsk_ents; |
209 |
|
chain->AddFile(ctrl.inputfile.c_str()); |
210 |
|
hltchain->AddFile(ctrl.inputfile.c_str()); |
211 |
+ |
runchain->AddFile(ctrl.inputfile.c_str()); |
212 |
|
} |
213 |
< |
// // write the total number of unskimmed events that went into making this output file to a text file |
214 |
< |
// writeEntries(ctrl,total_unskimmed); |
213 |
> |
// write the total number of unskimmed events that went into making this output file to a text file |
214 |
> |
writeEntries(ctrl,total_unskimmed); |
215 |
> |
ctrl.totalMC = total_unskimmed; |
216 |
|
|
217 |
|
const char * ofname; |
218 |
|
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
224 |
|
string xspath = (cmsswpath+string("/MitPhysics/data/xs.dat")); |
225 |
|
cout << "xspath: " << xspath.c_str() << endl; |
226 |
|
SimpleTable xstab(xspath.c_str()); |
227 |
+ |
if(ctrl.mc) { |
228 |
+ |
if(ctrl.use_xs_weights) getWeight(xstab,entrymap,chain); // test *now* whether we've got the xs in here, so it fails before it creates the output |
229 |
+ |
} |
230 |
|
|
231 |
< |
|
231 |
> |
//root will write to this temporary file instead of to memory and the selection will run faster |
232 |
|
|
233 |
|
// |
234 |
|
// Setup |
235 |
|
//-------------------------------------------------------------------------------------------------------------- |
236 |
|
Angles angles; |
237 |
< |
KinematicsStruct kinematics; |
237 |
> |
KinematicsStruct kine; |
238 |
|
InfoStruct evtinfo; |
239 |
|
WeightStruct weights; |
240 |
|
GenInfoStruct geninfo; |
241 |
+ |
JetInfoStruct ji; |
242 |
+ |
vector<SimpleLepton> simpleLeptonJets; |
243 |
|
|
244 |
|
AngleTuple nt( (const char*)ofname, (const char*)"zznt"); |
245 |
|
nt.makeAngleBranch(angles); |
246 |
< |
nt.makeKinematicsBranch(kinematics); |
246 |
> |
nt.makeKinematicsBranch(kine); |
247 |
|
nt.makeInfoBranch(evtinfo); |
248 |
+ |
nt.makeJetInfoBranch(ji); |
249 |
+ |
//nt.makeJetAngleBranches("DataStruct/data/jetAngleVars.txt"); |
250 |
|
|
251 |
< |
|
252 |
< |
FOTuple foTree( nt.getFile(), (const char*)"FOtree"); |
253 |
< |
foTree.makeFailedLeptonBranch(failingLeptons); |
254 |
< |
foTree.makePassedLeptonBranch(passingLeptons); |
251 |
> |
FOTuple *foTree=0; |
252 |
> |
if(ctrl.fakeScheme != "none") { |
253 |
> |
foTree = new FOTuple( nt.getFile(), (const char*)"FOtree"); |
254 |
> |
foTree->makeInfoBranch(evtinfo); |
255 |
> |
foTree->makeFailedLeptonBranch(failingLeptons); |
256 |
> |
foTree->makePassedLeptonBranch(passingLeptons); |
257 |
> |
} |
258 |
|
|
259 |
< |
TH1F * h_wf11_hpt; |
259 |
> |
int genSampleType(0); |
260 |
|
if(ctrl.mc) { |
261 |
|
nt.makeWeightBranch(weights); |
262 |
< |
if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo); |
263 |
< |
initEfficiencyWeights(); |
264 |
< |
initPUWeights(); |
265 |
< |
|
266 |
< |
// Higgs only, pt reweighting |
267 |
< |
if( ctrl.mH <= 140 ) { |
268 |
< |
char wptname[256]; |
237 |
< |
sprintf( wptname, "/data/blue/pharris/Flat/ntupler/root/weight_ptH_%i.root", ctrl.mH ); |
238 |
< |
TFile * f_hpt = new TFile(wptname); |
239 |
< |
f_hpt->Print(); |
240 |
< |
sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH); |
241 |
< |
h_wf11_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
262 |
> |
if(ctrl.fillGen) { |
263 |
> |
genSampleType = getGenSampleType(ofname); |
264 |
> |
if(genSampleType == -1) { |
265 |
> |
cout << "\ngenSampleType returned as -1, setting fillGen to false" << endl; |
266 |
> |
ctrl.fillGen = false; |
267 |
> |
} else |
268 |
> |
nt.makeGenInfoBranch(geninfo); |
269 |
|
} |
270 |
< |
|
270 |
> |
if(ctrl.use_eff_weights) initEfficiencyWeights(); |
271 |
|
} else { |
272 |
< |
initRunLumiRangeMap(); |
272 |
> |
if(!(ctrl.noJSON) ) |
273 |
> |
initRunLumiRangeMap(ctrl); |
274 |
|
} |
275 |
|
|
248 |
– |
// initMuonIDMVA(); |
276 |
|
initElectronIDMVAV1(); |
277 |
|
initTrigger(); |
278 |
+ |
initAnalysisTriggers(ti); |
279 |
+ |
initMela(ctrl); |
280 |
+ |
initMassErrors(); |
281 |
+ |
ti.dump(); |
282 |
+ |
|
283 |
+ |
{ |
284 |
+ |
TFile tmp_file("tmp_file.root","RECREATE"); |
285 |
+ |
} |
286 |
+ |
|
287 |
+ |
if(ctrl.do_eregression) { |
288 |
+ |
string regPath("EGamma/EGammaAnalysisTools/data/eleEnergyRegWeights_V1.root"); |
289 |
+ |
// if(TString(getenv("HOSTNAME")).Contains(TRegexp("t3[bd][te][cs][hk]"))) |
290 |
+ |
regPath = cmsswpath + "/" + regPath; |
291 |
+ |
electron_momentum_correction.initialize_regression(regPath); |
292 |
+ |
} |
293 |
+ |
|
294 |
+ |
if(ctrl.correct_muon_momentum) { |
295 |
+ |
muCorr = new MuCorr; |
296 |
+ |
muCorr->corr2011 = new rochcor; |
297 |
+ |
muCorr->corr2012 = new rochcor2012; |
298 |
+ |
} |
299 |
+ |
|
300 |
+ |
vector<TString> fJetCorrParsv; |
301 |
+ |
vector<JetCorrectorParameters> correctionParameters; |
302 |
+ |
FactorizedJetCorrector *fJetCorrector; |
303 |
+ |
JetIDMVA *fJetIDMVA; |
304 |
+ |
initJets(ctrl, cmsswpath, fJetCorrParsv, correctionParameters, fJetCorrector, fJetIDMVA); |
305 |
|
|
306 |
|
// |
307 |
|
// Setup tree I/O |
310 |
|
TTree *eventTree=0; |
311 |
|
string currentFile(""); |
312 |
|
|
313 |
< |
UInt_t fNMaxTriggers = 1024; |
314 |
< |
mithep::EventHeader *info = new mithep::EventHeader(); |
315 |
< |
mithep::Array<mithep::PFMet> *metArr = new mithep::Array<mithep::PFMet>(); |
316 |
< |
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
317 |
< |
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
318 |
< |
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
319 |
< |
mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>(); |
320 |
< |
mithep::Array<mithep::PileupInfo> *puArr = new mithep::Array<mithep::PileupInfo>(); |
321 |
< |
mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
322 |
< |
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
323 |
< |
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
324 |
< |
mithep::MCEventInfo *mcEvtInfo = new mithep::MCEventInfo(); |
325 |
< |
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
326 |
< |
mithep::TriggerTable *hltTable = new mithep::TriggerTable(fNMaxTriggers); |
327 |
< |
vector<string> *hltTableStrings = new vector<string>(); |
328 |
< |
vector<string> *hltLabelStrings = new vector<string>(); |
329 |
< |
mithep::Array<mithep::TriggerObject> *hltObjArr = new mithep::Array<mithep::TriggerObject>(); |
330 |
< |
mithep::Array<mithep::TriggerObjectRel> *hltRelsArr = new mithep::Array<mithep::TriggerObjectRel>(); |
331 |
< |
std::vector<std::string> *hltTab = new vector<string>(); |
332 |
< |
std::vector<std::string> *hltLab = new vector<string>(); |
333 |
< |
TriggerObjectsTable *fTrigObjs = new TriggerObjectsTable(hltTable,fNMaxTriggers); |
280 |
< |
|
281 |
< |
|
282 |
< |
TString fElectronName(Names::gkElectronBrn); |
283 |
< |
TString fMuonName(Names::gkMuonBrn); |
284 |
< |
TString fInfoName(Names::gkEvtHeaderBrn); |
285 |
< |
TString fPFMetName("PFMet"); |
286 |
< |
TString fPrimVtxName(Names::gkPVBrn); |
287 |
< |
TString fPFCandidateName(Names::gkPFCandidatesBrn); |
288 |
< |
TString fPileupInfoName(Names::gkPileupInfoBrn); |
289 |
< |
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
290 |
< |
TString fTrackName(Names::gkTrackBrn); |
291 |
< |
TString fMCParticleName(Names::gkMCPartBrn); |
292 |
< |
TString fMCEvtInfoName(Names::gkMCEvtInfoBrn); |
293 |
< |
TString fTriggerMaskName(Names::gkHltBitBrn); |
294 |
< |
TString fTriggerTableName(Names::gkHltTableBrn); |
295 |
< |
TString fTriggerLabelName(Names::gkHltLabelBrn); |
296 |
< |
TString fTriggerObjectName(Names::gkHltObjBrn); |
297 |
< |
TString fTriggerObjectRelsName(Form("HLTObjectsRelation")); |
298 |
< |
|
299 |
< |
// TString fHLTLabName(Names::gkHltLabelBrn); |
300 |
< |
// TString fHLTTabName(Names::gkHltTableBrn); |
301 |
< |
// TString fHLTTabNamePub(Form("%sFwk",fHLTTabName.Data())); |
302 |
< |
// TString fHLTLabNamePub(Form("%sFwk",fHLTLabName.Data())); |
303 |
< |
// TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data())); |
304 |
< |
|
305 |
< |
|
313 |
> |
UInt_t fNMaxTriggers = TRIGGER_BIG_NUMBER; |
314 |
> |
EventHeader *info = new EventHeader(); |
315 |
> |
Array<PFMet> *metArr = new Array<PFMet>(); |
316 |
> |
Array<Electron> *electronArr = new Array<Electron>(); |
317 |
> |
Array<Muon> *muonArr = new Array<Muon>(); |
318 |
> |
Array<Vertex> *vtxArr = new Array<Vertex>(); |
319 |
> |
Array<PFCandidate> *pfArr = new Array<PFCandidate>(); |
320 |
> |
Array<PFJet> *jetArr = new Array<PFJet>(); |
321 |
> |
Array<PileupInfo> *puArr = new Array<PileupInfo>(); |
322 |
> |
Array<PileupEnergyDensity> *puDArr = new Array<PileupEnergyDensity>(); |
323 |
> |
Array<Track> *trkArr = new Array<Track>(); |
324 |
> |
Array<MCParticle> *mcArr = new Array<MCParticle>(); |
325 |
> |
MCEventInfo *mcEvtInfo = new MCEventInfo(); |
326 |
> |
TriggerMask *trigMask = new TriggerMask(); |
327 |
> |
TriggerTable *hltTable = new TriggerTable(fNMaxTriggers); |
328 |
> |
vector<string> *hltTableStrings = new vector<string>(); |
329 |
> |
vector<string> *hltLabelStrings = new vector<string>(); |
330 |
> |
Array<TriggerObject> *hltObjArr = new Array<TriggerObject>(); |
331 |
> |
Array<TriggerObjectRel> *hltRelsArr = new Array<TriggerObjectRel>(); |
332 |
> |
TriggerObjectsTable *fTrigObjs = new TriggerObjectsTable(hltTable,fNMaxTriggers); |
333 |
> |
RunInfo *runInfo = new RunInfo(); |
334 |
|
|
335 |
< |
chain->SetBranchAddress(fInfoName, &info); |
336 |
< |
chain->SetBranchAddress(fPFMetName, &metArr); |
337 |
< |
chain->SetBranchAddress(fElectronName, &electronArr); |
338 |
< |
chain->SetBranchAddress(fMuonName, &muonArr); |
339 |
< |
chain->SetBranchAddress(fPrimVtxName, &vtxArr); |
340 |
< |
chain->SetBranchAddress(fPFCandidateName, &pfArr); |
335 |
> |
chain->SetBranchAddress(Names::gkEvtHeaderBrn, &info); |
336 |
> |
chain->SetBranchAddress("PFMet", &metArr); |
337 |
> |
chain->SetBranchAddress(Names::gkElectronBrn, &electronArr); |
338 |
> |
chain->SetBranchAddress(Names::gkMuonBrn, &muonArr); |
339 |
> |
chain->SetBranchAddress(Names::gkPVBrn, &vtxArr); |
340 |
> |
chain->SetBranchAddress(Names::gkPFCandidatesBrn, &pfArr); |
341 |
> |
chain->SetBranchAddress(Names::gkPFJetBrn, &jetArr); |
342 |
|
if( ctrl.mc ) { |
343 |
< |
chain->SetBranchAddress(fPileupInfoName, &puArr); |
344 |
< |
chain->SetBranchAddress(fMCParticleName, &mcArr); |
345 |
< |
chain->SetBranchAddress(fMCEvtInfoName, &mcEvtInfo); |
346 |
< |
} |
347 |
< |
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
348 |
< |
chain->SetBranchAddress(fTrackName, &trkArr); |
349 |
< |
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
350 |
< |
chain->SetBranchAddress(fTriggerObjectName, &hltObjArr); |
351 |
< |
chain->SetBranchAddress(fTriggerObjectRelsName, &hltRelsArr); |
352 |
< |
// chain->SetBranchAddress(fHLTTabNamePub, &hltTab); |
353 |
< |
// chain->SetBranchAddress(fHLTLabNamePub, &hltLab); |
325 |
< |
|
326 |
< |
cout << "hlttable: " << fTriggerTableName << endl; |
327 |
< |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
328 |
< |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
329 |
< |
|
330 |
< |
mithep::Vertex vtx; // best primary vertex in the event |
331 |
< |
|
332 |
< |
// ginfo = NULL; |
333 |
< |
// if( ctrl.mc ) { chain->SetBranchAddress("Gen", &ginfo);} |
334 |
< |
|
335 |
< |
int count=0, pass=0; |
336 |
< |
float passcorr=0., passcorr_errup=0., passcorr_errdown=0.; |
337 |
< |
float denom[3]={0.,0.,0.}; |
338 |
< |
float numer[3]={0.,0.,0.}; |
339 |
< |
float numercorr[3]={0.,0.,0.}; |
340 |
< |
|
341 |
< |
// only 1 HLT table / file ??? |
342 |
< |
hltchain->GetEntry(0); |
343 |
< |
|
344 |
< |
int imax = chain->GetEntries(); |
345 |
< |
cout << "nEntries: " << imax << endl; |
346 |
< |
|
347 |
< |
// |
348 |
< |
// Loop !!!!!!!!! |
349 |
< |
//-------------------------------------------------------------------------------------------------------------- |
350 |
< |
for(UInt_t ientry=0; ientry<imax; ientry++) |
351 |
< |
{ |
352 |
< |
chain->GetEntry(ientry); |
353 |
< |
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
354 |
< |
|
355 |
< |
if( ctrl.debug ) { |
356 |
< |
cout << "-----------------------------------------------------------------" << endl; |
357 |
< |
cout << "-----------------------------------------------------------------" << endl; |
358 |
< |
cout << "Run: " << info->RunNum() |
359 |
< |
<< "\tEvt: " << info->EvtNum() |
360 |
< |
<< "\tLumi: " << info->LumiSec() |
361 |
< |
<< endl; |
362 |
< |
cout << "-----------------------------------------------------------------" << endl; |
363 |
< |
} |
343 |
> |
chain->SetBranchAddress(Names::gkPileupInfoBrn, &puArr); |
344 |
> |
chain->SetBranchAddress(Names::gkMCPartBrn, &mcArr); |
345 |
> |
chain->SetBranchAddress(Names::gkMCEvtInfoBrn, &mcEvtInfo); |
346 |
> |
} |
347 |
> |
chain->SetBranchAddress(Names::gkPileupEnergyDensityBrn, &puDArr); |
348 |
> |
chain->SetBranchAddress(Names::gkTrackBrn, &trkArr); |
349 |
> |
chain->SetBranchAddress(Names::gkHltBitBrn, &trigMask); |
350 |
> |
chain->SetBranchAddress(Names::gkHltObjBrn, &hltObjArr); |
351 |
> |
chain->SetBranchAddress("HLTObjectsRelation", &hltRelsArr); |
352 |
> |
hltchain->SetBranchAddress(Names::gkHltTableBrn, &hltTableStrings); |
353 |
> |
hltchain->SetBranchAddress(Names::gkHltLabelBrn, &hltLabelStrings); |
354 |
|
|
355 |
+ |
runchain->SetBranchAddress(Names::gkRunInfoBrn, &runInfo); |
356 |
|
|
357 |
< |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
367 |
< |
if(ctrl.debug) cout << "era is " << ctrl.era << endl; |
368 |
< |
if( ctrl.era == 0 ) { |
369 |
< |
setEra( fname, ctrl ); |
370 |
< |
if(ctrl.debug) cout << "era is now " << ctrl.era << endl; |
371 |
< |
} |
357 |
> |
Vertex vtx; // best primary vertex in the event |
358 |
|
|
359 |
< |
// |
374 |
< |
// pfNoPU |
375 |
< |
// |
376 |
< |
//mithep::Array<PFCandidate> pfNoPileUp; |
377 |
< |
PFnoPUflag.clear(); |
378 |
< |
int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr ); |
379 |
< |
assert(pfnopu_size == pfArr->GetEntries()); |
380 |
< |
|
381 |
< |
// |
382 |
< |
// data/MC |
383 |
< |
// |
384 |
< |
if(ctrl.mc) { |
385 |
< |
// |
386 |
< |
// gen info |
387 |
< |
// |
388 |
< |
if( ctrl.fillGen ) |
389 |
< |
fillGenInfo( mcArr, mcEvtInfo, geninfo, ESampleType::kHZZ, ctrl); |
390 |
< |
|
391 |
< |
// |
392 |
< |
// xsec & PU weights |
393 |
< |
// |
394 |
< |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
395 |
< |
cout << "xsec weight: " << weights.w << endl; |
359 |
> |
hltchain->GetEntry(0); |
360 |
|
|
361 |
< |
unsigned npu = getNPU(puArr, 0); |
362 |
< |
weights.npu = npu; |
399 |
< |
weights.npuw = getPUWeight(ctrl.era,npu); |
400 |
< |
cerr << "weights.npuw: " << weights.npuw << endl; |
401 |
< |
|
402 |
< |
// |
403 |
< |
// pt reweighting for Higgs < 140, F11 |
404 |
< |
// |
405 |
< |
if( ctrl.fillGen ) { |
406 |
< |
if( (fname.find("f11-h115zz4l") != string::npos) || |
407 |
< |
(fname.find("f11-h120zz4l") != string::npos) || |
408 |
< |
(fname.find("f11-h130zz4l") != string::npos) ) { |
409 |
< |
weights.w *= h_wf11_hpt->GetBinContent(h_wf11_hpt->FindBin(geninfo.pt_zz)); |
410 |
< |
} |
411 |
< |
} |
361 |
> |
int imax = (ctrl.n_events_to_process < 0) ? chain->GetEntries() : ctrl.n_events_to_process; |
362 |
> |
cerr << "processing: " << imax << " ( / " << chain->GetEntries() << " )" << endl; |
363 |
|
|
364 |
< |
// |
365 |
< |
// trigger |
415 |
< |
// |
416 |
< |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
417 |
< |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
418 |
< |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
419 |
< |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
420 |
< |
hltchain->GetEntry(0); |
421 |
< |
hltTable->Clear(); |
422 |
< |
fillTriggerNames(hltTable, hltTableStrings ); |
423 |
< |
} |
424 |
< |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
425 |
< |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
426 |
< |
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
427 |
< |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) { |
428 |
< |
passes_HLT_MC = false; |
429 |
< |
} |
364 |
> |
if(ctrl.mc && ctrl.debugOffMc) // necessary for batch mode -- we need debug output for, data but size is too large to store MC output |
365 |
> |
ctrl.debug = false; |
366 |
|
|
367 |
< |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
367 |
> |
int lastHltEntry=-2; |
368 |
> |
for(UInt_t ientry=0; ientry<imax; ientry++) { |
369 |
> |
chain->GetEntry(ientry); |
370 |
> |
if(!(ientry%1000)) cerr << "entry: " << ientry << " ( / " << imax << " )" << endl; |
371 |
> |
|
372 |
> |
//if(info->EvtNum() != 217502611) continue; |
373 |
> |
|
374 |
> |
increment(counts,"start"); |
375 |
> |
if( ctrl.debug ) { |
376 |
> |
cout << "-----------------------------------------------------------------" << endl; |
377 |
> |
cout << "-----------------------------------------------------------------" << endl; |
378 |
> |
cout << "Run: " << info->RunNum() |
379 |
> |
<< "\tEvt: " << info->EvtNum() |
380 |
> |
<< "\tLumi: " << info->LumiSec() |
381 |
> |
<< endl; |
382 |
> |
cerr << "Run: " << info->RunNum() |
383 |
> |
<< "\tEvt: " << info->EvtNum() |
384 |
> |
<< "\tLumi: " << info->LumiSec() |
385 |
> |
<< endl; |
386 |
> |
cout << "-----------------------------------------------------------------" << endl; |
387 |
> |
} |
388 |
|
|
389 |
< |
} else { |
390 |
< |
// |
391 |
< |
// JSON |
392 |
< |
// |
393 |
< |
if(!(ctrl.noJSON) ) { |
394 |
< |
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
395 |
< |
if( !(rlrm.HasRunLumi(rl)) ) { |
396 |
< |
if( ctrl.debug ) cout << "fails JSON" << endl; |
397 |
< |
continue; |
398 |
< |
} |
399 |
< |
} |
400 |
< |
|
401 |
< |
// |
402 |
< |
// trigger |
403 |
< |
// |
404 |
< |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
449 |
< |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
450 |
< |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
451 |
< |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
452 |
< |
hltchain->GetEntry(0); |
453 |
< |
hltTable->Clear(); |
454 |
< |
fillTriggerNames(hltTable, hltTableStrings ); |
455 |
< |
} |
389 |
> |
runchain->GetEvent(info->RunEntry()); |
390 |
> |
hltchain->GetEntry(runInfo->HltEntry()); |
391 |
> |
hltTable->Clear(); |
392 |
> |
fillTriggerNames(hltTable, hltTableStrings ); |
393 |
> |
// if(ctrl.debug && (lastHltEntry != runInfo->HltEntry())) hltTable->Print(); |
394 |
> |
lastHltEntry = runInfo->HltEntry(); |
395 |
> |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
396 |
> |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
397 |
> |
// printTriggerObjs( hltTable, fTrigObjs); |
398 |
> |
|
399 |
> |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
400 |
> |
if(ctrl.debug) cout << "era is " << ctrl.era << endl; |
401 |
> |
if( ctrl.era == 0 ) { |
402 |
> |
setEra( fname, ctrl ); |
403 |
> |
if(ctrl.debug) cout << "era is now " << ctrl.era << endl; |
404 |
> |
} |
405 |
|
|
406 |
< |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
406 |
> |
// pfNoPU |
407 |
> |
PFnoPUflag.clear(); |
408 |
> |
int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr ); |
409 |
> |
assert(pfnopu_size == pfArr->GetEntries()); |
410 |
> |
|
411 |
> |
// trigger |
412 |
> |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
413 |
> |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
414 |
> |
} |
415 |
> |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
416 |
> |
passes_HLT = passHLT(ctrl, triggerBits, ti, info->RunNum(), hltTable, fTrigObjs); // NOTE: run value is not used if it's MC |
417 |
|
|
418 |
< |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
419 |
< |
/* |
420 |
< |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
421 |
< |
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
422 |
< |
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
418 |
> |
// data/MC |
419 |
> |
if(ctrl.mc) { |
420 |
> |
if(ctrl.fillGen) fillGenInfo( mcArr, mcEvtInfo, geninfo, genSampleType, ctrl); |
421 |
> |
// NOTE: xs weight and npuw are reset in merge.cc |
422 |
> |
if(ctrl.use_xs_weights) |
423 |
> |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
424 |
> |
else |
425 |
> |
weights.w = 1; |
426 |
> |
weights.npu = getNPU(puArr, 0); |
427 |
> |
weights.npuw = getPUWeight(ctrl.era, fname, weights.npu); |
428 |
> |
} else { |
429 |
> |
// JSON |
430 |
> |
if(!(ctrl.noJSON) ) { |
431 |
> |
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
432 |
> |
if( !(rlrm.HasRunLumi(rl)) ) { |
433 |
> |
if( ctrl.debug ) cout << "fails JSON" << endl; |
434 |
|
continue; |
435 |
|
} |
466 |
– |
*/ |
436 |
|
} |
437 |
+ |
} |
438 |
|
|
439 |
< |
// |
440 |
< |
// lepton/kinematic selection ... |
441 |
< |
// |
442 |
< |
failingLeptons.clear(); |
443 |
< |
passingLeptons.clear(); |
444 |
< |
EventData ret4l = |
445 |
< |
|
446 |
< |
|
447 |
< |
// reference |
448 |
< |
apply_HZZ4L_reference_selection(ctrl, info, |
449 |
< |
vtxArr, |
450 |
< |
pfArr, |
451 |
< |
puDArr, |
452 |
< |
electronArr, |
453 |
< |
&electronReferencePreSelection, |
454 |
< |
&electronReferenceIDMVASelectionV1, |
455 |
< |
&electronReferenceIsoSelection, |
486 |
< |
muonArr, |
487 |
< |
&muonReferencePreSelection, |
488 |
< |
&muonIDPFSelection, |
489 |
< |
&muonReferenceIsoSelection); |
439 |
> |
// |
440 |
> |
// lepton/kinematic selection ... |
441 |
> |
// |
442 |
> |
failingLeptons.clear(); |
443 |
> |
passingLeptons.clear(); |
444 |
> |
EventData ret4l = apply_HZZ4L_reference_selection(ctrl, info, |
445 |
> |
vtxArr, |
446 |
> |
pfArr, |
447 |
> |
puDArr, |
448 |
> |
electronArr, |
449 |
> |
&electronReferencePreSelection, |
450 |
> |
&electronReferenceIDMVASelectionV1, // not used anymore! (Blame the damn regression implementation, not me!) |
451 |
> |
&electronReferenceIsoSelection, |
452 |
> |
muonArr, |
453 |
> |
&muonReferencePreSelection, |
454 |
> |
&muonIDPFSelection, |
455 |
> |
&muonReferenceIsoSelection); |
456 |
|
|
457 |
< |
if( ctrl.debug ) cout << endl; |
492 |
< |
|
457 |
> |
if( ctrl.debug ) cout << endl; |
458 |
|
|
459 |
< |
int Z1type=0, Z2type=0; |
460 |
< |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZCANDIDATE ) { |
461 |
< |
if( abs(ret4l.Z1leptons[0].type) == 11 ) Z1type = 11; |
462 |
< |
if( abs(ret4l.Z1leptons[0].type) == 13 ) Z1type = 13; |
463 |
< |
} |
464 |
< |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZZCANDIDATE ) { |
465 |
< |
if( abs(ret4l.Z2leptons[0].type) == 11 ) Z2type = 11; |
466 |
< |
if( abs(ret4l.Z2leptons[0].type) == 13 ) Z2type = 13; |
467 |
< |
} |
468 |
< |
|
469 |
< |
#ifdef SYNC |
470 |
< |
if(ctrl.debug) |
471 |
< |
cout << "bits: " << ret4l.status.selectionBits << "\t" |
472 |
< |
<< "Z1: " << Z1type << "\t" |
473 |
< |
<< "Z2: " << Z2type << endl << endl; |
474 |
< |
#endif |
475 |
< |
|
476 |
< |
if( ret4l.status.pass() ) { |
477 |
< |
fillAngles(ret4l,angles); |
478 |
< |
fillKinematics(ret4l,kinematics); |
479 |
< |
fillMassErrors(ret4l,muonArr,electronArr,kinematics); |
480 |
< |
TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0); |
481 |
< |
fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0); |
517 |
< |
if( ctrl.mc) { |
518 |
< |
// if( std::string(ctrl.efftype) != std::string("WTF?")) { |
519 |
< |
setEffiencyWeights(ctrl.era, ret4l, weights); |
520 |
< |
// } else { |
521 |
< |
// weights.won = weights.woff = 1.; |
522 |
< |
// } |
523 |
< |
if(ctrl.debug) |
524 |
< |
cout << "w: " << weights.w << "\t" |
525 |
< |
<< "npuw: " << weights.npuw << "\t" |
526 |
< |
<< "won: " << weights.won << "\t" |
527 |
< |
<< "woff: " << weights.woff << endl; |
459 |
> |
if(ctrl.fakeScheme == "none") { // fill angletuple if event passes full selection |
460 |
> |
if( ret4l.status.pass() ) { |
461 |
> |
setNtupleVals(ctrl, ret4l, evtinfo, angles, kine, ji, weights, info, muonArr, electronArr, jetArr, metArr, simpleLeptonJets, fJetCorrector, puArr, puDArr, fJetIDMVA, vtxArr, triggerBits, hltTable, hltObjArr, fTrigObjs, &nt); |
462 |
> |
nt.Fill(); |
463 |
> |
|
464 |
> |
int theZ1type = kine.l1type; |
465 |
> |
int theZ2type = kine.l3type; |
466 |
> |
|
467 |
> |
if(ctrl.debug) cout << "simpleLeptonJets.size() = " << simpleLeptonJets.size() << endl; |
468 |
> |
|
469 |
> |
if(kine.m4l > 100){ |
470 |
> |
if(simpleLeptonJets.size() >= 1) { |
471 |
> |
increment(counts,"m4l > 100 && >= 1 jets",theZ1type,theZ2type); |
472 |
> |
if(simpleLeptonJets.size() == 2) { |
473 |
> |
increment(counts,"m4l > 100 && 2 jets",theZ1type,theZ2type); |
474 |
> |
SimpleLepton j1 = simpleLeptonJets[0]; |
475 |
> |
SimpleLepton j2 = simpleLeptonJets[1]; |
476 |
> |
double deta = abs(j1.vec.Eta()-j2.vec.Eta()); |
477 |
> |
double mjj = (j1.vec + j2.vec).M(); |
478 |
> |
double fisher = 0.09407 * deta +0.00041581*mjj; |
479 |
> |
if(fisher > 0.4) increment(counts, "m4l > 100 && fisher > 0.4",theZ1type,theZ2type); |
480 |
> |
} |
481 |
> |
} |
482 |
|
} |
529 |
– |
|
483 |
|
|
531 |
– |
nt.Fill(); |
484 |
|
|
485 |
< |
cerr << "PASS:: " |
486 |
< |
<< "\trun: " << evtinfo.run |
487 |
< |
<< "\tevt: " << evtinfo.evt |
488 |
< |
<< "\tlumi: " << evtinfo.lumi |
489 |
< |
<< "\tchannel: " << kinematics.channel |
490 |
< |
<< "\tm4l: " << kinematics.m4l |
491 |
< |
<< "\tmZ1: " << kinematics.mZ1 |
492 |
< |
<< "\tmZ2: " << kinematics.mZ2 |
493 |
< |
<< endl; |
494 |
< |
pass++; |
495 |
< |
// if( pass > 3 ) break; |
496 |
< |
|
545 |
< |
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) && |
546 |
< |
ret4l.status.selectionBits.to_ulong() < (1UL<<PASS_4L)) { // save for fakes ... |
547 |
< |
if(ctrl.debug) { |
548 |
< |
cout << "failingLeptons : " << failingLeptons.size() << endl; |
549 |
< |
for( int f=0; f<failingLeptons.size(); f++ ) { |
550 |
< |
SimpleLepton l = failingLeptons[f]; |
551 |
< |
cout << "f: " << f << "\t" |
552 |
< |
<< "type: " << l.type << "\t" |
553 |
< |
<< "pT: " << l.vec.Pt() << "\t" |
554 |
< |
<< "eta: " << l.vec.Eta() |
555 |
< |
<< endl; |
556 |
< |
} |
485 |
> |
} else { |
486 |
> |
if(ctrl.debug) cout << "failing with code : " << ret4l.status.selectionBits << endl; |
487 |
> |
} |
488 |
> |
} else { // fill FOtuple and angletuple if event has a good Z and one or two extra leptons |
489 |
> |
assert(ctrl.fakeScheme=="ZPlusF" || ctrl.fakeScheme=="ZPlusFF"); |
490 |
> |
if(ret4l.status.selectionBits.test(PASS_GOODZ1) ) { |
491 |
> |
unsigned nleps = passingLeptons.size() + failingLeptons.size(); |
492 |
> |
if( (nleps>=3 && ctrl.fakeScheme=="ZPlusF" ) || (nleps>=4 && ctrl.fakeScheme=="ZPlusFF" ) ) { |
493 |
> |
addDummyZ2Lepotons(ret4l); |
494 |
> |
setNtupleVals(ctrl, ret4l, evtinfo, angles, kine, ji, weights, info, muonArr, electronArr, jetArr, metArr, simpleLeptonJets, fJetCorrector, puArr, puDArr, fJetIDMVA, vtxArr, triggerBits, hltTable, hltObjArr, fTrigObjs, &nt); |
495 |
> |
nt.Fill(); |
496 |
> |
foTree->Fill(); |
497 |
|
} |
498 |
< |
foTree.Fill(); |
499 |
< |
} else { |
560 |
< |
if(ctrl.debug) |
561 |
< |
cout << "failing with some other code : " << ret4l.status.selectionBits << endl; |
498 |
> |
} else { |
499 |
> |
if(ctrl.debug) cout << "failing PASS_GOODZ1" << endl; |
500 |
|
} |
501 |
< |
} |
501 |
> |
} |
502 |
|
|
503 |
< |
|
566 |
< |
foTree.getFile()->cd(); |
567 |
< |
foTree.getTree()->Write(); |
568 |
< |
nt.WriteClose(); |
503 |
> |
hltTable->Delete(); |
504 |
|
|
505 |
< |
if(ctrl.debug) |
571 |
< |
cout << endl << endl; |
572 |
< |
for( int i=0; i<cutvec.size(); i++ ) { |
573 |
< |
cout << "cut: " << i << "\t" |
574 |
< |
<< "pass: " << cutvec[i]; |
505 |
> |
} |
506 |
|
|
507 |
< |
if( i>PASS_TRIGGER&&i<=PASS_GOODZ1 ) |
508 |
< |
cout << "\t2e: " << zcutvec[0][i] |
509 |
< |
<< "\t2m: " << zcutvec[1][i]; |
507 |
> |
if(ctrl.fakeScheme != "none") { |
508 |
> |
foTree->getFile()->cd(); |
509 |
> |
foTree->getTree()->Write(); |
510 |
> |
} |
511 |
> |
nt.WriteClose(); |
512 |
|
|
513 |
< |
if( i>PASS_ZCANDIDATE ) |
514 |
< |
cout << "\t4e: " << zzcutvec[0][i] |
515 |
< |
<< "\t4m: " << zzcutvec[1][i] |
516 |
< |
<< "\t2e2m: " << zzcutvec[2][i]; |
513 |
> |
for(unsigned icut=0; icut<cuts.size(); icut++) { |
514 |
> |
map<TString,int> thisCount(*(counts[cuts[icut]])); |
515 |
> |
cerr << setw(25) << cuts[icut] << "\t" << setw(9) << thisCount["all"] << " (" |
516 |
> |
<< setw(9) << thisCount["4e"] << setw(9) << thisCount["4m"] << setw(9) << thisCount["2e2m"] << ")" << endl; |
517 |
> |
} |
518 |
|
|
519 |
< |
cout << "\t" << cutstrs[i] << endl; |
519 |
> |
} |
520 |
> |
//---------------------------------------------------------------------------------------- |
521 |
> |
void addDummyZ2Lepotons(EventData &ret4l) |
522 |
> |
// for fake ntuples, we don't know which are the Z2 leptons yet, but need to fill something so we don't seg fault |
523 |
> |
{ |
524 |
> |
SimpleLepton dum1,dum2; |
525 |
> |
dum1.vec.SetPtEtaPhiM(1,2,3,4); |
526 |
> |
dum2.vec.SetPtEtaPhiM(5,6,7,8); |
527 |
> |
ret4l.Z2leptons.push_back(dum1); |
528 |
> |
ret4l.Z2leptons.push_back(dum2); |
529 |
> |
} |
530 |
> |
//---------------------------------------------------------------------------------------- |
531 |
> |
void setNtupleVals(ControlFlags &ctrl, EventData &ret4l, InfoStruct &evtinfo, Angles &angles, KinematicsStruct &kine, |
532 |
> |
JetInfoStruct &ji, WeightStruct &weights, EventHeader *info, Array<Muon> *muonArr, Array<Electron> *electronArr, Array<PFJet> *jetArr, Array<PFMet> *metArr, |
533 |
> |
vector<SimpleLepton> &simpleLeptonJets, FactorizedJetCorrector *fJetCorrector, Array<PileupInfo> *puArr, |
534 |
> |
Array<PileupEnergyDensity> *puDArr, JetIDMVA *fJetIDMVA, Array<Vertex> *vtxArr, bitset<1024> &triggerBits, |
535 |
> |
TriggerTable *hltTable, Array<TriggerObject> *hltObjArr, TriggerObjectsTable *fTrigObjs, AngleTuple *nt) |
536 |
> |
{ |
537 |
> |
fillKinematics(ret4l,kine); |
538 |
|
|
539 |
< |
cout << endl; |
540 |
< |
} |
539 |
> |
//the last two arguments are usePt and useY respectively |
540 |
> |
fillMela(kine,0,0); |
541 |
|
|
542 |
< |
} |
542 |
> |
fillMassErrors(ctrl,ret4l,muonArr,electronArr,kine); |
543 |
|
|
544 |
+ |
TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0); |
545 |
+ |
fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0, vtxArr->GetEntries()); |
546 |
+ |
fillJets(ctrl, jetArr, simpleLeptonJets, fJetCorrector, puDArr, fJetIDMVA, vtxArr, ret4l); |
547 |
+ |
fillJetInfo(simpleLeptonJets, ji, ctrl); |
548 |
+ |
//fillJetAngleBranches(ji, ret4l, nt, ctrl); |
549 |
+ |
evtinfo.status = 0; |
550 |
+ |
evtinfo.status = setHltBits(ti, triggerBits); |
551 |
+ |
|
552 |
+ |
if(ctrl.fakeScheme == "none") { |
553 |
+ |
fillAngles(ret4l,angles); |
554 |
+ |
|
555 |
+ |
if( ctrl.mc) { |
556 |
+ |
if(ctrl.use_eff_weights) setEfficiencyWeights(ctrl, ctrl.era, ret4l, triggerBits, hltTable, hltObjArr, fTrigObjs, weights); |
557 |
+ |
if(ctrl.debug) |
558 |
+ |
cout << "w: " << weights.w << "\t" << "npuw: " << weights.npuw << "\t" << "won: " << weights.won << "\t" << "woff: " << weights.woff << endl; |
559 |
+ |
} |
560 |
|
|
561 |
< |
//---------------------------------------------------------------------------- |
562 |
< |
void initRunLumiRangeMap(ControlFlags &ctrl) |
563 |
< |
//---------------------------------------------------------------------------- |
564 |
< |
{ |
565 |
< |
/* |
566 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt")); |
567 |
< |
// rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt")); |
568 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt")); |
569 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt")); |
570 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt")); |
571 |
< |
// r11b |
604 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt")); |
605 |
< |
*/ |
606 |
< |
|
607 |
< |
// 2012 only for now ... |
608 |
< |
std::string jsonFile; |
609 |
< |
if(ctrl.jsonFile=="") |
610 |
< |
jsonFile = "./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt"; |
611 |
< |
else |
612 |
< |
jsonFile = ctrl.jsonFile; |
613 |
< |
rlrm.AddJSONFile(jsonFile); |
614 |
< |
}; |
561 |
> |
if(ctrl.debug) { |
562 |
> |
stringstream ss; |
563 |
> |
ss << "PASS:: " << "\trun: " << evtinfo.run << "\tevt: " << evtinfo.evt << "\tlumi: " << evtinfo.lumi << "\tchannel: " |
564 |
> |
<< kine.channel << "\tm4l: " << kine.m4l << "\tmZ1: " << kine.mZ1 << "\tmZ2: " << kine.mZ2 << endl; |
565 |
> |
cerr << ss.str(); |
566 |
> |
cout << ss.str(); |
567 |
> |
} |
568 |
> |
} else { |
569 |
> |
// fillAngles(ret4l,angles); // at this point we don't know which four leptons will constitute the ZZ system, so doesn't make sense to fill the angles |
570 |
> |
} |
571 |
> |
} |