50 |
|
#include "MuonSelection.h" |
51 |
|
#include "ElectronSelection.h" |
52 |
|
#include "IsolationSelection.h" |
53 |
< |
|
54 |
< |
//#include "Selection.h" |
55 |
< |
//#include "ReferenceSelection.h" |
56 |
< |
#include "ReferenceSelection2.h" |
53 |
> |
#include "ReferenceSelection.h" |
54 |
|
|
55 |
|
#include "TriggerUtils.h" |
56 |
|
#include "PassHLT.h" |
57 |
|
#include "Angles.h" |
58 |
|
#include "KinematicsStruct.h" |
59 |
|
#include "InfoStruct.h" |
60 |
< |
//#include "GenInfoStruct.h" |
60 |
> |
#include "GenInfoStruct.h" |
61 |
|
#include "WeightStruct.h" |
65 |
– |
//#include "GlobalDataAndFuncs.h" |
66 |
– |
#include "RunLumiRangeMap.h" |
67 |
– |
|
62 |
|
#include "AngleTuple.h" |
63 |
|
#include "FOTuple.h" |
64 |
|
|
65 |
+ |
#include "RunLumiRangeMap.h" |
66 |
|
#include "SampleWeight.h" |
67 |
|
#include "EfficiencyWeightsInterface.h" |
68 |
|
|
94 |
|
//---------------------------------------------------------------------------- |
95 |
|
void initPUWeights(); |
96 |
|
double getPUWeight(unsigned npu); |
97 |
+ |
void setEra(string, ControlFlags&); |
98 |
|
void setEffiencyWeights(EventData&, WeightStruct& ); |
99 |
|
void initRunLumiRangeMap(); |
100 |
|
void initEvtRhoMap(map<unsigned,float> &); |
101 |
|
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
102 |
|
vector<bool> &pfNoPileUpFlag, |
103 |
< |
const mithep::VertexCol * vtxArr ); |
103 |
> |
const mithep::Array<mithep::Vertex> * vtxArr ); |
104 |
|
//---------------------------------------------------------------------------- |
105 |
|
|
106 |
|
|
210 |
|
KinematicsStruct kinematics; |
211 |
|
InfoStruct evtinfo; |
212 |
|
WeightStruct weights; |
213 |
< |
// GenInfoStruct geninfo; |
213 |
> |
GenInfoStruct geninfo; |
214 |
|
|
215 |
|
AngleTuple nt( (const char*)ofname, (const char*)"zznt"); |
216 |
|
nt.makeAngleBranch(angles); |
217 |
|
nt.makeKinematicsBranch(kinematics); |
218 |
|
nt.makeInfoBranch(evtinfo); |
219 |
|
|
220 |
+ |
|
221 |
|
FOTuple foTree( nt.getFile(), (const char*)"FOtree"); |
222 |
|
foTree.makeFailedLeptonBranch(failingLeptons); |
223 |
< |
foTree.makeZLeptonBranch(passingLeptons); |
223 |
> |
foTree.makePassedLeptonBranch(passingLeptons); |
224 |
|
|
225 |
< |
TH1F * h_w_hpt; |
225 |
> |
TH1F * h_wf11_hpt; |
226 |
|
if(ctrl.mc) { |
227 |
|
nt.makeWeightBranch(weights); |
228 |
< |
// nt.makeGenInfoBranch(geninfo); |
228 |
> |
if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo); |
229 |
|
initEfficiencyWeights(); |
230 |
|
initPUWeights(); |
231 |
< |
/* |
231 |
> |
|
232 |
|
// Higgs only, pt reweighting |
233 |
|
if( ctrl.mH <= 140 ) { |
234 |
|
char wptname[256]; |
236 |
|
TFile * f_hpt = new TFile(wptname); |
237 |
|
f_hpt->Print(); |
238 |
|
sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH); |
239 |
< |
h_w_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
243 |
< |
h_w_hpt->Print(); |
239 |
> |
h_wf11_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
240 |
|
} |
241 |
< |
*/ |
241 |
> |
|
242 |
|
} else { |
243 |
|
initRunLumiRangeMap(); |
244 |
|
} |
245 |
|
|
246 |
|
// initMuonIDMVA(); |
247 |
< |
initMuonIsoMVA(); |
252 |
< |
initElectronIDMVA(); |
253 |
< |
initElectronIsoMVA(); |
247 |
> |
initElectronIDMVAV1(); |
248 |
|
initTrigger(); |
249 |
|
|
250 |
|
// hack |
259 |
|
string currentFile(""); |
260 |
|
|
261 |
|
mithep::EventHeader *info = new mithep::EventHeader(); |
268 |
– |
// mithep::TGenInfo *ginfo = new mithep::TGenInfo(); |
262 |
|
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
263 |
|
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
264 |
< |
const mithep::VertexCol *vtxArr = 0;//new mithep::Array<mithep::Vertex>(); |
264 |
> |
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
265 |
|
mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>(); |
266 |
|
mithep::Array<mithep::PileupInfo> *puArr = new mithep::Array<mithep::PileupInfo>(); |
267 |
|
mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
268 |
|
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
269 |
|
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
270 |
+ |
mithep::MCEventInfo *mcEvtInfo = new mithep::MCEventInfo(); |
271 |
|
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
272 |
|
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
273 |
|
vector<string> *hltTableStrings = new vector<string>(); |
281 |
|
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
282 |
|
TString fTrackName(Names::gkTrackBrn); |
283 |
|
TString fMCParticleName(Names::gkMCPartBrn); |
284 |
+ |
TString fMCEvtInfoName(Names::gkMCEvtInfoBrn); |
285 |
|
TString fTriggerMaskName(Names::gkHltBitBrn); |
286 |
|
TString fTriggerTableName(Names::gkHltTableBrn); |
287 |
|
|
293 |
|
if( ctrl.mc ) { |
294 |
|
chain->SetBranchAddress(fPileupInfoName, &puArr); |
295 |
|
chain->SetBranchAddress(fMCParticleName, &mcArr); |
296 |
+ |
chain->SetBranchAddress(fMCEvtInfoName, &mcEvtInfo); |
297 |
|
} |
298 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
299 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
326 |
|
for(UInt_t ientry=0; ientry<imax; ientry++) |
327 |
|
{ |
328 |
|
chain->GetEntry(ientry); |
329 |
+ |
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
330 |
|
|
331 |
< |
/* |
332 |
< |
bool found_tau=false; |
333 |
< |
if( ctrl.mc) { // && ctrl.debug |
337 |
< |
cout << "nparticles: " << mcArr->GetEntries() << endl; |
338 |
< |
cout << "-----------------------------------" << endl; |
339 |
< |
for( int i=0; i<mcArr->GetEntries(); i++ ) { |
340 |
< |
const mithep::MCParticle *mc = mcArr->At(i); |
341 |
< |
cout << "i: " << i << "\t" |
342 |
< |
<< "id: " << mc->AbsPdgId() |
343 |
< |
<< endl; |
344 |
< |
if( mc->Is(MCParticle::kTau) ) { |
345 |
< |
found_tau=true; |
346 |
< |
} |
347 |
< |
} |
348 |
< |
} |
349 |
< |
cout << "-----------------------------------" << endl; |
350 |
< |
cout << "found tau: " << found_tau << endl; |
351 |
< |
*/ |
352 |
< |
|
353 |
< |
// events that fail bc ele overlaps w/ reco mu |
354 |
< |
/* |
355 |
< |
if( info->EvtNum() != 67315 && |
356 |
< |
info->EvtNum() != 288693 ) continue; |
357 |
< |
*/ |
358 |
< |
|
359 |
< |
// events where they apparently don't veto electrons ... |
360 |
< |
/* |
361 |
< |
if( info->EvtNum() != 141713 && |
362 |
< |
info->EvtNum() != 178019 && |
363 |
< |
info->EvtNum() != 60823 && |
364 |
< |
info->EvtNum() != 192795 ) continue; |
365 |
< |
*/ |
331 |
> |
//if( info->EvtNum() != 217998 ) continue; |
332 |
> |
// if( info->EvtNum() != 238893 ) continue; |
333 |
> |
// if( info->EvtNum() != 289066 ) continue; |
334 |
|
|
335 |
< |
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
336 |
< |
//if (!(setPV( ctrl, vtxArr, vtx)) ) continue; |
335 |
> |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
336 |
> |
setEra( fname, ctrl ); |
337 |
|
|
370 |
– |
float rho = evtrhoMap[info->EvtNum()]; |
338 |
|
|
339 |
|
// |
340 |
|
// pfNoPU |
349 |
|
// |
350 |
|
if(ctrl.mc) { |
351 |
|
// |
352 |
+ |
// gen info |
353 |
+ |
// |
354 |
+ |
if( ctrl.fillGen ) |
355 |
+ |
fillGenInfo( mcArr, mcEvtInfo, geninfo, ESampleType::kHZZ, ctrl); |
356 |
+ |
|
357 |
+ |
// |
358 |
|
// xsec & PU weights |
359 |
|
// |
360 |
< |
weights.w = 1;//getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
360 |
> |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
361 |
|
cout << "xsec weight: " << weights.w << endl; |
362 |
|
int npu = -1; |
363 |
|
for(int i=0;i<puArr->GetEntries();i++) { |
367 |
|
assert(npu>=0); |
368 |
|
evtinfo.npu; |
369 |
|
weights.npuw = getPUWeight(evtinfo.npu); |
370 |
< |
// cout << "weight: " << weights.w << endl; |
370 |
> |
|
371 |
> |
// |
372 |
> |
// pt reweighting for Higgs < 140, F11 |
373 |
> |
// |
374 |
> |
if( ctrl.fillGen ) { |
375 |
> |
if( (fname.find("f11-h115zz4l") != string::npos) || |
376 |
> |
(fname.find("f11-h120zz4l") != string::npos) || |
377 |
> |
(fname.find("f11-h130zz4l") != string::npos) ) { |
378 |
> |
weights.w *= h_wf11_hpt->GetBinContent(h_wf11_hpt->FindBin(geninfo.pt_zz)); |
379 |
> |
} |
380 |
> |
} |
381 |
> |
|
382 |
|
// |
383 |
|
// trigger |
384 |
|
// |
387 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
388 |
|
hltchain->GetEntry(0); |
389 |
|
hltTable->Clear(); |
390 |
< |
fillTriggerBits(hltTable, hltTableStrings ); |
390 |
> |
fillTriggerNames(hltTable, hltTableStrings ); |
391 |
|
} |
392 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
393 |
|
fillTriggerBits( hltTable, trigMask, triggerBits ); |
394 |
|
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
395 |
< |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
395 |
> |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) { |
396 |
|
passes_HLT_MC = false; |
397 |
|
} |
398 |
|
} else { |
414 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
415 |
|
hltchain->GetEntry(0); |
416 |
|
hltTable->Clear(); |
417 |
< |
fillTriggerBits(hltTable, hltTableStrings ); |
417 |
> |
fillTriggerNames(hltTable, hltTableStrings ); |
418 |
|
} |
419 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
420 |
|
/* |
435 |
|
|
436 |
|
|
437 |
|
// reference |
438 |
< |
apply_HZZ4L_reference2_selection(ctrl, info, |
439 |
< |
vtxArr, |
440 |
< |
pfArr, |
441 |
< |
#ifdef HACKED_RHOS |
442 |
< |
rho, |
443 |
< |
#else |
444 |
< |
puDArr, |
445 |
< |
#endif |
446 |
< |
electronArr, |
447 |
< |
&electronReferencePreSelection, |
448 |
< |
&electronReferenceIDMVASelectionV1, |
449 |
< |
&electronReferenceIsoSelection, |
450 |
< |
muonArr, |
467 |
< |
&muonReferencePreSelection, |
468 |
< |
&muonIDPFSelection, |
469 |
< |
&muonReferenceIsoSelection); |
470 |
< |
|
471 |
< |
/* |
472 |
< |
// evolved |
473 |
< |
apply_HZZ4L_reference2_selection(ctrl, info, |
474 |
< |
vtx, |
475 |
< |
pfArr, |
476 |
< |
//rho, |
477 |
< |
puDArr, |
478 |
< |
electronArr, |
479 |
< |
&electronReferencePreSelection, |
480 |
< |
//&electronPreSelection, |
481 |
< |
&electronReferenceIDMVASelection, |
482 |
< |
&electronIsoMVASelection, |
483 |
< |
muonArr, |
484 |
< |
&muonReferencePreSelection, |
485 |
< |
//&muonPreSelection, |
486 |
< |
&muonIDPFSelection, |
487 |
< |
&muonIsoMVASelection); |
488 |
< |
*/ |
489 |
< |
|
438 |
> |
apply_HZZ4L_reference_selection(ctrl, info, |
439 |
> |
vtxArr, |
440 |
> |
pfArr, |
441 |
> |
puDArr, |
442 |
> |
electronArr, |
443 |
> |
&electronReferencePreSelection, |
444 |
> |
&electronReferenceIDMVASelectionV1, |
445 |
> |
&electronReferenceIsoSelection, |
446 |
> |
muonArr, |
447 |
> |
&muonReferencePreSelection, |
448 |
> |
&muonIDPFSelection, |
449 |
> |
&muonReferenceIsoSelection); |
450 |
> |
|
451 |
|
if( ctrl.debug ) cout << endl; |
452 |
|
|
453 |
|
|
471 |
|
if( ret4l.status.pass() ) { |
472 |
|
fillAngles(ret4l,angles); |
473 |
|
fillKinematics(ret4l,kinematics); |
474 |
+ |
fillMassErrors(ret4l,muonArr,electronArr,kinematics); |
475 |
|
fillEventInfo(info,evtinfo); |
476 |
|
if( ctrl.mc) { |
515 |
– |
// fillGenInfo(ginfo,geninfo); |
477 |
|
setEffiencyWeights(ret4l, weights); |
478 |
|
if(ctrl.debug) |
479 |
|
cout << "w: " << weights.w << "\t" |
481 |
|
<< "woff: " << weights.woff << endl; |
482 |
|
} |
483 |
|
|
484 |
< |
/* |
524 |
< |
// only for Higgs < 140 |
525 |
< |
geninfo.weight *= h_w_hpt->GetBinContent(h_w_hpt->FindBin(geninfo.pt_zz)); |
526 |
< |
angles.bdt = reader->EvaluateMVA("BDTG"); |
527 |
< |
*/ |
484 |
> |
|
485 |
|
nt.Fill(); |
486 |
|
|
487 |
|
cerr << "PASS:: " |
496 |
|
pass++; |
497 |
|
// if( pass > 3 ) break; |
498 |
|
|
499 |
< |
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) ) { // save for fakes ... |
499 |
> |
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) && |
500 |
> |
ret4l.status.selectionBits.to_ulong() < PASS_4L) { // save for fakes ... |
501 |
|
// if(ctrl.debug) { |
502 |
|
cout << "failingLeptons : " << failingLeptons.size() << endl; |
503 |
|
for( int f=0; f<failingLeptons.size(); f++ ) { |
645 |
|
|
646 |
|
//---------------------------------------------------------------------------- |
647 |
|
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
648 |
< |
vector<bool> &pfNoPileUpflag, |
649 |
< |
const mithep::VertexCol * vtxArr ) |
648 |
> |
vector<bool> &pfNoPileUpflag, |
649 |
> |
const mithep::Array<mithep::Vertex> * vtxArr ) |
650 |
|
//---------------------------------------------------------------------------- |
651 |
|
{ |
652 |
|
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
714 |
|
return pfNoPileUpflag.size(); |
715 |
|
} |
716 |
|
|
717 |
+ |
void setEra(string fname, ControlFlags &ctrl) |
718 |
+ |
{ |
719 |
+ |
if( ctrl.mc && (fname.find("f11-") != string::npos) ) ctrl.era=2011 ; |
720 |
+ |
if( ctrl.mc && (fname.find("s12-") != string::npos) ) ctrl.era=2012 ; |
721 |
+ |
if( !ctrl.mc && (fname.find("r11-") != string::npos) ) ctrl.era=2011 ; |
722 |
+ |
if( !ctrl.mc && (fname.find("r12-") != string::npos) ) ctrl.era=2012 ; |
723 |
+ |
} |