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" |
62 |
|
//#include "GlobalDataAndFuncs.h" |
63 |
|
#include "RunLumiRangeMap.h" |
94 |
|
// |
95 |
|
// prototypes |
96 |
|
//---------------------------------------------------------------------------- |
100 |
– |
bool setPV(ControlFlags,const mithep::Array<mithep::Vertex>*, mithep::Vertex& ); |
97 |
|
void initPUWeights(); |
98 |
|
double getPUWeight(unsigned npu); |
99 |
+ |
void setEra(string, ControlFlags&); |
100 |
|
void setEffiencyWeights(EventData&, WeightStruct& ); |
101 |
|
void initRunLumiRangeMap(); |
102 |
|
void initEvtRhoMap(map<unsigned,float> &); |
103 |
|
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
104 |
|
vector<bool> &pfNoPileUpFlag, |
105 |
< |
mithep::Array<Vertex> * vtxArr ); |
105 |
> |
const mithep::Array<mithep::Vertex> * vtxArr ); |
106 |
|
//---------------------------------------------------------------------------- |
107 |
|
|
108 |
|
|
114 |
|
{ |
115 |
|
cutstrs.push_back(string("skim0")); //0 |
116 |
|
cutstrs.push_back(string("skim1")); //1 |
117 |
+ |
cutstrs.push_back(string("skim2")); //1 |
118 |
|
cutstrs.push_back(string("trigger")); //2 |
119 |
|
// ------------------------------------------------- |
120 |
|
cutstrs.push_back(string("Z candidate")); //3 |
126 |
|
cutstrs.push_back(string("ZZ 20/10")); //8 |
127 |
|
cutstrs.push_back(string("resonance")); //9 |
128 |
|
cutstrs.push_back(string("m4l>70")); //10 |
129 |
< |
cutstrs.push_back(string("m4l>100")); //11 |
129 |
> |
cutstrs.push_back(string("m4l>100, mZ2 > 12")); //11 |
130 |
|
|
131 |
|
|
132 |
|
|
212 |
|
KinematicsStruct kinematics; |
213 |
|
InfoStruct evtinfo; |
214 |
|
WeightStruct weights; |
215 |
< |
// GenInfoStruct geninfo; |
215 |
> |
GenInfoStruct geninfo; |
216 |
|
|
217 |
|
AngleTuple nt( (const char*)ofname, (const char*)"zznt"); |
218 |
|
nt.makeAngleBranch(angles); |
223 |
|
foTree.makeFailedLeptonBranch(failingLeptons); |
224 |
|
foTree.makeZLeptonBranch(passingLeptons); |
225 |
|
|
226 |
< |
TH1F * h_w_hpt; |
226 |
> |
TH1F * h_wf11_hpt; |
227 |
|
if(ctrl.mc) { |
228 |
|
nt.makeWeightBranch(weights); |
229 |
< |
// nt.makeGenInfoBranch(geninfo); |
229 |
> |
nt.makeGenInfoBranch(geninfo); |
230 |
|
initEfficiencyWeights(); |
231 |
|
initPUWeights(); |
232 |
< |
/* |
232 |
> |
|
233 |
|
// Higgs only, pt reweighting |
234 |
|
if( ctrl.mH <= 140 ) { |
235 |
|
char wptname[256]; |
237 |
|
TFile * f_hpt = new TFile(wptname); |
238 |
|
f_hpt->Print(); |
239 |
|
sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH); |
240 |
< |
h_w_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
243 |
< |
h_w_hpt->Print(); |
240 |
> |
h_wf11_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
241 |
|
} |
242 |
< |
*/ |
242 |
> |
|
243 |
|
} else { |
244 |
|
initRunLumiRangeMap(); |
245 |
|
} |
262 |
|
string currentFile(""); |
263 |
|
|
264 |
|
mithep::EventHeader *info = new mithep::EventHeader(); |
268 |
– |
// mithep::TGenInfo *ginfo = new mithep::TGenInfo(); |
265 |
|
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
266 |
|
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
267 |
|
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
270 |
|
mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
271 |
|
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
272 |
|
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
273 |
+ |
mithep::MCEventInfo *mcEvtInfo = new mithep::MCEventInfo(); |
274 |
|
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
275 |
|
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
276 |
|
vector<string> *hltTableStrings = new vector<string>(); |
284 |
|
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
285 |
|
TString fTrackName(Names::gkTrackBrn); |
286 |
|
TString fMCParticleName(Names::gkMCPartBrn); |
287 |
+ |
TString fMCEvtInfoName(Names::gkMCEvtInfoBrn); |
288 |
|
TString fTriggerMaskName(Names::gkHltBitBrn); |
289 |
|
TString fTriggerTableName(Names::gkHltTableBrn); |
290 |
|
|
296 |
|
if( ctrl.mc ) { |
297 |
|
chain->SetBranchAddress(fPileupInfoName, &puArr); |
298 |
|
chain->SetBranchAddress(fMCParticleName, &mcArr); |
299 |
+ |
chain->SetBranchAddress(fMCEvtInfoName, &mcEvtInfo); |
300 |
|
} |
301 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
302 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
329 |
|
for(UInt_t ientry=0; ientry<imax; ientry++) |
330 |
|
{ |
331 |
|
chain->GetEntry(ientry); |
333 |
– |
|
334 |
– |
/* |
335 |
– |
bool found_tau=false; |
336 |
– |
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 |
– |
*/ |
366 |
– |
|
332 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
368 |
– |
setPV( ctrl, vtxArr, vtx); |
369 |
– |
//if (!(setPV( ctrl, vtxArr, vtx)) ) continue; |
333 |
|
|
334 |
+ |
#ifdef HACKED_RHOS |
335 |
|
float rho = evtrhoMap[info->EvtNum()]; |
336 |
+ |
#endif |
337 |
+ |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
338 |
+ |
setEra( fname, ctrl ); |
339 |
+ |
|
340 |
|
|
341 |
|
// |
342 |
|
// pfNoPU |
351 |
|
// |
352 |
|
if(ctrl.mc) { |
353 |
|
// |
354 |
+ |
// gen info |
355 |
+ |
// |
356 |
+ |
if(ctrl.fillGen) |
357 |
+ |
fillGenInfo( mcArr, mcEvtInfo, geninfo, ESampleType::kHZZ, ctrl); |
358 |
+ |
|
359 |
+ |
// |
360 |
|
// xsec & PU weights |
361 |
|
// |
362 |
|
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
369 |
|
assert(npu>=0); |
370 |
|
evtinfo.npu; |
371 |
|
weights.npuw = getPUWeight(evtinfo.npu); |
372 |
< |
// cout << "weight: " << weights.w << endl; |
372 |
> |
|
373 |
> |
// |
374 |
> |
// pt reweighting for Higgs < 140, F11 |
375 |
> |
// |
376 |
> |
if( ctrl.fillGen ) { |
377 |
> |
if( (fname.find("f11-h115zz4l") != string::npos) || |
378 |
> |
(fname.find("f11-h120zz4l") != string::npos) || |
379 |
> |
(fname.find("f11-h130zz4l") != string::npos) ) { |
380 |
> |
weights.w *= h_wf11_hpt->GetBinContent(h_wf11_hpt->FindBin(geninfo.pt_zz)); |
381 |
> |
} |
382 |
> |
} |
383 |
> |
|
384 |
|
// |
385 |
|
// trigger |
386 |
|
// |
394 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
395 |
|
fillTriggerBits( hltTable, trigMask, triggerBits ); |
396 |
|
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
397 |
< |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
397 |
> |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) { |
398 |
|
passes_HLT_MC = false; |
399 |
|
} |
400 |
|
} else { |
437 |
|
|
438 |
|
|
439 |
|
// reference |
440 |
< |
/* |
441 |
< |
apply_HZZ4L_reference2_selection(ctrl, info, |
457 |
< |
vtx, |
440 |
> |
apply_HZZ4L_reference_selection(ctrl, info, |
441 |
> |
vtxArr, |
442 |
|
pfArr, |
443 |
< |
//rho, |
443 |
> |
#ifdef HACKED_RHOS |
444 |
> |
rho, |
445 |
> |
#else |
446 |
|
puDArr, |
447 |
+ |
#endif |
448 |
|
electronArr, |
449 |
|
&electronReferencePreSelection, |
450 |
< |
&electronReferenceIDMVASelection, |
450 |
> |
&electronReferenceIDMVASelectionV1, |
451 |
|
&electronReferenceIsoSelection, |
452 |
|
muonArr, |
453 |
|
&muonReferencePreSelection, |
454 |
|
&muonIDPFSelection, |
455 |
|
&muonReferenceIsoSelection); |
469 |
– |
*/ |
456 |
|
|
457 |
+ |
/* |
458 |
|
// evolved |
459 |
|
apply_HZZ4L_reference2_selection(ctrl, info, |
460 |
|
vtx, |
471 |
|
//&muonPreSelection, |
472 |
|
&muonIDPFSelection, |
473 |
|
&muonIsoMVASelection); |
474 |
< |
|
474 |
> |
*/ |
475 |
|
|
476 |
|
if( ctrl.debug ) cout << endl; |
477 |
|
|
506 |
|
<< "woff: " << weights.woff << endl; |
507 |
|
} |
508 |
|
|
509 |
< |
/* |
523 |
< |
// only for Higgs < 140 |
524 |
< |
geninfo.weight *= h_w_hpt->GetBinContent(h_w_hpt->FindBin(geninfo.pt_zz)); |
525 |
< |
angles.bdt = reader->EvaluateMVA("BDTG"); |
526 |
< |
*/ |
509 |
> |
|
510 |
|
nt.Fill(); |
511 |
|
|
512 |
|
cerr << "PASS:: " |
564 |
|
|
565 |
|
} |
566 |
|
|
584 |
– |
//---------------------------------------------------------------------------- |
585 |
– |
// |
586 |
– |
// Get primary vertices |
587 |
– |
// Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW) |
588 |
– |
// NOTE: if no PV is found from fitting tracks, the beamspot is used |
589 |
– |
// |
590 |
– |
//---------------------------------------------------------------------------- |
591 |
– |
bool setPV(ControlFlags ctrl, |
592 |
– |
const mithep::Array<mithep::Vertex> * vtxArr, |
593 |
– |
mithep::Vertex & vtx) |
594 |
– |
//---------------------------------------------------------------------------- |
595 |
– |
{ |
596 |
– |
const Vertex *bestPV = 0; |
597 |
– |
float best_sumpt=-1; |
598 |
– |
|
599 |
– |
// good PV requirements |
600 |
– |
const UInt_t fMinNTracksFit = 0; |
601 |
– |
const Double_t fMinNdof = 4; |
602 |
– |
const Double_t fMaxAbsZ = 24; |
603 |
– |
const Double_t fMaxRho = 2; |
604 |
– |
|
605 |
– |
for(int i=0; i<vtxArr->GetEntries(); ++i) { |
606 |
– |
const Vertex *pv = (Vertex*)(vtxArr->At(i)); |
607 |
– |
if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl; |
608 |
– |
|
609 |
– |
// Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used |
610 |
– |
if(!pv->IsValid()) continue; |
611 |
– |
if(pv->NTracksFit() < fMinNTracksFit) continue; |
612 |
– |
if(pv->Ndof() < fMinNdof) continue; |
613 |
– |
if(fabs(pv->Z()) > fMaxAbsZ) continue; |
614 |
– |
if(pv->Position().Rho() > fMaxRho) continue; |
615 |
– |
|
616 |
– |
// take the first ... |
617 |
– |
bestPV = pv; |
618 |
– |
break; |
619 |
– |
|
620 |
– |
// this never reached ... |
621 |
– |
float tmp_sumpt=0; |
622 |
– |
for( int t=0; t<pv->NTracks(); t++ ) |
623 |
– |
tmp_sumpt += pv->Trk(t)->Pt(); |
624 |
– |
|
625 |
– |
if( tmp_sumpt > best_sumpt ) { |
626 |
– |
bestPV = pv; |
627 |
– |
best_sumpt = tmp_sumpt; |
628 |
– |
if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl; |
629 |
– |
} |
630 |
– |
} |
631 |
– |
// sync |
632 |
– |
if(!bestPV) bestPV = vtxArr->At(0); |
633 |
– |
//if(!bestPV) return false; |
634 |
– |
vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z()); |
635 |
– |
vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr()); |
636 |
– |
return true; |
637 |
– |
}; |
638 |
– |
|
567 |
|
|
568 |
|
|
569 |
|
//---------------------------------------------------------------------------- |
656 |
|
cout << "initialzing EvtRhoMap "; |
657 |
|
//FILE * f = fopen("evtrho.dat", "r"); |
658 |
|
// FILE * f = fopen("allrho.cali.uniq.dat", "r"); |
659 |
< |
FILE * f = fopen("allrhoAA.cali.uniq.dat", "r"); |
659 |
> |
FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r"); |
660 |
|
int lcount=0; |
661 |
|
while( fscanf( f, "%u:%f", &evt, &rho ) ) { |
662 |
|
if( feof(f) ) break; |
669 |
|
|
670 |
|
//---------------------------------------------------------------------------- |
671 |
|
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
672 |
< |
vector<bool> &pfNoPileUpflag, |
673 |
< |
mithep::Array<Vertex> * vtxArr ) |
672 |
> |
vector<bool> &pfNoPileUpflag, |
673 |
> |
const mithep::Array<mithep::Vertex> * vtxArr ) |
674 |
|
//---------------------------------------------------------------------------- |
675 |
|
{ |
676 |
|
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
738 |
|
return pfNoPileUpflag.size(); |
739 |
|
} |
740 |
|
|
741 |
+ |
void setEra(string fname, ControlFlags &ctrl) |
742 |
+ |
{ |
743 |
+ |
if( ctrl.mc && (fname.find("f11-") != string::npos) ) ctrl.era=2011 ; |
744 |
+ |
if( ctrl.mc && (fname.find("s12-") != string::npos) ) ctrl.era=2012 ; |
745 |
+ |
if( !ctrl.mc && (fname.find("r11-") != string::npos) ) ctrl.era=2011 ; |
746 |
+ |
if( !ctrl.mc && (fname.find("r12-") != string::npos) ) ctrl.era=2012 ; |
747 |
+ |
} |