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.73 by lantonel, Thu May 30 18:09:58 2013 UTC vs.
Revision 1.97 by biliu, Tue Jul 9 20:21:51 2013 UTC

# Line 1 | Line 1
1   #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2
2   OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
3    // Retrieve parameters from the configuration file.
4    jets_ (cfg.getParameter<edm::InputTag> ("jets")),
# Line 28 | Line 27 | OSUAnalysis::OSUAnalysis (const edm::Par
27    datasetType_ (cfg.getParameter<string> ("datasetType")),
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
31 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
32    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
33    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
34    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
36 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
37 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
38 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
39    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
40    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
41    GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
42 < {
42 > {
43  
44    TH1::SetDefaultSumw2 ();
45  
# Line 46 | Line 50 | OSUAnalysis::OSUAnalysis (const edm::Par
50        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
51        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
52      }
53 +    if (applyBtagSF_){
54 +      bTagSFWeight_ = new BtagSFWeight;
55 +    }
56    }
57    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
58      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 58 | Line 65 | OSUAnalysis::OSUAnalysis (const edm::Par
65    //always get vertex collection so we can assign the primary vertex in the event
66    objectsToGet.push_back("primaryvertexs");
67    objectsToPlot.push_back("primaryvertexs");
68 <  objectsToCut.push_back("primaryvertexs");
68 >  objectsToFlag.push_back("primaryvertexs");
69  
70  
71    //always get the MC particles to do GEN-matching
# Line 67 | Line 74 | OSUAnalysis::OSUAnalysis (const edm::Par
74    //always get the event collection to do pile-up reweighting
75    objectsToGet.push_back("events");
76  
77 +
78 +  // Parse the tree variable definitions.
79 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
80 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
81 +    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; }
82 +    objectsToGet.push_back(tempInputCollection);
83 +    objectsToFlag.push_back(tempInputCollection);
84 +
85 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
86 +
87 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
88 +      BranchSpecs br;
89 +      br.inputCollection = tempInputCollection;
90 +      br.inputVariable = branchList.at(iBranch);
91 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
92 +      br.name = string(newName.Data());
93 +      treeBranches_.push_back(br);
94 +    }
95 +
96 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
97 +
98 +
99    //parse the histogram definitions
100    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
101  
102      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
103      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
104 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
105 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
106      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
107 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
108      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
109 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
110 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
111 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
112      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
113      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
114 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
115 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
116 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
119      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
120      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
121      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 89 | Line 129 | OSUAnalysis::OSUAnalysis (const edm::Par
129          objectsToGet.push_back(tempInputCollection);
130        }
131        objectsToPlot.push_back(tempInputCollection);
132 <      objectsToCut.push_back(tempInputCollection);
133 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
132 >      objectsToFlag.push_back(tempInputCollection);
133 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
134        string obj1;
135        string obj2;
136        getTwoObjs(tempInputCollection, obj1, obj2);
137        string obj2ToGet = getObjToGet(obj2);
138 <      objectsToCut.push_back(tempInputCollection);
139 <      objectsToCut.push_back(obj1);
140 <      objectsToCut.push_back(obj2);
138 >      objectsToFlag.push_back(tempInputCollection);
139 >      objectsToFlag.push_back(obj1);
140 >      objectsToFlag.push_back(obj2);
141        objectsToPlot.push_back(tempInputCollection);
142        objectsToPlot.push_back(obj1);
143        objectsToPlot.push_back(obj2);
144        objectsToGet.push_back(tempInputCollection);
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147 +    } // end else
148  
109    }
149  
150  
151      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 128 | Line 167 | OSUAnalysis::OSUAnalysis (const edm::Par
167        histograms.push_back(tempHistogram);
168  
169      }
170 <  }
170 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
171 >
172    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
173    sort( objectsToPlot.begin(), objectsToPlot.end() );
174    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 139 | Line 179 | OSUAnalysis::OSUAnalysis (const edm::Par
179    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
180  
181      string currentObject = objectsToPlot.at(currentObjectIndex);
182 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
182 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "secondary photons"&& currentObject != "superclusters") continue;
183  
184      histogram tempIdHisto;
185      histogram tempMomIdHisto;
# Line 154 | Line 194 | OSUAnalysis::OSUAnalysis (const edm::Par
194      tempIdVsGmaIdHisto.inputCollection = currentObject;
195  
196      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
197 +    if(currentObject == "secondary photons") currentObject = "secondaryPhotons";
198      if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
199  
200      currentObject = currentObject.substr(0, currentObject.size()-1);
# Line 236 | Line 277 | OSUAnalysis::OSUAnalysis (const edm::Par
277      //create cutFlow for this channel
278      cutFlows_.push_back (new CutFlow (fs_, channelName));
279      vector<TFileDirectory> directories; //vector of directories in the output file.
280 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
281      vector<string> subSubDirNames;//subdirectories in each channel.
282      //get list of cuts for this channel
283      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 247 | Line 289 | OSUAnalysis::OSUAnalysis (const edm::Par
289        //store input collection for cut
290        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
291        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
292 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
293 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
294        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
295        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
296 +      if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
297 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
298 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
299 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
300        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
301        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
302 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
303 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
304 +      if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
305 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
306 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
307        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
308        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
309        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 265 | Line 318 | OSUAnalysis::OSUAnalysis (const edm::Par
318            objectsToGet.push_back(tempInputCollection);
319          }
320          objectsToCut.push_back(tempInputCollection);
321 +        objectsToFlag.push_back(tempInputCollection);
322        }
323        else{//pair of objects, need to add them both to objectsToGet
324          string obj1;
# Line 274 | Line 328 | OSUAnalysis::OSUAnalysis (const edm::Par
328          objectsToCut.push_back(tempInputCollection);
329          objectsToCut.push_back(obj1);
330          objectsToCut.push_back(obj2);
331 +        objectsToFlag.push_back(tempInputCollection);
332 +        objectsToFlag.push_back(obj1);
333 +        objectsToFlag.push_back(obj2);
334          objectsToGet.push_back(tempInputCollection);
335          objectsToGet.push_back(obj1);
336          objectsToGet.push_back(obj2ToGet);
# Line 320 | Line 377 | OSUAnalysis::OSUAnalysis (const edm::Par
377        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
378        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
379  
380 <      //Set up vectors to store the directories and subDIrectories for each channel.
380 >      //Set up vectors to store the directories and subDirectories for each channel.
381        string subSubDirName;
382        string tempCutName;
383        if(cuts_.at(currentCut).exists("alias")){
384          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
385 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
385 >        subSubDirName = "After " + tempCutName + " Cut Applied";
386        }
387        else{
388          //construct string for cutflow table
# Line 336 | Line 393 | OSUAnalysis::OSUAnalysis (const edm::Par
393          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
394        }
395  
396 +      tempCut.isVeto = false;
397 +      if(cuts_.at(currentCut).exists("isVeto")){
398 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
399 +        if (isVeto == true) tempCut.isVeto = true;
400 +      }
401        subSubDirNames.push_back(subSubDirName);
402        tempCut.name = tempCutName;
403  
# Line 350 | Line 412 | OSUAnalysis::OSUAnalysis (const edm::Par
412      TFileDirectory subDir = fs_->mkdir( channelName );
413      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
414      if(GetPlotsAfterEachCut_){
415 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
416 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
417 <            directories.push_back(subSubDir);
418 <            map<string, TH1D*> oneDhistoMap;
419 <            oneDHistsTmp.push_back(oneDhistoMap);
420 <            map<string, TH2D*> twoDhistoMap;
421 <            twoDHistsTmp.push_back(twoDhistoMap);
415 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
416 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
417 >        directories.push_back(subSubDir);
418 >        map<string, TH1D*> oneDhistoMap;
419 >        oneDHistsTmp.push_back(oneDhistoMap);
420 >        map<string, TH2D*> twoDhistoMap;
421 >        twoDHistsTmp.push_back(twoDhistoMap);
422        }
423 +      treeDirectories.push_back(subDir);
424        oneDHists_.push_back(oneDHistsTmp);
425        twoDHists_.push_back(twoDHistsTmp);
426      }
427 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
428 <   else{
427 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
428 >    else{
429        map<string, TH1D*> oneDhistoMap;
430        oneDHistsTmp.push_back(oneDhistoMap);
431        map<string, TH2D*> twoDhistoMap;
# Line 370 | Line 433 | OSUAnalysis::OSUAnalysis (const edm::Par
433        oneDHists_.push_back(oneDHistsTmp);
434        twoDHists_.push_back(twoDHistsTmp);
435        directories.push_back(subDir);
436 <   }
436 >      treeDirectories.push_back(subDir);
437 >
438 >    }
439 >
440 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
441 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
442 >      BNTrees_.push_back(newTree);
443 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
444 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
445 >        vector<float> newVec;
446 >        BNTreeBranchVals_[currentVar.name] = newVec;
447 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
448 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
449 >    }
450 >
451      //book all histograms included in the configuration
452      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
453 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
454 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
455 <      int numBinsElements = currentHistogram.bins.size();
456 <      int numInputVariables = currentHistogram.inputVariables.size();
457 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
458 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
459 <
460 <      if(numBinsElements == 1){
461 <        if(numBinEdgesX > 1){
462 <          if(numBinEdgesY > 1)
463 <            numBinsElements = 6;
453 >
454 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
455 >
456 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
457 >        int numBinsElements = currentHistogram.bins.size();
458 >        int numInputVariables = currentHistogram.inputVariables.size();
459 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
460 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
461 >
462 >        if(numBinsElements == 1){
463 >          if(numBinEdgesX > 1){
464 >            if(numBinEdgesY > 1)
465 >              numBinsElements = 6;
466 >            else
467 >              numBinsElements = 3;
468 >          }
469 >        }
470 >        if(numBinsElements != 3 && numBinsElements !=6){
471 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
472 >          exit(0);
473 >        }
474 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
475 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
476 >          exit(0);
477 >        }
478 >        else if(numBinsElements == 3){
479 >          if (currentHistogram.bins.size () == 3)
480 >            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));
481            else
482 <            numBinsElements = 3;
482 >            {
483 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
484 >            }
485          }
486 <      }
487 <      if(numBinsElements != 3 && numBinsElements !=6){
488 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
489 <        exit(0);
490 <      }
491 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
492 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
493 <        exit(0);
494 <      }
495 <      else if(numBinsElements == 3){
496 <        if (currentHistogram.bins.size () == 3)
497 <          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));
498 <        else
499 <          {
500 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
486 >        else if(numBinsElements == 6){
487 >          if (currentHistogram.bins.size () == 6)
488 >            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));
489 >          else
490 >            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 ());
491 >        }
492 >
493 >
494 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
495 >
496 >        // bin      particle type
497 >        // ---      -------------
498 >        //  0        unmatched
499 >        //  1        u
500 >        //  2        d
501 >        //  3        s
502 >        //  4        c
503 >        //  5        b
504 >        //  6        t
505 >        //  7        e
506 >        //  8        mu
507 >        //  9        tau
508 >        // 10        nu
509 >        // 11        g
510 >        // 12        gamma
511 >        // 13        Z
512 >        // 14        W
513 >        // 15        light meson
514 >        // 16        K meson
515 >        // 17        D meson
516 >        // 18        B meson
517 >        // 19        light baryon
518 >        // 20        strange baryon
519 >        // 21        charm baryon
520 >        // 22        bottom baryon
521 >        // 23        QCD string
522 >        // 24        other
523 >
524 >        vector<TString> labelArray;
525 >        labelArray.push_back("unmatched");
526 >        labelArray.push_back("u");
527 >        labelArray.push_back("d");
528 >        labelArray.push_back("s");
529 >        labelArray.push_back("c");
530 >        labelArray.push_back("b");
531 >        labelArray.push_back("t");
532 >        labelArray.push_back("e");
533 >        labelArray.push_back("#mu");
534 >        labelArray.push_back("#tau");
535 >        labelArray.push_back("#nu");
536 >        labelArray.push_back("g");
537 >        labelArray.push_back("#gamma");
538 >        labelArray.push_back("Z");
539 >        labelArray.push_back("W");
540 >        labelArray.push_back("light meson");
541 >        labelArray.push_back("K meson");
542 >        labelArray.push_back("D meson");
543 >        labelArray.push_back("B meson");
544 >        labelArray.push_back("light baryon");
545 >        labelArray.push_back("strange baryon");
546 >        labelArray.push_back("charm baryon");
547 >        labelArray.push_back("bottom baryon");
548 >        labelArray.push_back("QCD string");
549 >        labelArray.push_back("other");
550 >
551 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
552 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
553 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
554            }
555 <      }
556 <      else if(numBinsElements == 6){
557 <        if (currentHistogram.bins.size () == 6)
558 <          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));
559 <        else
560 <          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 ());
561 <      }
555 >          else {
556 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
557 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
558 >          }
559 >        }
560 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
561 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
562 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
563 >        }
564  
565 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
566  
415      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
567  
568 <      // bin      particle type
569 <      // ---      -------------
570 <      //  0        unmatched
571 <      //  1        u
572 <      //  2        d
573 <      //  3        s
574 <      //  4        c
575 <      //  5        b
576 <      //  6        t
577 <      //  7        e
578 <      //  8        mu
579 <      //  9        tau
580 <      // 10        nu
581 <      // 11        g
582 <      // 12        gamma
583 <      // 13        Z
584 <      // 14        W
585 <      // 15        light meson
586 <      // 16        K meson
587 <      // 17        D meson
588 <      // 18        B meson
589 <      // 19        light baryon
590 <      // 20        strange baryon
591 <      // 21        charm baryon
592 <      // 22        bottom baryon
593 <      // 23        QCD string
594 <      // 24        other
595 <
596 <      vector<TString> labelArray;
597 <      labelArray.push_back("unmatched");
598 <      labelArray.push_back("u");
599 <      labelArray.push_back("d");
600 <      labelArray.push_back("s");
601 <      labelArray.push_back("c");
602 <      labelArray.push_back("b");
603 <      labelArray.push_back("t");
604 <      labelArray.push_back("e");
605 <      labelArray.push_back("#mu");
606 <      labelArray.push_back("#tau");
607 <      labelArray.push_back("#nu");
608 <      labelArray.push_back("g");
609 <      labelArray.push_back("#gamma");
610 <      labelArray.push_back("Z");
611 <      labelArray.push_back("W");
612 <      labelArray.push_back("light meson");
613 <      labelArray.push_back("K meson");
614 <      labelArray.push_back("D meson");
615 <      labelArray.push_back("B meson");
616 <      labelArray.push_back("light baryon");
617 <      labelArray.push_back("strange baryon");
618 <      labelArray.push_back("charm baryon");
468 <      labelArray.push_back("bottom baryon");
469 <      labelArray.push_back("QCD string");
470 <      labelArray.push_back("other");
471 <
472 <      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
473 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
474 <          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
475 <        }
476 <        else {
477 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
478 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
479 <        }
480 <      }
481 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
482 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
484 <      }
485 <
486 <    }
487 <
488 <    // Book a histogram for the number of each object type to be plotted.
489 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
490 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
491 <      string currentObject = objectsToPlot.at(currentObjectIndex);
492 <      int maxNum = 10;
493 <      if(currentObject == "mcparticles") maxNum = 50;
494 <      else if(currentObject == "primaryvertexs") maxNum = 50;
495 <
496 <      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
497 <      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
498 <      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
499 <      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
500 <      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
501 <      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
502 <      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
503 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
504 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
505 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
506 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
507 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
508 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
509 <      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
510 <      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
511 <      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
512 <      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
513 <      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
514 <      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
515 <
516 <      currentObject.at(0) = toupper(currentObject.at(0));
517 <      string histoName = "num" + currentObject;
518 <
519 <      if(histoName == "numPrimaryvertexs"){
520 <        string newHistoName = histoName + "BeforePileupCorrection";
521 <        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);
522 <        newHistoName = histoName + "AfterPileupCorrection";
523 <        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);
568 >      // Book a histogram for the number of each object type to be plotted.
569 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
570 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
571 >        string currentObject = objectsToPlot.at(currentObjectIndex);
572 >        int maxNum = 10;
573 >        if(currentObject == "mcparticles") maxNum = 50;
574 >        else if(currentObject == "primaryvertexs") maxNum = 50;
575 >
576 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
577 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
578 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
579 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
580 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
581 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
582 >        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
583 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
584 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
585 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
586 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
587 >        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
588 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
589 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
590 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
591 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
592 >        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
593 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
594 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
595 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
596 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
597 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
598 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
599 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
600 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
601 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
602 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
603 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
604 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
605 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
606 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
607 >
608 >        currentObject.at(0) = toupper(currentObject.at(0));
609 >        string histoName = "num" + currentObject;
610 >
611 >        if(histoName == "numPrimaryvertexs"){
612 >          string newHistoName = histoName + "BeforePileupCorrection";
613 >          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);
614 >          newHistoName = histoName + "AfterPileupCorrection";
615 >          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);
616 >        }
617 >        else
618 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
619        }
620 <      else
526 <        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
527 <    }
528 <   }//end of loop over directories
620 >    }//end of loop over directories
621      channels.push_back(tempChannel);
622      tempChannel.cuts.clear();
623    }//end loop over channels
# Line 537 | Line 629 | OSUAnalysis::OSUAnalysis (const edm::Par
629    //make unique vector of objects we need to cut on
630    sort( objectsToCut.begin(), objectsToCut.end() );
631    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
632 +  //make unique vector of objects we need to set flags for
633 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
634 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
635  
636 +  produces<map<string, bool> > ("channelDecisions");
637 +
638 + } // end constructor OSUAnalysis::OSUAnalysis()
639  
542 }
640  
641   OSUAnalysis::~OSUAnalysis ()
642   {
643 +
644    // Destroying the CutFlow objects causes the cut flow numbers and time
645    // information to be printed to standard output.
646    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
647      delete cutFlows_.at(currentChannel);
648    }
649 +
650 +  cout << "=============================================" << endl;  
651 +  cout << "Successfully completed OSUAnalysis." << endl;  
652 +  cout << "=============================================" << endl;  
653 +
654   }
655  
656   void
657 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
657 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
658   {
556
659    // Retrieve necessary collections from the event.
660  
661    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 619 | Line 721 | OSUAnalysis::analyze (const edm::Event &
721    //get pile-up event weight
722    if (doPileupReweighting_ && datasetType_ != "data") {
723      //for "data" datasets, the numTruePV is always set to -1
724 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
725 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
724 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
725 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
726    }
727  
728    stopCTauScaleFactor_ = 1.0;
# Line 630 | Line 732 | OSUAnalysis::analyze (const edm::Event &
732  
733    //loop over all channels
734  
735 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
736    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
737      channel currentChannel = channels.at(currentChannelIndex);
738  
# Line 637 | Line 740 | OSUAnalysis::analyze (const edm::Event &
740      counterMap passingCounter;
741      cumulativeFlags.clear ();
742  
743 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
744 +         iter != BNTreeBranchVals_.end(); iter++) {
745 +      iter->second.clear();  // clear array
746 +    }
747 +
748      bool triggerDecision = true;
749      if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
750        triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
# Line 646 | Line 754 | OSUAnalysis::analyze (const edm::Event &
754      //loop over all cuts
755      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
756        cut currentCut = currentChannel.cuts.at(currentCutIndex);
757 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
758 <        string currentObject = objectsToCut.at(currentObjectIndex);
757 >
758 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
759 >        string currentObject = objectsToFlag.at(currentObjectIndex);
760  
761          //initialize maps to get ready to set cuts
762 <        individualFlags[currentObject].push_back (vector<bool> ());
763 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
762 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
763 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
764  
765        }
766 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
767 <        string currentObject = objectsToCut.at(currentObjectIndex);
766 >
767 >      //set flags for all relevant objects
768 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
769 >        string currentObject = objectsToFlag.at(currentObjectIndex);
770  
771          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
772  
773  
774          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
775          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
776 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
777          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
778          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
779          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 686 | Line 798 | OSUAnalysis::analyze (const edm::Event &
798                                                                     "muon-muon pairs");
799  
800          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
801 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
802 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
803 <                                                                   "muon-secondary muon pairs");
801 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
802 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
803 >                                                                             "muon-secondary muon pairs");
804 >
805 >        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
806 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
807 >                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
808 >                                                                             "muon-secondary photon pairs");
809 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
810 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
811 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
812 >                                                                             "muon-secondary jet pairs");
813 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
814 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
815 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
816 >                                                                             "photon-secondary jet pairs");
817 >
818 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
819 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
820 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
821 >                                                                             "electron-secondary jet pairs");
822  
823          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
824 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
826 <                                                                   "electron-secondary electron pairs");
824 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
826 >                                                                                     "electron-secondary electron pairs");
827  
828          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
829                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 704 | Line 834 | OSUAnalysis::analyze (const edm::Event &
834                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
835                                                                         "electron-muon pairs");
836          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
837 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 <                                                                           "jet-jet pairs");
837 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 >                                                                 "jet-jet pairs");
840 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
841 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
842 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
843 >                                                                 "jet-secondary jet pairs");
844          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
845 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
846 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
847 <                                                                       "electron-jet pairs");
845 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
846 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
847 >                                                                      "electron-jet pairs");
848 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
849 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
850 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
851 >                                                                      "electron-photon pairs");
852 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
853 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
854 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
855 >                                                                      "photon-jet pairs");
856          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
857 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
858 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
859 <                                                                       "muon-jet pairs");
857 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
858 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
859 >                                                                  "muon-jet pairs");
860 >        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
861 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
862 >                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
863 >                                                                  "muon-event pairs");
864 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
865 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
866 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
867 >                                                                  "met-jet pairs");
868 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
869 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
870 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
871 >                                                                 "track-jet pairs");
872 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
873 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
874 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
875 >                                                                  "muon-photon pairs");
876          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
877                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
878                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 736 | Line 894 | OSUAnalysis::analyze (const edm::Event &
894                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
895                                                                   "tau-tau pairs");
896          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
897 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
898 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
899 <                                                                 "tau-track pairs");
897 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
898 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
899 >                                                                   "tau-track pairs");
900          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
901                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
902                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 756 | Line 914 | OSUAnalysis::analyze (const edm::Event &
914      }//end loop over all cuts
915      //use cumulative flags to apply cuts at event level
916  
759    bool eventPassedAllCuts = true;
917      //a vector to store cumulative cut descisions after each cut.
918      vector<bool> eventPassedPreviousCuts;
919 +    bool eventPassedAllCuts = true;
920      //apply trigger (true if none were specified)
921      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
922  
765
923      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
924  
925        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 770 | Line 927 | OSUAnalysis::analyze (const edm::Event &
927        int numberPassing = 0;
928  
929        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
930 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
930 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
931        }
932        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
933        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
934        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
935        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
936      }
937 +    //applying all appropriate scale factors
938      double scaleFactor = masterScaleFactor;
939 +    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
940  
782    muonScaleFactor_ = electronScaleFactor_ = 1.0;
941      if(applyLeptonSF_ && datasetType_ != "data"){
942 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
943 <        vector<bool> muonFlags;
942 >      //only apply SFs if we've cut on this object
943 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
944 >        flagPair muonFlags;
945 >        //get the last valid flags in the flag map
946          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
947            if (cumulativeFlags.at("muons").at(i).size()){
948              muonFlags = cumulativeFlags.at("muons").at(i);
949              break;
950            }
951          }
952 +        //apply the weight for each of those objects
953          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
954 <          if(!muonFlags.at(muonIndex)) continue;
954 >          if(!muonFlags.at(muonIndex).second) continue;
955            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
956          }
957        }
958 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
959 <        vector<bool> electronFlags;
958 >      //only apply SFs if we've cut on this object
959 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
960 >        flagPair electronFlags;
961 >        //get the last valid flags in the flag map
962          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
963            if (cumulativeFlags.at("electrons").at(i).size()){
964              electronFlags = cumulativeFlags.at("electrons").at(i);
965              break;
966            }
967          }
968 +        //apply the weight for each of those objects
969          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
970 <          if(!electronFlags.at(electronIndex)) continue;
970 >          if(!electronFlags.at(electronIndex).second) continue;
971            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
972          }
973        }
974      }
975 +    if(applyBtagSF_ && datasetType_ != "data"){
976 +      //only apply SFs if we've cut on this object
977 +      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
978 +        flagPair jetFlags;
979 +        vector<double> jetSFs;
980 +        //get the last valid flags in the flag map
981 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
982 +          if (cumulativeFlags.at("jets").at(i).size()){
983 +            jetFlags = cumulativeFlags.at("jets").at(i);
984 +            break;
985 +          }
986 +        }
987 +        //apply the weight for each of those objects
988 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
989 +          if(!jetFlags.at(jetIndex).second) continue;
990 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
991 +          jetSFs.push_back(jetSFTmp);
992 +        }
993 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
994 +      }
995 +    }
996      scaleFactor *= muonScaleFactor_;
997      scaleFactor *= electronScaleFactor_;
998 <
998 >    scaleFactor *= bTagScaleFactor_;
999      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1000  
816
1001      if (printEventInfo_) {
1002        // Write information about event to screen, for testing purposes.
1003        cout << "Event passed all cuts in channel " <<  currentChannel.name
# Line 824 | Line 1008 | OSUAnalysis::analyze (const edm::Event &
1008      }
1009  
1010  
827
1011      //filling histograms
1012      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
830
1013        uint currentDir;
1014 <      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
1015 <      else currentDir = currentCut;
1014 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1015 >      else{
1016 >        currentDir = currentCut;
1017 >      }
1018  
835      if(!eventPassedPreviousCuts.at(currentDir)) continue;
1019  
1020 +      if(eventPassedPreviousCuts.at(currentDir)){
1021  
1022 <      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1023 <        histogram currentHistogram = histograms.at(histogramIndex);
1022 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1023 >          histogram currentHistogram = histograms.at(histogramIndex);
1024  
1025 <        if(currentHistogram.inputVariables.size() == 1){
1026 <          TH1D* histo;
1027 <          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1028 <
1029 <          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1030 <          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1031 <          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1032 <          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1033 <          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1034 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1035 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1036 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1037 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1038 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1039 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1040 <          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1041 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1042 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1043 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1044 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1045 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1046 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1047 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1048 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1049 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1050 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1051 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1052 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1053 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1054 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1055 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1056 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1057 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1058 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1059 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1060 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1061 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1062 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1063 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1064 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1065 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1066 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1067 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1068 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1069 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1070 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1071 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1072 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1073 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1074 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1075 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1076 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1077 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1078 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1079 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1080 <          
1081 <          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1082 <          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1083 <          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1084 <          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1085 <          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1086 <          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1087 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1088 <          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1089 <          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1090 <          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1091 <          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1092 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1093 <        }
1094 <        else if(currentHistogram.inputVariables.size() == 2){
1095 <          TH2D* histo;
1096 <          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1097 <
1098 <          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1099 <          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1100 <          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1101 <          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1102 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1103 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1104 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1105 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1106 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1107 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1108 <          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1109 <          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1110 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1111 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1112 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1113 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1114 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1115 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1116 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1117 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1118 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1119 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1120 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1121 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1122 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1123 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1124 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1125 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1126 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1127 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1128 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1129 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1130 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1131 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1132 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1133 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1134 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1135 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1136 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1137 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1138 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1139 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1140 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1141 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1142 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1143 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1144 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1145 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1146 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1147 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1148 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1149 <          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1150 <          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1151 <          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1152 <          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1153 <          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1154 <                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1155 <                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1156 <          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1157 <          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1158 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1159 <          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1160 <          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1161 <          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1162 <          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1163 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1164 <        }
1165 <      }
1025 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1026 >
1027 >          if(currentHistogram.inputVariables.size() == 1){
1028 >            TH1D* histo;
1029 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1030 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1031 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1032 >            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1033 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1034 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1035 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1036 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1037 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1038 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1039 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1040 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1041 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1042 >             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1043 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1044 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1045 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1046 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1047 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1048 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1049 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1050 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1051 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1052 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1053 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1054 >
1055 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1056 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1057 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1058 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1059 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1060 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1061 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1062 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1063 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1064 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1065 >
1066 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1067 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1068 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1069 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1070 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1071 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1072 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1073 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1074 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1075 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1076 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1077 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1078 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1079 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1080 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1081 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1082 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1083 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1084 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1085 >                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1086 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1087 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1088 >                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1089 >                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1090 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1091 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1092 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1093 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1094 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1095 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1096 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1097 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1098 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1099 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1100 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1101 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1102 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1103 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1104 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1105 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1106 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1107 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1108 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1109 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1110 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1111 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1112 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1113 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1114 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1115 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1116 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1117 >
1118 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1119 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1120 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1121 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1122 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1123 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1124 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1125 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1126 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1127 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1128 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1129 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1130 >          }
1131 >          else if(currentHistogram.inputVariables.size() == 2){
1132 >            TH2D* histo;
1133 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1134 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1135 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1136 >            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1137 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1138 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1139 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1140 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1141 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1142 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1143 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1144 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1145 >            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1146 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1147 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1148 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1149 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1150 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1151 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1152 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1153 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1154 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1155 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1156 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1157 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1158 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1159 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1160 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1161 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1162 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1163 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1164 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1165 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1166 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1167 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1168 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1169 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1170 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1171 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1172 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1173 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1174 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1175 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1176 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1177 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1178 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1179 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1180 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1181 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1182 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1183 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1184 >                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1185 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1186 >            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1187 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1188 >                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1189 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1190 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1191 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1192 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1193 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1194 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1195 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1196 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1197 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1198 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1199 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1200 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1201 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1202 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1203 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1204 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1205 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1206 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1207 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1208 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1209 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1210 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1211 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1212 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1213 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1214 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1215 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1216 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1217 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1218 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1219 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1220 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1221 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1222 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1223 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1224 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1225 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1226 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1227 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1228 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1229 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1230 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1231 >          }
1232  
1233 <      //fills histograms with the sizes of collections
1233 >        }
1234  
1235 <      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1236 <        
1237 <        string currentObject = objectsToPlot.at(currentObjectIndex);
1238 <        string objectToPlot = "";
1239 <        
1240 <        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1241 <        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1242 <        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1243 <        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1244 <        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1245 <        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1246 <        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1247 <        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1248 <        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1249 <        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1250 <        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1251 <        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1252 <        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1253 <        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1254 <        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1255 <        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1256 <        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1257 <        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1258 <        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1259 <        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1260 <        else objectToPlot = currentObject;
1261 <        
1262 <        string tempCurrentObject = objectToPlot;
1263 <        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1264 <        string histoName = "num" + tempCurrentObject;
1265 <        
1266 <
1267 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1268 <
1269 <        //count the number of objects passing all cuts
1270 <        int numToPlot = 0;
1271 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1272 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1273 <        }
1274 <
1275 <        if(objectToPlot == "primaryvertexs"){
1276 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1277 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1278 <        }
1279 <        else {
1280 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1281 <        }
1282 <      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1235 >
1236 >        //fills histograms with the sizes of collections
1237 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1238 >
1239 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1240 >          string objectToPlot = "";
1241 >
1242 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1243 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1244 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1245 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1246 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1247 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1248 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1249 >          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1250 >          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1251 >          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1252 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1253 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1254 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1255 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1256 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1257 >          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1258 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1259 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1260 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1261 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1262 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1263 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1264 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1265 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1266 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1267 >          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1268 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1269 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1270 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1271 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1272 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1273 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1274 >          else objectToPlot = currentObject;
1275 >
1276 >          string tempCurrentObject = objectToPlot;
1277 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1278 >          string histoName = "num" + tempCurrentObject;
1279 >
1280 >
1281 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1282 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1283 >            int numToPlot = 0;
1284 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1285 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1286 >            }
1287 >
1288 >            if(objectToPlot == "primaryvertexs"){
1289 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1290 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1291 >            }
1292 >            else {
1293 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1294 >            }
1295 >          }
1296 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1297 >
1298 >
1299 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1300 >    } // end loop over cuts
1301 >
1302 >    if (!useEDMFormat_ && eventPassedAllCuts){
1303 >      // Assign BNTree variables
1304 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1305 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1306 >        string coll = brSpecs.inputCollection;
1307 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1308 >
1309 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1310 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1311 >        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1312 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1313 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1314 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1315 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1316 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1317 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1318 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1319 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1320 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1321 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1322 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1323 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1324 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1325 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1326 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1327 >        else if(coll == "stops"
1328 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1329 >      } // end loop over branches
1330 >
1331 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1332 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1333      }
1334  
1335 <  } //end loop over channel
1335 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1336 >
1337 >  } // end loop over channel
1338  
1339    masterCutFlow_->fillCutFlow(masterScaleFactor);
1340  
1341 +  event.put (channelDecisions, "channelDecisions");
1342 +
1343   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1344  
1345  
# Line 1076 | Line 1380 | OSUAnalysis::evaluateTriggers (vector<st
1380    //initialize to false until a chosen trigger is passed
1381    bool triggerDecision = false;
1382  
1383 +  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1384    //loop over all triggers defined in the event
1385    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1386  
1387 +    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1388 +
1389      //we're only interested in triggers that actually passed
1390      if(trigger->pass != 1) continue;
1391  
# Line 1089 | Line 1396 | OSUAnalysis::evaluateTriggers (vector<st
1396      //if the event passes one of the chosen triggers, set triggerDecision to true
1397      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1398        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1399 <    }  
1399 >    }
1400    }
1401 <  //if none of the veto triggers fired:
1401 >
1402 >  printAllTriggers_ = false;  // only print triggers once, not every event
1403 >
1404 >  //if none of the veto triggers fired:
1405    //return the OR of all the chosen triggers
1406    if (triggersToTest.size() != 0) return triggerDecision;
1407    //or if no triggers were defined return true
# Line 1260 | Line 1570 | OSUAnalysis::valueLookup (const BNjet* o
1570    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1571    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1572  
1573 +  //user defined variable
1574 +  else if(variable == "disappTrkLeadingJetID") {
1575 +    value = object->pt > 110
1576 +      && fabs(object->eta) < 2.4
1577 +      && object->chargedHadronEnergyFraction > 0.2
1578 +      && object->neutralHadronEnergyFraction < 0.7
1579 +      && object->chargedEmEnergyFraction < 0.5
1580 +      && object->neutralEmEnergyFraction < 0.7;
1581 +  }
1582 +
1583 +  else if(variable == "disappTrkSubLeadingJetID") {
1584 +    value = object->pt > 30
1585 +      && fabs(object->eta) < 4.5
1586 +      && object->neutralHadronEnergyFraction < 0.7
1587 +      && object->chargedEmEnergyFraction < 0.5;
1588 +  }
1589 +
1590 +  else if(variable == "dPhiMet") {
1591 +    if (const BNmet *met = chosenMET ()) {
1592 +      value = deltaPhi (object->phi, met->phi);
1593 +    } else value = -999;
1594 +  }
1595 +
1596  
1597    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1598  
1599    value = applyFunction(function, value);
1600  
1601    return value;
1602 < }
1602 > } // end jet valueLookup
1603  
1604  
1605   //!muon valueLookup
# Line 1363 | Line 1696 | OSUAnalysis::valueLookup (const BNmuon*
1696    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1697    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1698    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1699 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1700 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1701 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1702 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1703    else if(variable == "rhoPrime") value = object->rhoPrime;
1704    else if(variable == "AEffDr03") value = object->AEffDr03;
1705    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1370 | Line 1707 | OSUAnalysis::valueLookup (const BNmuon*
1707    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1708    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1709    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1710 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1711 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1712 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1713 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1714 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1715    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1716    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1717    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1426 | Line 1768 | OSUAnalysis::valueLookup (const BNmuon*
1768    else if(variable == "time_ndof") value = object->time_ndof;
1769  
1770    //user-defined variables
1771 +  else if(variable == "looseID") {
1772 +    value = object->pt > 10 &&
1773 +      (object->isGlobalMuon  > 0 ||
1774 +       object->isTrackerMuon > 0);
1775 +  }
1776    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1777    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1778    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1779    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1780 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1781    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1782    else if(variable == "metMT") {
1783      if (const BNmet *met = chosenMET ())
# Line 1553 | Line 1901 | OSUAnalysis::valueLookup (const BNmuon*
1901      value = object->isGlobalMuon > 0                \
1902        && object->isPFMuon > 0                        \
1903        && object->normalizedChi2 < 10                \
1904 <                                  && object->numberOfValidMuonHits > 0        \
1904 >      && object->numberOfValidMuonHits > 0        \
1905        && object->numberOfMatchedStations > 1        \
1906        && fabs(object->correctedD0Vertex) < 0.2        \
1907        && fabs(object->correctedDZ) < 0.5        \
# Line 1564 | Line 1912 | OSUAnalysis::valueLookup (const BNmuon*
1912      value = object->isGlobalMuon > 0                \
1913        && object->isPFMuon > 0                        \
1914        && object->normalizedChi2 < 10                \
1915 <                                  && object->numberOfValidMuonHits > 0        \
1915 >      && object->numberOfValidMuonHits > 0        \
1916        && object->numberOfMatchedStations > 1        \
1917        && object->numberOfValidPixelHits > 0        \
1918        && object->numberOfLayersWithMeasurement > 5;
# Line 1619 | Line 1967 | OSUAnalysis::valueLookup (const BNmuon*
1967      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1968      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1969      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1970 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1971 <         || fabs (object->correctedDZ / dzError) > 99.0;
1970 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1971 >      || fabs (object->correctedDZ / dzError) > 99.0;
1972      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1973    }
1974  
# Line 1631 | Line 1979 | OSUAnalysis::valueLookup (const BNmuon*
1979    value = applyFunction(function, value);
1980  
1981    return value;
1982 < }
1982 > } // end muon valueLookup
1983 >
1984  
1985   //!electron valueLookup
1986   double
# Line 1896 | Line 2245 | OSUAnalysis::valueLookup (const BNelectr
2245        }
2246    }
2247  
2248 +  else if(variable == "looseID"){
2249 +    value = object->pt > 10
2250 +      && object->mvaNonTrigV0 > 0;
2251 +      }
2252    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2253      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2254      else value = -999;
# Line 2019 | Line 2372 | OSUAnalysis::valueLookup (const BNelectr
2372      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2373      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2374      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2375 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2376 <         || fabs (object->correctedDZ / dzError) > 99.0;
2375 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2376 >      || fabs (object->correctedDZ / dzError) > 99.0;
2377      value = !value;
2378    }
2379  
# Line 2031 | Line 2384 | OSUAnalysis::valueLookup (const BNelectr
2384    value = applyFunction(function, value);
2385  
2386    return value;
2387 < }
2387 > } // end electron valueLookup
2388 >
2389  
2390   //!event valueLookup
2391   double
# Line 2112 | Line 2466 | OSUAnalysis::valueLookup (const BNevent*
2466    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2467    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2468    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2469 <
2469 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2470    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2471  
2472    value = applyFunction(function, value);
2473  
2474    return value;
2475 < }
2475 > } // end event valueLookup
2476 >
2477  
2478   //!tau valueLookup
2479   double
# Line 2166 | Line 2521 | OSUAnalysis::valueLookup (const BNtau* o
2521    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2522    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2523  
2524 <
2524 >  else if (variable == "looseHadronicID") {
2525 >    value = object->pt > 10
2526 >      && object->eta < 2.3
2527 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2528 >      && object->HPSdecayModeFinding > 0
2529 >      && object->HPSagainstElectronLoose > 0
2530 >      && object->HPSagainstMuonTight > 0;
2531 >  }
2532  
2533    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2534  
# Line 2218 | Line 2580 | OSUAnalysis::valueLookup (const BNtau* o
2580    value = applyFunction(function, value);
2581  
2582    return value;
2583 < }
2583 > } // end tau valueLookup
2584 >
2585  
2586   //!met valueLookup
2587   double
# Line 2291 | Line 2654 | OSUAnalysis::valueLookup (const BNmet* o
2654    value = applyFunction(function, value);
2655  
2656    return value;
2657 < }
2657 > } // end met valueLookup
2658 >
2659  
2660   //!track valueLookup
2661   double
# Line 2319 | Line 2683 | OSUAnalysis::valueLookup (const BNtrack*
2683    else if(variable == "numValidHits") value = object->numValidHits;
2684    else if(variable == "isHighPurity") value = object->isHighPurity;
2685  
2322
2686    //additional BNs info for disappTrks
2687 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2688 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2689 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2690 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2691 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2692 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2693 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2694 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2332 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2687 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2688 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2689 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2690 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2691 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2692 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2693 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2694 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2695    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2696 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2696 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2697 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2698 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2699 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2700 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2701 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2702 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2703 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2704 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2705 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2706 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2707 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2708 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2709 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2710 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2711 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2712 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2713 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2714  
2715    //user defined variables
2716    else if(variable == "d0wrtBS") value = (object->vx-events->at(0).BSx)*object->py/object->pt - (object->vy-events->at(0).BSy)*object->px/object->pt;
2717    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2718 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2718 >  else if(variable == "depTrkRp5MinusPt"){
2719 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2720 >           value = 0;
2721 >         }
2722 >         else value =  (object->depTrkRp5 - object->pt);
2723 >  }
2724 >  else if(variable == "depTrkRp3MinusPt"){
2725 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2726 >      value = 0;
2727 >    }
2728 >    else value =  (object->depTrkRp3 - object->pt);
2729 >  }
2730 >
2731 >  else if(variable == "dPhiMet") {
2732 >    if (const BNmet *met = chosenMET ()) {
2733 >      value = deltaPhi (object->phi, met->phi);
2734 >    } else value = -999;
2735 >  }
2736 >  
2737 >  
2738    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2739    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2740    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2364 | Line 2762 | OSUAnalysis::valueLookup (const BNtrack*
2762        pt = object->pt;
2763      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2764    }
2765 +
2766 +
2767    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2768  
2769    else if(variable == "genMatchedPdgId"){
# Line 2416 | Line 2816 | OSUAnalysis::valueLookup (const BNtrack*
2816    value = applyFunction(function, value);
2817  
2818    return value;
2819 < }
2819 > } // end track valueLookup
2820 >
2821  
2822   //!genjet valueLookup
2823   double
# Line 2579 | Line 2980 | OSUAnalysis::valueLookup (const BNmcpart
2980    value = applyFunction(function, value);
2981  
2982    return value;
2983 < }
2983 > } // end mcparticle valueLookup
2984 >
2985  
2986   //!primaryvertex valueLookup
2987   double
# Line 2758 | Line 3160 | OSUAnalysis::valueLookup (const BNphoton
3160    value = applyFunction(function, value);
3161  
3162    return value;
3163 < }
3163 > } // end photon valueLookup
3164 >
3165  
3166   //!supercluster valueLookup
3167   double
# Line 2886 | Line 3289 | OSUAnalysis::valueLookup (const BNmuon*
3289    value = applyFunction(function, value);
3290  
3291    return value;
3292 + } // end muon-muon pair valueLookup
3293 +
3294 +
3295 + //!muon-photon pair valueLookup
3296 + double
3297 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3298 +
3299 +  double value = 0.0;
3300 +
3301 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3302 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3303 +  else if(variable == "photonEta") value = object2->eta;
3304 +  else if(variable == "photonPt") value = object2->pt;
3305 +  else if(variable == "muonEta") value = object1->eta;
3306 +  else if(variable == "photonPhi") value = object2->phi;
3307 +  else if(variable == "muonPhi") value = object1->phi;
3308 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3309 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3310 +  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3311 +  else if(variable == "invMass"){
3312 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3313 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3314 +    value = (fourVector1 + fourVector2).M();
3315 +  }
3316 +  else if(variable == "pt"){
3317 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3318 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3319 +    value = (fourVector1 + fourVector2).Pt();
3320 +  }
3321 +  else if(variable == "threeDAngle")
3322 +    {
3323 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3324 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3325 +      value = (threeVector1.Angle(threeVector2));
3326 +    }
3327 +  else if(variable == "alpha")
3328 +    {
3329 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3330 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3331 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3332 +      value = (pi-threeVector1.Angle(threeVector2));
3333 +    }
3334 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3335 +
3336 +  value = applyFunction(function, value);
3337 +
3338 +  return value;
3339 + }
3340 +
3341 + //!electron-photon pair valueLookup
3342 + double
3343 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3344 +
3345 +  double value = 0.0;
3346 +
3347 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3348 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3349 +  else if(variable == "photonEta") value = object2->eta;
3350 +  else if(variable == "photonPt") value = object2->pt;
3351 +  else if(variable == "electronEta") value = object1->eta;
3352 +  else if(variable == "photonPhi") value = object2->phi;
3353 +  else if(variable == "electronPhi") value = object1->phi;
3354 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3355 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3356 +  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3357 +  else if(variable == "invMass"){
3358 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3359 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3360 +    value = (fourVector1 + fourVector2).M();
3361 +  }
3362 +  else if(variable == "pt"){
3363 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3364 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3365 +    value = (fourVector1 + fourVector2).Pt();
3366 +  }
3367 +  else if(variable == "threeDAngle")
3368 +    {
3369 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3370 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3371 +      value = (threeVector1.Angle(threeVector2));
3372 +    }
3373 +  else if(variable == "alpha")
3374 +    {
3375 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3376 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3377 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3378 +      value = (pi-threeVector1.Angle(threeVector2));
3379 +    }
3380 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3381 +
3382 +  value = applyFunction(function, value);
3383 +
3384 +  return value;
3385   }
3386  
3387   //!electron-electron pair valueLookup
# Line 2943 | Line 3439 | OSUAnalysis::valueLookup (const BNelectr
3439  
3440    return value;
3441   }
3442 +
3443   //!electron-muon pair valueLookup
3444   double
3445   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3007 | Line 3504 | OSUAnalysis::valueLookup (const BNelectr
3504    value = applyFunction(function, value);
3505  
3506    return value;
3507 < }
3507 > } // end electron-muon pair valueLookup
3508 >
3509  
3510   //!electron-jet pair valueLookup
3511   double
# Line 3017 | Line 3515 | OSUAnalysis::valueLookup (const BNelectr
3515  
3516    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3517    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3518 +  else if(variable == "jetEta") value = object2->eta;
3519 +  else if(variable == "jetPhi") value = object2->phi;
3520 +  else if(variable == "electronEta") value = object1->eta;
3521 +  else if(variable == "electronPhi") value = object1->phi;
3522    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3523    else if(variable == "invMass"){
3524      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3044 | Line 3546 | OSUAnalysis::valueLookup (const BNelectr
3546    return value;
3547   }
3548  
3549 + //!photon-jet pair valueLookup
3550 + double
3551 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3552 +
3553 +  double value = 0.0;
3554 +
3555 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3556 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3557 +  else if(variable == "jetEta") value = object2->eta;
3558 +  else if(variable == "jetPhi") value = object2->phi;
3559 +  else if(variable == "photonEta") value = object1->eta;
3560 +  else if(variable == "photonPhi") value = object1->phi;
3561 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3562 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3563 +  else if(variable == "invMass"){
3564 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3565 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3566 +    value = (fourVector1 + fourVector2).M();
3567 +  }
3568 +  else if(variable == "pt"){
3569 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3570 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3571 +    value = (fourVector1 + fourVector2).Pt();
3572 +  }
3573 +  else if(variable == "threeDAngle")
3574 +    {
3575 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3576 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3577 +      value = (threeVector1.Angle(threeVector2));
3578 +    }
3579 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3580 +  value = applyFunction(function, value);
3581 +
3582 +  return value;
3583 + }
3584 +
3585 + // track-jet pair valueLookup
3586 + double
3587 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3588 +
3589 +  double value = 0.0;
3590 +
3591 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3592 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3593 +
3594 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3595 +  value = applyFunction(function, value);
3596 +
3597 +  return value;
3598 +
3599 + }
3600 +
3601 +
3602 +
3603 + // met-jet pair valueLookup
3604 + double
3605 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3606 +
3607 +  double value = 0.0;
3608 +
3609 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3610 +
3611 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3612 +  value = applyFunction(function, value);
3613 +
3614 +  return value;
3615 +
3616 + }  
3617 +
3618 +
3619 +
3620   //!muon-jet pair valueLookup
3621   double
3622   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3051 | Line 3624 | OSUAnalysis::valueLookup (const BNmuon*
3624    double value = 0.0;
3625  
3626    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3627 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3627 >  else if(variable == "jetEta") value = object2->eta;
3628 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3629 >  else if(variable == "jetPt") value = object2->pt;
3630 >  else if(variable == "jetPhi") value = object2->phi;
3631 >  else if(variable == "muonEta") value = object1->eta;
3632 >  else if(variable == "muonPt") value = object1->pt;
3633 >  else if(variable == "muonPhi") value = object1->phi;
3634 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3635    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3636    else if(variable == "invMass"){
3637      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3079 | Line 3659 | OSUAnalysis::valueLookup (const BNmuon*
3659    return value;
3660   }
3661  
3662 + //!muon-event valueLookup
3663 + double
3664 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3665 +
3666 +  double value = 0.0;
3667 +
3668 +  if(variable == "muonEta") value = object1->eta;
3669 +  else if(variable == "muonPt") value = object1->pt;
3670 +  else if(variable == "muonPhi") value = object1->phi;
3671 +  else if(variable == "pthat")   value = object2->pthat;
3672 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3673 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3674 +  value = applyFunction(function, value);
3675 +
3676 +  return value;
3677 + }
3678   //!jet-jet pair valueLookup
3679   double
3680   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3114 | Line 3710 | OSUAnalysis::valueLookup (const BNjet* o
3710  
3711    return value;
3712   }
3713 +
3714   //!electron-track pair valueLookup
3715   double
3716   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3381 | Line 3978 | OSUAnalysis::valueLookup (const BNstop*
3978      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3979        vertex_rank++;
3980        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3981 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3982 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3981 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3982 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3983  
3984        if(abs(dist) < abs(minDistToVertex)){
3985          value = vertex_rank;
# Line 3400 | Line 3997 | OSUAnalysis::valueLookup (const BNstop*
3997  
3998    return value;
3999  
4000 < }
4000 > } // end stop valueLookup
4001 >
4002  
4003  
4004  
# Line 3546 | Line 4144 | void OSUAnalysis::setObjectFlags(cut &cu
4144      string obj1, obj2;
4145      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4146      if (inputType==obj1 ||
4147 <          inputType==obj2) {
4147 >        inputType==obj2) {
4148        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4149        // and the inputType is a member of the pair.
4150        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3558 | Line 4156 | void OSUAnalysis::setObjectFlags(cut &cu
4156  
4157    for (uint object = 0; object != inputCollection->size(); object++){
4158  
4159 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4159 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4160 >    bool plotDecision = true;
4161  
4162      if(currentCut.inputCollection == inputType){
4163  
# Line 3570 | Line 4169 | void OSUAnalysis::setObjectFlags(cut &cu
4169          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4170  
4171        }
4172 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4172 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4173        else{
4174          bool tempDecision = true;
4175          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3579 | Line 4178 | void OSUAnalysis::setObjectFlags(cut &cu
4178            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4179              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4180          }
4181 <        decision = tempDecision;
4181 >        cutDecision = tempDecision;
4182        }
4183 +      //invert the cut for plotting if this cut is a veto
4184 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4185 +      else plotDecision = cutDecision;
4186      }
4187  
4188 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4188 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4189  
4190 <    //set flags for objects that pass each cut AND all the previous cuts
4191 <    bool previousCumulativeFlag = true;
4190 >    //set flags for objects that pass this cut AND all the previous cuts
4191 >    bool previousCumulativeCutFlag = true;
4192      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4193 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4194 <      else{ previousCumulativeFlag = false; break;}
4193 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4194 >      else{ previousCumulativeCutFlag = false; break;}
4195      }
4196 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4196 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4197 >    bool previousCumulativePlotFlag = true;
4198 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4199 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4200 >      else{ previousCumulativePlotFlag = false; break;}
4201 >    }
4202 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4203 >
4204 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4205  
4206    }
4207  
# Line 3600 | Line 4210 | void OSUAnalysis::setObjectFlags(cut &cu
4210  
4211   template <class InputCollection1, class InputCollection2>
4212   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4213 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4213 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4214  
4215  
4216    bool sameObjects = false;
# Line 3616 | Line 4226 | void OSUAnalysis::setObjectFlags(cut &cu
4226    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4227    if (currentCut.inputCollection == inputType) {
4228      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4229 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4230 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4229 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4230 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4231      }
4232      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4233        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4234 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4235 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4234 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4235 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4236        }
4237      }
4238    }
# Line 3635 | Line 4245 | void OSUAnalysis::setObjectFlags(cut &cu
4245        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4246  
4247  
4248 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4248 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4249 >      bool plotDecision = true;
4250  
4251        if(currentCut.inputCollection == inputType){
4252  
# Line 3647 | Line 4258 | void OSUAnalysis::setObjectFlags(cut &cu
4258            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4259          }
4260  
4261 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4261 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4262          else{
4263            bool tempDecision = subcutDecisions.at(0);
4264            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3656 | Line 4267 | void OSUAnalysis::setObjectFlags(cut &cu
4267              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4268                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4269            }
4270 <          decision = tempDecision;
4270 >          cutDecision = tempDecision;
4271          }
4272 +        //invert the cut for plotting if this cut is a veto
4273 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4274 +        else plotDecision = cutDecision;
4275 +      }
4276 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4277 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4278 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4279 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4280 +      }
4281 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4282 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4283 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4284        }
4285 <      // if (decision) isPassObj1.at(object1) = true;
4286 <      // if (decision) isPassObj2.at(object2) = true;
4287 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4288 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4289 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4290 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4285 >
4286 >      //set flags for objects that pass this cut AND all the previous cuts
4287 >      bool previousCumulativeCutFlag = true;
4288 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4289 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4290 >        else{ previousCumulativeCutFlag = false; break;}
4291        }
4292 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4293  
4294 <      //set flags for objects that pass each cut AND all the previous cuts
3671 <      bool previousCumulativeFlag = true;
4294 >      bool previousCumulativePlotFlag = true;
4295        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4296 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4297 <        else{ previousCumulativeFlag = false; break;}
4296 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4297 >        else{ previousCumulativePlotFlag = false; break;}
4298        }
4299 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4300 +      
4301        //apply flags for the components of the composite object as well
4302 <      bool currentCumulativeFlag = true;
4303 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4304 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4305 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4306 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4307 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4308 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4309 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4310 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4302 >      bool currentCumulativeCutFlag = true;
4303 >      bool currentCumulativePlotFlag = true;
4304 >
4305 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4306 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4307 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4308 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4309 >
4310 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4311 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4312 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4313 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4314 >
4315 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4316 >
4317 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4318 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4319 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4320 >      }
4321 >
4322 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4323 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4324 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4325        }
4326 +
4327        counter++;
4328  
4329      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3692 | Line 4332 | void OSUAnalysis::setObjectFlags(cut &cu
4332   }
4333  
4334  
4335 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4335 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4336    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4337    // all cuts up to currentCutIndex
4338    bool previousCumulativeFlag = true;
4339    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4340 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4340 >    bool tempFlag = false;
4341 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4342 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4343 >
4344 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4345      else {
4346        previousCumulativeFlag = false; break;
4347      }
# Line 3706 | Line 4350 | bool OSUAnalysis::getPreviousCumulativeF
4350   }
4351  
4352  
4353 +
4354 +
4355   template <class InputCollection>
4356 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4356 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4357 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4358 >
4359 >  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;
4360 >  for (uint object = 0; object != inputCollection->size(); object++) {
4361 >
4362 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4363 >
4364 >    string inputVariable = parameters.inputVariable;
4365 >    string function = "";
4366 >    string stringValue = "";
4367 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4368 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4369 >
4370 >  }
4371 > }
4372 >
4373 >
4374 > template <class InputCollection>
4375 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4376 >
4377  
4378    for (uint object = 0; object != inputCollection->size(); object++){
4379  
4380 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4380 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4381  
4382      string currentString = parameters.inputVariables.at(0);
4383      string inputVariable = "";
# Line 3728 | Line 4394 | void OSUAnalysis::fill1DHistogram(TH1* h
4394      string stringValue = "";
4395      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4396      histo->Fill(value,scaleFactor);
4397 +
4398      if (printEventInfo_) {
4399        // Write information about event to screen, for testing purposes.
4400        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
# Line 3737 | Line 4404 | void OSUAnalysis::fill1DHistogram(TH1* h
4404   }
4405  
4406   template <class InputCollection1, class InputCollection2>
4407 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4407 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4408  
4409    bool sameObjects = false;
4410    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3750 | Line 4417 | void OSUAnalysis::fill1DHistogram(TH1* h
4417  
4418        pairCounter++;
4419        //only take objects which have passed all cuts and pairs which have passed all cuts
4420 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4421 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4422 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4420 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4421 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4422 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4423  
4424        string currentString = parameters.inputVariables.at(0);
4425        string inputVariable = "";
# Line 3777 | Line 4444 | void OSUAnalysis::fill1DHistogram(TH1* h
4444  
4445  
4446   template <class InputCollection>
4447 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4447 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4448  
4449    for (uint object = 0; object != inputCollection->size(); object++){
4450  
4451 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4451 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4452  
4453      string stringValue = "";
4454      string currentString = parameters.inputVariables.at(0);
# Line 3818 | Line 4485 | void OSUAnalysis::fill2DHistogram(TH2* h
4485   }
4486  
4487   template <class InputCollection1, class InputCollection2>
4488 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4488 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4489  
4490    bool sameObjects = false;
4491    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3832 | Line 4499 | void OSUAnalysis::fill2DHistogram(TH2* h
4499        pairCounter++;
4500  
4501        //only take objects which have passed all cuts and pairs which have passed all cuts
4502 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4503 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4504 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4502 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4503 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4504 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4505  
4506        string stringValue = "";
4507        string currentString = parameters.inputVariables.at(0);
# Line 3994 | Line 4661 | OSUAnalysis::chosenVertex ()
4661   {
4662    const BNprimaryvertex *chosenVertex = 0;
4663    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4664 <    vector<bool> vertexFlags;
4664 >    flagPair vertexFlags;
4665      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4666        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4667          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4002 | Line 4669 | OSUAnalysis::chosenVertex ()
4669        }
4670      }
4671      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4672 <      if(!vertexFlags.at(vertexIndex)) continue;
4672 >      if(!vertexFlags.at(vertexIndex).first) continue;
4673        chosenVertex = & primaryvertexs->at(vertexIndex);
4674        break;
4675      }
# Line 4018 | Line 4685 | OSUAnalysis::chosenMET ()
4685   {
4686    const BNmet *chosenMET = 0;
4687    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4688 <    vector<bool> metFlags;
4688 >    flagPair metFlags;
4689      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4690        if (cumulativeFlags.at("mets").at(i).size()){
4691          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4026 | Line 4693 | OSUAnalysis::chosenMET ()
4693        }
4694      }
4695      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4696 <      if(!metFlags.at(metIndex)) continue;
4696 >      if(!metFlags.at(metIndex).first) continue;
4697        chosenMET = & mets->at(metIndex);
4698        break;
4699      }
# Line 4042 | Line 4709 | OSUAnalysis::chosenElectron ()
4709   {
4710    const BNelectron *chosenElectron = 0;
4711    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4712 <    vector<bool> electronFlags;
4712 >    flagPair electronFlags;
4713      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4714        if (cumulativeFlags.at("electrons").at(i).size()){
4715          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4050 | Line 4717 | OSUAnalysis::chosenElectron ()
4717        }
4718      }
4719      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4720 <      if(!electronFlags.at(electronIndex)) continue;
4720 >      if(!electronFlags.at(electronIndex).first) continue;
4721        chosenElectron = & electrons->at(electronIndex);
4722        break;
4723      }
# Line 4061 | Line 4728 | OSUAnalysis::chosenElectron ()
4728    return chosenElectron;
4729   }
4730  
4731 +
4732   const BNmuon *
4733   OSUAnalysis::chosenMuon ()
4734   {
4735    const BNmuon *chosenMuon = 0;
4736    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4737 <    vector<bool> muonFlags;
4737 >    flagPair muonFlags;
4738      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4739        if (cumulativeFlags.at("muons").at(i).size()){
4740          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4074 | Line 4742 | OSUAnalysis::chosenMuon ()
4742        }
4743      }
4744      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4745 <      if(!muonFlags.at(muonIndex)) continue;
4745 >      if(!muonFlags.at(muonIndex).first) continue;
4746        chosenMuon = & muons->at(muonIndex);
4747        break;
4748      }
# Line 4085 | Line 4753 | OSUAnalysis::chosenMuon ()
4753    return chosenMuon;
4754   }
4755  
4756 +
4757   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines