90 |
|
vector<vector<unsigned> > zzcutvec; |
91 |
|
map<unsigned,float> evtrhoMap; |
92 |
|
vector<string> cutstrs; |
93 |
+ |
bool passes_HLT_MC; |
94 |
+ |
vector<bool> PFnoPUflag;; |
95 |
|
|
96 |
|
// |
97 |
|
// prototypes |
102 |
|
void setEffiencyWeights(EventData&, WeightStruct& ); |
103 |
|
void initRunLumiRangeMap(); |
104 |
|
void initEvtRhoMap(map<unsigned,float> &); |
105 |
+ |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
106 |
+ |
vector<bool> &pfNoPileUpFlag, |
107 |
+ |
mithep::Array<Vertex> * vtxArr ); |
108 |
|
//---------------------------------------------------------------------------- |
109 |
|
|
110 |
|
|
116 |
|
{ |
117 |
|
cutstrs.push_back(string("skim0")); //0 |
118 |
|
cutstrs.push_back(string("skim1")); //1 |
119 |
+ |
cutstrs.push_back(string("trigger")); //2 |
120 |
|
// ------------------------------------------------- |
121 |
< |
cutstrs.push_back(string("Z candidate")); //2 |
122 |
< |
cutstrs.push_back(string("good Z1")); //3 |
121 |
> |
cutstrs.push_back(string("Z candidate")); //3 |
122 |
> |
cutstrs.push_back(string("good Z1")); //4 |
123 |
|
// ------------------------------------------------- |
124 |
< |
cutstrs.push_back(string("4l")); //4 |
125 |
< |
cutstrs.push_back(string("ZZ candidate")); //5 |
126 |
< |
cutstrs.push_back(string("good Z2")); //6 |
127 |
< |
cutstrs.push_back(string("ZZ 20/10")); //7 |
128 |
< |
cutstrs.push_back(string("resonance")); //8 |
129 |
< |
cutstrs.push_back(string("m4l>70")); //9 |
130 |
< |
cutstrs.push_back(string("m4l>100")); //10 |
124 |
> |
cutstrs.push_back(string("4l")); //5 |
125 |
> |
cutstrs.push_back(string("ZZ candidate")); //6 |
126 |
> |
cutstrs.push_back(string("good Z2")); //7 |
127 |
> |
cutstrs.push_back(string("ZZ 20/10")); //8 |
128 |
> |
cutstrs.push_back(string("resonance")); //9 |
129 |
> |
cutstrs.push_back(string("m4l>70")); //10 |
130 |
> |
cutstrs.push_back(string("m4l>100")); //11 |
131 |
|
|
132 |
|
|
133 |
|
|
138 |
|
vector<vector<string> > inputFiles; |
139 |
|
inputFiles.push_back(vector<string>()); |
140 |
|
map<string,unsigned> entrymap; // number of unskimmed entries in each file |
141 |
< |
for( int i=0; i<11; i++ ) cutvec.push_back(0); |
141 |
> |
for( int i=0; i<cutstrs.size(); i++ ) cutvec.push_back(0); |
142 |
|
for( int i=0; i<2; i++ ) { |
143 |
|
zcutvec.push_back(vector<unsigned>()); |
144 |
< |
for( int j=0; j<11; j++ ) zcutvec[i].push_back(0); |
144 |
> |
for( int j=0; j<cutstrs.size(); j++ ) zcutvec[i].push_back(0); |
145 |
|
} |
146 |
|
for( int i=0; i<3; i++ ) { |
147 |
|
zzcutvec.push_back(vector<unsigned>()); |
148 |
< |
for( int j=0; j<11; j++ ) zzcutvec[i].push_back(0); |
148 |
> |
for( int j=0; j<cutstrs.size(); j++ ) zzcutvec[i].push_back(0); |
149 |
|
} |
150 |
|
|
151 |
|
|
324 |
|
for(UInt_t ientry=0; ientry<imax; ientry++) |
325 |
|
{ |
326 |
|
chain->GetEntry(ientry); |
327 |
+ |
|
328 |
+ |
// events that fail bc ele overlaps w/ reco mu |
329 |
+ |
/* |
330 |
+ |
if( info->EvtNum() != 67315 && |
331 |
+ |
info->EvtNum() != 288693 ) continue; |
332 |
+ |
*/ |
333 |
+ |
|
334 |
+ |
// events where they apparently don't veto electrons ... |
335 |
+ |
/* |
336 |
+ |
if( info->EvtNum() != 141713 && |
337 |
+ |
info->EvtNum() != 178019 && |
338 |
+ |
info->EvtNum() != 60823 && |
339 |
+ |
info->EvtNum() != 192795 ) continue; |
340 |
+ |
*/ |
341 |
+ |
|
342 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
343 |
|
setPV( ctrl, vtxArr, vtx); |
344 |
+ |
//if (!(setPV( ctrl, vtxArr, vtx)) ) continue; |
345 |
|
|
346 |
< |
cout << "origrho: " << puDArr->At(0)->Rho() |
325 |
< |
<< "\torigrholoweta: " << puDArr->At(0)->RhoLowEta() |
326 |
< |
<< endl; |
346 |
> |
float rho = evtrhoMap[info->EvtNum()]; |
347 |
|
|
348 |
+ |
// |
349 |
+ |
// pfNoPU |
350 |
+ |
// |
351 |
+ |
//mithep::Array<PFCandidate> pfNoPileUp; |
352 |
+ |
PFnoPUflag.clear(); |
353 |
+ |
int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr ); |
354 |
+ |
assert(pfnopu_size == pfArr->GetEntries()); |
355 |
|
|
356 |
|
// |
357 |
|
// data/MC |
360 |
|
// |
361 |
|
// xsec & PU weights |
362 |
|
// |
363 |
< |
// weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
363 |
> |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
364 |
|
int npu = -1; |
365 |
|
for(int i=0;i<puArr->GetEntries();i++) { |
366 |
|
if(puArr->At(i)->GetBunchCrossing() == 0) |
382 |
|
} |
383 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
384 |
|
fillTriggerBits( hltTable, trigMask, triggerBits ); |
385 |
< |
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
386 |
< |
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
387 |
< |
continue; |
385 |
> |
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
386 |
> |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
387 |
> |
passes_HLT_MC = false; |
388 |
|
} |
389 |
|
} else { |
390 |
|
// |
408 |
|
fillTriggerBits(hltTable, hltTableStrings ); |
409 |
|
} |
410 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
411 |
+ |
/* |
412 |
|
fillTriggerBits( hltTable, trigMask, triggerBits ); |
413 |
|
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
414 |
|
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
415 |
|
continue; |
416 |
|
} |
417 |
+ |
*/ |
418 |
|
} |
419 |
|
|
420 |
|
// |
423 |
|
failingLeptons.clear(); |
424 |
|
passingLeptons.clear(); |
425 |
|
EventData ret4l = |
426 |
+ |
|
427 |
+ |
/* |
428 |
|
apply_HZZ4L_reference2_selection(ctrl, info, |
429 |
|
vtx, |
430 |
|
pfArr, |
431 |
< |
// evtrhoMap[info->EvtNum()], |
431 |
> |
//rho, |
432 |
|
puDArr, |
433 |
|
electronArr, |
434 |
|
&electronReferencePreSelection, |
438 |
|
&muonReferencePreSelection, |
439 |
|
&muonIDPFSelection, |
440 |
|
&muonReferenceIsoSelection); |
410 |
– |
/* |
411 |
– |
apply_HZZ4L_reference_selection(ctrl, info, |
412 |
– |
vtx, |
413 |
– |
pfArr, |
414 |
– |
puArr, |
415 |
– |
electronArr, |
416 |
– |
&electronPreSelection, |
417 |
– |
&electronIDMVASelection, |
418 |
– |
&electronIsoMVASelection, |
419 |
– |
muonArr, |
420 |
– |
&muonPreSelection, |
421 |
– |
&muonIDPFSelection, |
422 |
– |
&muonIsoMVASelection); |
441 |
|
*/ |
442 |
+ |
apply_HZZ4L_reference2_selection(ctrl, info, |
443 |
+ |
vtx, |
444 |
+ |
pfArr, |
445 |
+ |
//rho, |
446 |
+ |
puDArr, |
447 |
+ |
electronArr, |
448 |
+ |
&electronReferencePreSelection, |
449 |
+ |
&electronReferenceIDMVASelection, |
450 |
+ |
&electronIsoMVASelection, |
451 |
+ |
muonArr, |
452 |
+ |
&muonReferencePreSelection, |
453 |
+ |
&muonIDPFSelection, |
454 |
+ |
&muonIsoMVASelection); |
455 |
+ |
|
456 |
+ |
|
457 |
+ |
|
458 |
|
|
459 |
|
if( ctrl.debug ) cout << endl; |
460 |
|
|
469 |
|
if( abs(ret4l.Z2leptons[0].type) == 13 ) Z2type = 13; |
470 |
|
} |
471 |
|
|
472 |
+ |
#ifdef SYNC |
473 |
|
cout << "bits: " << ret4l.status.selectionBits << "\t" |
474 |
|
<< "Z1: " << Z1type << "\t" |
475 |
|
<< "Z2: " << Z2type << endl; |
476 |
|
cout << endl; |
477 |
< |
|
477 |
> |
#endif |
478 |
|
|
479 |
|
if( ret4l.status.pass() ) { |
480 |
|
fillAngles(ret4l,angles); |
508 |
|
pass++; |
509 |
|
// if( pass > 3 ) break; |
510 |
|
|
511 |
< |
} else if( ret4l.status.selectionBits.test(PASS_ZCANDIDATE) ) { // save for fakes ... |
512 |
< |
if(ctrl.debug) { |
511 |
> |
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) ) { // save for fakes ... |
512 |
> |
// if(ctrl.debug) { |
513 |
|
cout << "failingLeptons : " << failingLeptons.size() << endl; |
514 |
|
for( int f=0; f<failingLeptons.size(); f++ ) { |
515 |
|
SimpleLepton l = failingLeptons[f]; |
518 |
|
<< "pT: " << l.vec.Pt() << "\t" |
519 |
|
<< "eta: " << l.vec.Eta() |
520 |
|
<< endl; |
521 |
< |
} |
521 |
> |
// } |
522 |
|
} |
523 |
|
foTree.Fill(); |
524 |
|
} |
535 |
|
cout << "cut: " << i << "\t" |
536 |
|
<< "pass: " << cutvec[i]; |
537 |
|
|
538 |
< |
if( i>1&&i<=3 ) |
538 |
> |
if( i>PASS_TRIGGER&&i<=PASS_GOODZ1 ) |
539 |
|
cout << "\t2e: " << zcutvec[0][i] |
540 |
|
<< "\t2m: " << zcutvec[1][i]; |
541 |
|
|
542 |
< |
if( i>3 ) |
542 |
> |
if( i>PASS_ZCANDIDATE ) |
543 |
|
cout << "\t4e: " << zzcutvec[0][i] |
544 |
|
<< "\t4m: " << zzcutvec[1][i] |
545 |
|
<< "\t2e2m: " << zzcutvec[2][i]; |
577 |
|
if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl; |
578 |
|
|
579 |
|
// Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used |
580 |
< |
// if(!pv->IsValid()) continue; |
580 |
> |
if(!pv->IsValid()) continue; |
581 |
|
if(pv->NTracksFit() < fMinNTracksFit) continue; |
582 |
|
if(pv->Ndof() < fMinNdof) continue; |
583 |
|
if(fabs(pv->Z()) > fMaxAbsZ) continue; |
598 |
|
if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl; |
599 |
|
} |
600 |
|
} |
601 |
< |
|
601 |
> |
// sync |
602 |
|
if(!bestPV) bestPV = vtxArr->At(0); |
603 |
+ |
//if(!bestPV) return false; |
604 |
|
vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z()); |
605 |
|
vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr()); |
606 |
|
return true; |
695 |
|
unsigned evt; |
696 |
|
float rho; |
697 |
|
|
698 |
< |
FILE * f = fopen("evtrho.dat", "r"); |
698 |
> |
cout << "initialzing EvtRhoMap "; |
699 |
> |
//FILE * f = fopen("evtrho.dat", "r"); |
700 |
> |
// FILE * f = fopen("allrho.cali.uniq.dat", "r"); |
701 |
> |
FILE * f = fopen("allrhoAA.cali.uniq.dat", "r"); |
702 |
> |
int lcount=0; |
703 |
|
while( fscanf( f, "%u:%f", &evt, &rho ) ) { |
704 |
+ |
if( feof(f) ) break; |
705 |
|
evtrhoMap[evt] = rho; |
706 |
+ |
lcount++; |
707 |
+ |
if( !(lcount%1000) ) cout << "."; flush(cout); |
708 |
|
} |
709 |
< |
|
709 |
> |
cout << " done" << endl; |
710 |
> |
} |
711 |
> |
|
712 |
> |
//---------------------------------------------------------------------------- |
713 |
> |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
714 |
> |
vector<bool> &pfNoPileUpflag, |
715 |
> |
mithep::Array<Vertex> * vtxArr ) |
716 |
> |
//---------------------------------------------------------------------------- |
717 |
> |
{ |
718 |
> |
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
719 |
> |
const PFCandidate *pf = fPFCandidates->At(i); |
720 |
> |
assert(pf); |
721 |
> |
|
722 |
> |
if(pf->PFType() == PFCandidate::eHadron) { |
723 |
> |
if(pf->HasTrackerTrk() && |
724 |
> |
vtxArr->At(0)->HasTrack(pf->TrackerTrk()) && |
725 |
> |
vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) { |
726 |
> |
|
727 |
> |
pfNoPileUpflag.push_back(1); |
728 |
> |
|
729 |
> |
} else { |
730 |
> |
|
731 |
> |
Bool_t vertexFound = kFALSE; |
732 |
> |
const Vertex *closestVtx = 0; |
733 |
> |
Double_t dzmin = 10000; |
734 |
> |
|
735 |
> |
// loop over vertices |
736 |
> |
for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) { |
737 |
> |
const Vertex *vtx = vtxArr->At(j); |
738 |
> |
assert(vtx); |
739 |
> |
|
740 |
> |
if(pf->HasTrackerTrk() && |
741 |
> |
vtx->HasTrack(pf->TrackerTrk()) && |
742 |
> |
vtx->TrackWeight(pf->TrackerTrk()) > 0) { |
743 |
> |
vertexFound = kTRUE; |
744 |
> |
closestVtx = vtx; |
745 |
> |
break; |
746 |
> |
} |
747 |
> |
Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z()); |
748 |
> |
if(dz < dzmin) { |
749 |
> |
closestVtx = vtx; |
750 |
> |
dzmin = dz; |
751 |
> |
} |
752 |
> |
} |
753 |
> |
|
754 |
> |
// if(fCheckClosestZVertex) { |
755 |
> |
if(1) { |
756 |
> |
// Fallback: if track is not associated with any vertex, |
757 |
> |
// associate it with the vertex closest in z |
758 |
> |
if(vertexFound || closestVtx != vtxArr->At(0)) { |
759 |
> |
// pfPileUp->Add(pf); |
760 |
> |
pfNoPileUpflag.push_back(0); |
761 |
> |
} else { |
762 |
> |
pfNoPileUpflag.push_back(1); |
763 |
> |
} |
764 |
> |
} else { |
765 |
> |
if(vertexFound && closestVtx != vtxArr->At(0)) { |
766 |
> |
// pfPileUp->Add(pf); |
767 |
> |
pfNoPileUpflag.push_back(0); |
768 |
> |
} else { |
769 |
> |
// PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is |
770 |
> |
pfNoPileUpflag.push_back(1); |
771 |
> |
} |
772 |
> |
} |
773 |
> |
} //hadron & trk stuff |
774 |
> |
} else { // hadron |
775 |
> |
// PFCandidate * ptr = pfNoPileUp->AddNew(); |
776 |
> |
pfNoPileUpflag.push_back(1); |
777 |
> |
} |
778 |
> |
} // Loop over PF candidates |
779 |
> |
|
780 |
> |
return pfNoPileUpflag.size(); |
781 |
|
} |
782 |
+ |
|