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 |
|
// |
51 |
|
#include "IsolationSelection.h" |
52 |
|
|
53 |
|
//#include "Selection.h" |
54 |
< |
#include "ReferenceSelection.h" |
54 |
> |
//#include "ReferenceSelection.h" |
55 |
> |
#include "ReferenceSelection2.h" |
56 |
|
|
57 |
|
#include "TriggerUtils.h" |
58 |
|
#include "PassHLT.h" |
85 |
|
RunLumiRangeMap rlrm; |
86 |
|
vector<SimpleLepton> failingLeptons ; // for fake estimation |
87 |
|
vector<SimpleLepton> passingLeptons; // for fake estimation |
88 |
+ |
vector<unsigned> cutvec; |
89 |
+ |
vector<vector<unsigned> > zcutvec; |
90 |
+ |
vector<vector<unsigned> > zzcutvec; |
91 |
+ |
map<unsigned,float> evtrhoMap; |
92 |
+ |
vector<string> cutstrs; |
93 |
|
|
94 |
|
// |
95 |
|
// prototypes |
99 |
|
double getPUWeight(unsigned npu); |
100 |
|
void setEffiencyWeights(EventData&, WeightStruct& ); |
101 |
|
void initRunLumiRangeMap(); |
102 |
+ |
void initEvtRhoMap(map<unsigned,float> &); |
103 |
|
//---------------------------------------------------------------------------- |
104 |
|
|
105 |
|
|
109 |
|
int main(int argc, char** argv) |
110 |
|
//---------------------------------------------------------------------------- |
111 |
|
{ |
112 |
+ |
cutstrs.push_back(string("skim0")); //0 |
113 |
+ |
cutstrs.push_back(string("skim1")); //1 |
114 |
+ |
// ------------------------------------------------- |
115 |
+ |
cutstrs.push_back(string("Z candidate")); //2 |
116 |
+ |
cutstrs.push_back(string("good Z1")); //3 |
117 |
+ |
// ------------------------------------------------- |
118 |
+ |
cutstrs.push_back(string("4l")); //4 |
119 |
+ |
cutstrs.push_back(string("ZZ candidate")); //5 |
120 |
+ |
cutstrs.push_back(string("good Z2")); //6 |
121 |
+ |
cutstrs.push_back(string("ZZ 20/10")); //7 |
122 |
+ |
cutstrs.push_back(string("resonance")); //8 |
123 |
+ |
cutstrs.push_back(string("m4l>70")); //9 |
124 |
+ |
cutstrs.push_back(string("m4l>100")); //10 |
125 |
+ |
|
126 |
+ |
|
127 |
+ |
|
128 |
+ |
|
129 |
|
string cmsswpath(CMSSW_BASE); |
130 |
|
cmsswpath.append("/src"); |
131 |
|
std::bitset<1024> triggerBits; |
132 |
|
vector<vector<string> > inputFiles; |
133 |
|
inputFiles.push_back(vector<string>()); |
134 |
|
map<string,unsigned> entrymap; // number of unskimmed entries in each file |
135 |
+ |
for( int i=0; i<11; i++ ) cutvec.push_back(0); |
136 |
+ |
for( int i=0; i<2; i++ ) { |
137 |
+ |
zcutvec.push_back(vector<unsigned>()); |
138 |
+ |
for( int j=0; j<11; j++ ) zcutvec[i].push_back(0); |
139 |
+ |
} |
140 |
+ |
for( int i=0; i<3; i++ ) { |
141 |
+ |
zzcutvec.push_back(vector<unsigned>()); |
142 |
+ |
for( int j=0; j<11; j++ ) zzcutvec[i].push_back(0); |
143 |
+ |
} |
144 |
+ |
|
145 |
|
|
146 |
|
// |
147 |
|
// args |
245 |
|
initElectronIDMVA(); |
246 |
|
initElectronIsoMVA(); |
247 |
|
initTrigger(); |
248 |
< |
|
248 |
> |
|
249 |
> |
// hack |
250 |
> |
initEvtRhoMap(evtrhoMap); |
251 |
|
|
252 |
|
|
253 |
|
// |
286 |
|
chain->SetBranchAddress(fMuonName, &muonArr); |
287 |
|
chain->SetBranchAddress(fPrimVtxName, &vtxArr); |
288 |
|
chain->SetBranchAddress(fPFCandidateName, &pfArr); |
289 |
< |
chain->SetBranchAddress(fPileupInfoName, &puArr); |
289 |
> |
if( ctrl.mc ) chain->SetBranchAddress(fPileupInfoName, &puArr); |
290 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
291 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
292 |
|
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
319 |
|
{ |
320 |
|
chain->GetEntry(ientry); |
321 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
285 |
– |
if( ientry > 100) break; |
322 |
|
setPV( ctrl, vtxArr, vtx); |
323 |
|
|
324 |
+ |
cout << "origrho: " << puDArr->At(0)->Rho() |
325 |
+ |
<< "\torigrholoweta: " << puDArr->At(0)->RhoLowEta() |
326 |
+ |
<< endl; |
327 |
+ |
|
328 |
|
|
329 |
|
// |
330 |
|
// data/MC |
333 |
|
// |
334 |
|
// xsec & PU weights |
335 |
|
// |
336 |
< |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
336 |
> |
// weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
337 |
|
int npu = -1; |
338 |
|
for(int i=0;i<puArr->GetEntries();i++) { |
339 |
|
if(puArr->At(i)->GetBunchCrossing() == 0) |
343 |
|
evtinfo.npu; |
344 |
|
weights.npuw = getPUWeight(evtinfo.npu); |
345 |
|
// cout << "weight: " << weights.w << endl; |
346 |
+ |
// |
347 |
+ |
// trigger |
348 |
+ |
// |
349 |
+ |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
350 |
+ |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
351 |
+ |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
352 |
+ |
hltchain->GetEntry(0); |
353 |
+ |
hltTable->Clear(); |
354 |
+ |
fillTriggerBits(hltTable, hltTableStrings ); |
355 |
+ |
} |
356 |
+ |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
357 |
+ |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
358 |
+ |
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
359 |
+ |
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
360 |
+ |
continue; |
361 |
+ |
} |
362 |
|
} else { |
363 |
|
// |
364 |
|
// JSON |
365 |
|
// |
366 |
+ |
/* |
367 |
|
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
368 |
|
if( !(rlrm.HasRunLumi(rl)) ) { |
369 |
|
if( ctrl.debug ) cout << "\tfails JSON" << endl; |
370 |
|
continue; |
371 |
|
} |
372 |
+ |
*/ |
373 |
|
// |
374 |
|
// trigger |
375 |
|
// |
394 |
|
failingLeptons.clear(); |
395 |
|
passingLeptons.clear(); |
396 |
|
EventData ret4l = |
397 |
< |
apply_HZZ4L_reference_selection(ctrl, info, |
398 |
< |
vtx, |
399 |
< |
pfArr, |
400 |
< |
puDArr, |
401 |
< |
electronArr, |
402 |
< |
&electronReferencePreSelection, |
403 |
< |
&electronReferenceIDMVASelection, |
404 |
< |
&electronReferenceIsoSelection, |
405 |
< |
muonArr, |
406 |
< |
&muonReferencePreSelection, |
407 |
< |
&muonIDPFSelection, |
408 |
< |
&muonReferenceIsoSelection); |
397 |
> |
apply_HZZ4L_reference2_selection(ctrl, info, |
398 |
> |
vtx, |
399 |
> |
pfArr, |
400 |
> |
// evtrhoMap[info->EvtNum()], |
401 |
> |
puDArr, |
402 |
> |
electronArr, |
403 |
> |
&electronReferencePreSelection, |
404 |
> |
&electronReferenceIDMVASelection, |
405 |
> |
&electronReferenceIsoSelection, |
406 |
> |
muonArr, |
407 |
> |
&muonReferencePreSelection, |
408 |
> |
&muonIDPFSelection, |
409 |
> |
&muonReferenceIsoSelection); |
410 |
|
/* |
411 |
|
apply_HZZ4L_reference_selection(ctrl, info, |
412 |
|
vtx, |
424 |
|
|
425 |
|
if( ctrl.debug ) cout << endl; |
426 |
|
|
427 |
< |
// cout << "bits: " << ret4l.status.selectionBits << endl; |
427 |
> |
|
428 |
> |
int Z1type=0, Z2type=0; |
429 |
> |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZCANDIDATE ) { |
430 |
> |
if( abs(ret4l.Z1leptons[0].type) == 11 ) Z1type = 11; |
431 |
> |
if( abs(ret4l.Z1leptons[0].type) == 13 ) Z1type = 13; |
432 |
> |
} |
433 |
> |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZZCANDIDATE ) { |
434 |
> |
if( abs(ret4l.Z2leptons[0].type) == 11 ) Z2type = 11; |
435 |
> |
if( abs(ret4l.Z2leptons[0].type) == 13 ) Z2type = 13; |
436 |
> |
} |
437 |
> |
|
438 |
> |
cout << "bits: " << ret4l.status.selectionBits << "\t" |
439 |
> |
<< "Z1: " << Z1type << "\t" |
440 |
> |
<< "Z2: " << Z2type << endl; |
441 |
> |
cout << endl; |
442 |
> |
|
443 |
|
|
444 |
|
if( ret4l.status.pass() ) { |
445 |
|
fillAngles(ret4l,angles); |
474 |
|
// if( pass > 3 ) break; |
475 |
|
|
476 |
|
} else if( ret4l.status.selectionBits.test(PASS_ZCANDIDATE) ) { // save for fakes ... |
477 |
< |
cout << "failingLeptons : " << failingLeptons.size() << endl; |
478 |
< |
for( int f=0; f<failingLeptons.size(); f++ ) { |
479 |
< |
SimpleLepton l = failingLeptons[f]; |
480 |
< |
cout << "f: " << f << "\t" |
481 |
< |
<< "type: " << l.type << "\t" |
482 |
< |
<< "pT: " << l.vec.Pt() << "\t" |
483 |
< |
<< "eta: " << l.vec.Eta() |
484 |
< |
<< endl; |
477 |
> |
if(ctrl.debug) { |
478 |
> |
cout << "failingLeptons : " << failingLeptons.size() << endl; |
479 |
> |
for( int f=0; f<failingLeptons.size(); f++ ) { |
480 |
> |
SimpleLepton l = failingLeptons[f]; |
481 |
> |
cout << "f: " << f << "\t" |
482 |
> |
<< "type: " << l.type << "\t" |
483 |
> |
<< "pT: " << l.vec.Pt() << "\t" |
484 |
> |
<< "eta: " << l.vec.Eta() |
485 |
> |
<< endl; |
486 |
> |
} |
487 |
|
} |
412 |
– |
/* |
413 |
– |
cout << "passingLeptons : " << passingLeptons.GetSize() << endl; |
414 |
– |
for( int f=0; f<passingLeptons.GetSize(); f++ ) { |
415 |
– |
cout << "f: " << f << "\t" |
416 |
– |
<< "type: " << passingLeptons.At(f).type << "\t" |
417 |
– |
<< "pT: " << passingLeptons.At(f).vec.Pt() |
418 |
– |
<< endl; |
419 |
– |
} |
420 |
– |
*/ |
421 |
– |
cout << endl; |
488 |
|
foTree.Fill(); |
489 |
|
} |
490 |
|
} |
493 |
|
foTree.getFile()->cd(); |
494 |
|
foTree.getTree()->Write(); |
495 |
|
nt.WriteClose(); |
496 |
+ |
|
497 |
+ |
cout << endl; |
498 |
+ |
cout << endl; |
499 |
+ |
for( int i=0; i<cutvec.size(); i++ ) { |
500 |
+ |
cout << "cut: " << i << "\t" |
501 |
+ |
<< "pass: " << cutvec[i]; |
502 |
+ |
|
503 |
+ |
if( i>1&&i<=3 ) |
504 |
+ |
cout << "\t2e: " << zcutvec[0][i] |
505 |
+ |
<< "\t2m: " << zcutvec[1][i]; |
506 |
+ |
|
507 |
+ |
if( i>3 ) |
508 |
+ |
cout << "\t4e: " << zzcutvec[0][i] |
509 |
+ |
<< "\t4m: " << zzcutvec[1][i] |
510 |
+ |
<< "\t2e2m: " << zzcutvec[2][i]; |
511 |
+ |
|
512 |
+ |
cout << "\t" << cutstrs[i] << endl; |
513 |
+ |
|
514 |
+ |
cout << endl; |
515 |
+ |
} |
516 |
+ |
|
517 |
|
} |
518 |
|
|
519 |
|
//---------------------------------------------------------------------------- |
651 |
|
{ |
652 |
|
return hpu->GetBinContent(hpu->FindBin(npu)); |
653 |
|
} |
654 |
+ |
|
655 |
+ |
//---------------------------------------------------------------------------- |
656 |
+ |
void initEvtRhoMap( map<unsigned, float> & evtrhoMap ) |
657 |
+ |
//---------------------------------------------------------------------------- |
658 |
+ |
{ |
659 |
+ |
unsigned evt; |
660 |
+ |
float rho; |
661 |
+ |
|
662 |
+ |
FILE * f = fopen("evtrho.dat", "r"); |
663 |
+ |
while( fscanf( f, "%u:%f", &evt, &rho ) ) { |
664 |
+ |
evtrhoMap[evt] = rho; |
665 |
+ |
} |
666 |
+ |
|
667 |
+ |
} |