28 |
|
datasetType_ (cfg.getParameter<string> ("datasetType")), |
29 |
|
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")), |
30 |
|
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")), |
31 |
+ |
treeBranchSets_ (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")), |
32 |
|
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")), |
33 |
|
doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")), |
34 |
|
applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")), |
35 |
< |
printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")), |
35 |
> |
applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")), |
36 |
> |
minBtag_ (cfg.getParameter<int> ("minBtag")), |
37 |
> |
maxBtag_ (cfg.getParameter<int> ("maxBtag")), |
38 |
> |
printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")), |
39 |
> |
printAllTriggers_ (cfg.getParameter<bool> ("printAllTriggers")), |
40 |
|
useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")), |
41 |
< |
stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")) |
42 |
< |
|
43 |
< |
{ |
41 |
> |
stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")), |
42 |
> |
GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut")) |
43 |
> |
{ |
44 |
|
|
45 |
|
TH1::SetDefaultSumw2 (); |
46 |
|
|
51 |
|
muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_); |
52 |
|
electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_); |
53 |
|
} |
54 |
+ |
if (applyBtagSF_){ |
55 |
+ |
bTagSFWeight_ = new BtagSFWeight; |
56 |
+ |
} |
57 |
|
} |
58 |
|
if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*"))) |
59 |
|
stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_); |
62 |
|
// Construct Cutflow Objects. These store the results of cut decisions and |
63 |
|
// handle filling cut flow histograms. |
64 |
|
masterCutFlow_ = new CutFlow (fs_); |
57 |
– |
vector<TFileDirectory> directories; |
65 |
|
|
66 |
|
//always get vertex collection so we can assign the primary vertex in the event |
67 |
|
objectsToGet.push_back("primaryvertexs"); |
61 |
– |
|
62 |
– |
//always make the plot of number of primary vertices (to check pile-up reweighting) |
68 |
|
objectsToPlot.push_back("primaryvertexs"); |
69 |
+ |
objectsToCut.push_back("primaryvertexs"); |
70 |
+ |
|
71 |
|
|
72 |
|
//always get the MC particles to do GEN-matching |
73 |
|
objectsToGet.push_back("mcparticles"); |
75 |
|
//always get the event collection to do pile-up reweighting |
76 |
|
objectsToGet.push_back("events"); |
77 |
|
|
78 |
+ |
|
79 |
+ |
// Parse the tree variable definitions. |
80 |
+ |
for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) { |
81 |
+ |
string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection"); |
82 |
+ |
if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning: tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; } |
83 |
+ |
objectsToGet.push_back(tempInputCollection); |
84 |
+ |
objectsToCut.push_back(tempInputCollection); |
85 |
+ |
|
86 |
+ |
vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches")); |
87 |
+ |
|
88 |
+ |
for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) { |
89 |
+ |
BranchSpecs br; |
90 |
+ |
br.inputCollection = tempInputCollection; |
91 |
+ |
br.inputVariable = branchList.at(iBranch); |
92 |
+ |
TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable); |
93 |
+ |
br.name = string(newName.Data()); |
94 |
+ |
treeBranches_.push_back(br); |
95 |
+ |
} |
96 |
+ |
|
97 |
+ |
} // end for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) { |
98 |
+ |
|
99 |
+ |
|
100 |
|
//parse the histogram definitions |
101 |
|
for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){ |
102 |
|
|
120 |
|
} |
121 |
|
objectsToPlot.push_back(tempInputCollection); |
122 |
|
objectsToCut.push_back(tempInputCollection); |
123 |
< |
} |
95 |
< |
else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut |
123 |
> |
} else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut |
124 |
|
string obj1; |
125 |
|
string obj2; |
126 |
|
getTwoObjs(tempInputCollection, obj1, obj2); |
134 |
|
objectsToGet.push_back(tempInputCollection); |
135 |
|
objectsToGet.push_back(obj1); |
136 |
|
objectsToGet.push_back(obj2ToGet); |
137 |
+ |
} // end else |
138 |
+ |
|
139 |
|
|
110 |
– |
} |
140 |
|
|
141 |
|
vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms")); |
142 |
|
|
157 |
|
histograms.push_back(tempHistogram); |
158 |
|
|
159 |
|
} |
160 |
< |
} |
160 |
> |
} // for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){ |
161 |
> |
|
162 |
|
//make unique vector of objects we need to plot (so we can book a histogram with the number of each object) |
163 |
|
sort( objectsToPlot.begin(), objectsToPlot.end() ); |
164 |
|
objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() ); |
201 |
|
tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother"; |
202 |
|
|
203 |
|
|
204 |
< |
int maxNum = 24; |
204 |
> |
int maxNum = 25; |
205 |
|
vector<double> binVector; |
206 |
|
binVector.push_back(maxNum); |
207 |
|
binVector.push_back(0); |
243 |
|
//set triggers for this channel |
244 |
|
vector<string> triggerNames; |
245 |
|
triggerNames.clear(); |
246 |
+ |
vector<string> triggerToVetoNames; |
247 |
+ |
triggerToVetoNames.clear(); |
248 |
+ |
|
249 |
|
tempChannel.triggers.clear(); |
250 |
+ |
tempChannel.triggersToVeto.clear(); |
251 |
|
if(channels_.at(currentChannel).exists("triggers")){ |
252 |
|
triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers"); |
253 |
|
for(uint trigger = 0; trigger!= triggerNames.size(); trigger++) |
254 |
|
tempChannel.triggers.push_back(triggerNames.at(trigger)); |
255 |
|
objectsToGet.push_back("triggers"); |
256 |
|
} |
257 |
< |
|
257 |
> |
if(channels_.at(currentChannel).exists("triggersToVeto")){ |
258 |
> |
triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto"); |
259 |
> |
for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++) |
260 |
> |
tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger)); |
261 |
> |
objectsToGet.push_back("triggers"); |
262 |
> |
} |
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
//create cutFlow for this channel |
267 |
|
cutFlows_.push_back (new CutFlow (fs_, channelName)); |
268 |
< |
|
269 |
< |
//book a directory in the output file with the name of the channel |
231 |
< |
TFileDirectory subDir = fs_->mkdir( channelName ); |
232 |
< |
directories.push_back(subDir); |
233 |
< |
|
234 |
< |
map<string, TH1D*> oneDhistoMap; |
235 |
< |
oneDHists_.push_back(oneDhistoMap); |
236 |
< |
map<string, TH2D*> twoDhistoMap; |
237 |
< |
twoDHists_.push_back(twoDhistoMap); |
238 |
< |
|
239 |
< |
|
240 |
< |
|
241 |
< |
//book all histograms included in the configuration |
242 |
< |
for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){ |
243 |
< |
histogram currentHistogram = histograms.at(currentHistogramIndex); |
244 |
< |
int numBinsElements = currentHistogram.bins.size(); |
245 |
< |
int numInputVariables = currentHistogram.inputVariables.size(); |
246 |
< |
int numBinEdgesX = currentHistogram.variableBinsX.size(); |
247 |
< |
int numBinEdgesY = currentHistogram.variableBinsY.size(); |
248 |
< |
|
249 |
< |
if(numBinsElements == 1){ |
250 |
< |
if(numBinEdgesX > 1){ |
251 |
< |
if(numBinEdgesY > 1) |
252 |
< |
numBinsElements = 6; |
253 |
< |
else |
254 |
< |
numBinsElements = 3; |
255 |
< |
} |
256 |
< |
} |
257 |
< |
if(numBinsElements != 3 && numBinsElements !=6){ |
258 |
< |
cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
259 |
< |
exit(0); |
260 |
< |
} |
261 |
< |
else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){ |
262 |
< |
cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
263 |
< |
exit(0); |
264 |
< |
} |
265 |
< |
else if(numBinsElements == 3){ |
266 |
< |
if (currentHistogram.bins.size () == 3) |
267 |
< |
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)); |
268 |
< |
else |
269 |
< |
{ |
270 |
< |
oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ()); |
271 |
< |
} |
272 |
< |
} |
273 |
< |
else if(numBinsElements == 6){ |
274 |
< |
if (currentHistogram.bins.size () == 6) |
275 |
< |
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)); |
276 |
< |
else |
277 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ()); |
278 |
< |
} |
279 |
< |
|
280 |
< |
|
281 |
< |
if(currentHistogram.name.find("GenMatch")==string::npos) continue; |
282 |
< |
|
283 |
< |
// bin particle type |
284 |
< |
// --- ------------- |
285 |
< |
// 0 unmatched |
286 |
< |
// 1 u |
287 |
< |
// 2 d |
288 |
< |
// 3 s |
289 |
< |
// 4 c |
290 |
< |
// 5 b |
291 |
< |
// 6 t |
292 |
< |
// 7 e |
293 |
< |
// 8 mu |
294 |
< |
// 9 tau |
295 |
< |
// 10 nu |
296 |
< |
// 11 g |
297 |
< |
// 12 gamma |
298 |
< |
// 13 Z |
299 |
< |
// 14 W |
300 |
< |
// 15 light meson |
301 |
< |
// 16 K meson |
302 |
< |
// 17 D meson |
303 |
< |
// 18 B meson |
304 |
< |
// 19 light baryon |
305 |
< |
// 20 strange baryon |
306 |
< |
// 21 charm baryon |
307 |
< |
// 22 bottom baryon |
308 |
< |
// 23 other |
309 |
< |
|
310 |
< |
vector<TString> labelArray; |
311 |
< |
labelArray.push_back("unmatched"); |
312 |
< |
labelArray.push_back("u"); |
313 |
< |
labelArray.push_back("d"); |
314 |
< |
labelArray.push_back("s"); |
315 |
< |
labelArray.push_back("c"); |
316 |
< |
labelArray.push_back("b"); |
317 |
< |
labelArray.push_back("t"); |
318 |
< |
labelArray.push_back("e"); |
319 |
< |
labelArray.push_back("#mu"); |
320 |
< |
labelArray.push_back("#tau"); |
321 |
< |
labelArray.push_back("#nu"); |
322 |
< |
labelArray.push_back("g"); |
323 |
< |
labelArray.push_back("#gamma"); |
324 |
< |
labelArray.push_back("Z"); |
325 |
< |
labelArray.push_back("W"); |
326 |
< |
labelArray.push_back("light meson"); |
327 |
< |
labelArray.push_back("K meson"); |
328 |
< |
labelArray.push_back("D meson"); |
329 |
< |
labelArray.push_back("B meson"); |
330 |
< |
labelArray.push_back("light baryon"); |
331 |
< |
labelArray.push_back("strange baryon"); |
332 |
< |
labelArray.push_back("charm baryon"); |
333 |
< |
labelArray.push_back("bottom baryon"); |
334 |
< |
labelArray.push_back("other"); |
335 |
< |
|
336 |
< |
for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){ |
337 |
< |
if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) { |
338 |
< |
oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
339 |
< |
} |
340 |
< |
else { |
341 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1)); |
342 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
343 |
< |
} |
344 |
< |
} |
345 |
< |
if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) { |
346 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle(); |
347 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle(); |
348 |
< |
} |
349 |
< |
|
350 |
< |
} |
351 |
< |
|
352 |
< |
// Book a histogram for the number of each object type to be plotted. |
353 |
< |
// Name of objectToPlot here must match the name specified in OSUAnalysis::analyze(). |
354 |
< |
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
355 |
< |
string currentObject = objectsToPlot.at(currentObjectIndex); |
356 |
< |
int maxNum = 10; |
357 |
< |
if(currentObject == "mcparticles") maxNum = 50; |
358 |
< |
else if(currentObject == "primaryvertexs") maxNum = 50; |
359 |
< |
|
360 |
< |
if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
361 |
< |
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
362 |
< |
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
363 |
< |
else if(currentObject == "jet-jet pairs") currentObject = "dijetPairs"; |
364 |
< |
else if(currentObject == "electron-jet pairs") currentObject = "electronJetPairs"; |
365 |
< |
else if(currentObject == "muon-jet pairs") currentObject = "muonJetPairs"; |
366 |
< |
else if(currentObject == "track-event pairs") currentObject = "trackEventPairs"; |
367 |
< |
else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs"; |
368 |
< |
else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs"; |
369 |
< |
else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs"; |
370 |
< |
else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs"; |
371 |
< |
else if(currentObject == "tau-track pairs") currentObject = "tauTrackPairs"; |
372 |
< |
else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs"; |
373 |
< |
else if(currentObject == "secondary muons") currentObject = "secondaryMuons"; |
374 |
< |
else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs"; |
375 |
< |
else if(currentObject == "secondary electrons") currentObject = "secondaryElectrons"; |
376 |
< |
else if(currentObject == "electron-trigobj pairs") currentObject = "electronTrigobjPairs"; |
377 |
< |
else if(currentObject == "muon-trigobj pairs") currentObject = "muonTrigobjPairs"; |
378 |
< |
|
379 |
< |
currentObject.at(0) = toupper(currentObject.at(0)); |
380 |
< |
string histoName = "num" + currentObject; |
381 |
< |
|
382 |
< |
if(histoName == "numPrimaryvertexs"){ |
383 |
< |
string newHistoName = histoName + "BeforePileupCorrection"; |
384 |
< |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
385 |
< |
newHistoName = histoName + "AfterPileupCorrection"; |
386 |
< |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
387 |
< |
} |
388 |
< |
else |
389 |
< |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
390 |
< |
} |
391 |
< |
|
392 |
< |
|
393 |
< |
|
394 |
< |
|
268 |
> |
vector<TFileDirectory> directories; //vector of directories in the output file. |
269 |
> |
vector<string> subSubDirNames;//subdirectories in each channel. |
270 |
|
//get list of cuts for this channel |
271 |
|
vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts")); |
272 |
|
|
273 |
+ |
|
274 |
|
//loop over and parse all cuts |
275 |
|
for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){ |
276 |
|
cut tempCut; |
350 |
|
tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut |
351 |
|
tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make |
352 |
|
|
353 |
< |
|
353 |
> |
//Set up vectors to store the directories and subDIrectories for each channel. |
354 |
> |
string subSubDirName; |
355 |
|
string tempCutName; |
356 |
|
if(cuts_.at(currentCut).exists("alias")){ |
357 |
|
tempCutName = cuts_.at(currentCut).getParameter<string> ("alias"); |
358 |
+ |
subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied"; |
359 |
|
} |
360 |
|
else{ |
361 |
|
//construct string for cutflow table |
363 |
|
string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1); |
364 |
|
string cutName = numberRequiredString + " " + collectionString + " with " + cutString; |
365 |
|
tempCutName = cutName; |
366 |
+ |
subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied"; |
367 |
|
} |
368 |
+ |
|
369 |
+ |
subSubDirNames.push_back(subSubDirName); |
370 |
|
tempCut.name = tempCutName; |
371 |
|
|
372 |
|
tempChannel.cuts.push_back(tempCut); |
374 |
|
|
375 |
|
}//end loop over cuts |
376 |
|
|
377 |
+ |
vector<map<string, TH1D*>> oneDHistsTmp; |
378 |
+ |
vector<map<string, TH2D*>> twoDHistsTmp; |
379 |
+ |
//book a directory in the output file with the name of the channel |
380 |
+ |
TFileDirectory subDir = fs_->mkdir( channelName ); |
381 |
+ |
//loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true. |
382 |
+ |
if(GetPlotsAfterEachCut_){ |
383 |
+ |
for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){ |
384 |
+ |
TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] ); |
385 |
+ |
directories.push_back(subSubDir); |
386 |
+ |
map<string, TH1D*> oneDhistoMap; |
387 |
+ |
oneDHistsTmp.push_back(oneDhistoMap); |
388 |
+ |
map<string, TH2D*> twoDhistoMap; |
389 |
+ |
twoDHistsTmp.push_back(twoDhistoMap); |
390 |
+ |
} |
391 |
+ |
oneDHists_.push_back(oneDHistsTmp); |
392 |
+ |
twoDHists_.push_back(twoDHistsTmp); |
393 |
+ |
} |
394 |
+ |
//only set up directories with names of the channels if GetPlotsAfterEachCut_ is false. |
395 |
+ |
else{ |
396 |
+ |
map<string, TH1D*> oneDhistoMap; |
397 |
+ |
oneDHistsTmp.push_back(oneDhistoMap); |
398 |
+ |
map<string, TH2D*> twoDhistoMap; |
399 |
+ |
twoDHistsTmp.push_back(twoDhistoMap); |
400 |
+ |
oneDHists_.push_back(oneDHistsTmp); |
401 |
+ |
twoDHists_.push_back(twoDHistsTmp); |
402 |
+ |
directories.push_back(subDir); |
403 |
+ |
|
404 |
+ |
} |
405 |
+ |
|
406 |
+ |
|
407 |
+ |
//book all histograms included in the configuration |
408 |
+ |
for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories. |
409 |
+ |
|
410 |
+ |
TTree* newTree = directories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel)); |
411 |
+ |
BNTrees_.push_back(newTree); |
412 |
+ |
for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){ |
413 |
+ |
BranchSpecs currentVar = treeBranches_.at(iBranch); |
414 |
+ |
vector<float> newVec; |
415 |
+ |
BNTreeBranchVals_[currentVar.name] = newVec; |
416 |
+ |
BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name)); |
417 |
+ |
} // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){ |
418 |
+ |
|
419 |
+ |
for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){ |
420 |
+ |
|
421 |
+ |
histogram currentHistogram = histograms.at(currentHistogramIndex); |
422 |
+ |
int numBinsElements = currentHistogram.bins.size(); |
423 |
+ |
int numInputVariables = currentHistogram.inputVariables.size(); |
424 |
+ |
int numBinEdgesX = currentHistogram.variableBinsX.size(); |
425 |
+ |
int numBinEdgesY = currentHistogram.variableBinsY.size(); |
426 |
+ |
|
427 |
+ |
if(numBinsElements == 1){ |
428 |
+ |
if(numBinEdgesX > 1){ |
429 |
+ |
if(numBinEdgesY > 1) |
430 |
+ |
numBinsElements = 6; |
431 |
+ |
else |
432 |
+ |
numBinsElements = 3; |
433 |
+ |
} |
434 |
+ |
} |
435 |
+ |
if(numBinsElements != 3 && numBinsElements !=6){ |
436 |
+ |
cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
437 |
+ |
exit(0); |
438 |
+ |
} |
439 |
+ |
else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){ |
440 |
+ |
cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
441 |
+ |
exit(0); |
442 |
+ |
} |
443 |
+ |
else if(numBinsElements == 3){ |
444 |
+ |
if (currentHistogram.bins.size () == 3) |
445 |
+ |
oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2)); |
446 |
+ |
else |
447 |
+ |
{ |
448 |
+ |
oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ()); |
449 |
+ |
} |
450 |
+ |
} |
451 |
+ |
else if(numBinsElements == 6){ |
452 |
+ |
if (currentHistogram.bins.size () == 6) |
453 |
+ |
twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).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)); |
454 |
+ |
else |
455 |
+ |
twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ()); |
456 |
+ |
} |
457 |
+ |
|
458 |
+ |
|
459 |
+ |
if(currentHistogram.name.find("GenMatch")==string::npos) continue; |
460 |
+ |
|
461 |
+ |
// bin particle type |
462 |
+ |
// --- ------------- |
463 |
+ |
// 0 unmatched |
464 |
+ |
// 1 u |
465 |
+ |
// 2 d |
466 |
+ |
// 3 s |
467 |
+ |
// 4 c |
468 |
+ |
// 5 b |
469 |
+ |
// 6 t |
470 |
+ |
// 7 e |
471 |
+ |
// 8 mu |
472 |
+ |
// 9 tau |
473 |
+ |
// 10 nu |
474 |
+ |
// 11 g |
475 |
+ |
// 12 gamma |
476 |
+ |
// 13 Z |
477 |
+ |
// 14 W |
478 |
+ |
// 15 light meson |
479 |
+ |
// 16 K meson |
480 |
+ |
// 17 D meson |
481 |
+ |
// 18 B meson |
482 |
+ |
// 19 light baryon |
483 |
+ |
// 20 strange baryon |
484 |
+ |
// 21 charm baryon |
485 |
+ |
// 22 bottom baryon |
486 |
+ |
// 23 QCD string |
487 |
+ |
// 24 other |
488 |
+ |
|
489 |
+ |
vector<TString> labelArray; |
490 |
+ |
labelArray.push_back("unmatched"); |
491 |
+ |
labelArray.push_back("u"); |
492 |
+ |
labelArray.push_back("d"); |
493 |
+ |
labelArray.push_back("s"); |
494 |
+ |
labelArray.push_back("c"); |
495 |
+ |
labelArray.push_back("b"); |
496 |
+ |
labelArray.push_back("t"); |
497 |
+ |
labelArray.push_back("e"); |
498 |
+ |
labelArray.push_back("#mu"); |
499 |
+ |
labelArray.push_back("#tau"); |
500 |
+ |
labelArray.push_back("#nu"); |
501 |
+ |
labelArray.push_back("g"); |
502 |
+ |
labelArray.push_back("#gamma"); |
503 |
+ |
labelArray.push_back("Z"); |
504 |
+ |
labelArray.push_back("W"); |
505 |
+ |
labelArray.push_back("light meson"); |
506 |
+ |
labelArray.push_back("K meson"); |
507 |
+ |
labelArray.push_back("D meson"); |
508 |
+ |
labelArray.push_back("B meson"); |
509 |
+ |
labelArray.push_back("light baryon"); |
510 |
+ |
labelArray.push_back("strange baryon"); |
511 |
+ |
labelArray.push_back("charm baryon"); |
512 |
+ |
labelArray.push_back("bottom baryon"); |
513 |
+ |
labelArray.push_back("QCD string"); |
514 |
+ |
labelArray.push_back("other"); |
515 |
+ |
|
516 |
+ |
for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){ |
517 |
+ |
if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) { |
518 |
+ |
oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
519 |
+ |
} |
520 |
+ |
else { |
521 |
+ |
twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1)); |
522 |
+ |
twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
523 |
+ |
} |
524 |
+ |
} |
525 |
+ |
if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) { |
526 |
+ |
twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle(); |
527 |
+ |
twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle(); |
528 |
+ |
} |
529 |
+ |
|
530 |
+ |
} // end for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){ |
531 |
+ |
|
532 |
+ |
|
533 |
+ |
// Book a histogram for the number of each object type to be plotted. |
534 |
+ |
// Name of objectToPlot here must match the name specified in OSUAnalysis::analyze(). |
535 |
+ |
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
536 |
+ |
string currentObject = objectsToPlot.at(currentObjectIndex); |
537 |
+ |
int maxNum = 10; |
538 |
+ |
if(currentObject == "mcparticles") maxNum = 50; |
539 |
+ |
else if(currentObject == "primaryvertexs") maxNum = 50; |
540 |
+ |
|
541 |
+ |
if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
542 |
+ |
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
543 |
+ |
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
544 |
+ |
else if(currentObject == "secondary jets") currentObject = "secondaryJets"; |
545 |
+ |
else if(currentObject == "jet-jet pairs") currentObject = "dijetPairs"; |
546 |
+ |
else if(currentObject == "electron-jet pairs") currentObject = "electronJetPairs"; |
547 |
+ |
else if(currentObject == "muon-jet pairs") currentObject = "muonJetPairs"; |
548 |
+ |
else if(currentObject == "track-event pairs") currentObject = "trackEventPairs"; |
549 |
+ |
else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs"; |
550 |
+ |
else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs"; |
551 |
+ |
else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs"; |
552 |
+ |
else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs"; |
553 |
+ |
else if(currentObject == "tau-track pairs") currentObject = "tauTrackPairs"; |
554 |
+ |
else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs"; |
555 |
+ |
else if(currentObject == "secondary muons") currentObject = "secondaryMuons"; |
556 |
+ |
else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs"; |
557 |
+ |
else if(currentObject == "secondary electrons") currentObject = "secondaryElectrons"; |
558 |
+ |
else if(currentObject == "electron-trigobj pairs") currentObject = "electronTrigobjPairs"; |
559 |
+ |
else if(currentObject == "muon-trigobj pairs") currentObject = "muonTrigobjPairs"; |
560 |
+ |
|
561 |
+ |
currentObject.at(0) = toupper(currentObject.at(0)); |
562 |
+ |
string histoName = "num" + currentObject; |
563 |
+ |
|
564 |
+ |
if(histoName == "numPrimaryvertexs"){ |
565 |
+ |
string newHistoName = histoName + "BeforePileupCorrection"; |
566 |
+ |
oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
567 |
+ |
newHistoName = histoName + "AfterPileupCorrection"; |
568 |
+ |
oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
569 |
+ |
} |
570 |
+ |
else |
571 |
+ |
oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
572 |
+ |
} |
573 |
+ |
}//end of loop over directories |
574 |
|
channels.push_back(tempChannel); |
575 |
|
tempChannel.cuts.clear(); |
498 |
– |
|
576 |
|
}//end loop over channels |
577 |
|
|
578 |
|
|
584 |
|
objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() ); |
585 |
|
|
586 |
|
|
587 |
< |
} |
587 |
> |
} // end constructor OSUAnalysis::OSUAnalysis() |
588 |
> |
|
589 |
|
|
590 |
|
OSUAnalysis::~OSUAnalysis () |
591 |
|
{ |
592 |
+ |
|
593 |
|
// Destroying the CutFlow objects causes the cut flow numbers and time |
594 |
|
// information to be printed to standard output. |
595 |
|
for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){ |
664 |
|
double masterScaleFactor = 1.0; |
665 |
|
|
666 |
|
//get pile-up event weight |
667 |
< |
if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV); |
667 |
> |
if (doPileupReweighting_ && datasetType_ != "data") { |
668 |
> |
//for "data" datasets, the numTruePV is always set to -1 |
669 |
> |
if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0. Turning off pile-up reweighting." << endl; |
670 |
> |
else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV); |
671 |
> |
} |
672 |
|
|
673 |
|
stopCTauScaleFactor_ = 1.0; |
674 |
|
if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*"))) |
684 |
|
counterMap passingCounter; |
685 |
|
cumulativeFlags.clear (); |
686 |
|
|
687 |
+ |
for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin(); |
688 |
+ |
iter != BNTreeBranchVals_.end(); iter++) { |
689 |
+ |
iter->second.clear(); // clear array |
690 |
+ |
} |
691 |
+ |
|
692 |
|
bool triggerDecision = true; |
693 |
< |
if(currentChannel.triggers.size() != 0){ //triggers specified |
694 |
< |
triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product()); |
693 |
> |
if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){ //triggers specified |
694 |
> |
triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product()); |
695 |
|
cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision; |
696 |
|
} |
697 |
|
|
698 |
|
//loop over all cuts |
611 |
– |
|
699 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
700 |
|
cut currentCut = currentChannel.cuts.at(currentCutIndex); |
614 |
– |
|
701 |
|
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
702 |
|
string currentObject = objectsToCut.at(currentObjectIndex); |
703 |
|
|
712 |
|
int flagsForPairCutsIndex = max(int(currentCutIndex-1),0); |
713 |
|
|
714 |
|
|
715 |
< |
if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
716 |
< |
|
717 |
< |
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
632 |
< |
|
715 |
> |
if (currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
716 |
> |
else if(currentObject == "secondary jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets"); |
717 |
> |
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
718 |
|
else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons"); |
719 |
|
else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons"); |
720 |
|
else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons"); |
738 |
|
"muon-muon pairs"); |
739 |
|
|
740 |
|
else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \ |
741 |
< |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
742 |
< |
cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \ |
743 |
< |
"muon-secondary muon pairs"); |
741 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
742 |
> |
cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \ |
743 |
> |
"muon-secondary muon pairs"); |
744 |
|
|
745 |
|
else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \ |
746 |
< |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
747 |
< |
cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \ |
748 |
< |
"electron-secondary electron pairs"); |
746 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
747 |
> |
cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \ |
748 |
> |
"electron-secondary electron pairs"); |
749 |
|
|
750 |
|
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \ |
751 |
|
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
756 |
|
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
757 |
|
"electron-muon pairs"); |
758 |
|
else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \ |
759 |
< |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
760 |
< |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
761 |
< |
"jet-jet pairs"); |
759 |
> |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
760 |
> |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
761 |
> |
"jet-jet pairs"); |
762 |
|
else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \ |
763 |
< |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
764 |
< |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
765 |
< |
"electron-jet pairs"); |
763 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
764 |
> |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
765 |
> |
"electron-jet pairs"); |
766 |
|
else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \ |
767 |
< |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
768 |
< |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
769 |
< |
"muon-jet pairs"); |
767 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
768 |
> |
cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \ |
769 |
> |
"muon-jet pairs"); |
770 |
|
else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(), |
771 |
|
cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), |
772 |
|
cumulativeFlags.at("events").at(flagsForPairCutsIndex), |
788 |
|
cumulativeFlags.at("taus").at(flagsForPairCutsIndex), |
789 |
|
"tau-tau pairs"); |
790 |
|
else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(), |
791 |
< |
cumulativeFlags.at("taus").at(flagsForPairCutsIndex), |
792 |
< |
cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), |
793 |
< |
"tau-track pairs"); |
791 |
> |
cumulativeFlags.at("taus").at(flagsForPairCutsIndex), |
792 |
> |
cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), |
793 |
> |
"tau-track pairs"); |
794 |
|
else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(), |
795 |
|
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), |
796 |
|
cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex), |
806 |
|
|
807 |
|
|
808 |
|
}//end loop over all cuts |
724 |
– |
|
725 |
– |
|
809 |
|
//use cumulative flags to apply cuts at event level |
810 |
|
|
811 |
|
bool eventPassedAllCuts = true; |
812 |
< |
|
812 |
> |
//a vector to store cumulative cut descisions after each cut. |
813 |
> |
vector<bool> eventPassedPreviousCuts; |
814 |
|
//apply trigger (true if none were specified) |
815 |
|
eventPassedAllCuts = eventPassedAllCuts && triggerDecision; |
816 |
|
|
733 |
– |
|
817 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
818 |
|
|
819 |
|
//loop over all objects and count how many passed the cumulative selection up to this point |
826 |
|
bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired); |
827 |
|
cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision; |
828 |
|
eventPassedAllCuts = eventPassedAllCuts && cutDecision; |
829 |
< |
|
829 |
> |
eventPassedPreviousCuts.push_back(eventPassedAllCuts); |
830 |
|
} |
748 |
– |
|
831 |
|
double scaleFactor = masterScaleFactor; |
832 |
|
|
833 |
+ |
muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0; |
834 |
|
if(applyLeptonSF_ && datasetType_ != "data"){ |
835 |
< |
if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta); |
836 |
< |
if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt); |
835 |
> |
if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){ |
836 |
> |
vector<bool> muonFlags; |
837 |
> |
for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){ |
838 |
> |
if (cumulativeFlags.at("muons").at(i).size()){ |
839 |
> |
muonFlags = cumulativeFlags.at("muons").at(i); |
840 |
> |
break; |
841 |
> |
} |
842 |
> |
} |
843 |
> |
for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){ |
844 |
> |
if(!muonFlags.at(muonIndex)) continue; |
845 |
> |
muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta); |
846 |
> |
} |
847 |
> |
} |
848 |
> |
if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){ |
849 |
> |
vector<bool> electronFlags; |
850 |
> |
for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){ |
851 |
> |
if (cumulativeFlags.at("electrons").at(i).size()){ |
852 |
> |
electronFlags = cumulativeFlags.at("electrons").at(i); |
853 |
> |
break; |
854 |
> |
} |
855 |
> |
} |
856 |
> |
for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){ |
857 |
> |
if(!electronFlags.at(electronIndex)) continue; |
858 |
> |
electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt); |
859 |
> |
} |
860 |
> |
} |
861 |
|
} |
862 |
< |
|
862 |
> |
if(applyBtagSF_ && datasetType_ != "data"){ |
863 |
> |
if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){ |
864 |
> |
vector<bool> jetFlags; |
865 |
> |
vector<double> jetSFs; |
866 |
> |
for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){ |
867 |
> |
if (cumulativeFlags.at("jets").at(i).size()){ |
868 |
> |
jetFlags = cumulativeFlags.at("jets").at(i); |
869 |
> |
break; |
870 |
> |
} |
871 |
> |
} |
872 |
> |
for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){ |
873 |
> |
if(!jetFlags.at(jetIndex)) continue; |
874 |
> |
double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt); |
875 |
> |
jetSFs.push_back(jetSFTmp); |
876 |
> |
} |
877 |
> |
bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ ); |
878 |
> |
} |
879 |
> |
} |
880 |
> |
scaleFactor *= muonScaleFactor_; |
881 |
> |
scaleFactor *= electronScaleFactor_; |
882 |
> |
scaleFactor *= bTagScaleFactor_; |
883 |
|
cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor); |
884 |
|
|
758 |
– |
if(!eventPassedAllCuts)continue; |
759 |
– |
|
885 |
|
if (printEventInfo_) { |
886 |
|
// Write information about event to screen, for testing purposes. |
887 |
|
cout << "Event passed all cuts in channel " << currentChannel.name |
891 |
|
<< endl; |
892 |
|
} |
893 |
|
|
769 |
– |
//filling histograms |
770 |
– |
for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){ |
771 |
– |
histogram currentHistogram = histograms.at(histogramIndex); |
772 |
– |
|
773 |
– |
if(currentHistogram.inputVariables.size() == 1){ |
774 |
– |
TH1D* histo; |
775 |
– |
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
776 |
– |
|
777 |
– |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor); |
778 |
– |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor); |
779 |
– |
else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor); |
780 |
– |
else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor); |
781 |
– |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
782 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
783 |
– |
cumulativeFlags.at("muon-muon pairs").back(),scaleFactor); |
784 |
– |
else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
785 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \ |
786 |
– |
cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor); |
787 |
– |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor); |
788 |
– |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
789 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
790 |
– |
cumulativeFlags.at("electron-electron pairs").back(),scaleFactor); |
791 |
– |
else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\ |
792 |
– |
cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\ |
793 |
– |
cumulativeFlags.at("jet-jet pairs").back(),scaleFactor); |
794 |
– |
else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
795 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \ |
796 |
– |
cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor); |
797 |
– |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
798 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
799 |
– |
cumulativeFlags.at("electron-muon pairs").back(),scaleFactor); |
800 |
– |
else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \ |
801 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), |
802 |
– |
cumulativeFlags.at("electron-jet pairs").back(),scaleFactor); |
803 |
– |
else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \ |
804 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), |
805 |
– |
cumulativeFlags.at("muon-jet pairs").back(),scaleFactor); |
806 |
– |
else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), |
807 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), |
808 |
– |
cumulativeFlags.at("electron-track pairs").back(),scaleFactor); |
809 |
– |
else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), |
810 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), |
811 |
– |
cumulativeFlags.at("muon-track pairs").back(),scaleFactor); |
812 |
– |
else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), |
813 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), |
814 |
– |
cumulativeFlags.at("muon-tau pairs").back(),scaleFactor); |
815 |
– |
else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), |
816 |
– |
cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), |
817 |
– |
cumulativeFlags.at("tau-tau pairs").back(),scaleFactor); |
818 |
– |
else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(), |
819 |
– |
cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(), |
820 |
– |
cumulativeFlags.at("tau-track pairs").back(),scaleFactor); |
821 |
– |
else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(), |
822 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(), |
823 |
– |
cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor); |
824 |
– |
else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(), |
825 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(), |
826 |
– |
cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor); |
827 |
– |
|
828 |
– |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor); |
829 |
– |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor); |
830 |
– |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor); |
831 |
– |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor); |
832 |
– |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor); |
833 |
– |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor); |
834 |
– |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor); |
835 |
– |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor); |
836 |
– |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor); |
837 |
– |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor); |
838 |
– |
else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor); |
839 |
– |
else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor); |
840 |
– |
} |
841 |
– |
else if(currentHistogram.inputVariables.size() == 2){ |
842 |
– |
TH2D* histo; |
843 |
– |
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
844 |
– |
|
845 |
– |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor); |
846 |
– |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor); |
847 |
– |
else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor); |
848 |
– |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
849 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
850 |
– |
cumulativeFlags.at("muon-muon pairs").back(),scaleFactor); |
851 |
– |
else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
852 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \ |
853 |
– |
cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor); |
854 |
– |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor); |
855 |
– |
else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor); |
856 |
– |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
857 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
858 |
– |
cumulativeFlags.at("electron-electron pairs").back(),scaleFactor); |
859 |
– |
else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \ |
860 |
– |
cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \ |
861 |
– |
cumulativeFlags.at("jet-jet pairs").back(),scaleFactor); |
862 |
– |
else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
863 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \ |
864 |
– |
cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor); |
865 |
– |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
866 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
867 |
– |
cumulativeFlags.at("electron-muon pairs").back(),scaleFactor); |
868 |
– |
else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \ |
869 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \ |
870 |
– |
cumulativeFlags.at("electron-jet pairs").back(),scaleFactor); |
871 |
– |
else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \ |
872 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \ |
873 |
– |
cumulativeFlags.at("muon-jet pairs").back(),scaleFactor); |
874 |
– |
else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), |
875 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), |
876 |
– |
cumulativeFlags.at("electron-track pairs").back(),scaleFactor); |
877 |
– |
else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), |
878 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), |
879 |
– |
cumulativeFlags.at("muon-track pairs").back(),scaleFactor); |
880 |
– |
else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), |
881 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), |
882 |
– |
cumulativeFlags.at("muon-tau pairs").back(),scaleFactor); |
883 |
– |
else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), |
884 |
– |
cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), |
885 |
– |
cumulativeFlags.at("tau-tau pairs").back(),scaleFactor); |
886 |
– |
else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(), |
887 |
– |
cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(), |
888 |
– |
cumulativeFlags.at("tau-track pairs").back(),scaleFactor); |
889 |
– |
else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(), |
890 |
– |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(), |
891 |
– |
cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor); |
892 |
– |
else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(), |
893 |
– |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(), |
894 |
– |
cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor); |
895 |
– |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor); |
896 |
– |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor); |
897 |
– |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor); |
898 |
– |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor); |
899 |
– |
else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(), |
900 |
– |
cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(), |
901 |
– |
cumulativeFlags.at("track-event pairs").back(),scaleFactor); |
902 |
– |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor); |
903 |
– |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor); |
904 |
– |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor); |
905 |
– |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor); |
906 |
– |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor); |
907 |
– |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor); |
908 |
– |
else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor); |
909 |
– |
else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor); |
910 |
– |
} |
911 |
– |
} |
912 |
– |
|
913 |
– |
|
894 |
|
|
895 |
< |
//fills histograms with the sizes of collections |
896 |
< |
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
897 |
< |
|
898 |
< |
string currentObject = objectsToPlot.at(currentObjectIndex); |
899 |
< |
|
900 |
< |
string objectToPlot = ""; |
921 |
< |
|
922 |
< |
// Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis(). |
923 |
< |
if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs"; |
924 |
< |
else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs"; |
925 |
< |
else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs"; |
926 |
< |
else if(currentObject == "electron-jet pairs") objectToPlot = "electronJetPairs"; |
927 |
< |
else if(currentObject == "muon-jet pairs") objectToPlot = "muonJetPairs"; |
928 |
< |
else if(currentObject == "jet-jet pairs") objectToPlot = "dijetPairs"; |
929 |
< |
else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs"; |
930 |
< |
else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs"; |
931 |
< |
else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs"; |
932 |
< |
else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs"; |
933 |
< |
else if(currentObject == "tau-track pairs") objectToPlot = "tauTrackPairs"; |
934 |
< |
else if(currentObject == "track-event pairs") objectToPlot = "trackEventPairs"; |
935 |
< |
else if(currentObject == "muon-secondary muon pairs") objectToPlot = "muonSecondaryMuonPairs"; |
936 |
< |
else if(currentObject == "secondary muons") objectToPlot = "secondaryMuons"; |
937 |
< |
else if(currentObject == "electron-secondary electron pairs") objectToPlot = "electronSecondaryElectronPairs"; |
938 |
< |
else if(currentObject == "secondary electrons") objectToPlot = "secondaryElectrons"; |
939 |
< |
else if(currentObject == "electron-trigobj pairs") objectToPlot = "electronTrigobjPairs"; |
940 |
< |
else if(currentObject == "muon-trigobj pairs") objectToPlot = "muonTrigobjPairs"; |
941 |
< |
else objectToPlot = currentObject; |
942 |
< |
|
943 |
< |
string tempCurrentObject = objectToPlot; |
944 |
< |
tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0)); |
945 |
< |
string histoName = "num" + tempCurrentObject; |
946 |
< |
|
947 |
< |
//set position of primary vertex in event, in order to calculate quantities relative to it |
948 |
< |
if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) { |
949 |
< |
vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back(); |
950 |
< |
int numToPlot = 0; |
951 |
< |
for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){ |
952 |
< |
if(lastCutFlags.at(currentFlag)) numToPlot++; |
953 |
< |
} |
954 |
< |
if(objectToPlot == "primaryvertexs"){ |
955 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
956 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
957 |
< |
} |
958 |
< |
else { |
959 |
< |
oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor); |
960 |
< |
} |
961 |
< |
} |
962 |
< |
else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor); |
963 |
< |
else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor); |
964 |
< |
else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor); |
965 |
< |
else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor); |
966 |
< |
else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor); |
967 |
< |
else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor); |
968 |
< |
else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor); |
969 |
< |
else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor); |
970 |
< |
else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor); |
971 |
< |
else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor); |
972 |
< |
else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor); |
973 |
< |
else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor); |
974 |
< |
else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor); |
975 |
< |
else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor); |
976 |
< |
else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor); |
977 |
< |
else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor); |
978 |
< |
else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor); |
979 |
< |
else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor); |
980 |
< |
else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor); |
981 |
< |
else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor); |
982 |
< |
else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor); |
983 |
< |
else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor); |
984 |
< |
else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor); |
985 |
< |
else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor); |
986 |
< |
else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(trigobjs->size(),scaleFactor); |
987 |
< |
else if(objectToPlot == "primaryvertexs"){ |
988 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
989 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
895 |
> |
//filling histograms |
896 |
> |
for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel. |
897 |
> |
uint currentDir; |
898 |
> |
if (!GetPlotsAfterEachCut_) { currentDir = currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut. |
899 |
> |
else{ |
900 |
> |
currentDir = currentCut; |
901 |
|
} |
902 |
< |
if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor); |
902 |
> |
if(eventPassedPreviousCuts.at(currentDir)){ |
903 |
|
|
904 |
< |
} // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++) |
904 |
> |
// Assign BNTree variables |
905 |
> |
for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) { |
906 |
> |
BranchSpecs brSpecs = treeBranches_.at(iBranch); |
907 |
> |
string coll = brSpecs.inputCollection; |
908 |
> |
if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection: " << coll << ", will cause a seg fault" << endl; |
909 |
> |
|
910 |
> |
if (coll == "jets") assignTreeBranch(brSpecs,jets.product(), cumulativeFlags.at(coll).at(currentDir)); |
911 |
> |
else if(coll == "secondary jets") assignTreeBranch(brSpecs,jets.product(), cumulativeFlags.at(coll).at(currentDir)); |
912 |
> |
else if(coll == "muons") assignTreeBranch(brSpecs,muons.product(), cumulativeFlags.at(coll).at(currentDir)); |
913 |
> |
else if(coll == "secondary muons") assignTreeBranch(brSpecs,muons.product(), cumulativeFlags.at(coll).at(currentDir)); |
914 |
> |
else if(coll == "electrons") assignTreeBranch(brSpecs,electrons.product(), cumulativeFlags.at(coll).at(currentDir)); |
915 |
> |
else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(), cumulativeFlags.at(coll).at(currentDir)); |
916 |
> |
else if(coll == "events") assignTreeBranch(brSpecs,events.product(), cumulativeFlags.at(coll).at(currentDir)); |
917 |
> |
else if(coll == "taus") assignTreeBranch(brSpecs,taus.product(), cumulativeFlags.at(coll).at(currentDir)); |
918 |
> |
else if(coll == "mets") assignTreeBranch(brSpecs,mets.product(), cumulativeFlags.at(coll).at(currentDir)); |
919 |
> |
else if(coll == "tracks") assignTreeBranch(brSpecs,tracks.product(), cumulativeFlags.at(coll).at(currentDir)); |
920 |
> |
else if(coll == "genjets") assignTreeBranch(brSpecs,genjets.product(), cumulativeFlags.at(coll).at(currentDir)); |
921 |
> |
else if(coll == "mcparticles") assignTreeBranch(brSpecs,mcparticles.product(), cumulativeFlags.at(coll).at(currentDir)); |
922 |
> |
else if(coll == "primaryvertexs") assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).at(currentDir)); |
923 |
> |
else if(coll == "bxlumis") assignTreeBranch(brSpecs,bxlumis.product(), cumulativeFlags.at(coll).at(currentDir)); |
924 |
> |
else if(coll == "photons") assignTreeBranch(brSpecs,photons.product(), cumulativeFlags.at(coll).at(currentDir)); |
925 |
> |
else if(coll == "superclusters") assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).at(currentDir)); |
926 |
> |
else if(coll == "trigobjs") assignTreeBranch(brSpecs,trigobjs.product(), cumulativeFlags.at(coll).at(currentDir)); |
927 |
> |
else if(coll == "stops" |
928 |
> |
&& datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(), cumulativeFlags.at(coll).at(currentDir)); |
929 |
> |
} // end loop over branches |
930 |
> |
|
931 |
> |
for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){ |
932 |
> |
histogram currentHistogram = histograms.at(histogramIndex); |
933 |
> |
|
934 |
> |
if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection: " << currentHistogram.inputCollection << ", will cause a seg fault" << endl; |
935 |
> |
|
936 |
> |
if(currentHistogram.inputVariables.size() == 1){ |
937 |
> |
TH1D* histo; |
938 |
> |
histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name); |
939 |
> |
if (currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor); |
940 |
> |
else if(currentHistogram.inputCollection == "secondary jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor); |
941 |
> |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor); |
942 |
> |
else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor); |
943 |
> |
else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor); |
944 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
945 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \ |
946 |
> |
cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor); |
947 |
> |
else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
948 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \ |
949 |
> |
cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor); |
950 |
> |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor); |
951 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
952 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\ |
953 |
> |
cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor); |
954 |
> |
else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\ |
955 |
> |
cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\ |
956 |
> |
cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor); |
957 |
> |
else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
958 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \ |
959 |
> |
cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor); |
960 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
961 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), |
962 |
> |
cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor); |
963 |
> |
else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \ |
964 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), |
965 |
> |
cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor); |
966 |
> |
else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \ |
967 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), |
968 |
> |
cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor); |
969 |
> |
else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), |
970 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir), |
971 |
> |
cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor); |
972 |
> |
else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), |
973 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir), |
974 |
> |
cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor); |
975 |
> |
else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), |
976 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir), |
977 |
> |
cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor); |
978 |
> |
else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), |
979 |
> |
cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir), |
980 |
> |
cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor); |
981 |
> |
else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(), |
982 |
> |
cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir), |
983 |
> |
cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor); |
984 |
> |
else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(), |
985 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir), |
986 |
> |
cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor); |
987 |
> |
else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(), |
988 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir), |
989 |
> |
cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor); |
990 |
> |
|
991 |
> |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor); |
992 |
> |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor); |
993 |
> |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor); |
994 |
> |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor); |
995 |
> |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor); |
996 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor); |
997 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor); |
998 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor); |
999 |
> |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor); |
1000 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor); |
1001 |
> |
else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor); |
1002 |
> |
else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor); |
1003 |
> |
} |
1004 |
> |
else if(currentHistogram.inputVariables.size() == 2){ |
1005 |
> |
TH2D* histo; |
1006 |
> |
histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name); |
1007 |
> |
if (currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor); |
1008 |
> |
else if(currentHistogram.inputCollection == "secondary jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor); |
1009 |
> |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor); |
1010 |
> |
else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor); |
1011 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
1012 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \ |
1013 |
> |
cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor); |
1014 |
> |
else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
1015 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \ |
1016 |
> |
cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor); |
1017 |
> |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor); |
1018 |
> |
else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor); |
1019 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
1020 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \ |
1021 |
> |
cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor); |
1022 |
> |
else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \ |
1023 |
> |
cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \ |
1024 |
> |
cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor); |
1025 |
> |
else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
1026 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \ |
1027 |
> |
cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor); |
1028 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
1029 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \ |
1030 |
> |
cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor); |
1031 |
> |
else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \ |
1032 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \ |
1033 |
> |
cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor); |
1034 |
> |
else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \ |
1035 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \ |
1036 |
> |
cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor); |
1037 |
> |
else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), |
1038 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir), |
1039 |
> |
cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor); |
1040 |
> |
else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), |
1041 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir), |
1042 |
> |
cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor); |
1043 |
> |
else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), |
1044 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir), |
1045 |
> |
cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor); |
1046 |
> |
else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), |
1047 |
> |
cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir), |
1048 |
> |
cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor); |
1049 |
> |
else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(), |
1050 |
> |
cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir), |
1051 |
> |
cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor); |
1052 |
> |
else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(), |
1053 |
> |
cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir), |
1054 |
> |
cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor); |
1055 |
> |
else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(), |
1056 |
> |
cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir), |
1057 |
> |
cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor); |
1058 |
> |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor); |
1059 |
> |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor); |
1060 |
> |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor); |
1061 |
> |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor); |
1062 |
> |
else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(), |
1063 |
> |
cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir), |
1064 |
> |
cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor); |
1065 |
> |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor); |
1066 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor); |
1067 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor); |
1068 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor); |
1069 |
> |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor); |
1070 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor); |
1071 |
> |
else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor); |
1072 |
> |
else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor); |
1073 |
> |
} |
1074 |
> |
|
1075 |
> |
} |
1076 |
> |
|
1077 |
> |
|
1078 |
> |
//fills histograms with the sizes of collections |
1079 |
> |
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
1080 |
> |
|
1081 |
> |
string currentObject = objectsToPlot.at(currentObjectIndex); |
1082 |
> |
string objectToPlot = ""; |
1083 |
> |
|
1084 |
> |
// Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis(). |
1085 |
> |
if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs"; |
1086 |
> |
else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs"; |
1087 |
> |
else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs"; |
1088 |
> |
else if(currentObject == "electron-jet pairs") objectToPlot = "electronJetPairs"; |
1089 |
> |
else if(currentObject == "muon-jet pairs") objectToPlot = "muonJetPairs"; |
1090 |
> |
else if(currentObject == "jet-jet pairs") objectToPlot = "dijetPairs"; |
1091 |
> |
else if(currentObject == "secondary jets") objectToPlot = "secondaryJets"; |
1092 |
> |
else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs"; |
1093 |
> |
else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs"; |
1094 |
> |
else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs"; |
1095 |
> |
else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs"; |
1096 |
> |
else if(currentObject == "tau-track pairs") objectToPlot = "tauTrackPairs"; |
1097 |
> |
else if(currentObject == "track-event pairs") objectToPlot = "trackEventPairs"; |
1098 |
> |
else if(currentObject == "muon-secondary muon pairs") objectToPlot = "muonSecondaryMuonPairs"; |
1099 |
> |
else if(currentObject == "secondary muons") objectToPlot = "secondaryMuons"; |
1100 |
> |
else if(currentObject == "electron-secondary electron pairs") objectToPlot = "electronSecondaryElectronPairs"; |
1101 |
> |
else if(currentObject == "secondary electrons") objectToPlot = "secondaryElectrons"; |
1102 |
> |
else if(currentObject == "electron-trigobj pairs") objectToPlot = "electronTrigobjPairs"; |
1103 |
> |
else if(currentObject == "muon-trigobj pairs") objectToPlot = "muonTrigobjPairs"; |
1104 |
> |
else objectToPlot = currentObject; |
1105 |
> |
|
1106 |
> |
string tempCurrentObject = objectToPlot; |
1107 |
> |
tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0)); |
1108 |
> |
string histoName = "num" + tempCurrentObject; |
1109 |
> |
|
1110 |
> |
//set position of primary vertex in event, in order to calculate quantities relative to it |
1111 |
> |
if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) { |
1112 |
> |
vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir); |
1113 |
> |
int numToPlot = 0; |
1114 |
> |
for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){ |
1115 |
> |
if(lastCutFlags.at(currentFlag)) numToPlot++; |
1116 |
> |
} |
1117 |
> |
if(objectToPlot == "primaryvertexs"){ |
1118 |
> |
oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
1119 |
> |
oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
1120 |
> |
} |
1121 |
> |
else { |
1122 |
> |
oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor); |
1123 |
> |
} |
1124 |
> |
} |
1125 |
> |
} // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++) |
1126 |
> |
|
1127 |
> |
if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR: Undefined BNTree. Will likely seg fault." << endl; } |
1128 |
> |
BNTrees_.at(currentChannelIndex)->Fill(); // only fill if event has passed cuts |
1129 |
> |
|
1130 |
> |
} // end if(eventPassedPreviousCuts.at(currentDir)){ |
1131 |
> |
} // end loop over cuts |
1132 |
> |
|
1133 |
> |
} // end loop over channel |
1134 |
|
|
995 |
– |
} //end loop over channel |
1135 |
|
|
1136 |
|
masterCutFlow_->fillCutFlow(masterScaleFactor); |
1137 |
|
|
1138 |
+ |
|
1139 |
|
} // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup) |
1140 |
|
|
1141 |
|
|
1171 |
|
} |
1172 |
|
|
1173 |
|
bool |
1174 |
< |
OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){ |
1174 |
> |
OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){ |
1175 |
|
|
1176 |
+ |
//initialize to false until a chosen trigger is passed |
1177 |
|
bool triggerDecision = false; |
1178 |
|
|
1179 |
< |
for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++) |
1180 |
< |
{ |
1181 |
< |
if(trigger->pass != 1) continue; |
1182 |
< |
for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++) |
1183 |
< |
{ |
1184 |
< |
if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){ |
1185 |
< |
triggerDecision = true; |
1186 |
< |
} |
1187 |
< |
} |
1179 |
> |
if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl; |
1180 |
> |
//loop over all triggers defined in the event |
1181 |
> |
for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){ |
1182 |
> |
|
1183 |
> |
if (printAllTriggers_) cout << " " << trigger->name << endl; |
1184 |
> |
|
1185 |
> |
//we're only interested in triggers that actually passed |
1186 |
> |
if(trigger->pass != 1) continue; |
1187 |
> |
|
1188 |
> |
//if the event passes one of the veto triggers, exit and return false |
1189 |
> |
for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){ |
1190 |
> |
if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false; |
1191 |
|
} |
1192 |
< |
return triggerDecision; |
1192 |
> |
//if the event passes one of the chosen triggers, set triggerDecision to true |
1193 |
> |
for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){ |
1194 |
> |
if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true; |
1195 |
> |
} |
1196 |
> |
} |
1197 |
> |
|
1198 |
> |
printAllTriggers_ = false; // only print triggers once, not every event |
1199 |
|
|
1200 |
+ |
//if none of the veto triggers fired: |
1201 |
+ |
//return the OR of all the chosen triggers |
1202 |
+ |
if (triggersToTest.size() != 0) return triggerDecision; |
1203 |
+ |
//or if no triggers were defined return true |
1204 |
+ |
else return true; |
1205 |
|
} |
1206 |
|
|
1207 |
+ |
|
1208 |
|
vector<string> |
1209 |
|
OSUAnalysis::splitString (string inputString){ |
1210 |
|
|
1538 |
|
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
1539 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1540 |
|
else if(variable == "metMT") { |
1541 |
< |
const BNmet *met = chosenMET (); |
1386 |
< |
if (met) |
1541 |
> |
if (const BNmet *met = chosenMET ()) |
1542 |
|
{ |
1543 |
< |
TLorentzVector p1 (object->px, object->py, object->pz, object->energy), |
1544 |
< |
p2 (met->px, met->py, 0.0, met->pt); |
1390 |
< |
|
1391 |
< |
value = (p1 + p2).Mt (); |
1543 |
> |
double dPhi = deltaPhi (object->phi, met->phi); |
1544 |
> |
value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi))); |
1545 |
|
} |
1546 |
|
else |
1547 |
|
value = -999; |
1659 |
|
value = object->isGlobalMuon > 0 \ |
1660 |
|
&& object->isPFMuon > 0 \ |
1661 |
|
&& object->normalizedChi2 < 10 \ |
1662 |
< |
&& object->numberOfValidMuonHits > 0 \ |
1662 |
> |
&& object->numberOfValidMuonHits > 0 \ |
1663 |
|
&& object->numberOfMatchedStations > 1 \ |
1664 |
|
&& fabs(object->correctedD0Vertex) < 0.2 \ |
1665 |
|
&& fabs(object->correctedDZ) < 0.5 \ |
1668 |
|
} |
1669 |
|
else if(variable == "tightIDdisplaced"){ |
1670 |
|
value = object->isGlobalMuon > 0 \ |
1671 |
+ |
&& object->isPFMuon > 0 \ |
1672 |
|
&& object->normalizedChi2 < 10 \ |
1673 |
< |
&& object->numberOfValidMuonHits > 0 \ |
1673 |
> |
&& object->numberOfValidMuonHits > 0 \ |
1674 |
|
&& object->numberOfMatchedStations > 1 \ |
1675 |
|
&& object->numberOfValidPixelHits > 0 \ |
1676 |
|
&& object->numberOfLayersWithMeasurement > 5; |
1696 |
|
} |
1697 |
|
else if(variable == "genMatchedMotherIdReverse"){ |
1698 |
|
int index = getGenMatchedParticleIndex(object); |
1699 |
< |
if(index == -1) value = 23; |
1700 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId); |
1699 |
> |
if(index == -1) value = 24; |
1700 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId); |
1701 |
|
} |
1702 |
|
else if(variable == "genMatchedGrandmotherId"){ |
1703 |
|
int index = getGenMatchedParticleIndex(object); |
1711 |
|
} |
1712 |
|
else if(variable == "genMatchedGrandmotherIdReverse"){ |
1713 |
|
int index = getGenMatchedParticleIndex(object); |
1714 |
< |
if(index == -1) value = 23; |
1714 |
> |
if(index == -1) value = 24; |
1715 |
|
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1716 |
|
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1717 |
< |
if(motherIndex == -1) value = 23; |
1718 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1717 |
> |
if(motherIndex == -1) value = 24; |
1718 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1719 |
|
} |
1720 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1720 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1721 |
> |
} |
1722 |
> |
else if(variable == "pfMuonsFromVertex"){ |
1723 |
> |
double d0Error, dzError; |
1724 |
> |
|
1725 |
> |
d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1726 |
> |
dzError = hypot (object->tkDZerr, chosenVertex ()->zError); |
1727 |
> |
value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5 |
1728 |
> |
|| fabs (object->correctedD0Vertex / d0Error) > 99.0 |
1729 |
> |
|| fabs (object->correctedDZ / dzError) > 99.0; |
1730 |
> |
value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value; |
1731 |
|
} |
1732 |
|
|
1733 |
|
|
1907 |
|
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1908 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1909 |
|
else if(variable == "metMT") { |
1910 |
< |
const BNmet *met = chosenMET (); |
1747 |
< |
if (met) |
1910 |
> |
if (const BNmet *met = chosenMET ()) |
1911 |
|
{ |
1912 |
< |
TLorentzVector p1 (object->px, object->py, object->pz, object->energy), |
1913 |
< |
p2 (met->px, met->py, 0.0, met->pt); |
1751 |
< |
|
1752 |
< |
value = (p1 + p2).Mt (); |
1912 |
> |
double dPhi = deltaPhi (object->phi, met->phi); |
1913 |
> |
value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi))); |
1914 |
|
} |
1915 |
|
else |
1916 |
|
value = -999; |
2096 |
|
} |
2097 |
|
else if(variable == "genMatchedMotherIdReverse"){ |
2098 |
|
int index = getGenMatchedParticleIndex(object); |
2099 |
< |
if(index == -1) value = 23; |
2100 |
< |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2099 |
> |
if(index == -1) value = 24; |
2100 |
> |
else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2101 |
|
} |
2102 |
|
else if(variable == "genMatchedGrandmotherId"){ |
2103 |
|
int index = getGenMatchedParticleIndex(object); |
2111 |
|
} |
2112 |
|
else if(variable == "genMatchedGrandmotherIdReverse"){ |
2113 |
|
int index = getGenMatchedParticleIndex(object); |
2114 |
< |
if(index == -1) value = 23; |
2114 |
> |
if(index == -1) value = 24; |
2115 |
|
else if(fabs(mcparticles->at(index).motherId) == 15){ |
2116 |
|
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
2117 |
< |
if(motherIndex == -1) value = 23; |
2118 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2117 |
> |
if(motherIndex == -1) value = 24; |
2118 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2119 |
|
} |
2120 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2120 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2121 |
> |
} |
2122 |
> |
else if(variable == "pfElectronsFromVertex"){ |
2123 |
> |
double d0Error, dzError; |
2124 |
> |
|
2125 |
> |
d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
2126 |
> |
dzError = hypot (object->tkDZerr, chosenVertex ()->zError); |
2127 |
> |
value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5 |
2128 |
> |
|| fabs (object->correctedD0Vertex / d0Error) > 99.0 |
2129 |
> |
|| fabs (object->correctedDZ / dzError) > 99.0; |
2130 |
> |
value = !value; |
2131 |
|
} |
2132 |
|
|
2133 |
|
|
2210 |
|
else if(variable == "id2") value = object->id2; |
2211 |
|
else if(variable == "evt") value = object->evt; |
2212 |
|
else if(variable == "puScaleFactor"){ |
2213 |
< |
if(datasetType_ != "data") |
2213 |
> |
if(doPileupReweighting_ && datasetType_ != "data") |
2214 |
|
value = puWeight_->at (events->at (0).numTruePV); |
2215 |
|
else |
2216 |
|
value = 1.0; |
2217 |
|
} |
2218 |
< |
else if(variable == "muonScaleFactor"){ |
2219 |
< |
if(datasetType_ != "data" && applyLeptonSF_) |
2220 |
< |
value = muonSFWeight_->at (chosenMuon ()->eta); |
2221 |
< |
else |
2051 |
< |
value = 1.0; |
2052 |
< |
} |
2053 |
< |
else if(variable == "electronScaleFactor"){ |
2054 |
< |
if(datasetType_ != "data" && applyLeptonSF_) |
2055 |
< |
value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt); |
2056 |
< |
else |
2057 |
< |
value = 1.0; |
2058 |
< |
} |
2059 |
< |
else if(variable == "stopCTauScaleFactor") |
2060 |
< |
value = stopCTauScaleFactor_; |
2061 |
< |
|
2218 |
> |
else if(variable == "muonScaleFactor") value = muonScaleFactor_; |
2219 |
> |
else if(variable == "electronScaleFactor") value = electronScaleFactor_; |
2220 |
> |
else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_; |
2221 |
> |
else if(variable == "bTagScaleFactor") value = bTagScaleFactor_; |
2222 |
|
else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2223 |
|
|
2224 |
|
value = applyFunction(function, value); |
2294 |
|
} |
2295 |
|
else if(variable == "genMatchedMotherIdReverse"){ |
2296 |
|
int index = getGenMatchedParticleIndex(object); |
2297 |
< |
if(index == -1) value = 23; |
2298 |
< |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2297 |
> |
if(index == -1) value = 24; |
2298 |
> |
else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2299 |
|
} |
2300 |
|
else if(variable == "genMatchedGrandmotherId"){ |
2301 |
|
int index = getGenMatchedParticleIndex(object); |
2309 |
|
} |
2310 |
|
else if(variable == "genMatchedGrandmotherIdReverse"){ |
2311 |
|
int index = getGenMatchedParticleIndex(object); |
2312 |
< |
if(index == -1) value = 23; |
2312 |
> |
if(index == -1) value = 24; |
2313 |
|
else if(fabs(mcparticles->at(index).motherId) == 15){ |
2314 |
|
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
2315 |
< |
if(motherIndex == -1) value = 23; |
2316 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2315 |
> |
if(motherIndex == -1) value = 24; |
2316 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2317 |
|
} |
2318 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2318 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2319 |
|
} |
2320 |
|
|
2321 |
|
|
2491 |
|
} |
2492 |
|
else if(variable == "genMatchedMotherIdReverse"){ |
2493 |
|
int index = getGenMatchedParticleIndex(object); |
2494 |
< |
if(index == -1) value = 23; |
2495 |
< |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2494 |
> |
if(index == -1) value = 24; |
2495 |
> |
else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2496 |
|
} |
2497 |
|
else if(variable == "genMatchedGrandmotherId"){ |
2498 |
|
int index = getGenMatchedParticleIndex(object); |
2506 |
|
} |
2507 |
|
else if(variable == "genMatchedGrandmotherIdReverse"){ |
2508 |
|
int index = getGenMatchedParticleIndex(object); |
2509 |
< |
if(index == -1) value = 23; |
2509 |
> |
if(index == -1) value = 24; |
2510 |
|
else if(fabs(mcparticles->at(index).motherId) == 15){ |
2511 |
|
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
2512 |
< |
if(motherIndex == -1) value = 23; |
2513 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2512 |
> |
if(motherIndex == -1) value = 24; |
2513 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2514 |
|
} |
2515 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2515 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2516 |
|
} |
2517 |
|
|
2518 |
|
|
2834 |
|
} |
2835 |
|
else if(variable == "genMatchedMotherIdReverse"){ |
2836 |
|
int index = getGenMatchedParticleIndex(object); |
2837 |
< |
if(index == -1) value = 23; |
2838 |
< |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2837 |
> |
if(index == -1) value = 24; |
2838 |
> |
else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2839 |
|
} |
2840 |
|
else if(variable == "genMatchedGrandmotherId"){ |
2841 |
|
int index = getGenMatchedParticleIndex(object); |
2849 |
|
} |
2850 |
|
else if(variable == "genMatchedGrandmotherIdReverse"){ |
2851 |
|
int index = getGenMatchedParticleIndex(object); |
2852 |
< |
if(index == -1) value = 23; |
2852 |
> |
if(index == -1) value = 24; |
2853 |
|
else if(fabs(mcparticles->at(index).motherId) == 15){ |
2854 |
|
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
2855 |
< |
if(motherIndex == -1) value = 23; |
2856 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2855 |
> |
if(motherIndex == -1) value = 24; |
2856 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2857 |
|
} |
2858 |
< |
else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2858 |
> |
else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2859 |
|
} |
2860 |
|
|
2861 |
|
|
3123 |
|
|
3124 |
|
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
3125 |
|
else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta); |
3126 |
+ |
else if(variable == "jetEta") value = object2->eta; |
3127 |
+ |
else if(variable == "jetPhi") value = object2->phi; |
3128 |
+ |
else if(variable == "electronEta") value = object1->eta; |
3129 |
+ |
else if(variable == "electronPhi") value = object1->phi; |
3130 |
|
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
3131 |
|
else if(variable == "invMass"){ |
3132 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
3161 |
|
double value = 0.0; |
3162 |
|
|
3163 |
|
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
3164 |
+ |
else if(variable == "jetEta") value = object2->eta; |
3165 |
+ |
else if(variable == "jetPhi") value = object2->phi; |
3166 |
+ |
else if(variable == "muonEta") value = object1->eta; |
3167 |
+ |
else if(variable == "muonPhi") value = object1->phi; |
3168 |
|
else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta); |
3169 |
|
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
3170 |
|
else if(variable == "invMass"){ |
3201 |
|
|
3202 |
|
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
3203 |
|
else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta); |
3204 |
+ |
else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt); |
3205 |
|
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
3206 |
|
else if(variable == "invMass"){ |
3207 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
3237 |
|
TLorentzVector fourVector2(0, 0, 0, 0); |
3238 |
|
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
3239 |
|
else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta); |
3240 |
< |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
3241 |
< |
else if(variable == "invMass"){ |
3242 |
< |
fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass); |
3243 |
< |
fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass ); |
3244 |
< |
|
3245 |
< |
value = (fourVector1 + fourVector2).M(); |
3240 |
> |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
3241 |
> |
else if(variable == "invMass"){ |
3242 |
> |
fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass); |
3243 |
> |
fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass ); |
3244 |
> |
|
3245 |
> |
value = (fourVector1 + fourVector2).M(); |
3246 |
|
} |
3247 |
|
else if(variable == "chargeProduct"){ |
3248 |
|
value = object1->charge*object2->charge; |
3249 |
|
} |
3250 |
< |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
3251 |
< |
value = applyFunction(function, value); |
3252 |
< |
return value; |
3250 |
> |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
3251 |
> |
value = applyFunction(function, value); |
3252 |
> |
return value; |
3253 |
|
|
3254 |
|
} |
3255 |
|
|
3369 |
|
double value = 0.0; |
3370 |
|
|
3371 |
|
if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
3372 |
+ |
else if (variable == "match"){ |
3373 |
+ |
if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11) |
3374 |
+ |
stringValue = object2->filter; |
3375 |
+ |
else |
3376 |
+ |
stringValue = "none"; |
3377 |
+ |
} |
3378 |
|
|
3379 |
|
else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; } |
3380 |
|
|
3495 |
|
for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){ |
3496 |
|
vertex_rank++; |
3497 |
|
int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \ |
3498 |
< |
(object->vy-vertex->y)*(object->vy-vertex->y) + \ |
3499 |
< |
(object->vz-vertex->z)*(object->vz-vertex->z)); |
3498 |
> |
(object->vy-vertex->y)*(object->vy-vertex->y) + \ |
3499 |
> |
(object->vz-vertex->z)*(object->vz-vertex->z)); |
3500 |
|
|
3501 |
|
if(abs(dist) < abs(minDistToVertex)){ |
3502 |
|
value = vertex_rank; |
3660 |
|
string obj1, obj2; |
3661 |
|
getTwoObjs(currentCut.inputCollection, obj1, obj2); |
3662 |
|
if (inputType==obj1 || |
3663 |
< |
inputType==obj2) { |
3663 |
> |
inputType==obj2) { |
3664 |
|
// Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection, |
3665 |
|
// and the inputType is a member of the pair. |
3666 |
|
// The cut will instead be applied when the setObjectFlags() is called for the paired collection. |
3820 |
|
} |
3821 |
|
|
3822 |
|
|
3823 |
+ |
|
3824 |
+ |
template <class InputCollection> |
3825 |
+ |
void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, vector<bool> flags){ |
3826 |
+ |
// This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree |
3827 |
+ |
|
3828 |
+ |
if (BNTreeBranchVals_.count(parameters.name)==0) cout << "Error[assignTreeBranch]: trying to assign value to " << parameters.name << " that does not have a branch set up. Will likely seg fault." << endl; |
3829 |
+ |
for (uint object = 0; object != inputCollection->size(); object++) { |
3830 |
+ |
|
3831 |
+ |
if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue; |
3832 |
+ |
|
3833 |
+ |
string inputVariable = parameters.inputVariable; |
3834 |
+ |
string function = ""; |
3835 |
+ |
string stringValue = ""; |
3836 |
+ |
double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue); |
3837 |
+ |
BNTreeBranchVals_.at(parameters.name).push_back(value); |
3838 |
+ |
|
3839 |
+ |
} |
3840 |
+ |
} |
3841 |
+ |
|
3842 |
+ |
|
3843 |
|
template <class InputCollection> |
3844 |
|
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){ |
3845 |
|
|
3857 |
|
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
3858 |
|
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
3859 |
|
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
3860 |
< |
} |
3860 |
> |
} |
3861 |
|
|
3862 |
< |
string stringValue = ""; |
3863 |
< |
double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue); |
3864 |
< |
histo->Fill(value,scaleFactor); |
3862 |
> |
string stringValue = ""; |
3863 |
> |
double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue); |
3864 |
> |
histo->Fill(value,scaleFactor); |
3865 |
|
|
3866 |
|
if (printEventInfo_) { |
3867 |
|
// Write information about event to screen, for testing purposes. |
4091 |
|
// 20 strange baryon |
4092 |
|
// 21 charm baryon |
4093 |
|
// 22 bottom baryon |
4094 |
< |
// 23 other |
4094 |
> |
// 23 QCD string |
4095 |
> |
// 24 other |
4096 |
|
|
4097 |
|
int OSUAnalysis::getPdgIdBinValue(int pdgId){ |
4098 |
|
|
4116 |
|
else if(absPdgId > 3000 && absPdgId < 4000 ) binValue = 20; |
4117 |
|
else if(absPdgId > 4000 && absPdgId < 5000 ) binValue = 21; |
4118 |
|
else if(absPdgId > 5000 && absPdgId < 6000 ) binValue = 22; |
4119 |
+ |
else if(absPdgId == 92 ) binValue = 23; |
4120 |
|
|
4121 |
< |
else binValue = 23; |
4121 |
> |
else binValue = 24; |
4122 |
|
|
4123 |
|
return binValue; |
4124 |
|
|
4128 |
|
OSUAnalysis::chosenVertex () |
4129 |
|
{ |
4130 |
|
const BNprimaryvertex *chosenVertex = 0; |
4131 |
< |
if(find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) { |
4131 |
> |
if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){ |
4132 |
|
vector<bool> vertexFlags; |
4133 |
|
for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){ |
4134 |
|
if (cumulativeFlags.at("primaryvertexs").at(i).size()){ |
4142 |
|
break; |
4143 |
|
} |
4144 |
|
} |
4145 |
< |
else { |
4146 |
< |
chosenVertex = &primaryvertexs->at(0); |
3950 |
< |
} |
4145 |
> |
else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ()) |
4146 |
> |
chosenVertex = & primaryvertexs->at (0); |
4147 |
|
|
4148 |
|
return chosenVertex; |
4149 |
|
} |
4152 |
|
OSUAnalysis::chosenMET () |
4153 |
|
{ |
4154 |
|
const BNmet *chosenMET = 0; |
4155 |
< |
if(find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) { |
4155 |
> |
if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){ |
4156 |
|
vector<bool> metFlags; |
4157 |
|
for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){ |
4158 |
|
if (cumulativeFlags.at("mets").at(i).size()){ |
4166 |
|
break; |
4167 |
|
} |
4168 |
|
} |
4169 |
< |
else { |
4170 |
< |
chosenMET = &mets->at(0); |
3975 |
< |
} |
4169 |
> |
else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ()) |
4170 |
> |
chosenMET = & mets->at (0); |
4171 |
|
|
4172 |
|
return chosenMET; |
4173 |
|
} |
4176 |
|
OSUAnalysis::chosenElectron () |
4177 |
|
{ |
4178 |
|
const BNelectron *chosenElectron = 0; |
4179 |
< |
if(find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) { |
4179 |
> |
if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){ |
4180 |
|
vector<bool> electronFlags; |
4181 |
|
for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){ |
4182 |
|
if (cumulativeFlags.at("electrons").at(i).size()){ |
4190 |
|
break; |
4191 |
|
} |
4192 |
|
} |
4193 |
< |
else { |
4194 |
< |
chosenElectron = &electrons->at(0); |
4000 |
< |
} |
4193 |
> |
else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ()) |
4194 |
> |
chosenElectron = & electrons->at (0); |
4195 |
|
|
4196 |
|
return chosenElectron; |
4197 |
|
} |
4200 |
|
OSUAnalysis::chosenMuon () |
4201 |
|
{ |
4202 |
|
const BNmuon *chosenMuon = 0; |
4203 |
< |
if(find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) { |
4203 |
> |
if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){ |
4204 |
|
vector<bool> muonFlags; |
4205 |
|
for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){ |
4206 |
|
if (cumulativeFlags.at("muons").at(i).size()){ |
4214 |
|
break; |
4215 |
|
} |
4216 |
|
} |
4217 |
< |
else { |
4218 |
< |
chosenMuon = &muons->at(0); |
4025 |
< |
} |
4217 |
> |
else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ()) |
4218 |
> |
chosenMuon = & muons->at (0); |
4219 |
|
|
4220 |
|
return chosenMuon; |
4221 |
|
} |