60 |
|
#include "Angles.h" |
61 |
|
#include "KinematicsStruct.h" |
62 |
|
#include "InfoStruct.h" |
63 |
< |
//#include "GenInfoStruct.h" |
63 |
> |
#include "GenInfoStruct.h" |
64 |
|
#include "WeightStruct.h" |
65 |
|
//#include "GlobalDataAndFuncs.h" |
66 |
|
#include "RunLumiRangeMap.h" |
99 |
|
//---------------------------------------------------------------------------- |
100 |
|
void initPUWeights(); |
101 |
|
double getPUWeight(unsigned npu); |
102 |
+ |
void setEra(string, ControlFlags&); |
103 |
|
void setEffiencyWeights(EventData&, WeightStruct& ); |
104 |
|
void initRunLumiRangeMap(); |
105 |
|
void initEvtRhoMap(map<unsigned,float> &); |
106 |
|
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
107 |
|
vector<bool> &pfNoPileUpFlag, |
108 |
< |
const mithep::VertexCol * vtxArr ); |
108 |
> |
const mithep::Array<mithep::Vertex> * vtxArr ); |
109 |
|
//---------------------------------------------------------------------------- |
110 |
|
|
111 |
|
|
215 |
|
KinematicsStruct kinematics; |
216 |
|
InfoStruct evtinfo; |
217 |
|
WeightStruct weights; |
218 |
< |
// GenInfoStruct geninfo; |
218 |
> |
GenInfoStruct geninfo; |
219 |
|
|
220 |
|
AngleTuple nt( (const char*)ofname, (const char*)"zznt"); |
221 |
|
nt.makeAngleBranch(angles); |
226 |
|
foTree.makeFailedLeptonBranch(failingLeptons); |
227 |
|
foTree.makeZLeptonBranch(passingLeptons); |
228 |
|
|
229 |
< |
TH1F * h_w_hpt; |
229 |
> |
TH1F * h_wf11_hpt; |
230 |
|
if(ctrl.mc) { |
231 |
|
nt.makeWeightBranch(weights); |
232 |
< |
// nt.makeGenInfoBranch(geninfo); |
232 |
> |
nt.makeGenInfoBranch(geninfo); |
233 |
|
initEfficiencyWeights(); |
234 |
|
initPUWeights(); |
235 |
< |
/* |
235 |
> |
|
236 |
|
// Higgs only, pt reweighting |
237 |
|
if( ctrl.mH <= 140 ) { |
238 |
|
char wptname[256]; |
240 |
|
TFile * f_hpt = new TFile(wptname); |
241 |
|
f_hpt->Print(); |
242 |
|
sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH); |
243 |
< |
h_w_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
243 |
< |
h_w_hpt->Print(); |
243 |
> |
h_wf11_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
244 |
|
} |
245 |
< |
*/ |
245 |
> |
|
246 |
|
} else { |
247 |
|
initRunLumiRangeMap(); |
248 |
|
} |
265 |
|
string currentFile(""); |
266 |
|
|
267 |
|
mithep::EventHeader *info = new mithep::EventHeader(); |
268 |
– |
// mithep::TGenInfo *ginfo = new mithep::TGenInfo(); |
268 |
|
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
269 |
|
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
270 |
< |
const mithep::VertexCol *vtxArr = 0;//new mithep::Array<mithep::Vertex>(); |
270 |
> |
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
271 |
|
mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>(); |
272 |
|
mithep::Array<mithep::PileupInfo> *puArr = new mithep::Array<mithep::PileupInfo>(); |
273 |
|
mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
274 |
|
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
275 |
|
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
276 |
+ |
mithep::MCEventInfo *mcEvtInfo = new mithep::MCEventInfo(); |
277 |
|
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
278 |
|
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
279 |
|
vector<string> *hltTableStrings = new vector<string>(); |
287 |
|
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
288 |
|
TString fTrackName(Names::gkTrackBrn); |
289 |
|
TString fMCParticleName(Names::gkMCPartBrn); |
290 |
+ |
TString fMCEvtInfoName(Names::gkMCEvtInfoBrn); |
291 |
|
TString fTriggerMaskName(Names::gkHltBitBrn); |
292 |
|
TString fTriggerTableName(Names::gkHltTableBrn); |
293 |
|
|
299 |
|
if( ctrl.mc ) { |
300 |
|
chain->SetBranchAddress(fPileupInfoName, &puArr); |
301 |
|
chain->SetBranchAddress(fMCParticleName, &mcArr); |
302 |
+ |
chain->SetBranchAddress(fMCEvtInfoName, &mcEvtInfo); |
303 |
|
} |
304 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
305 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
332 |
|
for(UInt_t ientry=0; ientry<imax; ientry++) |
333 |
|
{ |
334 |
|
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 |
– |
|
335 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
368 |
– |
//if (!(setPV( ctrl, vtxArr, vtx)) ) continue; |
336 |
|
|
337 |
+ |
#ifdef HACKED_RHOS |
338 |
|
float rho = evtrhoMap[info->EvtNum()]; |
339 |
+ |
#endif |
340 |
+ |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
341 |
+ |
setEra( fname, ctrl ); |
342 |
+ |
|
343 |
|
|
344 |
|
// |
345 |
|
// pfNoPU |
354 |
|
// |
355 |
|
if(ctrl.mc) { |
356 |
|
// |
357 |
+ |
// gen info |
358 |
+ |
// |
359 |
+ |
if(ctrl.fillGen) |
360 |
+ |
fillGenInfo( mcArr, mcEvtInfo, geninfo, ESampleType::kHZZ, ctrl); |
361 |
+ |
|
362 |
+ |
// |
363 |
|
// xsec & PU weights |
364 |
|
// |
365 |
< |
weights.w = 1;//getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
365 |
> |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
366 |
|
cout << "xsec weight: " << weights.w << endl; |
367 |
|
int npu = -1; |
368 |
|
for(int i=0;i<puArr->GetEntries();i++) { |
372 |
|
assert(npu>=0); |
373 |
|
evtinfo.npu; |
374 |
|
weights.npuw = getPUWeight(evtinfo.npu); |
375 |
< |
// cout << "weight: " << weights.w << endl; |
375 |
> |
|
376 |
> |
// |
377 |
> |
// pt reweighting for Higgs < 140, F11 |
378 |
> |
// |
379 |
> |
if( ctrl.fillGen ) { |
380 |
> |
if( (fname.find("f11-h115zz4l") != string::npos) || |
381 |
> |
(fname.find("f11-h120zz4l") != string::npos) || |
382 |
> |
(fname.find("f11-h130zz4l") != string::npos) ) { |
383 |
> |
weights.w *= h_wf11_hpt->GetBinContent(h_wf11_hpt->FindBin(geninfo.pt_zz)); |
384 |
> |
} |
385 |
> |
} |
386 |
> |
|
387 |
|
// |
388 |
|
// trigger |
389 |
|
// |
509 |
|
<< "woff: " << weights.woff << endl; |
510 |
|
} |
511 |
|
|
512 |
< |
/* |
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 |
< |
*/ |
512 |
> |
|
513 |
|
nt.Fill(); |
514 |
|
|
515 |
|
cerr << "PASS:: " |
672 |
|
|
673 |
|
//---------------------------------------------------------------------------- |
674 |
|
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
675 |
< |
vector<bool> &pfNoPileUpflag, |
676 |
< |
const mithep::VertexCol * vtxArr ) |
675 |
> |
vector<bool> &pfNoPileUpflag, |
676 |
> |
const mithep::Array<mithep::Vertex> * vtxArr ) |
677 |
|
//---------------------------------------------------------------------------- |
678 |
|
{ |
679 |
|
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
741 |
|
return pfNoPileUpflag.size(); |
742 |
|
} |
743 |
|
|
744 |
+ |
void setEra(string fname, ControlFlags &ctrl) |
745 |
+ |
{ |
746 |
+ |
if( ctrl.mc && (fname.find("f11-") != string::npos) ) ctrl.era=2011 ; |
747 |
+ |
if( ctrl.mc && (fname.find("s12-") != string::npos) ) ctrl.era=2012 ; |
748 |
+ |
if( !ctrl.mc && (fname.find("r11-") != string::npos) ) ctrl.era=2011 ; |
749 |
+ |
if( !ctrl.mc && (fname.find("r12-") != string::npos) ) ctrl.era=2012 ; |
750 |
+ |
} |