5 |
|
#include <iostream> // standard I/O |
6 |
|
#include <iomanip> // functions to format standard I/O |
7 |
|
#include <bitset> |
8 |
+ |
#include <map> |
9 |
|
using namespace std; |
10 |
|
|
11 |
|
// |
37 |
|
#include "PFCandidateCol.h" |
38 |
|
#include "PileupInfoCol.h" |
39 |
|
#include "PileupEnergyDensity.h" |
40 |
+ |
#include "MCParticle.h" |
41 |
|
#include "TriggerMask.h" |
42 |
|
#include "TriggerTable.h" |
43 |
|
#include "Names.h" |
52 |
|
#include "IsolationSelection.h" |
53 |
|
|
54 |
|
//#include "Selection.h" |
55 |
< |
#include "ReferenceSelection.h" |
55 |
> |
//#include "ReferenceSelection.h" |
56 |
> |
#include "ReferenceSelection2.h" |
57 |
|
|
58 |
|
#include "TriggerUtils.h" |
59 |
|
#include "PassHLT.h" |
86 |
|
RunLumiRangeMap rlrm; |
87 |
|
vector<SimpleLepton> failingLeptons ; // for fake estimation |
88 |
|
vector<SimpleLepton> passingLeptons; // for fake estimation |
89 |
+ |
vector<unsigned> cutvec; |
90 |
+ |
vector<vector<unsigned> > zcutvec; |
91 |
+ |
vector<vector<unsigned> > zzcutvec; |
92 |
+ |
map<unsigned,float> evtrhoMap; |
93 |
+ |
vector<string> cutstrs; |
94 |
+ |
bool passes_HLT_MC; |
95 |
+ |
vector<bool> PFnoPUflag;; |
96 |
|
|
97 |
|
// |
98 |
|
// prototypes |
99 |
|
//---------------------------------------------------------------------------- |
90 |
– |
bool setPV(ControlFlags,const mithep::Array<mithep::Vertex>*, mithep::Vertex& ); |
100 |
|
void initPUWeights(); |
101 |
|
double getPUWeight(unsigned npu); |
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 |
+ |
const mithep::VertexCol * vtxArr ); |
108 |
|
//---------------------------------------------------------------------------- |
109 |
|
|
110 |
|
|
114 |
|
int main(int argc, char** argv) |
115 |
|
//---------------------------------------------------------------------------- |
116 |
|
{ |
117 |
+ |
cutstrs.push_back(string("skim0")); //0 |
118 |
+ |
cutstrs.push_back(string("skim1")); //1 |
119 |
+ |
cutstrs.push_back(string("skim2")); //1 |
120 |
+ |
cutstrs.push_back(string("trigger")); //2 |
121 |
+ |
// ------------------------------------------------- |
122 |
+ |
cutstrs.push_back(string("Z candidate")); //3 |
123 |
+ |
cutstrs.push_back(string("good Z1")); //4 |
124 |
+ |
// ------------------------------------------------- |
125 |
+ |
cutstrs.push_back(string("4l")); //5 |
126 |
+ |
cutstrs.push_back(string("ZZ candidate")); //6 |
127 |
+ |
cutstrs.push_back(string("good Z2")); //7 |
128 |
+ |
cutstrs.push_back(string("ZZ 20/10")); //8 |
129 |
+ |
cutstrs.push_back(string("resonance")); //9 |
130 |
+ |
cutstrs.push_back(string("m4l>70")); //10 |
131 |
+ |
cutstrs.push_back(string("m4l>100, mZ2 > 12")); //11 |
132 |
+ |
|
133 |
+ |
|
134 |
+ |
|
135 |
+ |
|
136 |
|
string cmsswpath(CMSSW_BASE); |
137 |
|
cmsswpath.append("/src"); |
138 |
|
std::bitset<1024> triggerBits; |
139 |
|
vector<vector<string> > inputFiles; |
140 |
|
inputFiles.push_back(vector<string>()); |
141 |
|
map<string,unsigned> entrymap; // number of unskimmed entries in each file |
142 |
+ |
for( int i=0; i<cutstrs.size(); i++ ) cutvec.push_back(0); |
143 |
+ |
for( int i=0; i<2; i++ ) { |
144 |
+ |
zcutvec.push_back(vector<unsigned>()); |
145 |
+ |
for( int j=0; j<cutstrs.size(); j++ ) zcutvec[i].push_back(0); |
146 |
+ |
} |
147 |
+ |
for( int i=0; i<3; i++ ) { |
148 |
+ |
zzcutvec.push_back(vector<unsigned>()); |
149 |
+ |
for( int j=0; j<cutstrs.size(); j++ ) zzcutvec[i].push_back(0); |
150 |
+ |
} |
151 |
+ |
|
152 |
|
|
153 |
|
// |
154 |
|
// args |
252 |
|
initElectronIDMVA(); |
253 |
|
initElectronIsoMVA(); |
254 |
|
initTrigger(); |
255 |
< |
|
255 |
> |
|
256 |
> |
// hack |
257 |
> |
initEvtRhoMap(evtrhoMap); |
258 |
|
|
259 |
|
|
260 |
|
// |
268 |
|
// mithep::TGenInfo *ginfo = new mithep::TGenInfo(); |
269 |
|
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
270 |
|
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
271 |
< |
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
271 |
> |
const mithep::VertexCol *vtxArr = 0;//new mithep::Array<mithep::Vertex>(); |
272 |
|
mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>(); |
273 |
|
mithep::Array<mithep::PileupInfo> *puArr = new mithep::Array<mithep::PileupInfo>(); |
274 |
|
mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
275 |
|
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
276 |
+ |
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
277 |
|
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
278 |
|
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
279 |
|
vector<string> *hltTableStrings = new vector<string>(); |
286 |
|
TString fPileupInfoName(Names::gkPileupInfoBrn); |
287 |
|
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
288 |
|
TString fTrackName(Names::gkTrackBrn); |
289 |
+ |
TString fMCParticleName(Names::gkMCPartBrn); |
290 |
|
TString fTriggerMaskName(Names::gkHltBitBrn); |
291 |
|
TString fTriggerTableName(Names::gkHltTableBrn); |
292 |
|
|
295 |
|
chain->SetBranchAddress(fMuonName, &muonArr); |
296 |
|
chain->SetBranchAddress(fPrimVtxName, &vtxArr); |
297 |
|
chain->SetBranchAddress(fPFCandidateName, &pfArr); |
298 |
< |
if( ctrl.mc ) chain->SetBranchAddress(fPileupInfoName, &puArr); |
298 |
> |
if( ctrl.mc ) { |
299 |
> |
chain->SetBranchAddress(fPileupInfoName, &puArr); |
300 |
> |
chain->SetBranchAddress(fMCParticleName, &mcArr); |
301 |
> |
} |
302 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
303 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
304 |
|
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
330 |
|
for(UInt_t ientry=0; ientry<imax; ientry++) |
331 |
|
{ |
332 |
|
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 |
+ |
|
367 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
368 |
< |
setPV( ctrl, vtxArr, vtx); |
368 |
> |
//if (!(setPV( ctrl, vtxArr, vtx)) ) continue; |
369 |
|
|
370 |
+ |
float rho = evtrhoMap[info->EvtNum()]; |
371 |
+ |
|
372 |
+ |
// |
373 |
+ |
// pfNoPU |
374 |
+ |
// |
375 |
+ |
//mithep::Array<PFCandidate> pfNoPileUp; |
376 |
+ |
PFnoPUflag.clear(); |
377 |
+ |
int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr ); |
378 |
+ |
assert(pfnopu_size == pfArr->GetEntries()); |
379 |
|
|
380 |
|
// |
381 |
|
// data/MC |
384 |
|
// |
385 |
|
// xsec & PU weights |
386 |
|
// |
387 |
< |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
387 |
> |
weights.w = 1;//getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
388 |
> |
cout << "xsec weight: " << weights.w << endl; |
389 |
|
int npu = -1; |
390 |
|
for(int i=0;i<puArr->GetEntries();i++) { |
391 |
|
if(puArr->At(i)->GetBunchCrossing() == 0) |
395 |
|
evtinfo.npu; |
396 |
|
weights.npuw = getPUWeight(evtinfo.npu); |
397 |
|
// cout << "weight: " << weights.w << endl; |
398 |
+ |
// |
399 |
+ |
// trigger |
400 |
+ |
// |
401 |
+ |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
402 |
+ |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
403 |
+ |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
404 |
+ |
hltchain->GetEntry(0); |
405 |
+ |
hltTable->Clear(); |
406 |
+ |
fillTriggerBits(hltTable, hltTableStrings ); |
407 |
+ |
} |
408 |
+ |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
409 |
+ |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
410 |
+ |
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
411 |
+ |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) { |
412 |
+ |
passes_HLT_MC = false; |
413 |
+ |
} |
414 |
|
} else { |
415 |
|
// |
416 |
|
// JSON |
433 |
|
fillTriggerBits(hltTable, hltTableStrings ); |
434 |
|
} |
435 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
436 |
+ |
/* |
437 |
|
fillTriggerBits( hltTable, trigMask, triggerBits ); |
438 |
|
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
439 |
|
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
440 |
|
continue; |
441 |
|
} |
442 |
+ |
*/ |
443 |
|
} |
444 |
|
|
445 |
|
// |
448 |
|
failingLeptons.clear(); |
449 |
|
passingLeptons.clear(); |
450 |
|
EventData ret4l = |
451 |
< |
apply_HZZ4L_reference_selection(ctrl, info, |
452 |
< |
vtx, |
453 |
< |
pfArr, |
454 |
< |
puDArr, |
455 |
< |
electronArr, |
456 |
< |
&electronReferencePreSelection, |
457 |
< |
&electronReferenceIDMVASelection, |
458 |
< |
&electronReferenceIsoSelection, |
459 |
< |
muonArr, |
460 |
< |
&muonReferencePreSelection, |
461 |
< |
&muonIDPFSelection, |
462 |
< |
&muonReferenceIsoSelection); |
463 |
< |
/* |
464 |
< |
apply_HZZ4L_reference_selection(ctrl, info, |
465 |
< |
vtx, |
466 |
< |
pfArr, |
467 |
< |
puArr, |
468 |
< |
electronArr, |
469 |
< |
&electronPreSelection, |
470 |
< |
&electronIDMVASelection, |
471 |
< |
&electronIsoMVASelection, |
472 |
< |
muonArr, |
473 |
< |
&muonPreSelection, |
474 |
< |
&muonIDPFSelection, |
475 |
< |
&muonIsoMVASelection); |
476 |
< |
*/ |
451 |
> |
|
452 |
> |
|
453 |
> |
// reference |
454 |
> |
apply_HZZ4L_reference2_selection(ctrl, info, |
455 |
> |
vtxArr, |
456 |
> |
pfArr, |
457 |
> |
#ifdef HACKED_RHOS |
458 |
> |
rho, |
459 |
> |
#else |
460 |
> |
puDArr, |
461 |
> |
#endif |
462 |
> |
electronArr, |
463 |
> |
&electronReferencePreSelection, |
464 |
> |
&electronReferenceIDMVASelectionV1, |
465 |
> |
&electronReferenceIsoSelection, |
466 |
> |
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 |
|
|
490 |
|
if( ctrl.debug ) cout << endl; |
491 |
|
|
492 |
< |
// cout << "bits: " << ret4l.status.selectionBits << endl; |
492 |
> |
|
493 |
> |
int Z1type=0, Z2type=0; |
494 |
> |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZCANDIDATE ) { |
495 |
> |
if( abs(ret4l.Z1leptons[0].type) == 11 ) Z1type = 11; |
496 |
> |
if( abs(ret4l.Z1leptons[0].type) == 13 ) Z1type = 13; |
497 |
> |
} |
498 |
> |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZZCANDIDATE ) { |
499 |
> |
if( abs(ret4l.Z2leptons[0].type) == 11 ) Z2type = 11; |
500 |
> |
if( abs(ret4l.Z2leptons[0].type) == 13 ) Z2type = 13; |
501 |
> |
} |
502 |
> |
|
503 |
> |
#ifdef SYNC |
504 |
> |
cout << "bits: " << ret4l.status.selectionBits << "\t" |
505 |
> |
<< "Z1: " << Z1type << "\t" |
506 |
> |
<< "Z2: " << Z2type << endl; |
507 |
> |
cout << endl; |
508 |
> |
#endif |
509 |
|
|
510 |
|
if( ret4l.status.pass() ) { |
511 |
|
fillAngles(ret4l,angles); |
539 |
|
pass++; |
540 |
|
// if( pass > 3 ) break; |
541 |
|
|
542 |
< |
} else if( ret4l.status.selectionBits.test(PASS_ZCANDIDATE) ) { // save for fakes ... |
543 |
< |
if(ctrl.debug) { |
542 |
> |
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) ) { // save for fakes ... |
543 |
> |
// if(ctrl.debug) { |
544 |
|
cout << "failingLeptons : " << failingLeptons.size() << endl; |
545 |
|
for( int f=0; f<failingLeptons.size(); f++ ) { |
546 |
|
SimpleLepton l = failingLeptons[f]; |
549 |
|
<< "pT: " << l.vec.Pt() << "\t" |
550 |
|
<< "eta: " << l.vec.Eta() |
551 |
|
<< endl; |
552 |
< |
} |
552 |
> |
// } |
553 |
|
} |
554 |
|
foTree.Fill(); |
555 |
|
} |
559 |
|
foTree.getFile()->cd(); |
560 |
|
foTree.getTree()->Write(); |
561 |
|
nt.WriteClose(); |
423 |
– |
} |
562 |
|
|
563 |
< |
//---------------------------------------------------------------------------- |
564 |
< |
// |
565 |
< |
// Get primary vertices |
566 |
< |
// Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW) |
567 |
< |
// NOTE: if no PV is found from fitting tracks, the beamspot is used |
568 |
< |
// |
569 |
< |
//---------------------------------------------------------------------------- |
570 |
< |
bool setPV(ControlFlags ctrl, |
571 |
< |
const mithep::Array<mithep::Vertex> * vtxArr, |
572 |
< |
mithep::Vertex & vtx) |
573 |
< |
//---------------------------------------------------------------------------- |
574 |
< |
{ |
575 |
< |
const Vertex *bestPV = 0; |
576 |
< |
float best_sumpt=-1; |
577 |
< |
|
578 |
< |
// good PV requirements |
579 |
< |
const UInt_t fMinNTracksFit = 0; |
580 |
< |
const Double_t fMinNdof = 4; |
443 |
< |
const Double_t fMaxAbsZ = 24; |
444 |
< |
const Double_t fMaxRho = 2; |
445 |
< |
|
446 |
< |
for(int i=0; i<vtxArr->GetEntries(); ++i) { |
447 |
< |
const Vertex *pv = (Vertex*)(vtxArr->At(i)); |
448 |
< |
if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl; |
449 |
< |
|
450 |
< |
// Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used |
451 |
< |
// if(!pv->IsValid()) continue; |
452 |
< |
if(pv->NTracksFit() < fMinNTracksFit) continue; |
453 |
< |
if(pv->Ndof() < fMinNdof) continue; |
454 |
< |
if(fabs(pv->Z()) > fMaxAbsZ) continue; |
455 |
< |
if(pv->Position().Rho() > fMaxRho) continue; |
456 |
< |
|
457 |
< |
// take the first ... |
458 |
< |
bestPV = pv; |
459 |
< |
break; |
460 |
< |
|
461 |
< |
// this never reached ... |
462 |
< |
float tmp_sumpt=0; |
463 |
< |
for( int t=0; t<pv->NTracks(); t++ ) |
464 |
< |
tmp_sumpt += pv->Trk(t)->Pt(); |
465 |
< |
|
466 |
< |
if( tmp_sumpt > best_sumpt ) { |
467 |
< |
bestPV = pv; |
468 |
< |
best_sumpt = tmp_sumpt; |
469 |
< |
if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl; |
470 |
< |
} |
563 |
> |
cout << endl; |
564 |
> |
cout << endl; |
565 |
> |
for( int i=0; i<cutvec.size(); i++ ) { |
566 |
> |
cout << "cut: " << i << "\t" |
567 |
> |
<< "pass: " << cutvec[i]; |
568 |
> |
|
569 |
> |
if( i>PASS_TRIGGER&&i<=PASS_GOODZ1 ) |
570 |
> |
cout << "\t2e: " << zcutvec[0][i] |
571 |
> |
<< "\t2m: " << zcutvec[1][i]; |
572 |
> |
|
573 |
> |
if( i>PASS_ZCANDIDATE ) |
574 |
> |
cout << "\t4e: " << zzcutvec[0][i] |
575 |
> |
<< "\t4m: " << zzcutvec[1][i] |
576 |
> |
<< "\t2e2m: " << zzcutvec[2][i]; |
577 |
> |
|
578 |
> |
cout << "\t" << cutstrs[i] << endl; |
579 |
> |
|
580 |
> |
cout << endl; |
581 |
|
} |
582 |
< |
|
583 |
< |
if(!bestPV) bestPV = vtxArr->At(0); |
474 |
< |
vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z()); |
475 |
< |
vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr()); |
476 |
< |
return true; |
477 |
< |
}; |
582 |
> |
|
583 |
> |
} |
584 |
|
|
585 |
|
|
586 |
|
|
663 |
|
{ |
664 |
|
return hpu->GetBinContent(hpu->FindBin(npu)); |
665 |
|
} |
666 |
+ |
|
667 |
+ |
//---------------------------------------------------------------------------- |
668 |
+ |
void initEvtRhoMap( map<unsigned, float> & evtrhoMap ) |
669 |
+ |
//---------------------------------------------------------------------------- |
670 |
+ |
{ |
671 |
+ |
unsigned evt; |
672 |
+ |
float rho; |
673 |
+ |
|
674 |
+ |
cout << "initialzing EvtRhoMap "; |
675 |
+ |
//FILE * f = fopen("evtrho.dat", "r"); |
676 |
+ |
// FILE * f = fopen("allrho.cali.uniq.dat", "r"); |
677 |
+ |
FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r"); |
678 |
+ |
int lcount=0; |
679 |
+ |
while( fscanf( f, "%u:%f", &evt, &rho ) ) { |
680 |
+ |
if( feof(f) ) break; |
681 |
+ |
evtrhoMap[evt] = rho; |
682 |
+ |
lcount++; |
683 |
+ |
if( !(lcount%1000) ) cout << "."; flush(cout); |
684 |
+ |
} |
685 |
+ |
cout << " done" << endl; |
686 |
+ |
} |
687 |
+ |
|
688 |
+ |
//---------------------------------------------------------------------------- |
689 |
+ |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
690 |
+ |
vector<bool> &pfNoPileUpflag, |
691 |
+ |
const mithep::VertexCol * vtxArr ) |
692 |
+ |
//---------------------------------------------------------------------------- |
693 |
+ |
{ |
694 |
+ |
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
695 |
+ |
const PFCandidate *pf = fPFCandidates->At(i); |
696 |
+ |
assert(pf); |
697 |
+ |
|
698 |
+ |
if(pf->PFType() == PFCandidate::eHadron) { |
699 |
+ |
if(pf->HasTrackerTrk() && |
700 |
+ |
vtxArr->At(0)->HasTrack(pf->TrackerTrk()) && |
701 |
+ |
vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) { |
702 |
+ |
|
703 |
+ |
pfNoPileUpflag.push_back(1); |
704 |
+ |
|
705 |
+ |
} else { |
706 |
+ |
|
707 |
+ |
Bool_t vertexFound = kFALSE; |
708 |
+ |
const Vertex *closestVtx = 0; |
709 |
+ |
Double_t dzmin = 10000; |
710 |
+ |
|
711 |
+ |
// loop over vertices |
712 |
+ |
for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) { |
713 |
+ |
const Vertex *vtx = vtxArr->At(j); |
714 |
+ |
assert(vtx); |
715 |
+ |
|
716 |
+ |
if(pf->HasTrackerTrk() && |
717 |
+ |
vtx->HasTrack(pf->TrackerTrk()) && |
718 |
+ |
vtx->TrackWeight(pf->TrackerTrk()) > 0) { |
719 |
+ |
vertexFound = kTRUE; |
720 |
+ |
closestVtx = vtx; |
721 |
+ |
break; |
722 |
+ |
} |
723 |
+ |
Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z()); |
724 |
+ |
if(dz < dzmin) { |
725 |
+ |
closestVtx = vtx; |
726 |
+ |
dzmin = dz; |
727 |
+ |
} |
728 |
+ |
} |
729 |
+ |
|
730 |
+ |
// if(fCheckClosestZVertex) { |
731 |
+ |
if(1) { |
732 |
+ |
// Fallback: if track is not associated with any vertex, |
733 |
+ |
// associate it with the vertex closest in z |
734 |
+ |
if(vertexFound || closestVtx != vtxArr->At(0)) { |
735 |
+ |
// pfPileUp->Add(pf); |
736 |
+ |
pfNoPileUpflag.push_back(0); |
737 |
+ |
} else { |
738 |
+ |
pfNoPileUpflag.push_back(1); |
739 |
+ |
} |
740 |
+ |
} else { |
741 |
+ |
if(vertexFound && closestVtx != vtxArr->At(0)) { |
742 |
+ |
// pfPileUp->Add(pf); |
743 |
+ |
pfNoPileUpflag.push_back(0); |
744 |
+ |
} else { |
745 |
+ |
// PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is |
746 |
+ |
pfNoPileUpflag.push_back(1); |
747 |
+ |
} |
748 |
+ |
} |
749 |
+ |
} //hadron & trk stuff |
750 |
+ |
} else { // hadron |
751 |
+ |
// PFCandidate * ptr = pfNoPileUp->AddNew(); |
752 |
+ |
pfNoPileUpflag.push_back(1); |
753 |
+ |
} |
754 |
+ |
} // Loop over PF candidates |
755 |
+ |
|
756 |
+ |
return pfNoPileUpflag.size(); |
757 |
+ |
} |
758 |
+ |
|