ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc (file contents):
Revision 1.60 by jbrinson, Thu May 9 10:28:52 2013 UTC vs.
Revision 1.88 by jbrinson, Mon Jun 24 15:52:58 2013 UTC

# Line 28 | Line 28 | OSUAnalysis::OSUAnalysis (const edm::Par
28    datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
32 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
33    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
34    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
35    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
36 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
38 >  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
39 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
40 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
41    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
42 <  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
43 <
44 < {
42 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
43 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
44 > {
45  
46    TH1::SetDefaultSumw2 ();
47  
# Line 46 | Line 52 | OSUAnalysis::OSUAnalysis (const edm::Par
52        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
53        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
54      }
55 +    if (applyBtagSF_){
56 +      bTagSFWeight_ = new BtagSFWeight;
57 +    }
58    }
59    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
60      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 54 | Line 63 | OSUAnalysis::OSUAnalysis (const edm::Par
63    // Construct Cutflow Objects. These store the results of cut decisions and
64    // handle filling cut flow histograms.
65    masterCutFlow_ = new CutFlow (fs_);
57  vector<TFileDirectory> directories;
66  
67    //always get vertex collection so we can assign the primary vertex in the event
68    objectsToGet.push_back("primaryvertexs");
61
62  //always make the plot of number of primary vertices (to check pile-up reweighting)
69    objectsToPlot.push_back("primaryvertexs");
70 +  objectsToCut.push_back("primaryvertexs");
71 +
72  
73    //always get the MC particles to do GEN-matching
74    objectsToGet.push_back("mcparticles");
# Line 68 | Line 76 | OSUAnalysis::OSUAnalysis (const edm::Par
76    //always get the event collection to do pile-up reweighting
77    objectsToGet.push_back("events");
78  
79 +
80 +  // Parse the tree variable definitions.
81 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
82 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
83 +    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; }
84 +    objectsToGet.push_back(tempInputCollection);
85 +    objectsToCut.push_back(tempInputCollection);
86 +
87 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
88 +
89 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
90 +      BranchSpecs br;
91 +      br.inputCollection = tempInputCollection;
92 +      br.inputVariable = branchList.at(iBranch);
93 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
94 +      br.name = string(newName.Data());
95 +      treeBranches_.push_back(br);
96 +    }
97 +
98 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
99 +
100 +
101    //parse the histogram definitions
102    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
103  
104      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
105      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
106 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
107 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
108      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
109 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
110      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
111      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
112      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
113 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
114 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
115 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
116 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
117      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
118      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
119      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 91 | Line 128 | OSUAnalysis::OSUAnalysis (const edm::Par
128        }
129        objectsToPlot.push_back(tempInputCollection);
130        objectsToCut.push_back(tempInputCollection);
131 <    }
95 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
131 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
132        string obj1;
133        string obj2;
134        getTwoObjs(tempInputCollection, obj1, obj2);
# Line 106 | Line 142 | OSUAnalysis::OSUAnalysis (const edm::Par
142        objectsToGet.push_back(tempInputCollection);
143        objectsToGet.push_back(obj1);
144        objectsToGet.push_back(obj2ToGet);
145 +    } // end else
146 +
147  
110    }
148  
149      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
150  
# Line 128 | Line 165 | OSUAnalysis::OSUAnalysis (const edm::Par
165        histograms.push_back(tempHistogram);
166  
167      }
168 <  }
168 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
169 >
170    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
171    sort( objectsToPlot.begin(), objectsToPlot.end() );
172    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 171 | Line 209 | OSUAnalysis::OSUAnalysis (const edm::Par
209      tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
210  
211  
212 <    int maxNum = 24;
212 >    int maxNum = 25;
213      vector<double> binVector;
214      binVector.push_back(maxNum);
215      binVector.push_back(0);
# Line 213 | Line 251 | OSUAnalysis::OSUAnalysis (const edm::Par
251      //set triggers for this channel
252      vector<string> triggerNames;
253      triggerNames.clear();
254 +    vector<string> triggerToVetoNames;
255 +    triggerToVetoNames.clear();
256 +
257      tempChannel.triggers.clear();
258 +    tempChannel.triggersToVeto.clear();
259      if(channels_.at(currentChannel).exists("triggers")){
260        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
261        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
262          tempChannel.triggers.push_back(triggerNames.at(trigger));
263        objectsToGet.push_back("triggers");
264      }
265 <
265 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
266 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
267 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
268 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
269 >      objectsToGet.push_back("triggers");
270 >    }
271  
272  
273  
274      //create cutFlow for this channel
275      cutFlows_.push_back (new CutFlow (fs_, channelName));
276 <
277 <    //book a directory in the output file with the name of the channel
278 <    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 <
276 >    vector<TFileDirectory> directories; //vector of directories in the output file.
277 >    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
278 >    vector<string> subSubDirNames;//subdirectories in each channel.
279      //get list of cuts for this channel
280      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
281  
282 +
283      //loop over and parse all cuts
284      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
285        cut tempCut;
286        //store input collection for cut
287        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
288        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
289 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
290 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
291        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
292        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
293 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
294        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
295        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
296 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
297 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
298 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
299 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
300        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
301        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
302        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 474 | Line 366 | OSUAnalysis::OSUAnalysis (const edm::Par
366        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
367        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
368  
369 <
369 >      //Set up vectors to store the directories and subDirectories for each channel.
370 >      string subSubDirName;
371        string tempCutName;
372        if(cuts_.at(currentCut).exists("alias")){
373          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
374 +        subSubDirName = "After " + tempCutName + " Cut Applied";
375        }
376        else{
377          //construct string for cutflow table
# Line 485 | Line 379 | OSUAnalysis::OSUAnalysis (const edm::Par
379          string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
380          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
381          tempCutName = cutName;
382 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
383 +      }
384 +
385 +      tempCut.isVeto = false;
386 +      if(cuts_.at(currentCut).exists("isVeto")){
387 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
388 +        if (isVeto == true) tempCut.isVeto = true;
389        }
390 +      subSubDirNames.push_back(subSubDirName);
391        tempCut.name = tempCutName;
392  
393        tempChannel.cuts.push_back(tempCut);
# Line 493 | Line 395 | OSUAnalysis::OSUAnalysis (const edm::Par
395  
396      }//end loop over cuts
397  
398 +    vector<map<string, TH1D*>> oneDHistsTmp;
399 +    vector<map<string, TH2D*>> twoDHistsTmp;
400 +    //book a directory in the output file with the name of the channel
401 +    TFileDirectory subDir = fs_->mkdir( channelName );
402 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
403 +    if(GetPlotsAfterEachCut_){
404 +      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
405 +        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
406 +        directories.push_back(subSubDir);
407 +        map<string, TH1D*> oneDhistoMap;
408 +        oneDHistsTmp.push_back(oneDhistoMap);
409 +        map<string, TH2D*> twoDhistoMap;
410 +        twoDHistsTmp.push_back(twoDhistoMap);
411 +      }
412 +      treeDirectories.push_back(subDir);
413 +      oneDHists_.push_back(oneDHistsTmp);
414 +      twoDHists_.push_back(twoDHistsTmp);
415 +    }
416 +    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
417 +    else{
418 +      map<string, TH1D*> oneDhistoMap;
419 +      oneDHistsTmp.push_back(oneDhistoMap);
420 +      map<string, TH2D*> twoDhistoMap;
421 +      twoDHistsTmp.push_back(twoDhistoMap);
422 +      oneDHists_.push_back(oneDHistsTmp);
423 +      twoDHists_.push_back(twoDHistsTmp);
424 +      directories.push_back(subDir);
425 +      treeDirectories.push_back(subDir);
426 +
427 +    }
428 +
429 +    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
430 +      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
431 +      BNTrees_.push_back(newTree);
432 +      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
433 +        BranchSpecs currentVar = treeBranches_.at(iBranch);
434 +        vector<float> newVec;
435 +        BNTreeBranchVals_[currentVar.name] = newVec;
436 +        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
437 +      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
438 +    }
439 +
440 +    //book all histograms included in the configuration
441 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
442 +
443 +      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
444 +
445 +        histogram currentHistogram = histograms.at(currentHistogramIndex);
446 +        int numBinsElements = currentHistogram.bins.size();
447 +        int numInputVariables = currentHistogram.inputVariables.size();
448 +        int numBinEdgesX = currentHistogram.variableBinsX.size();
449 +        int numBinEdgesY = currentHistogram.variableBinsY.size();
450 +
451 +        if(numBinsElements == 1){
452 +          if(numBinEdgesX > 1){
453 +            if(numBinEdgesY > 1)
454 +              numBinsElements = 6;
455 +            else
456 +              numBinsElements = 3;
457 +          }
458 +        }
459 +        if(numBinsElements != 3 && numBinsElements !=6){
460 +          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
461 +          exit(0);
462 +        }
463 +        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
464 +          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
465 +          exit(0);
466 +        }
467 +        else if(numBinsElements == 3){
468 +          if (currentHistogram.bins.size () == 3)
469 +            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));
470 +          else
471 +            {
472 +              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
473 +            }
474 +        }
475 +        else if(numBinsElements == 6){
476 +          if (currentHistogram.bins.size () == 6)
477 +            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));
478 +          else
479 +            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 ());
480 +        }
481 +
482 +
483 +        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
484 +
485 +        // bin      particle type
486 +        // ---      -------------
487 +        //  0        unmatched
488 +        //  1        u
489 +        //  2        d
490 +        //  3        s
491 +        //  4        c
492 +        //  5        b
493 +        //  6        t
494 +        //  7        e
495 +        //  8        mu
496 +        //  9        tau
497 +        // 10        nu
498 +        // 11        g
499 +        // 12        gamma
500 +        // 13        Z
501 +        // 14        W
502 +        // 15        light meson
503 +        // 16        K meson
504 +        // 17        D meson
505 +        // 18        B meson
506 +        // 19        light baryon
507 +        // 20        strange baryon
508 +        // 21        charm baryon
509 +        // 22        bottom baryon
510 +        // 23        QCD string
511 +        // 24        other
512 +
513 +        vector<TString> labelArray;
514 +        labelArray.push_back("unmatched");
515 +        labelArray.push_back("u");
516 +        labelArray.push_back("d");
517 +        labelArray.push_back("s");
518 +        labelArray.push_back("c");
519 +        labelArray.push_back("b");
520 +        labelArray.push_back("t");
521 +        labelArray.push_back("e");
522 +        labelArray.push_back("#mu");
523 +        labelArray.push_back("#tau");
524 +        labelArray.push_back("#nu");
525 +        labelArray.push_back("g");
526 +        labelArray.push_back("#gamma");
527 +        labelArray.push_back("Z");
528 +        labelArray.push_back("W");
529 +        labelArray.push_back("light meson");
530 +        labelArray.push_back("K meson");
531 +        labelArray.push_back("D meson");
532 +        labelArray.push_back("B meson");
533 +        labelArray.push_back("light baryon");
534 +        labelArray.push_back("strange baryon");
535 +        labelArray.push_back("charm baryon");
536 +        labelArray.push_back("bottom baryon");
537 +        labelArray.push_back("QCD string");
538 +        labelArray.push_back("other");
539 +
540 +        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
541 +          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
542 +            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
543 +          }
544 +          else {
545 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
546 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
547 +          }
548 +        }
549 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
550 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
551 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
552 +        }
553 +
554 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
555 +
556 +
557 +      // Book a histogram for the number of each object type to be plotted.
558 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
559 +      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
560 +        string currentObject = objectsToPlot.at(currentObjectIndex);
561 +        int maxNum = 10;
562 +        if(currentObject == "mcparticles") maxNum = 50;
563 +        else if(currentObject == "primaryvertexs") maxNum = 50;
564 +
565 +        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
566 +        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
567 +        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
568 +        else if(currentObject == "electron-photon pairs")       currentObject = "electronPhotonPairs";
569 +        else if(currentObject == "muon-photon pairs")       currentObject = "muonPhotonPairs";
570 +        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
571 +        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
572 +        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
573 +        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
574 +        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
575 +        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
576 +        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
577 +        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
578 +        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
579 +        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
580 +        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
581 +        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
582 +        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
583 +        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
584 +        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
585 +        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
586 +        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
587 +        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
588 +        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
589 +        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
590 +        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
591 +
592 +        currentObject.at(0) = toupper(currentObject.at(0));
593 +        string histoName = "num" + currentObject;
594 +
595 +        if(histoName == "numPrimaryvertexs"){
596 +          string newHistoName = histoName + "BeforePileupCorrection";
597 +          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);
598 +          newHistoName = histoName + "AfterPileupCorrection";
599 +          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);
600 +        }
601 +        else
602 +          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
603 +      }
604 +    }//end of loop over directories
605      channels.push_back(tempChannel);
606      tempChannel.cuts.clear();
498
607    }//end loop over channels
608  
609  
# Line 506 | Line 614 | OSUAnalysis::OSUAnalysis (const edm::Par
614    sort( objectsToCut.begin(), objectsToCut.end() );
615    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
616  
617 +  produces<map<string, bool> > ("channelDecisions");
618 +
619 + } // end constructor OSUAnalysis::OSUAnalysis()
620  
510 }
621  
622   OSUAnalysis::~OSUAnalysis ()
623   {
624 +
625    // Destroying the CutFlow objects causes the cut flow numbers and time
626    // information to be printed to standard output.
627    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
# Line 519 | Line 630 | OSUAnalysis::~OSUAnalysis ()
630   }
631  
632   void
633 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
633 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
634   {
635 <
635 >  //cout << "**********************\n\n\n";
636    // Retrieve necessary collections from the event.
637  
638    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 585 | Line 696 | OSUAnalysis::analyze (const edm::Event &
696    double masterScaleFactor = 1.0;
697  
698    //get pile-up event weight
699 <  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
699 >  if (doPileupReweighting_ && datasetType_ != "data") {
700 >    //for "data" datasets, the numTruePV is always set to -1
701 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
702 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
703 >  }
704  
705    stopCTauScaleFactor_ = 1.0;
706    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
# Line 594 | Line 709 | OSUAnalysis::analyze (const edm::Event &
709  
710    //loop over all channels
711  
712 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
713    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
714      channel currentChannel = channels.at(currentChannelIndex);
715  
# Line 601 | Line 717 | OSUAnalysis::analyze (const edm::Event &
717      counterMap passingCounter;
718      cumulativeFlags.clear ();
719  
720 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
721 +         iter != BNTreeBranchVals_.end(); iter++) {
722 +      iter->second.clear();  // clear array
723 +    }
724 +
725      bool triggerDecision = true;
726 <    if(currentChannel.triggers.size() != 0){  //triggers specified
727 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
726 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
727 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
728        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
729      }
730  
731      //loop over all cuts
611
732      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
733        cut currentCut = currentChannel.cuts.at(currentCutIndex);
614
734        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
735          string currentObject = objectsToCut.at(currentObjectIndex);
736  
737          //initialize maps to get ready to set cuts
738 <        individualFlags[currentObject].push_back (vector<bool> ());
739 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
738 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
739 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
740  
741        }
742        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
# Line 626 | Line 745 | OSUAnalysis::analyze (const edm::Event &
745          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
746  
747  
748 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
749 <
750 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
632 <
748 >        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
749 >        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
750 >        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
751          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
752          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
753          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 653 | Line 771 | OSUAnalysis::analyze (const edm::Event &
771                                                                     "muon-muon pairs");
772  
773          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
774 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
775 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
776 <                                                                   "muon-secondary muon pairs");
774 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
775 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
776 >                                                                             "muon-secondary muon pairs");
777 >
778 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
779 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
780 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
781 >                                                                             "muon-secondary jet pairs");
782 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
783 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
784 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
785 >                                                                             "photon-secondary jet pairs");
786 >
787 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
788 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
789 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
790 >                                                                             "electron-secondary jet pairs");
791  
792          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
793 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
794 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
795 <                                                                   "electron-secondary electron pairs");
793 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
794 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
795 >                                                                                     "electron-secondary electron pairs");
796  
797          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
798                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 671 | Line 803 | OSUAnalysis::analyze (const edm::Event &
803                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
804                                                                         "electron-muon pairs");
805          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
806 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
807 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
808 <                                                                           "jet-jet pairs");
806 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
807 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
808 >                                                                 "jet-jet pairs");
809 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
810 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
811 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
812 >                                                                 "jet-secondary jet pairs");
813          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
814 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
815 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
816 <                                                                       "electron-jet pairs");
814 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
815 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
816 >                                                                      "electron-jet pairs");
817 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
818 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
819 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
820 >                                                                      "electron-photon pairs");
821 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
822 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
823 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
824 >                                                                      "photon-jet pairs");
825          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
826 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
827 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
828 <                                                                       "muon-jet pairs");
826 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
827 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
828 >                                                                  "muon-jet pairs");
829 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
830 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
831 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
832 >                                                                  "muon-photon pairs");
833          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
834                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
835                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 703 | Line 851 | OSUAnalysis::analyze (const edm::Event &
851                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
852                                                                   "tau-tau pairs");
853          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
854 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
855 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
856 <                                                                 "tau-track pairs");
854 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
855 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
856 >                                                                   "tau-track pairs");
857          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
858                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
859                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 721 | Line 869 | OSUAnalysis::analyze (const edm::Event &
869  
870  
871      }//end loop over all cuts
724
725
872      //use cumulative flags to apply cuts at event level
873  
874 +    //a vector to store cumulative cut descisions after each cut.
875 +    vector<bool> eventPassedPreviousCuts;
876      bool eventPassedAllCuts = true;
729
877      //apply trigger (true if none were specified)
878      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
879  
733
880      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
881  
882        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 738 | Line 884 | OSUAnalysis::analyze (const edm::Event &
884        int numberPassing = 0;
885  
886        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
887 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
887 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
888        }
889        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
890        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
891        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
892 <
892 >      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
893      }
748
894      double scaleFactor = masterScaleFactor;
895  
896 +    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
897      if(applyLeptonSF_ && datasetType_ != "data"){
898 <      if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
899 <      if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
898 >      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
899 >        flagPair muonFlags;
900 >        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
901 >          if (cumulativeFlags.at("muons").at(i).size()){
902 >            muonFlags = cumulativeFlags.at("muons").at(i);
903 >            break;
904 >          }
905 >        }
906 >        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
907 >          if(!muonFlags.at(muonIndex).second) continue;
908 >          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
909 >        }
910 >      }
911 >      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
912 >        flagPair electronFlags;
913 >        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
914 >          if (cumulativeFlags.at("electrons").at(i).size()){
915 >            electronFlags = cumulativeFlags.at("electrons").at(i);
916 >            break;
917 >          }
918 >        }
919 >        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
920 >          if(!electronFlags.at(electronIndex).second) continue;
921 >          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
922 >        }
923 >      }
924      }
925 <
925 >    if(applyBtagSF_ && datasetType_ != "data"){
926 >     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
927 >       flagPair jetFlags;
928 >        vector<double> jetSFs;
929 >        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
930 >          if (cumulativeFlags.at("jets").at(i).size()){
931 >            jetFlags = cumulativeFlags.at("jets").at(i);
932 >            break;
933 >          }
934 >        }
935 >        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
936 >          if(!jetFlags.at(jetIndex).second) continue;
937 >          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
938 >          jetSFs.push_back(jetSFTmp);
939 >        }
940 >        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
941 >      }
942 >    }
943 >    scaleFactor *= muonScaleFactor_;
944 >    scaleFactor *= electronScaleFactor_;
945 >    scaleFactor *= bTagScaleFactor_;
946      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
947  
758    if(!eventPassedAllCuts)continue;
759
948      if (printEventInfo_) {
949        // Write information about event to screen, for testing purposes.
950        cout << "Event passed all cuts in channel " <<  currentChannel.name
# Line 766 | Line 954 | OSUAnalysis::analyze (const edm::Event &
954             << endl;
955      }
956  
769    //filling histograms
770    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
771      histogram currentHistogram = histograms.at(histogramIndex);
957  
958 <      if(currentHistogram.inputVariables.size() == 1){
959 <        TH1D* histo;
960 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
961 <
962 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
963 <        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);
958 >    //filling histograms
959 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
960 >      uint currentDir;
961 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
962 >      else{
963 >        currentDir = currentCut;
964        }
911    }
965  
966  
967 +      if(eventPassedPreviousCuts.at(currentDir)){
968 +
969 +        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
970 +          histogram currentHistogram = histograms.at(histogramIndex);
971 +
972 +          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
973 +
974 +          if(currentHistogram.inputVariables.size() == 1){
975 +            TH1D* histo;
976 +            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
977 +            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
978 +            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
979 +            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
980 +            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
981 +            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
982 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
983 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
984 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
985 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
986 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
987 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
988 +             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
989 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
990 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
991 +             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
992 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
993 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
994 +             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
995 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
996 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
997 +
998 +            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
999 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1000 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1001 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1002 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1003 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1004 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1005 +             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1006 +                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1007 +                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1008 +
1009 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1010 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1011 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1012 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1013 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1014 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1015 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1016 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1017 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1018 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1019 +                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1020 +                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1021 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1022 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1023 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1024 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1025 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1026 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1027 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1028 +                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1029 +                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1030 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1031 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1032 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1033 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1034 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1035 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1036 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1037 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1038 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1039 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1040 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1041 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1042 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1043 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1044 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1045 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1046 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1047 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1048 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1049 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1050 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1051 +
1052 +            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1053 +            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1054 +            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1055 +            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1056 +            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1057 +            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1058 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1059 +            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1060 +            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1061 +            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1062 +            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1063 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1064 +          }
1065 +          else if(currentHistogram.inputVariables.size() == 2){
1066 +            TH2D* histo;
1067 +            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1068 +            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1069 +            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1070 +            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1071 +            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1072 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1073 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1074 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1075 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1076 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1077 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1078 +            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1079 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1080 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1081 +            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1082 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1083 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1084 +            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1085 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1086 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1087 +            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1088 +            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1089 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1090 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1091 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1092 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1093 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1094 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1095 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1096 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1097 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1098 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1099 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1100 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1101 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1102 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1103 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1104 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1105 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1106 +                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1107 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1108 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1109 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1110 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1111 +                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1112 +                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1113 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1114 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1115 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1116 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1117 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1118 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1119 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1120 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1121 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1122 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1123 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1124 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1125 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1126 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1127 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1128 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1129 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1130 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1131 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1132 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1133 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1134 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1135 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1136 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1137 +            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1138 +            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1139 +            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1140 +            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1141 +            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1142 +                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1143 +                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1144 +            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1145 +            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1146 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1147 +            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1148 +            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1149 +            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1150 +            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1151 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1152 +          }
1153 +
1154 +        }
1155  
915    //fills histograms with the sizes of collections
916    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
917
918      string currentObject = objectsToPlot.at(currentObjectIndex);
919
920      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);
990      }
991      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
1156  
1157 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1157 >        //fills histograms with the sizes of collections
1158 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1159  
1160 <  } //end loop over channel
1160 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1161 >          string objectToPlot = "";
1162 >
1163 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1164 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1165 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1166 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1167 >          else if(currentObject == "electron-photon pairs")                objectToPlot = "electronPhotonPairs";
1168 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1169 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1170 >          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1171 >          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1172 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1173 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1174 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1175 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1176 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1177 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1178 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1179 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1180 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1181 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1182 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1183 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1184 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1185 >          else if(currentObject == "photon-secondary jet pairs")       objectToPlot = "photonSecondaryJetPairs";
1186 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1187 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1188 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1189 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1190 >          else objectToPlot = currentObject;
1191 >
1192 >          string tempCurrentObject = objectToPlot;
1193 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1194 >          string histoName = "num" + tempCurrentObject;
1195 >
1196 >
1197 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1198 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1199 >            int numToPlot = 0;
1200 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1201 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1202 >            }
1203 >
1204 >            if(objectToPlot == "primaryvertexs"){
1205 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1206 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1207 >            }
1208 >            else {
1209 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1210 >            }
1211 >          }
1212 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1213 >
1214 >
1215 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1216 >    } // end loop over cuts
1217 >
1218 >    if (!useEDMFormat_ && eventPassedAllCuts){
1219 >      // Assign BNTree variables
1220 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1221 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1222 >        string coll = brSpecs.inputCollection;
1223 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1224 >
1225 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1226 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1227 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1228 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1229 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1230 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1231 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1232 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1233 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1234 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1235 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1236 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1237 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1238 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1239 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1240 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1241 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1242 >        else if(coll == "stops"
1243 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1244 >      } // end loop over branches
1245 >
1246 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1247 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1248 >    }
1249 >
1250 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1251 >
1252 >  } // end loop over channel
1253  
1254    masterCutFlow_->fillCutFlow(masterScaleFactor);
1255  
1256 +  event.put (channelDecisions, "channelDecisions");
1257 +
1258   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1259  
1260  
# Line 1031 | Line 1290 | OSUAnalysis::evaluateComparison (string
1290   }
1291  
1292   bool
1293 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1293 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1294  
1295 +  //initialize to false until a chosen trigger is passed
1296    bool triggerDecision = false;
1297  
1298 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1299 <    {
1300 <      if(trigger->pass != 1) continue;
1301 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1302 <        {
1303 <          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1304 <            triggerDecision = true;
1305 <          }
1306 <        }
1298 >  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1299 >  //loop over all triggers defined in the event
1300 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1301 >
1302 >    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1303 >
1304 >    //we're only interested in triggers that actually passed
1305 >    if(trigger->pass != 1) continue;
1306 >
1307 >    //if the event passes one of the veto triggers, exit and return false
1308 >    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1309 >      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1310 >    }
1311 >    //if the event passes one of the chosen triggers, set triggerDecision to true
1312 >    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1313 >      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1314      }
1315 <  return triggerDecision;
1315 >  }
1316  
1317 +  printAllTriggers_ = false;  // only print triggers once, not every event
1318 +
1319 +  //if none of the veto triggers fired:
1320 +  //return the OR of all the chosen triggers
1321 +  if (triggersToTest.size() != 0) return triggerDecision;
1322 +  //or if no triggers were defined return true
1323 +  else return true;
1324   }
1325  
1326 +
1327   vector<string>
1328   OSUAnalysis::splitString (string inputString){
1329  
# Line 1210 | Line 1485 | OSUAnalysis::valueLookup (const BNjet* o
1485    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1486    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1487  
1488 +  //user defined variable
1489 +  else if(variable == "disappTrkLeadingJetID") {
1490 +    value = object->pt > 110
1491 +      && fabs(object->eta) < 2.4
1492 +      && object->chargedHadronEnergyFraction > 0.2
1493 +      && object->neutralHadronEnergyFraction < 0.7
1494 +      && object->chargedEmEnergyFraction < 0.5
1495 +      && object->neutralEmEnergyFraction < 0.7;
1496 +  }
1497 +
1498 +  else if(variable == "disappTrkSubLeadingJetID") {
1499 +    value = object->pt > 30
1500 +      && fabs(object->eta) < 4.5
1501 +      && object->neutralHadronEnergyFraction < 0.7
1502 +      && object->chargedEmEnergyFraction < 0.5;
1503 +  }
1504 +
1505  
1506    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1507  
# Line 1376 | Line 1668 | OSUAnalysis::valueLookup (const BNmuon*
1668    else if(variable == "time_ndof") value = object->time_ndof;
1669  
1670    //user-defined variables
1671 +  else if(variable == "looseID") {
1672 +    value = object->pt > 10
1673 +      && object->isGlobalMuon > 0
1674 +      && object->isTrackerMuon > 0;
1675 +      }
1676    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1677    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1678    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1679    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1680    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1681    else if(variable == "metMT") {
1682 <    const BNmet *met = chosenMET ();
1386 <    if (met)
1682 >    if (const BNmet *met = chosenMET ())
1683        {
1684 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1685 <          p2 (met->px, met->py, 0.0, met->pt);
1390 <
1391 <        value = (p1 + p2).Mt ();
1684 >        double dPhi = deltaPhi (object->phi, met->phi);
1685 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1686        }
1687      else
1688        value = -999;
# Line 1506 | Line 1800 | OSUAnalysis::valueLookup (const BNmuon*
1800      value = object->isGlobalMuon > 0                \
1801        && object->isPFMuon > 0                        \
1802        && object->normalizedChi2 < 10                \
1803 <                                  && object->numberOfValidMuonHits > 0        \
1803 >      && object->numberOfValidMuonHits > 0        \
1804        && object->numberOfMatchedStations > 1        \
1805        && fabs(object->correctedD0Vertex) < 0.2        \
1806        && fabs(object->correctedDZ) < 0.5        \
# Line 1515 | Line 1809 | OSUAnalysis::valueLookup (const BNmuon*
1809    }
1810    else if(variable == "tightIDdisplaced"){
1811      value = object->isGlobalMuon > 0                \
1812 +      && object->isPFMuon > 0                        \
1813        && object->normalizedChi2 < 10                \
1814 <                                  && object->numberOfValidMuonHits > 0        \
1814 >      && object->numberOfValidMuonHits > 0        \
1815        && object->numberOfMatchedStations > 1        \
1816        && object->numberOfValidPixelHits > 0        \
1817        && object->numberOfLayersWithMeasurement > 5;
# Line 1542 | Line 1837 | OSUAnalysis::valueLookup (const BNmuon*
1837    }
1838    else if(variable == "genMatchedMotherIdReverse"){
1839      int index = getGenMatchedParticleIndex(object);
1840 <    if(index == -1) value = 23;
1841 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1840 >    if(index == -1) value = 24;
1841 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1842    }
1843    else if(variable == "genMatchedGrandmotherId"){
1844      int index = getGenMatchedParticleIndex(object);
# Line 1557 | Line 1852 | OSUAnalysis::valueLookup (const BNmuon*
1852    }
1853    else if(variable == "genMatchedGrandmotherIdReverse"){
1854      int index = getGenMatchedParticleIndex(object);
1855 <    if(index == -1) value = 23;
1855 >    if(index == -1) value = 24;
1856      else if(fabs(mcparticles->at(index).motherId) == 15){
1857        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1858 <      if(motherIndex == -1) value = 23;
1859 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1858 >      if(motherIndex == -1) value = 24;
1859 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1860      }
1861 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1861 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1862 >  }
1863 >  else if(variable == "pfMuonsFromVertex"){
1864 >    double d0Error, dzError;
1865 >
1866 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1867 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1868 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1869 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1870 >      || fabs (object->correctedDZ / dzError) > 99.0;
1871 >    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1872    }
1873  
1874  
# Line 1743 | Line 2048 | OSUAnalysis::valueLookup (const BNelectr
2048    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2049    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2050    else if(variable == "metMT") {
2051 <    const BNmet *met = chosenMET ();
1747 <    if (met)
2051 >    if (const BNmet *met = chosenMET ())
2052        {
2053 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
2054 <          p2 (met->px, met->py, 0.0, met->pt);
1751 <
1752 <        value = (p1 + p2).Mt ();
2053 >        double dPhi = deltaPhi (object->phi, met->phi);
2054 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
2055        }
2056      else
2057        value = -999;
# Line 1841 | Line 2143 | OSUAnalysis::valueLookup (const BNelectr
2143        }
2144    }
2145  
2146 +  else if(variable == "looseID"){
2147 +    value = object->pt > 10
2148 +      && object->mvaNonTrigV0 > 0;
2149 +      }
2150    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2151      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2152      else value = -999;
# Line 1935 | Line 2241 | OSUAnalysis::valueLookup (const BNelectr
2241    }
2242    else if(variable == "genMatchedMotherIdReverse"){
2243      int index = getGenMatchedParticleIndex(object);
2244 <    if(index == -1) value = 23;
2245 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2244 >    if(index == -1) value = 24;
2245 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2246    }
2247    else if(variable == "genMatchedGrandmotherId"){
2248      int index = getGenMatchedParticleIndex(object);
# Line 1950 | Line 2256 | OSUAnalysis::valueLookup (const BNelectr
2256    }
2257    else if(variable == "genMatchedGrandmotherIdReverse"){
2258      int index = getGenMatchedParticleIndex(object);
2259 <    if(index == -1) value = 23;
2259 >    if(index == -1) value = 24;
2260      else if(fabs(mcparticles->at(index).motherId) == 15){
2261        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2262 <      if(motherIndex == -1) value = 23;
2263 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2262 >      if(motherIndex == -1) value = 24;
2263 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2264      }
2265 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2265 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2266 >  }
2267 >  else if(variable == "pfElectronsFromVertex"){
2268 >    double d0Error, dzError;
2269 >
2270 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2271 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2272 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2273 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2274 >      || fabs (object->correctedDZ / dzError) > 99.0;
2275 >    value = !value;
2276    }
2277  
2278  
# Line 2039 | Line 2355 | OSUAnalysis::valueLookup (const BNevent*
2355    else if(variable == "id2") value = object->id2;
2356    else if(variable == "evt") value = object->evt;
2357    else if(variable == "puScaleFactor"){
2358 <    if(datasetType_ != "data")
2358 >    if(doPileupReweighting_ && datasetType_ != "data")
2359        value = puWeight_->at (events->at (0).numTruePV);
2360      else
2361        value = 1.0;
2362    }
2363 <  else if(variable == "muonScaleFactor"){
2364 <    if(datasetType_ != "data" && applyLeptonSF_)
2365 <      value = muonSFWeight_->at (chosenMuon ()->eta);
2366 <    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 <
2363 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2364 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2365 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2366 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2367    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2368  
2369    value = applyFunction(function, value);
# Line 2112 | Line 2417 | OSUAnalysis::valueLookup (const BNtau* o
2417    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2418    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2419  
2420 <
2420 >  else if (variable == "looseHadronicID") {
2421 >    value = object->pt > 10
2422 >      && object->eta < 2.3
2423 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2424 >      && object->HPSdecayModeFinding > 0
2425 >      && object->HPSagainstElectronLoose > 0
2426 >      && object->HPSagainstMuonTight > 0;
2427 >  }
2428  
2429    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2430  
# Line 2134 | Line 2446 | OSUAnalysis::valueLookup (const BNtau* o
2446    }
2447    else if(variable == "genMatchedMotherIdReverse"){
2448      int index = getGenMatchedParticleIndex(object);
2449 <    if(index == -1) value = 23;
2450 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2449 >    if(index == -1) value = 24;
2450 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2451    }
2452    else if(variable == "genMatchedGrandmotherId"){
2453      int index = getGenMatchedParticleIndex(object);
# Line 2149 | Line 2461 | OSUAnalysis::valueLookup (const BNtau* o
2461    }
2462    else if(variable == "genMatchedGrandmotherIdReverse"){
2463      int index = getGenMatchedParticleIndex(object);
2464 <    if(index == -1) value = 23;
2464 >    if(index == -1) value = 24;
2465      else if(fabs(mcparticles->at(index).motherId) == 15){
2466        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2467 <      if(motherIndex == -1) value = 23;
2468 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2467 >      if(motherIndex == -1) value = 24;
2468 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2469      }
2470 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2470 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2471    }
2472  
2473  
# Line 2310 | Line 2622 | OSUAnalysis::valueLookup (const BNtrack*
2622        pt = object->pt;
2623      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2624    }
2625 +
2626 +
2627    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2628  
2629    else if(variable == "genMatchedPdgId"){
# Line 2331 | Line 2645 | OSUAnalysis::valueLookup (const BNtrack*
2645    }
2646    else if(variable == "genMatchedMotherIdReverse"){
2647      int index = getGenMatchedParticleIndex(object);
2648 <    if(index == -1) value = 23;
2649 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2648 >    if(index == -1) value = 24;
2649 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2650    }
2651    else if(variable == "genMatchedGrandmotherId"){
2652      int index = getGenMatchedParticleIndex(object);
# Line 2346 | Line 2660 | OSUAnalysis::valueLookup (const BNtrack*
2660    }
2661    else if(variable == "genMatchedGrandmotherIdReverse"){
2662      int index = getGenMatchedParticleIndex(object);
2663 <    if(index == -1) value = 23;
2663 >    if(index == -1) value = 24;
2664      else if(fabs(mcparticles->at(index).motherId) == 15){
2665        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2666 <      if(motherIndex == -1) value = 23;
2667 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2666 >      if(motherIndex == -1) value = 24;
2667 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2668      }
2669 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2669 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2670    }
2671  
2672  
# Line 2674 | Line 2988 | OSUAnalysis::valueLookup (const BNphoton
2988    }
2989    else if(variable == "genMatchedMotherIdReverse"){
2990      int index = getGenMatchedParticleIndex(object);
2991 <    if(index == -1) value = 23;
2992 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2991 >    if(index == -1) value = 24;
2992 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2993    }
2994    else if(variable == "genMatchedGrandmotherId"){
2995      int index = getGenMatchedParticleIndex(object);
# Line 2689 | Line 3003 | OSUAnalysis::valueLookup (const BNphoton
3003    }
3004    else if(variable == "genMatchedGrandmotherIdReverse"){
3005      int index = getGenMatchedParticleIndex(object);
3006 <    if(index == -1) value = 23;
3006 >    if(index == -1) value = 24;
3007      else if(fabs(mcparticles->at(index).motherId) == 15){
3008        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
3009 <      if(motherIndex == -1) value = 23;
3010 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3009 >      if(motherIndex == -1) value = 24;
3010 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3011      }
3012 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3012 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3013    }
3014  
3015  
# Line 2834 | Line 3148 | OSUAnalysis::valueLookup (const BNmuon*
3148    return value;
3149   }
3150  
3151 + //!muon-photon pair valueLookup
3152 + double
3153 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3154 +
3155 +  double value = 0.0;
3156 +
3157 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3158 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3159 +  else if(variable == "photonEta") value = object2->eta;
3160 +  else if(variable == "muonEta") value = object1->eta;
3161 +  else if(variable == "photonPhi") value = object2->phi;
3162 +  else if(variable == "muonPhi") value = object1->phi;
3163 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3164 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3165 +  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3166 +  else if(variable == "invMass"){
3167 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3168 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3169 +    value = (fourVector1 + fourVector2).M();
3170 +  }
3171 +  else if(variable == "pt"){
3172 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3173 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3174 +    value = (fourVector1 + fourVector2).Pt();
3175 +  }
3176 +  else if(variable == "threeDAngle")
3177 +    {
3178 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3179 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3180 +      value = (threeVector1.Angle(threeVector2));
3181 +    }
3182 +  else if(variable == "alpha")
3183 +    {
3184 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3185 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3186 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3187 +      value = (pi-threeVector1.Angle(threeVector2));
3188 +    }
3189 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3190 +
3191 +  value = applyFunction(function, value);
3192 +
3193 +  return value;
3194 + }
3195 +
3196 + //!electron-photon pair valueLookup
3197 + double
3198 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3199 +
3200 +  double value = 0.0;
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 == "photonEta") value = object2->eta;
3205 +  else if(variable == "electronEta") value = object1->eta;
3206 +  else if(variable == "photonPhi") value = object2->phi;
3207 +  else if(variable == "electronPhi") value = object1->phi;
3208 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3209 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3210 +  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3211 +  else if(variable == "invMass"){
3212 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3213 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3214 +    value = (fourVector1 + fourVector2).M();
3215 +  }
3216 +  else if(variable == "pt"){
3217 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3218 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3219 +    value = (fourVector1 + fourVector2).Pt();
3220 +  }
3221 +  else if(variable == "threeDAngle")
3222 +    {
3223 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3224 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3225 +      value = (threeVector1.Angle(threeVector2));
3226 +    }
3227 +  else if(variable == "alpha")
3228 +    {
3229 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3230 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3231 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3232 +      value = (pi-threeVector1.Angle(threeVector2));
3233 +    }
3234 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3235 +
3236 +  value = applyFunction(function, value);
3237 +
3238 +  return value;
3239 + }
3240 +
3241   //!electron-electron pair valueLookup
3242   double
3243   OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
# Line 2963 | Line 3367 | OSUAnalysis::valueLookup (const BNelectr
3367  
3368    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3369    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3370 +  else if(variable == "jetEta") value = object2->eta;
3371 +  else if(variable == "jetPhi") value = object2->phi;
3372 +  else if(variable == "electronEta") value = object1->eta;
3373 +  else if(variable == "electronPhi") value = object1->phi;
3374    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3375    else if(variable == "invMass"){
3376      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2990 | Line 3398 | OSUAnalysis::valueLookup (const BNelectr
3398    return value;
3399   }
3400  
3401 + //!photon-jet pair valueLookup
3402 + double
3403 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3404 +
3405 +  double value = 0.0;
3406 +
3407 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3408 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3409 +  else if(variable == "jetEta") value = object2->eta;
3410 +  else if(variable == "jetPhi") value = object2->phi;
3411 +  else if(variable == "photonEta") value = object1->eta;
3412 +  else if(variable == "photonPhi") value = object1->phi;
3413 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3414 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3415 +  else if(variable == "invMass"){
3416 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3417 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3418 +    value = (fourVector1 + fourVector2).M();
3419 +  }
3420 +  else if(variable == "pt"){
3421 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3422 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3423 +    value = (fourVector1 + fourVector2).Pt();
3424 +  }
3425 +  else if(variable == "threeDAngle")
3426 +    {
3427 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3428 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3429 +      value = (threeVector1.Angle(threeVector2));
3430 +    }
3431 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3432 +  value = applyFunction(function, value);
3433 +
3434 +  return value;
3435 + }
3436 +
3437   //!muon-jet pair valueLookup
3438   double
3439   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 2997 | Line 3441 | OSUAnalysis::valueLookup (const BNmuon*
3441    double value = 0.0;
3442  
3443    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3444 +  else if(variable == "jetEta") value = object2->eta;
3445 +  else if(variable == "jetPhi") value = object2->phi;
3446 +  else if(variable == "muonEta") value = object1->eta;
3447 +  else if(variable == "muonPhi") value = object1->phi;
3448    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3449    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3450    else if(variable == "invMass"){
# Line 3024 | Line 3472 | OSUAnalysis::valueLookup (const BNmuon*
3472  
3473    return value;
3474   }
3027
3475   //!jet-jet pair valueLookup
3476   double
3477   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3033 | Line 3480 | OSUAnalysis::valueLookup (const BNjet* o
3480  
3481    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3482    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3483 +  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3484    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3485    else if(variable == "invMass"){
3486      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3068 | Line 3516 | OSUAnalysis::valueLookup (const BNelectr
3516    TLorentzVector fourVector2(0, 0, 0, 0);
3517    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3518    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3519 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3520 <  else if(variable == "invMass"){        
3521 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3522 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3523 <        
3524 <    value = (fourVector1 + fourVector2).M();    
3519 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3520 >  else if(variable == "invMass"){
3521 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3522 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3523 >
3524 >    value = (fourVector1 + fourVector2).M();
3525    }
3526    else if(variable == "chargeProduct"){
3527      value = object1->charge*object2->charge;
3528    }
3529 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3530 <  value = applyFunction(function, value);        
3531 <  return value;  
3529 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3530 >  value = applyFunction(function, value);
3531 >  return value;
3532  
3533   }
3534  
# Line 3200 | Line 3648 | OSUAnalysis::valueLookup (const BNelectr
3648    double value = 0.0;
3649  
3650    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3651 +  else if (variable == "match"){
3652 +    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3653 +      stringValue = object2->filter;
3654 +    else
3655 +      stringValue = "none";
3656 +  }
3657  
3658    else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3659  
# Line 3320 | Line 3774 | OSUAnalysis::valueLookup (const BNstop*
3774      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3775        vertex_rank++;
3776        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3777 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3778 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3777 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3778 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3779  
3780        if(abs(dist) < abs(minDistToVertex)){
3781          value = vertex_rank;
# Line 3485 | Line 3939 | void OSUAnalysis::setObjectFlags(cut &cu
3939      string obj1, obj2;
3940      getTwoObjs(currentCut.inputCollection, obj1, obj2);
3941      if (inputType==obj1 ||
3942 <          inputType==obj2) {
3942 >        inputType==obj2) {
3943        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3944        // and the inputType is a member of the pair.
3945        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3497 | Line 3951 | void OSUAnalysis::setObjectFlags(cut &cu
3951  
3952    for (uint object = 0; object != inputCollection->size(); object++){
3953  
3954 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
3954 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
3955 >    bool plotDecision = true;
3956  
3957      if(currentCut.inputCollection == inputType){
3958  
# Line 3509 | Line 3964 | void OSUAnalysis::setObjectFlags(cut &cu
3964          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3965  
3966        }
3967 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3967 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
3968        else{
3969          bool tempDecision = true;
3970          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3518 | Line 3973 | void OSUAnalysis::setObjectFlags(cut &cu
3973            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
3974              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
3975          }
3976 <        decision = tempDecision;
3976 >        cutDecision = tempDecision;
3977        }
3978 +      //invert the cut for plotting if this cut is a veto
3979 +      if(currentCut.isVeto) plotDecision = !cutDecision;
3980 +      else plotDecision = cutDecision;
3981      }
3982  
3983 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3983 >    //if(cutDecision != plotDecision && currentCut.variables.at(0) == "pt") cout << "---------------\n" << cutDecision << " " << plotDecision << endl;
3984 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
3985  
3986 <    //set flags for objects that pass each cut AND all the previous cuts
3987 <    bool previousCumulativeFlag = true;
3986 >    //set flags for objects that pass this cut AND all the previous cuts
3987 >    bool previousCumulativeCutFlag = true;
3988 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3989 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
3990 >      else{ previousCumulativeCutFlag = false; break;}
3991 >    }
3992 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
3993 >    bool previousCumulativePlotFlag = true;
3994      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3995 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
3996 <      else{ previousCumulativeFlag = false; break;}
3995 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
3996 >      else{ previousCumulativePlotFlag = false; break;}
3997      }
3998 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3998 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
3999 >
4000 >    //if(inputType == "muons") cout << previousCumulativeCutFlag << " " << previousCumulativePlotFlag << " " << currentCut.variables.at(0) << "\n---------------\n\n";
4001 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4002  
4003    }
4004  
# Line 3539 | Line 4007 | void OSUAnalysis::setObjectFlags(cut &cu
4007  
4008   template <class InputCollection1, class InputCollection2>
4009   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4010 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4010 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4011  
4012  
4013    bool sameObjects = false;
# Line 3555 | Line 4023 | void OSUAnalysis::setObjectFlags(cut &cu
4023    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4024    if (currentCut.inputCollection == inputType) {
4025      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4026 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4027 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4026 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4027 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4028      }
4029      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4030        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4031 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4032 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4031 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4032 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4033        }
4034      }
4035    }
# Line 3574 | Line 4042 | void OSUAnalysis::setObjectFlags(cut &cu
4042        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4043  
4044  
4045 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4045 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4046 >      bool plotDecision = true;
4047  
4048        if(currentCut.inputCollection == inputType){
4049  
# Line 3586 | Line 4055 | void OSUAnalysis::setObjectFlags(cut &cu
4055            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4056          }
4057  
4058 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4058 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4059          else{
4060            bool tempDecision = subcutDecisions.at(0);
4061            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3595 | Line 4064 | void OSUAnalysis::setObjectFlags(cut &cu
4064              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4065                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4066            }
4067 <          decision = tempDecision;
4067 >          cutDecision = tempDecision;
4068          }
4069 +        //invert the cut for plotting if this cut is a veto
4070 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4071 +        else plotDecision = cutDecision;
4072 +      }
4073 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4074 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4075 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4076 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4077 +      }
4078 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4079 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4080 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4081        }
4082 <      // if (decision) isPassObj1.at(object1) = true;
4083 <      // if (decision) isPassObj2.at(object2) = true;
4084 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4085 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4086 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4087 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4082 >
4083 >      //set flags for objects that pass this cut AND all the previous cuts
4084 >      bool previousCumulativeCutFlag = true;
4085 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4086 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4087 >        else{ previousCumulativeCutFlag = false; break;}
4088        }
4089 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4090  
4091 <      //set flags for objects that pass each cut AND all the previous cuts
3610 <      bool previousCumulativeFlag = true;
4091 >      bool previousCumulativePlotFlag = true;
4092        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4093 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4094 <        else{ previousCumulativeFlag = false; break;}
4093 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4094 >        else{ previousCumulativePlotFlag = false; break;}
4095        }
4096 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4097 +      
4098        //apply flags for the components of the composite object as well
4099 <      bool currentCumulativeFlag = true;
4100 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4101 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4102 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4103 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4104 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4105 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4106 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4107 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4099 >      bool currentCumulativeCutFlag = true;
4100 >      bool currentCumulativePlotFlag = true;
4101 >
4102 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4103 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4104 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4105 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4106 >
4107 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4108 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4109 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4110 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4111 >
4112 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4113 >
4114 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4115 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4116 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4117        }
4118 +
4119 +      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4120 +        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4121 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4122 +      }
4123 +
4124        counter++;
4125  
4126      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3631 | Line 4129 | void OSUAnalysis::setObjectFlags(cut &cu
4129   }
4130  
4131  
4132 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4132 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4133    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4134    // all cuts up to currentCutIndex
4135    bool previousCumulativeFlag = true;
4136    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4137 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4137 >    bool tempFlag = false;
4138 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4139 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4140 >
4141 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4142      else {
4143        previousCumulativeFlag = false; break;
4144      }
# Line 3645 | Line 4147 | bool OSUAnalysis::getPreviousCumulativeF
4147   }
4148  
4149  
4150 +
4151 +
4152 + template <class InputCollection>
4153 + void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4154 +  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4155 +
4156 +  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;
4157 +  for (uint object = 0; object != inputCollection->size(); object++) {
4158 +
4159 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4160 +
4161 +    string inputVariable = parameters.inputVariable;
4162 +    string function = "";
4163 +    string stringValue = "";
4164 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4165 +    BNTreeBranchVals_.at(parameters.name).push_back(value);
4166 +
4167 +  }
4168 + }
4169 +
4170 +
4171   template <class InputCollection>
4172 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4172 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4173 >
4174  
4175    for (uint object = 0; object != inputCollection->size(); object++){
4176  
4177 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4177 >    //cout << "flags.at(object).second: " << flags.at(object).second << endl;
4178 >
4179 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4180  
4181      string currentString = parameters.inputVariables.at(0);
4182      string inputVariable = "";
# Line 3677 | Line 4203 | void OSUAnalysis::fill1DHistogram(TH1* h
4203   }
4204  
4205   template <class InputCollection1, class InputCollection2>
4206 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4206 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4207  
4208    bool sameObjects = false;
4209    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3690 | Line 4216 | void OSUAnalysis::fill1DHistogram(TH1* h
4216  
4217        pairCounter++;
4218        //only take objects which have passed all cuts and pairs which have passed all cuts
4219 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4220 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4221 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4219 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4220 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4221 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4222  
4223        string currentString = parameters.inputVariables.at(0);
4224        string inputVariable = "";
# Line 3717 | Line 4243 | void OSUAnalysis::fill1DHistogram(TH1* h
4243  
4244  
4245   template <class InputCollection>
4246 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4246 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4247  
4248    for (uint object = 0; object != inputCollection->size(); object++){
4249  
4250 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4250 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4251  
4252      string stringValue = "";
4253      string currentString = parameters.inputVariables.at(0);
# Line 3758 | Line 4284 | void OSUAnalysis::fill2DHistogram(TH2* h
4284   }
4285  
4286   template <class InputCollection1, class InputCollection2>
4287 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4287 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4288  
4289    bool sameObjects = false;
4290    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3772 | Line 4298 | void OSUAnalysis::fill2DHistogram(TH2* h
4298        pairCounter++;
4299  
4300        //only take objects which have passed all cuts and pairs which have passed all cuts
4301 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4302 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4303 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4301 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4302 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4303 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4304  
4305        string stringValue = "";
4306        string currentString = parameters.inputVariables.at(0);
# Line 3896 | Line 4422 | int OSUAnalysis::findTauMotherIndex(cons
4422   // 20        strange baryon
4423   // 21        charm baryon
4424   // 22        bottom baryon
4425 < // 23        other
4425 > // 23        QCD string
4426 > // 24        other
4427  
4428   int OSUAnalysis::getPdgIdBinValue(int pdgId){
4429  
# Line 3920 | Line 4447 | int OSUAnalysis::getPdgIdBinValue(int pd
4447    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
4448    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
4449    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
4450 +  else if(absPdgId == 92  ) binValue = 23;
4451  
4452 <  else binValue = 23;
4452 >  else binValue = 24;
4453  
4454    return binValue;
4455  
# Line 3931 | Line 4459 | const BNprimaryvertex *
4459   OSUAnalysis::chosenVertex ()
4460   {
4461    const BNprimaryvertex *chosenVertex = 0;
4462 <  if(find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
4463 <    vector<bool> vertexFlags;
4462 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4463 >    flagPair vertexFlags;
4464      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4465        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4466          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 3940 | Line 4468 | OSUAnalysis::chosenVertex ()
4468        }
4469      }
4470      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4471 <      if(!vertexFlags.at(vertexIndex)) continue;
4471 >      if(!vertexFlags.at(vertexIndex).first) continue;
4472        chosenVertex = & primaryvertexs->at(vertexIndex);
4473        break;
4474      }
4475    }
4476 <  else {
4477 <    chosenVertex = &primaryvertexs->at(0);
3950 <  }
4476 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4477 >    chosenVertex = & primaryvertexs->at (0);
4478  
4479    return chosenVertex;
4480   }
# Line 3956 | Line 4483 | const BNmet *
4483   OSUAnalysis::chosenMET ()
4484   {
4485    const BNmet *chosenMET = 0;
4486 <  if(find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4487 <    vector<bool> metFlags;
4486 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4487 >    flagPair metFlags;
4488      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4489        if (cumulativeFlags.at("mets").at(i).size()){
4490          metFlags = cumulativeFlags.at("mets").at(i);
# Line 3965 | Line 4492 | OSUAnalysis::chosenMET ()
4492        }
4493      }
4494      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4495 <      if(!metFlags.at(metIndex)) continue;
4495 >      if(!metFlags.at(metIndex).first) continue;
4496        chosenMET = & mets->at(metIndex);
4497        break;
4498      }
4499    }
4500 <  else {
4501 <    chosenMET = &mets->at(0);
3975 <  }
4500 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4501 >    chosenMET = & mets->at (0);
4502  
4503    return chosenMET;
4504   }
# Line 3981 | Line 4507 | const BNelectron *
4507   OSUAnalysis::chosenElectron ()
4508   {
4509    const BNelectron *chosenElectron = 0;
4510 <  if(find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4511 <    vector<bool> electronFlags;
4510 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4511 >    flagPair electronFlags;
4512      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4513        if (cumulativeFlags.at("electrons").at(i).size()){
4514          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 3990 | Line 4516 | OSUAnalysis::chosenElectron ()
4516        }
4517      }
4518      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4519 <      if(!electronFlags.at(electronIndex)) continue;
4519 >      if(!electronFlags.at(electronIndex).first) continue;
4520        chosenElectron = & electrons->at(electronIndex);
4521        break;
4522      }
4523    }
4524 <  else {
4525 <    chosenElectron = &electrons->at(0);
4000 <  }
4524 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4525 >    chosenElectron = & electrons->at (0);
4526  
4527    return chosenElectron;
4528   }
4529  
4530 +
4531   const BNmuon *
4532   OSUAnalysis::chosenMuon ()
4533   {
4534    const BNmuon *chosenMuon = 0;
4535 <  if(find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4536 <    vector<bool> muonFlags;
4535 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4536 >    flagPair muonFlags;
4537      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4538        if (cumulativeFlags.at("muons").at(i).size()){
4539          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4015 | Line 4541 | OSUAnalysis::chosenMuon ()
4541        }
4542      }
4543      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4544 <      if(!muonFlags.at(muonIndex)) continue;
4544 >      if(!muonFlags.at(muonIndex).first) continue;
4545        chosenMuon = & muons->at(muonIndex);
4546        break;
4547      }
4548    }
4549 <  else {
4550 <    chosenMuon = &muons->at(0);
4025 <  }
4549 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4550 >    chosenMuon = & muons->at (0);
4551  
4552    return chosenMuon;
4553   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines