18 |
|
triggers_ (cfg.getParameter<edm::InputTag> ("triggers")), |
19 |
|
puFile_ (cfg.getParameter<std::string> ("puFile")), |
20 |
|
deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")), |
21 |
+ |
muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")), |
22 |
|
dataPU_ (cfg.getParameter<std::string> ("dataPU")), |
23 |
+ |
electronSFID_ (cfg.getParameter<std::string> ("electronSFID")), |
24 |
+ |
muonSF_ (cfg.getParameter<std::string> ("muonSF")), |
25 |
|
dataset_ (cfg.getParameter<std::string> ("dataset")), |
26 |
|
datasetType_ (cfg.getParameter<std::string> ("datasetType")), |
27 |
|
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")), |
28 |
|
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")), |
29 |
< |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")) |
30 |
< |
|
29 |
> |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")), |
30 |
> |
doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")) |
31 |
|
{ |
32 |
|
|
33 |
|
TH1::SetDefaultSumw2 (); |
34 |
|
|
35 |
|
//create pile-up reweighting object, if necessary |
36 |
< |
if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
36 |
> |
if(datasetType_ != "data") { |
37 |
> |
if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
38 |
> |
muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_); |
39 |
> |
electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_); |
40 |
> |
} |
41 |
|
|
42 |
|
// Construct Cutflow Objects. These store the results of cut decisions and |
43 |
|
// handle filling cut flow histograms. |
61 |
|
|
62 |
|
string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection"); |
63 |
|
if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs"; |
64 |
< |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
64 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
65 |
|
objectsToGet.push_back(tempInputCollection); |
66 |
|
objectsToPlot.push_back(tempInputCollection); |
67 |
|
objectsToCut.push_back(tempInputCollection); |
83 |
|
} |
84 |
|
|
85 |
|
vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms")); |
86 |
< |
|
86 |
> |
|
87 |
|
for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){ |
88 |
|
|
89 |
|
histogram tempHistogram; |
92 |
|
tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title"); |
93 |
|
tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins"); |
94 |
|
tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables"); |
95 |
< |
|
95 |
> |
|
96 |
|
histograms.push_back(tempHistogram); |
97 |
|
|
98 |
|
} |
143 |
|
histograms.push_back(tempIdHisto); |
144 |
|
histograms.push_back(tempMomIdHisto); |
145 |
|
histograms.push_back(tempGmaIdHisto); |
146 |
< |
|
146 |
> |
|
147 |
|
} |
148 |
|
|
149 |
|
|
191 |
|
int numInputVariables = currentHistogram.inputVariables.size(); |
192 |
|
|
193 |
|
if(numBinsElements != 3 && numBinsElements !=6) { |
194 |
< |
std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
195 |
< |
exit(0); |
194 |
> |
std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
195 |
> |
exit(0); |
196 |
|
} |
197 |
|
else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){ |
198 |
< |
std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
199 |
< |
exit(0); |
198 |
> |
std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
199 |
> |
exit(0); |
200 |
|
} |
201 |
|
else if(numBinsElements == 3){ |
202 |
< |
oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2)); |
202 |
> |
oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2)); |
203 |
|
} |
204 |
|
else if(numBinsElements == 6){ |
205 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5)); |
205 |
> |
twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5)); |
206 |
|
|
207 |
|
} |
208 |
|
|
263 |
|
labelArray.push_back("other"); |
264 |
|
|
265 |
|
for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){ |
266 |
< |
oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
266 |
> |
oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
267 |
|
} |
268 |
|
} |
269 |
|
|
282 |
|
string histoName = "num" + currentObject; |
283 |
|
|
284 |
|
if(histoName == "numPrimaryvertexs"){ |
285 |
< |
string newHistoName = histoName + "BeforePileupCorrection"; |
286 |
< |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
287 |
< |
newHistoName = histoName + "AfterPileupCorrection"; |
288 |
< |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
285 |
> |
string newHistoName = histoName + "BeforePileupCorrection"; |
286 |
> |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
287 |
> |
newHistoName = histoName + "AfterPileupCorrection"; |
288 |
> |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
289 |
|
} |
290 |
|
else |
291 |
< |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
291 |
> |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
< |
|
295 |
> |
|
296 |
|
|
297 |
|
|
298 |
|
//get list of cuts for this channel |
304 |
|
//store input collection for cut |
305 |
|
string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection"); |
306 |
|
tempCut.inputCollection = tempInputCollection; |
307 |
< |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
308 |
< |
objectsToGet.push_back(tempInputCollection); |
309 |
< |
objectsToCut.push_back(tempInputCollection); |
307 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
308 |
> |
objectsToGet.push_back(tempInputCollection); |
309 |
> |
objectsToCut.push_back(tempInputCollection); |
310 |
|
} |
311 |
|
else{//pair of objects, need to add them both to the things to objectsToGet |
312 |
< |
int dashIndex = tempInputCollection.find("-"); |
313 |
< |
int spaceIndex = tempInputCollection.find(" "); |
314 |
< |
int secondWordLength = spaceIndex - dashIndex; |
315 |
< |
objectsToGet.push_back(tempInputCollection); |
316 |
< |
objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
312 |
> |
int dashIndex = tempInputCollection.find("-"); |
313 |
> |
int spaceIndex = tempInputCollection.find(" "); |
314 |
> |
int secondWordLength = spaceIndex - dashIndex; |
315 |
> |
objectsToGet.push_back(tempInputCollection); |
316 |
> |
objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
317 |
|
objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
318 |
< |
objectsToCut.push_back(tempInputCollection); |
319 |
< |
objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
318 |
> |
objectsToCut.push_back(tempInputCollection); |
319 |
> |
objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
320 |
|
objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
321 |
|
|
322 |
|
} |
327 |
|
string cutString = cuts_.at(currentCut).getParameter<string> ("cutString"); |
328 |
|
std::vector<string> cutStringVector = splitString(cutString); |
329 |
|
if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){ |
330 |
< |
std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n"; |
331 |
< |
exit(0); |
330 |
> |
std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n"; |
331 |
> |
exit(0); |
332 |
|
} |
333 |
|
tempCut.numSubcuts = (cutStringVector.size()+1)/4; |
334 |
|
for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,| |
335 |
< |
int indexOffset = 4 * subcutIndex; |
336 |
< |
string currentVariableString = cutStringVector.at(indexOffset); |
337 |
< |
if(currentVariableString.find("(")==std::string::npos){ |
338 |
< |
tempCut.functions.push_back("");//no function was specified |
339 |
< |
tempCut.variables.push_back(currentVariableString);// variable to cut on |
340 |
< |
} |
341 |
< |
else{ |
342 |
< |
tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "(" |
343 |
< |
string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string |
344 |
< |
tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")" |
345 |
< |
} |
346 |
< |
tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make |
347 |
< |
tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut |
348 |
< |
if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or) |
335 |
> |
int indexOffset = 4 * subcutIndex; |
336 |
> |
string currentVariableString = cutStringVector.at(indexOffset); |
337 |
> |
if(currentVariableString.find("(")==std::string::npos){ |
338 |
> |
tempCut.functions.push_back("");//no function was specified |
339 |
> |
tempCut.variables.push_back(currentVariableString);// variable to cut on |
340 |
> |
} |
341 |
> |
else{ |
342 |
> |
tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "(" |
343 |
> |
string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string |
344 |
> |
tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")" |
345 |
> |
} |
346 |
> |
tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make |
347 |
> |
tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut |
348 |
> |
if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or) |
349 |
|
} |
350 |
|
|
351 |
|
//get number of objects required to pass cut for event to pass |
352 |
|
string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired"); |
353 |
|
std::vector<string> numberRequiredVector = splitString(numberRequiredString); |
354 |
|
if(numberRequiredVector.size()!=2){ |
355 |
< |
std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n"; |
355 |
> |
std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n"; |
356 |
|
exit(0); |
357 |
|
} |
358 |
|
|
454 |
|
if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end()) |
455 |
|
event.getByLabel (superclusters_, superclusters); |
456 |
|
|
450 |
– |
|
457 |
|
//get pile-up event weight |
458 |
< |
double puScaleFactor = 1.00; |
459 |
< |
if(datasetType_ != "data"){ |
460 |
< |
puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
455 |
< |
//cout << puScaleFactor << endl; |
456 |
< |
} |
457 |
< |
|
458 |
> |
double scaleFactor = 1.00; |
459 |
> |
if(doPileupReweighting_ && datasetType_ != "data") |
460 |
> |
scaleFactor = puWeight_->at (events->at (0).numTruePV); |
461 |
|
|
462 |
|
|
463 |
|
//loop over all channels |
466 |
|
channel currentChannel = channels.at(currentChannelIndex); |
467 |
|
|
468 |
|
flagMap individualFlags; |
466 |
– |
flagMap cumulativeFlags; |
469 |
|
counterMap passingCounter; |
470 |
+ |
cumulativeFlags.clear (); |
471 |
|
|
472 |
|
bool triggerDecision = true; |
473 |
|
if(currentChannel.triggers.size() != 0){ //triggers specified |
485 |
|
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
486 |
|
string currentObject = objectsToCut.at(currentObjectIndex); |
487 |
|
|
488 |
< |
//initialize maps to get ready to set cuts |
488 |
> |
//initialize maps to get ready to set cuts |
489 |
|
individualFlags[currentObject].push_back (vector<bool> ()); |
490 |
|
cumulativeFlags[currentObject].push_back (vector<bool> ()); |
491 |
|
|
493 |
|
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
494 |
|
string currentObject = objectsToCut.at(currentObjectIndex); |
495 |
|
|
496 |
< |
int flagsForPairCutsIndex = max(int(currentCutIndex-1),0); |
496 |
> |
int flagsForPairCutsIndex = max(int(currentCutIndex-1),0); |
497 |
> |
|
498 |
|
|
499 |
|
if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
500 |
|
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
510 |
|
else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons"); |
511 |
|
else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters"); |
512 |
|
|
513 |
< |
|
514 |
< |
else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \ |
515 |
< |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
516 |
< |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
517 |
< |
"muon-muon pairs"); |
518 |
< |
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \ |
519 |
< |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
520 |
< |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
521 |
< |
"electron-electron pairs"); |
522 |
< |
else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \ |
523 |
< |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
524 |
< |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
525 |
< |
"electron-muon pairs"); |
513 |
> |
|
514 |
> |
else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \ |
515 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
516 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
517 |
> |
"muon-muon pairs"); |
518 |
> |
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \ |
519 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
520 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
521 |
> |
"electron-electron pairs"); |
522 |
> |
else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \ |
523 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
524 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
525 |
> |
"electron-muon pairs"); |
526 |
|
|
527 |
|
|
528 |
|
} |
558 |
|
|
559 |
|
} |
560 |
|
|
561 |
< |
cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor); |
561 |
> |
cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor); |
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
if(!eventPassedAllCuts)continue; |
566 |
|
|
567 |
|
|
568 |
< |
|
569 |
< |
|
570 |
< |
//set position of primary vertex in event, in order to calculate quantities relative to it |
571 |
< |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) { |
568 |
< |
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back(); |
569 |
< |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
570 |
< |
if(!vertexFlags.at(vertexIndex)) continue; |
571 |
< |
chosenPrimaryVertex = & primaryvertexs->at(vertexIndex); |
572 |
< |
break; |
573 |
< |
} |
574 |
< |
} |
575 |
< |
else { |
576 |
< |
chosenPrimaryVertex = & primaryvertexs->at(0); |
577 |
< |
} |
578 |
< |
|
579 |
< |
|
568 |
> |
//if(datasetType_ != "data") { |
569 |
> |
// scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta); |
570 |
> |
// scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt); |
571 |
> |
//} |
572 |
|
|
573 |
|
//filling histograms |
574 |
|
for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){ |
575 |
|
histogram currentHistogram = histograms.at(histogramIndex); |
576 |
|
|
577 |
|
if(currentHistogram.inputVariables.size() == 1){ |
578 |
< |
TH1D* histo; |
579 |
< |
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
578 |
> |
TH1D* histo; |
579 |
> |
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
< |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
584 |
< |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
585 |
< |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
586 |
< |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
587 |
< |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
588 |
< |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
589 |
< |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
590 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
591 |
< |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
592 |
< |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
593 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
594 |
< |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
595 |
< |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
596 |
< |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
597 |
< |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
598 |
< |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
599 |
< |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
600 |
< |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
601 |
< |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
602 |
< |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
603 |
< |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
604 |
< |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
583 |
> |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor); |
584 |
> |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor); |
585 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
586 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
587 |
> |
cumulativeFlags.at("muon-muon pairs").back(),scaleFactor); |
588 |
> |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor); |
589 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
590 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
591 |
> |
cumulativeFlags.at("electron-electron pairs").back(),scaleFactor); |
592 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
593 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
594 |
> |
cumulativeFlags.at("electron-muon pairs").back(),scaleFactor); |
595 |
> |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor); |
596 |
> |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor); |
597 |
> |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor); |
598 |
> |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor); |
599 |
> |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor); |
600 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor); |
601 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor); |
602 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor); |
603 |
> |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor); |
604 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor); |
605 |
|
} |
606 |
|
else if(currentHistogram.inputVariables.size() == 2){ |
607 |
< |
TH2D* histo; |
608 |
< |
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
607 |
> |
TH2D* histo; |
608 |
> |
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
609 |
|
|
610 |
|
|
611 |
|
|
612 |
< |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
613 |
< |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
614 |
< |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
615 |
< |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
616 |
< |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
617 |
< |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
618 |
< |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
619 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
620 |
< |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
621 |
< |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
622 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
623 |
< |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
624 |
< |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
625 |
< |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
626 |
< |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
627 |
< |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
628 |
< |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
629 |
< |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
630 |
< |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
631 |
< |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
632 |
< |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
633 |
< |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
634 |
< |
} |
612 |
> |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor); |
613 |
> |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor); |
614 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
615 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
616 |
> |
cumulativeFlags.at("muon-muon pairs").back(),scaleFactor); |
617 |
> |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor); |
618 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
619 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
620 |
> |
cumulativeFlags.at("electron-electron pairs").back(),scaleFactor); |
621 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
622 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
623 |
> |
cumulativeFlags.at("electron-muon pairs").back(),scaleFactor); |
624 |
> |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor); |
625 |
> |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor); |
626 |
> |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor); |
627 |
> |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor); |
628 |
> |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor); |
629 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor); |
630 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor); |
631 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor); |
632 |
> |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor); |
633 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor); |
634 |
> |
} |
635 |
|
} |
636 |
|
|
637 |
|
//fills histograms with the sizes of collections |
653 |
|
|
654 |
|
//set position of primary vertex in event, in order to calculate quantities relative to it |
655 |
|
if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) { |
656 |
< |
vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back(); |
657 |
< |
int numToPlot = 0; |
658 |
< |
for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){ |
659 |
< |
if(lastCutFlags.at(currentFlag)) numToPlot++; |
660 |
< |
} |
661 |
< |
if(objectToPlot == "primaryvertexs"){ |
662 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
663 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor); |
664 |
< |
} |
665 |
< |
else |
666 |
< |
oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor); |
667 |
< |
} |
668 |
< |
else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor); |
669 |
< |
else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor); |
670 |
< |
else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor); |
671 |
< |
else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor); |
672 |
< |
else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor); |
673 |
< |
else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor); |
674 |
< |
else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor); |
675 |
< |
else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor); |
676 |
< |
else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor); |
677 |
< |
else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor); |
678 |
< |
else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor); |
679 |
< |
else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor); |
680 |
< |
else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor); |
681 |
< |
else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor); |
682 |
< |
else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor); |
656 |
> |
vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back(); |
657 |
> |
int numToPlot = 0; |
658 |
> |
for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){ |
659 |
> |
if(lastCutFlags.at(currentFlag)) numToPlot++; |
660 |
> |
} |
661 |
> |
if(objectToPlot == "primaryvertexs"){ |
662 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
663 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
664 |
> |
} |
665 |
> |
else |
666 |
> |
oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor); |
667 |
> |
} |
668 |
> |
else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor); |
669 |
> |
else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor); |
670 |
> |
else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor); |
671 |
> |
else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor); |
672 |
> |
else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor); |
673 |
> |
else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor); |
674 |
> |
else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor); |
675 |
> |
else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor); |
676 |
> |
else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor); |
677 |
> |
else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor); |
678 |
> |
else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor); |
679 |
> |
else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor); |
680 |
> |
else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor); |
681 |
> |
else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor); |
682 |
> |
else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor); |
683 |
|
else if(objectToPlot == "primaryvertexs"){ |
684 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
685 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor); |
684 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
685 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
686 |
|
} |
687 |
|
|
688 |
|
} |
692 |
|
|
693 |
|
} //end loop over channel |
694 |
|
|
695 |
< |
masterCutFlow_->fillCutFlow(puScaleFactor); |
695 |
> |
masterCutFlow_->fillCutFlow(scaleFactor); |
696 |
|
|
697 |
|
|
698 |
|
|
1030 |
|
else if(variable == "time_ndof") value = object->time_ndof; |
1031 |
|
|
1032 |
|
//user-defined variables |
1033 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1034 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1033 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1034 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1035 |
|
else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt; |
1036 |
< |
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
1036 |
> |
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
1037 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1038 |
+ |
else if(variable == "metMT") { |
1039 |
+ |
const BNmet *met = chosenMET (); |
1040 |
+ |
if (met) |
1041 |
+ |
{ |
1042 |
+ |
TLorentzVector p1 (object->px, object->py, object->pz, object->energy), |
1043 |
+ |
p2 (met->px, met->py, 0.0, met->pt); |
1044 |
+ |
|
1045 |
+ |
value = (p1 + p2).Mt (); |
1046 |
+ |
} |
1047 |
+ |
else |
1048 |
+ |
value = -999; |
1049 |
+ |
} |
1050 |
|
|
1051 |
|
|
1052 |
|
|
1157 |
|
|
1158 |
|
|
1159 |
|
else if(variable == "tightID") { |
1160 |
< |
value = object->isGlobalMuon > 0 \ |
1161 |
< |
&& object->isPFMuon > 0 \ |
1162 |
< |
&& object->normalizedChi2 < 10 \ |
1163 |
< |
&& object->numberOfValidMuonHits > 0 \ |
1164 |
< |
&& object->numberOfMatchedStations > 1 \ |
1165 |
< |
&& fabs(object->correctedD0Vertex) < 0.2 \ |
1166 |
< |
&& fabs(object->correctedDZ) < 0.5 \ |
1167 |
< |
&& object->numberOfValidPixelHits > 0 \ |
1160 |
> |
value = object->isGlobalMuon > 0 \ |
1161 |
> |
&& object->isPFMuon > 0 \ |
1162 |
> |
&& object->normalizedChi2 < 10 \ |
1163 |
> |
&& object->numberOfValidMuonHits > 0 \ |
1164 |
> |
&& object->numberOfMatchedStations > 1 \ |
1165 |
> |
&& fabs(object->correctedD0Vertex) < 0.2 \ |
1166 |
> |
&& fabs(object->correctedDZ) < 0.5 \ |
1167 |
> |
&& object->numberOfValidPixelHits > 0 \ |
1168 |
|
&& object->numberOfLayersWithMeasurement > 5; |
1169 |
|
} |
1170 |
|
else if(variable == "tightIDdisplaced"){ |
1171 |
< |
value = object->isGlobalMuon > 0 \ |
1172 |
< |
&& object->normalizedChi2 < 10 \ |
1173 |
< |
&& object->numberOfValidMuonHits > 0 \ |
1174 |
< |
&& object->numberOfMatchedStations > 1 \ |
1175 |
< |
&& object->numberOfValidPixelHits > 0 \ |
1171 |
> |
value = object->isGlobalMuon > 0 \ |
1172 |
> |
&& object->normalizedChi2 < 10 \ |
1173 |
> |
&& object->numberOfValidMuonHits > 0 \ |
1174 |
> |
&& object->numberOfMatchedStations > 1 \ |
1175 |
> |
&& object->numberOfValidPixelHits > 0 \ |
1176 |
|
&& object->numberOfLayersWithMeasurement > 5; |
1177 |
|
} |
1178 |
|
|
1371 |
|
else if(variable == "passConvVeto") value = object->passConvVeto; |
1372 |
|
|
1373 |
|
//user-defined variables |
1374 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1375 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1374 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1375 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1376 |
|
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1377 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1378 |
+ |
else if(variable == "metMT") { |
1379 |
+ |
const BNmet *met = chosenMET (); |
1380 |
+ |
if (met) |
1381 |
+ |
{ |
1382 |
+ |
TLorentzVector p1 (object->px, object->py, object->pz, object->energy), |
1383 |
+ |
p2 (met->px, met->py, 0.0, met->pt); |
1384 |
|
|
1385 |
+ |
value = (p1 + p2).Mt (); |
1386 |
+ |
} |
1387 |
+ |
else |
1388 |
+ |
value = -999; |
1389 |
+ |
} |
1390 |
|
|
1391 |
|
else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){ |
1392 |
|
if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex; |
1397 |
|
else value = -999; |
1398 |
|
} |
1399 |
|
|
1385 |
– |
|
1400 |
|
else if(variable == "correctedD0VertexInEBPlus"){ |
1401 |
|
if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex; |
1402 |
|
else value = -999; |
1449 |
|
else value = -999; |
1450 |
|
} |
1451 |
|
|
1452 |
+ |
else if(variable == "tightID"){ |
1453 |
+ |
if (object->isEB) |
1454 |
+ |
{ |
1455 |
+ |
value = fabs(object->delEtaIn) < 0.004 \ |
1456 |
+ |
&& fabs (object->delPhiIn) < 0.03 \ |
1457 |
+ |
&& object->scSigmaIEtaIEta < 0.01 \ |
1458 |
+ |
&& object->hadOverEm < 0.12 \ |
1459 |
+ |
&& fabs (object->correctedD0Vertex) < 0.02 \ |
1460 |
+ |
&& fabs (object->correctedDZ) < 0.1 \ |
1461 |
+ |
&& object->absInvEMinusInvPin < 0.05 \ |
1462 |
+ |
&& object->passConvVeto; |
1463 |
+ |
} |
1464 |
+ |
else |
1465 |
+ |
{ |
1466 |
+ |
value = fabs(object->delEtaIn) < 0.005 \ |
1467 |
+ |
&& fabs (object->delPhiIn) < 0.02 \ |
1468 |
+ |
&& object->scSigmaIEtaIEta < 0.03 \ |
1469 |
+ |
&& object->hadOverEm < 0.10 \ |
1470 |
+ |
&& fabs (object->correctedD0Vertex) < 0.02 \ |
1471 |
+ |
&& fabs (object->correctedDZ) < 0.1 \ |
1472 |
+ |
&& object->absInvEMinusInvPin < 0.05 \ |
1473 |
+ |
&& object->passConvVeto; |
1474 |
+ |
} |
1475 |
+ |
} |
1476 |
|
|
1477 |
|
else if(variable == "correctedD0VertexInEBPositiveCharge"){ |
1478 |
|
if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex; |
1530 |
|
else if(variable == "tightIDdisplaced"){ |
1531 |
|
if (object->isEB) |
1532 |
|
{ |
1533 |
< |
value = fabs(object->delEtaIn) < 0.004 \ |
1534 |
< |
&& fabs (object->delPhiIn) < 0.03 \ |
1533 |
> |
value = fabs(object->delEtaIn) < 0.004 \ |
1534 |
> |
&& fabs (object->delPhiIn) < 0.03 \ |
1535 |
|
&& object->scSigmaIEtaIEta < 0.01 \ |
1536 |
|
&& object->hadOverEm < 0.12 \ |
1537 |
< |
&& object->absInvEMinusInvPin < 0.05; |
1537 |
> |
&& object->absInvEMinusInvPin < 0.05; |
1538 |
|
} |
1539 |
|
else |
1540 |
|
{ |
1541 |
< |
value = fabs (object->delEtaIn) < 0.005 \ |
1542 |
< |
&& fabs (object->delPhiIn) < 0.02 \ |
1541 |
> |
value = fabs (object->delEtaIn) < 0.005 \ |
1542 |
> |
&& fabs (object->delPhiIn) < 0.02 \ |
1543 |
|
&& object->scSigmaIEtaIEta < 0.03 \ |
1544 |
|
&& object->hadOverEm < 0.10 \ |
1545 |
< |
&& object->absInvEMinusInvPin < 0.05; |
1545 |
> |
&& object->absInvEMinusInvPin < 0.05; |
1546 |
|
} |
1547 |
|
} |
1548 |
|
|
1646 |
|
else if(variable == "id1") value = object->id1; |
1647 |
|
else if(variable == "id2") value = object->id2; |
1648 |
|
else if(variable == "evt") value = object->evt; |
1649 |
+ |
else if(variable == "puScaleFactor"){ |
1650 |
+ |
if(datasetType_ != "data") |
1651 |
+ |
value = puWeight_->at (events->at (0).numTruePV); |
1652 |
+ |
else |
1653 |
+ |
value = 1.0; |
1654 |
+ |
} |
1655 |
+ |
else if(variable == "muonScaleFactor"){ |
1656 |
+ |
if(datasetType_ != "data") |
1657 |
+ |
value = muonSFWeight_->at (chosenMuon ()->eta); |
1658 |
+ |
else |
1659 |
+ |
value = 1.0; |
1660 |
+ |
} |
1661 |
+ |
else if(variable == "electronScaleFactor"){ |
1662 |
+ |
if(datasetType_ != "data") |
1663 |
+ |
value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt); |
1664 |
+ |
else |
1665 |
+ |
value = 1.0; |
1666 |
+ |
} |
1667 |
|
|
1668 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1669 |
|
|
1825 |
|
double value = 0.0; |
1826 |
|
double pMag = sqrt(object->pt * object->pt + |
1827 |
|
object->pz * object->pz); |
1828 |
< |
|
1828 |
> |
|
1829 |
|
if(variable == "pt") value = object->pt; |
1830 |
|
else if(variable == "px") value = object->px; |
1831 |
|
else if(variable == "py") value = object->py; |
1845 |
|
else if(variable == "isHighPurity") value = object->isHighPurity; |
1846 |
|
|
1847 |
|
|
1848 |
< |
//additional BNs info for disappTrks |
1848 |
> |
//additional BNs info for disappTrks |
1849 |
|
else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution; |
1850 |
|
else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3; |
1851 |
|
else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3; |
1862 |
|
else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5); |
1863 |
|
else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag); |
1864 |
|
else if(variable == "isIso") value = getTrkIsIso(object, tracks.product()); |
1865 |
< |
else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object); |
1866 |
< |
else if(variable == "ptErrorByPt") value = (object->ptError/object->pt); |
1867 |
< |
else if(variable == "ptError") value = object->ptError; |
1868 |
< |
else if(variable == "ptRes") value = getTrkPtRes(object); |
1865 |
> |
else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object); |
1866 |
> |
else if(variable == "ptErrorByPt") value = (object->ptError/object->pt); |
1867 |
> |
else if(variable == "ptError") value = object->ptError; |
1868 |
> |
else if(variable == "ptRes") value = getTrkPtRes(object); |
1869 |
|
|
1870 |
|
|
1871 |
|
else if(variable == "genMatchedId"){ |
2018 |
|
|
2019 |
|
//user-defined variables |
2020 |
|
else if (variable == "d0"){ |
2021 |
< |
double vx = object->vx - chosenPrimaryVertex->x, |
2022 |
< |
vy = object->vy - chosenPrimaryVertex->y, |
2021 |
> |
double vx = object->vx - chosenVertex ()->x, |
2022 |
> |
vy = object->vy - chosenVertex ()->y, |
2023 |
|
px = object->px, |
2024 |
|
py = object->py, |
2025 |
|
pt = object->pt; |
2026 |
|
value = (-vx * py + vy * px) / pt; |
2027 |
|
} |
2028 |
|
else if (variable == "dz"){ |
2029 |
< |
double vx = object->vx - chosenPrimaryVertex->x, |
2030 |
< |
vy = object->vy - chosenPrimaryVertex->y, |
2031 |
< |
vz = object->vz - chosenPrimaryVertex->z, |
2029 |
> |
double vx = object->vx - chosenVertex ()->x, |
2030 |
> |
vy = object->vy - chosenVertex ()->y, |
2031 |
> |
vz = object->vz - chosenVertex ()->z, |
2032 |
|
px = object->px, |
2033 |
|
py = object->py, |
2034 |
|
pz = object->pz, |
2039 |
|
value = sqrt(object->vx*object->vx + object->vy*object->vy); |
2040 |
|
} |
2041 |
|
else if(variable == "deltaV0"){ |
2042 |
< |
value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y)); |
2042 |
> |
value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y)); |
2043 |
|
} |
2044 |
|
else if (variable == "deltaVx"){ |
2045 |
< |
value = object->vx - chosenPrimaryVertex->x; |
2045 |
> |
value = object->vx - chosenVertex ()->x; |
2046 |
|
} |
2047 |
|
else if (variable == "deltaVy"){ |
2048 |
< |
value = object->vy - chosenPrimaryVertex->y; |
2048 |
> |
value = object->vy - chosenVertex ()->y; |
2049 |
|
} |
2050 |
|
else if (variable == "deltaVz"){ |
2051 |
< |
value = object->vz - chosenPrimaryVertex->z; |
2051 |
> |
value = object->vz - chosenVertex ()->z; |
2052 |
|
} |
2053 |
|
|
2054 |
|
|
2370 |
|
else if(variable == "muonCorrectedD0"){ |
2371 |
|
value = object2->correctedD0; |
2372 |
|
} |
2373 |
+ |
else if(variable == "electronDetIso"){ |
2374 |
+ |
value = (object1->trackIso) / object1->pt; |
2375 |
+ |
} |
2376 |
+ |
else if(variable == "muonDetIso"){ |
2377 |
+ |
value = (object2->trackIsoDR03) / object2->pt; |
2378 |
+ |
} |
2379 |
+ |
else if(variable == "chargeProduct"){ |
2380 |
+ |
value = object1->charge * object2->charge; |
2381 |
+ |
} |
2382 |
|
|
2383 |
|
|
2384 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2389 |
|
} |
2390 |
|
|
2391 |
|
|
2392 |
< |
// Calculate the number of tracks in cone of DeltaR<0.5 around track1. |
2393 |
< |
// Return true iff no other tracks are found in this cone. |
2394 |
< |
int |
2392 |
> |
// Calculate the number of tracks in cone of DeltaR<0.5 around track1. |
2393 |
> |
// Return true iff no other tracks are found in this cone. |
2394 |
> |
int |
2395 |
|
OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){ |
2396 |
|
for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){ |
2397 |
< |
if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself. |
2397 |
> |
if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself. |
2398 |
|
double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi); |
2399 |
|
if(deltaRtrk < 0.5) return 0; |
2400 |
|
} |
2401 |
|
return 1; |
2402 |
< |
|
2402 |
> |
|
2403 |
|
} |
2404 |
|
|
2405 |
|
|
2406 |
< |
double |
2406 |
> |
double |
2407 |
|
OSUAnalysis::getTrkPtRes (const BNtrack* track1){ |
2408 |
|
|
2409 |
|
double ptTrue = getTrkPtTrue(track1, mcparticles.product()); |
2410 |
|
double PtRes = (track1->pt - ptTrue) / ptTrue; |
2411 |
|
|
2412 |
|
return PtRes; |
2413 |
< |
|
2413 |
> |
|
2414 |
|
} |
2415 |
|
|
2416 |
|
|
2417 |
< |
double |
2417 |
> |
double |
2418 |
|
OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){ |
2419 |
|
double value = -99; |
2420 |
|
double genDeltaRLowest = 999; |
2423 |
|
double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi); |
2424 |
|
if (genDeltaRtemp < genDeltaRLowest) { |
2425 |
|
genDeltaRLowest = genDeltaRtemp; |
2426 |
< |
if (genDeltaRLowest < 0.05) { // Only consider it truth-matched if DeltaR<0.15. |
2427 |
< |
double ptTrue = genPart->pt; |
2428 |
< |
value = ptTrue; |
2426 |
> |
if (genDeltaRLowest < 0.05) { // Only consider it truth-matched if DeltaR<0.15. |
2427 |
> |
double ptTrue = genPart->pt; |
2428 |
> |
value = ptTrue; |
2429 |
|
} |
2430 |
< |
} |
2430 |
> |
} |
2431 |
|
} |
2432 |
|
|
2433 |
|
return value; |
2437 |
|
//creates a map of the dead Ecal channels in the barrel and endcap |
2438 |
|
//to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here: |
2439 |
|
//http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup |
2440 |
< |
void |
2440 |
> |
void |
2441 |
|
OSUAnalysis::WriteDeadEcal (){ |
2442 |
|
double etaEcal, phiEcal; |
2443 |
|
ifstream DeadEcalFile(deadEcalFile_); |
2444 |
|
if(!DeadEcalFile) { |
2445 |
|
cout << "Error: DeadEcalFile has not been found." << endl; |
2446 |
< |
return; |
2447 |
< |
} |
2448 |
< |
if(DeadEcalVec.size()!= 0){ |
2446 |
> |
return; |
2447 |
> |
} |
2448 |
> |
if(DeadEcalVec.size()!= 0){ |
2449 |
|
cout << "Error: DeadEcalVec has a nonzero size" << endl; |
2450 |
|
return; |
2451 |
< |
} |
2451 |
> |
} |
2452 |
|
while(!DeadEcalFile.eof()) |
2453 |
|
{ |
2454 |
|
DeadEcalFile >> etaEcal >> phiEcal; |
2461 |
|
} |
2462 |
|
|
2463 |
|
//if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0 |
2464 |
< |
int |
2464 |
> |
int |
2465 |
|
OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){ |
2466 |
|
double deltaRLowest = 999; |
2467 |
|
int value = 0; |
2510 |
|
|
2511 |
|
vector<bool> subcutDecisions; |
2512 |
|
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2513 |
< |
double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2514 |
< |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2513 |
> |
double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2514 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2515 |
|
} |
2516 |
|
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2517 |
|
else{ |
2518 |
< |
bool tempDecision = true; |
2519 |
< |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2520 |
< |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2521 |
< |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2522 |
< |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2518 |
> |
bool tempDecision = true; |
2519 |
> |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2520 |
> |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2521 |
> |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2522 |
> |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2523 |
|
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
2524 |
< |
} |
2525 |
< |
decision = tempDecision; |
2524 |
> |
} |
2525 |
> |
decision = tempDecision; |
2526 |
|
} |
2527 |
|
} |
2528 |
|
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
2544 |
|
|
2545 |
|
template <class InputCollection1, class InputCollection2> |
2546 |
|
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \ |
2547 |
< |
InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){ |
2547 |
> |
InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){ |
2548 |
|
|
2549 |
|
|
2550 |
|
bool sameObjects = false; |
2551 |
|
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2552 |
|
|
2553 |
|
|
2554 |
< |
int counter = 0; |
2554 |
> |
int counter = 0; |
2555 |
|
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2556 |
|
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2557 |
< |
|
2557 |
> |
|
2558 |
|
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2559 |
|
|
2560 |
|
|
2561 |
|
bool decision = true;//object passes if this cut doesn't cut on that type of object |
2562 |
|
|
2563 |
|
if(currentCut.inputCollection == inputType){ |
2564 |
< |
|
2565 |
< |
vector<bool> subcutDecisions; |
2566 |
< |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2567 |
< |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2568 |
< |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2569 |
< |
} |
2570 |
< |
|
2571 |
< |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2572 |
< |
else{ |
2573 |
< |
bool tempDecision = subcutDecisions.at(0); |
2574 |
< |
for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){ |
2575 |
< |
if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&") |
2576 |
< |
tempDecision = tempDecision && subcutDecisions.at(subcutIndex); |
2577 |
< |
else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||") |
2578 |
< |
tempDecision = tempDecision || subcutDecisions.at(subcutIndex); |
2579 |
< |
} |
2580 |
< |
decision = tempDecision; |
2581 |
< |
} |
2564 |
> |
|
2565 |
> |
vector<bool> subcutDecisions; |
2566 |
> |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2567 |
> |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2568 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2569 |
> |
} |
2570 |
> |
|
2571 |
> |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2572 |
> |
else{ |
2573 |
> |
bool tempDecision = subcutDecisions.at(0); |
2574 |
> |
for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){ |
2575 |
> |
if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&") |
2576 |
> |
tempDecision = tempDecision && subcutDecisions.at(subcutIndex); |
2577 |
> |
else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||") |
2578 |
> |
tempDecision = tempDecision || subcutDecisions.at(subcutIndex); |
2579 |
> |
} |
2580 |
> |
decision = tempDecision; |
2581 |
> |
} |
2582 |
|
} |
2583 |
|
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
2584 |
< |
|
2584 |
> |
|
2585 |
|
//set flags for objects that pass each cut AND all the previous cuts |
2586 |
|
bool previousCumulativeFlag = true; |
2587 |
|
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
2588 |
< |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true; |
2589 |
< |
else{ previousCumulativeFlag = false; break;} |
2588 |
> |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true; |
2589 |
> |
else{ previousCumulativeFlag = false; break;} |
2590 |
|
} |
2591 |
|
//apply flags for the components of the composite object as well |
2592 |
|
bool currentCumulativeFlag = true; |
2596 |
|
else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2); |
2597 |
|
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag); |
2598 |
|
|
2599 |
< |
counter++; |
2599 |
> |
counter++; |
2600 |
|
} |
2601 |
< |
|
2601 |
> |
|
2602 |
|
} |
2603 |
|
|
2604 |
|
|
2606 |
|
|
2607 |
|
|
2608 |
|
template <class InputCollection> |
2609 |
< |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
2609 |
> |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){ |
2610 |
|
|
2611 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2612 |
|
|
2616 |
|
string inputVariable = ""; |
2617 |
|
string function = ""; |
2618 |
|
if(currentString.find("(")==std::string::npos){ |
2619 |
< |
inputVariable = currentString;// variable to cut on |
2619 |
> |
inputVariable = currentString;// variable to cut on |
2620 |
|
} |
2621 |
|
else{ |
2622 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2623 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2624 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2622 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2623 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2624 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2625 |
|
} |
2626 |
|
|
2627 |
|
double value = valueLookup(&inputCollection->at(object), inputVariable, function); |
2628 |
< |
histo->Fill(value,puScaleFactor); |
2628 |
> |
histo->Fill(value,scaleFactor); |
2629 |
|
|
2630 |
|
} |
2631 |
|
|
2632 |
|
} |
2633 |
|
|
2634 |
|
template <class InputCollection1, class InputCollection2> |
2635 |
< |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
2635 |
> |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){ |
2636 |
|
|
2637 |
|
bool sameObjects = false; |
2638 |
|
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2639 |
|
|
2640 |
< |
int pairCounter = 0; |
2640 |
> |
int pairCounter = 0; |
2641 |
|
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2642 |
|
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2643 |
< |
|
2643 |
> |
|
2644 |
|
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2645 |
|
|
2646 |
|
//only take objects which have passed all cuts and pairs which have passed all cuts |
2652 |
|
string inputVariable = ""; |
2653 |
|
string function = ""; |
2654 |
|
if(currentString.find("(")==std::string::npos){ |
2655 |
< |
inputVariable = currentString;// variable to cut on |
2655 |
> |
inputVariable = currentString;// variable to cut on |
2656 |
|
} |
2657 |
|
else{ |
2658 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2659 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2660 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2658 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2659 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2660 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2661 |
|
} |
2662 |
< |
|
2662 |
> |
|
2663 |
|
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2664 |
< |
histo->Fill(value,puScaleFactor); |
2664 |
> |
histo->Fill(value,scaleFactor); |
2665 |
|
|
2666 |
< |
pairCounter++; |
2666 |
> |
pairCounter++; |
2667 |
|
} |
2668 |
|
} |
2669 |
|
|
2671 |
|
|
2672 |
|
|
2673 |
|
template <class InputCollection> |
2674 |
< |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
2674 |
> |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){ |
2675 |
|
|
2676 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2677 |
|
|
2681 |
|
string inputVariable = ""; |
2682 |
|
string function = ""; |
2683 |
|
if(currentString.find("(")==std::string::npos){ |
2684 |
< |
inputVariable = currentString;// variable to cut on |
2684 |
> |
inputVariable = currentString;// variable to cut on |
2685 |
|
} |
2686 |
|
else{ |
2687 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2688 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2689 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2687 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2688 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2689 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2690 |
|
} |
2691 |
|
double valueX = valueLookup(&inputCollection->at(object), inputVariable, function); |
2692 |
|
|
2694 |
|
inputVariable = ""; |
2695 |
|
function = ""; |
2696 |
|
if(currentString.find("(")==std::string::npos){ |
2697 |
< |
inputVariable = currentString;// variable to cut on |
2697 |
> |
inputVariable = currentString;// variable to cut on |
2698 |
|
} |
2699 |
|
else{ |
2700 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2701 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2702 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2700 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2701 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2702 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2703 |
|
} |
2704 |
|
|
2705 |
|
double valueY = valueLookup(&inputCollection->at(object), inputVariable, function); |
2706 |
|
|
2707 |
< |
histo->Fill(valueX,valueY,puScaleFactor); |
2707 |
> |
histo->Fill(valueX,valueY,scaleFactor); |
2708 |
|
|
2709 |
|
} |
2710 |
|
|
2711 |
|
} |
2712 |
|
|
2713 |
|
template <class InputCollection1, class InputCollection2> |
2714 |
< |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
2714 |
> |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){ |
2715 |
|
|
2716 |
|
bool sameObjects = false; |
2717 |
|
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2718 |
|
|
2719 |
< |
int pairCounter = 0; |
2719 |
> |
int pairCounter = 0; |
2720 |
|
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2721 |
|
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2722 |
< |
|
2722 |
> |
|
2723 |
|
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2724 |
|
|
2725 |
|
//only take objects which have passed all cuts and pairs which have passed all cuts |
2731 |
|
string inputVariable = ""; |
2732 |
|
string function = ""; |
2733 |
|
if(currentString.find("(")==std::string::npos){ |
2734 |
< |
inputVariable = currentString;// variable to cut on |
2734 |
> |
inputVariable = currentString;// variable to cut on |
2735 |
|
} |
2736 |
|
else{ |
2737 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2738 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2739 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2737 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2738 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2739 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2740 |
|
} |
2741 |
|
double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2742 |
|
|
2744 |
|
inputVariable = ""; |
2745 |
|
function = ""; |
2746 |
|
if(currentString.find("(")==std::string::npos){ |
2747 |
< |
inputVariable = currentString;// variable to cut on |
2747 |
> |
inputVariable = currentString;// variable to cut on |
2748 |
|
} |
2749 |
|
else{ |
2750 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2751 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2752 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2750 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2751 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2752 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2753 |
|
} |
2754 |
|
double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2755 |
|
|
2756 |
|
|
2757 |
< |
histo->Fill(valueX,valueY,puScaleFactor); |
2757 |
> |
histo->Fill(valueX,valueY,scaleFactor); |
2758 |
|
|
2759 |
< |
pairCounter++; |
2759 |
> |
pairCounter++; |
2760 |
|
|
2761 |
|
} |
2762 |
|
} |
2774 |
|
|
2775 |
|
double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi); |
2776 |
|
if(currentDeltaR > 0.05) continue; |
2777 |
< |
// cout << std::setprecision(3) << std::setw(20) |
2778 |
< |
// << "\tcurrentParticle: eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta |
2779 |
< |
// << std::setw(20) |
2780 |
< |
// << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi |
2781 |
< |
// << std::setw(20) |
2782 |
< |
// << "\tdeltaR = " << currentDeltaR |
2783 |
< |
// << std::setprecision(1) |
2784 |
< |
// << std::setw(20) |
2785 |
< |
// << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id |
2786 |
< |
// << std::setw(20) |
2787 |
< |
// << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId |
2788 |
< |
// << std::setw(20) |
2789 |
< |
// << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl; |
2777 |
> |
// cout << std::setprecision(3) << std::setw(20) |
2778 |
> |
// << "\tcurrentParticle: eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta |
2779 |
> |
// << std::setw(20) |
2780 |
> |
// << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi |
2781 |
> |
// << std::setw(20) |
2782 |
> |
// << "\tdeltaR = " << currentDeltaR |
2783 |
> |
// << std::setprecision(1) |
2784 |
> |
// << std::setw(20) |
2785 |
> |
// << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id |
2786 |
> |
// << std::setw(20) |
2787 |
> |
// << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId |
2788 |
> |
// << std::setw(20) |
2789 |
> |
// << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl; |
2790 |
|
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2791 |
|
bestMatchIndex = mcparticle - mcparticles->begin(); |
2792 |
|
bestMatchDeltaR = currentDeltaR; |
2853 |
|
int OSUAnalysis::getPdgIdBinValue(int pdgId){ |
2854 |
|
|
2855 |
|
int binValue = -999; |
2856 |
< |
int absPdgId = fabs(pdgId); |
2856 |
> |
int absPdgId = fabs(pdgId); |
2857 |
|
if(pdgId == -1) binValue = 0; |
2858 |
|
else if(absPdgId <= 6 ) binValue = absPdgId; |
2859 |
|
else if(absPdgId == 11 ) binValue = 7; |
2879 |
|
|
2880 |
|
} |
2881 |
|
|
2882 |
+ |
const BNprimaryvertex * |
2883 |
+ |
OSUAnalysis::chosenVertex () |
2884 |
+ |
{ |
2885 |
+ |
const BNprimaryvertex *chosenVertex = 0; |
2886 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) { |
2887 |
+ |
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() : |
2888 |
+ |
cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2); |
2889 |
+ |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
2890 |
+ |
if(!vertexFlags.at(vertexIndex)) continue; |
2891 |
+ |
chosenVertex = & primaryvertexs->at(vertexIndex); |
2892 |
+ |
break; |
2893 |
+ |
} |
2894 |
+ |
} |
2895 |
+ |
else { |
2896 |
+ |
chosenVertex = &primaryvertexs->at(0); |
2897 |
+ |
} |
2898 |
+ |
|
2899 |
+ |
return chosenVertex; |
2900 |
+ |
} |
2901 |
+ |
|
2902 |
+ |
const BNmet * |
2903 |
+ |
OSUAnalysis::chosenMET () |
2904 |
+ |
{ |
2905 |
+ |
const BNmet *chosenMET = 0; |
2906 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) { |
2907 |
+ |
vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() : |
2908 |
+ |
cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2); |
2909 |
+ |
for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){ |
2910 |
+ |
if(!metFlags.at(metIndex)) continue; |
2911 |
+ |
chosenMET = & mets->at(metIndex); |
2912 |
+ |
break; |
2913 |
+ |
} |
2914 |
+ |
} |
2915 |
+ |
else { |
2916 |
+ |
chosenMET = &mets->at(0); |
2917 |
+ |
} |
2918 |
|
|
2919 |
< |
DEFINE_FWK_MODULE(OSUAnalysis); |
2919 |
> |
return chosenMET; |
2920 |
> |
} |
2921 |
> |
|
2922 |
> |
const BNelectron * |
2923 |
> |
OSUAnalysis::chosenElectron () |
2924 |
> |
{ |
2925 |
> |
const BNelectron *chosenElectron = 0; |
2926 |
> |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) { |
2927 |
> |
vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() : |
2928 |
> |
cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2); |
2929 |
> |
for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){ |
2930 |
> |
if(!electronFlags.at(electronIndex)) continue; |
2931 |
> |
chosenElectron = & electrons->at(electronIndex); |
2932 |
> |
break; |
2933 |
> |
} |
2934 |
> |
} |
2935 |
> |
else { |
2936 |
> |
chosenElectron = &electrons->at(0); |
2937 |
> |
} |
2938 |
|
|
2939 |
+ |
return chosenElectron; |
2940 |
+ |
} |
2941 |
|
|
2942 |
+ |
const BNmuon * |
2943 |
+ |
OSUAnalysis::chosenMuon () |
2944 |
+ |
{ |
2945 |
+ |
const BNmuon *chosenMuon = 0; |
2946 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) { |
2947 |
+ |
vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() : |
2948 |
+ |
cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2); |
2949 |
+ |
for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){ |
2950 |
+ |
if(!muonFlags.at(muonIndex)) continue; |
2951 |
+ |
chosenMuon = & muons->at(muonIndex); |
2952 |
+ |
break; |
2953 |
+ |
} |
2954 |
+ |
} |
2955 |
+ |
else { |
2956 |
+ |
chosenMuon = &muons->at(0); |
2957 |
+ |
} |
2958 |
+ |
|
2959 |
+ |
return chosenMuon; |
2960 |
+ |
} |
2961 |
+ |
|
2962 |
+ |
|
2963 |
+ |
DEFINE_FWK_MODULE(OSUAnalysis); |