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.70 by qpython, Wed May 29 15:29:27 2013 UTC vs.
Revision 1.95 by jbrinson, Tue Jul 9 08:16:18 2013 UTC

# Line 28 | Line 28 | OSUAnalysis::OSUAnalysis (const edm::Par
28    datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
32 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
33    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
34    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
35    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
36 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
38 >  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
39 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
40 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
41    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
42    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
43    GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
44 < {
44 > {
45  
46    TH1::SetDefaultSumw2 ();
47  
# Line 46 | Line 52 | OSUAnalysis::OSUAnalysis (const edm::Par
52        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
53        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
54      }
55 +    if (applyBtagSF_){
56 +      bTagSFWeight_ = new BtagSFWeight;
57 +    }
58    }
59    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
60      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 57 | Line 66 | OSUAnalysis::OSUAnalysis (const edm::Par
66  
67    //always get vertex collection so we can assign the primary vertex in the event
68    objectsToGet.push_back("primaryvertexs");
60
61  //always make the plot of number of primary vertices (to check pile-up reweighting)
69    objectsToPlot.push_back("primaryvertexs");
70 +  objectsToCut.push_back("primaryvertexs");
71 +
72  
73    //always get the MC particles to do GEN-matching
74    objectsToGet.push_back("mcparticles");
# Line 67 | Line 76 | OSUAnalysis::OSUAnalysis (const edm::Par
76    //always get the event collection to do pile-up reweighting
77    objectsToGet.push_back("events");
78  
79 +
80 +  // Parse the tree variable definitions.
81 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
82 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
83 +    if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
84 +    objectsToGet.push_back(tempInputCollection);
85 +    objectsToCut.push_back(tempInputCollection);
86 +
87 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
88 +
89 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
90 +      BranchSpecs br;
91 +      br.inputCollection = tempInputCollection;
92 +      br.inputVariable = branchList.at(iBranch);
93 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
94 +      br.name = string(newName.Data());
95 +      treeBranches_.push_back(br);
96 +    }
97 +
98 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
99 +
100 +
101    //parse the histogram definitions
102    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
103  
104      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
105      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
106 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
107 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
108      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
109 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
110      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
111 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
112 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
113      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
114      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
115 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet 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 90 | Line 130 | OSUAnalysis::OSUAnalysis (const edm::Par
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
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);
# Line 105 | Line 144 | OSUAnalysis::OSUAnalysis (const edm::Par
144        objectsToGet.push_back(tempInputCollection);
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147 +    } // end else
148 +
149  
109    }
150  
151      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
152  
# Line 127 | 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 212 | Line 253 | OSUAnalysis::OSUAnalysis (const edm::Par
253      //set triggers for this channel
254      vector<string> triggerNames;
255      triggerNames.clear();
256 +    vector<string> triggerToVetoNames;
257 +    triggerToVetoNames.clear();
258 +
259      tempChannel.triggers.clear();
260 +    tempChannel.triggersToVeto.clear();
261      if(channels_.at(currentChannel).exists("triggers")){
262        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
263        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
264          tempChannel.triggers.push_back(triggerNames.at(trigger));
265        objectsToGet.push_back("triggers");
266      }
267 <
267 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
268 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
269 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
270 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
271 >      objectsToGet.push_back("triggers");
272 >    }
273  
274  
275  
276      //create cutFlow for this channel
277      cutFlows_.push_back (new CutFlow (fs_, channelName));
278      vector<TFileDirectory> directories; //vector of directories in the output file.
279 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
280      vector<string> subSubDirNames;//subdirectories in each channel.
281      //get list of cuts for this channel
282      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 237 | Line 288 | OSUAnalysis::OSUAnalysis (const edm::Par
288        //store input collection for cut
289        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
290        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
291 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
292 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
293        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
294        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
295 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
296 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
297 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
298        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
299        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
300 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
301 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
302 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
303 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
304        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
305        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
306        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 310 | Line 370 | OSUAnalysis::OSUAnalysis (const edm::Par
370        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
371        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
372  
373 <      //Set up vectors to store the directories and subDIrectories for each channel.
373 >      //Set up vectors to store the directories and subDirectories for each channel.
374        string subSubDirName;
375        string tempCutName;
376        if(cuts_.at(currentCut).exists("alias")){
377          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
378 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
378 >        subSubDirName = "After " + tempCutName + " Cut Applied";
379        }
380        else{
381          //construct string for cutflow table
# Line 326 | Line 386 | OSUAnalysis::OSUAnalysis (const edm::Par
386          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
387        }
388  
389 +      tempCut.isVeto = false;
390 +      if(cuts_.at(currentCut).exists("isVeto")){
391 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
392 +        if (isVeto == true) tempCut.isVeto = true;
393 +      }
394        subSubDirNames.push_back(subSubDirName);
395        tempCut.name = tempCutName;
396  
# Line 340 | Line 405 | OSUAnalysis::OSUAnalysis (const edm::Par
405      TFileDirectory subDir = fs_->mkdir( channelName );
406      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
407      if(GetPlotsAfterEachCut_){
408 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
409 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
410 <            directories.push_back(subSubDir);
411 <            map<string, TH1D*> oneDhistoMap;
412 <            oneDHistsTmp.push_back(oneDhistoMap);
413 <            map<string, TH2D*> twoDhistoMap;
414 <            twoDHistsTmp.push_back(twoDhistoMap);
408 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
409 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
410 >        directories.push_back(subSubDir);
411 >        map<string, TH1D*> oneDhistoMap;
412 >        oneDHistsTmp.push_back(oneDhistoMap);
413 >        map<string, TH2D*> twoDhistoMap;
414 >        twoDHistsTmp.push_back(twoDhistoMap);
415        }
416 +      treeDirectories.push_back(subDir);
417        oneDHists_.push_back(oneDHistsTmp);
418        twoDHists_.push_back(twoDHistsTmp);
419      }
420 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
421 <   else{
420 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
421 >    else{
422        map<string, TH1D*> oneDhistoMap;
423        oneDHistsTmp.push_back(oneDhistoMap);
424        map<string, TH2D*> twoDhistoMap;
# Line 360 | Line 426 | OSUAnalysis::OSUAnalysis (const edm::Par
426        oneDHists_.push_back(oneDHistsTmp);
427        twoDHists_.push_back(twoDHistsTmp);
428        directories.push_back(subDir);
429 <   }
429 >      treeDirectories.push_back(subDir);
430 >
431 >    }
432 >
433 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
434 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
435 >      BNTrees_.push_back(newTree);
436 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
437 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
438 >        vector<float> newVec;
439 >        BNTreeBranchVals_[currentVar.name] = newVec;
440 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
441 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
442 >    }
443 >
444      //book all histograms included in the configuration
445      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
446 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
447 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
448 <      int numBinsElements = currentHistogram.bins.size();
449 <      int numInputVariables = currentHistogram.inputVariables.size();
450 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
451 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
452 <
453 <      if(numBinsElements == 1){
454 <        if(numBinEdgesX > 1){
455 <          if(numBinEdgesY > 1)
456 <            numBinsElements = 6;
446 >
447 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
448 >
449 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
450 >        int numBinsElements = currentHistogram.bins.size();
451 >        int numInputVariables = currentHistogram.inputVariables.size();
452 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
453 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
454 >
455 >        if(numBinsElements == 1){
456 >          if(numBinEdgesX > 1){
457 >            if(numBinEdgesY > 1)
458 >              numBinsElements = 6;
459 >            else
460 >              numBinsElements = 3;
461 >          }
462 >        }
463 >        if(numBinsElements != 3 && numBinsElements !=6){
464 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
465 >          exit(0);
466 >        }
467 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
468 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
469 >          exit(0);
470 >        }
471 >        else if(numBinsElements == 3){
472 >          if (currentHistogram.bins.size () == 3)
473 >            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));
474            else
475 <            numBinsElements = 3;
475 >            {
476 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
477 >            }
478          }
479 <      }
480 <      if(numBinsElements != 3 && numBinsElements !=6){
481 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
482 <        exit(0);
483 <      }
484 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
485 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
486 <        exit(0);
487 <      }
488 <      else if(numBinsElements == 3){
489 <        if (currentHistogram.bins.size () == 3)
490 <          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));
491 <        else
492 <          {
493 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
479 >        else if(numBinsElements == 6){
480 >          if (currentHistogram.bins.size () == 6)
481 >            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));
482 >          else
483 >            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 ());
484 >        }
485 >
486 >
487 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
488 >
489 >        // bin      particle type
490 >        // ---      -------------
491 >        //  0        unmatched
492 >        //  1        u
493 >        //  2        d
494 >        //  3        s
495 >        //  4        c
496 >        //  5        b
497 >        //  6        t
498 >        //  7        e
499 >        //  8        mu
500 >        //  9        tau
501 >        // 10        nu
502 >        // 11        g
503 >        // 12        gamma
504 >        // 13        Z
505 >        // 14        W
506 >        // 15        light meson
507 >        // 16        K meson
508 >        // 17        D meson
509 >        // 18        B meson
510 >        // 19        light baryon
511 >        // 20        strange baryon
512 >        // 21        charm baryon
513 >        // 22        bottom baryon
514 >        // 23        QCD string
515 >        // 24        other
516 >
517 >        vector<TString> labelArray;
518 >        labelArray.push_back("unmatched");
519 >        labelArray.push_back("u");
520 >        labelArray.push_back("d");
521 >        labelArray.push_back("s");
522 >        labelArray.push_back("c");
523 >        labelArray.push_back("b");
524 >        labelArray.push_back("t");
525 >        labelArray.push_back("e");
526 >        labelArray.push_back("#mu");
527 >        labelArray.push_back("#tau");
528 >        labelArray.push_back("#nu");
529 >        labelArray.push_back("g");
530 >        labelArray.push_back("#gamma");
531 >        labelArray.push_back("Z");
532 >        labelArray.push_back("W");
533 >        labelArray.push_back("light meson");
534 >        labelArray.push_back("K meson");
535 >        labelArray.push_back("D meson");
536 >        labelArray.push_back("B meson");
537 >        labelArray.push_back("light baryon");
538 >        labelArray.push_back("strange baryon");
539 >        labelArray.push_back("charm baryon");
540 >        labelArray.push_back("bottom baryon");
541 >        labelArray.push_back("QCD string");
542 >        labelArray.push_back("other");
543 >
544 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
545 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
546 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
547            }
548 <      }
549 <      else if(numBinsElements == 6){
550 <        if (currentHistogram.bins.size () == 6)
551 <          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));
552 <        else
553 <          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 ());
554 <      }
548 >          else {
549 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
550 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
551 >          }
552 >        }
553 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
554 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
555 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
556 >        }
557  
558 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
559  
405      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
560  
561 <      // bin      particle type
562 <      // ---      -------------
563 <      //  0        unmatched
564 <      //  1        u
565 <      //  2        d
566 <      //  3        s
567 <      //  4        c
568 <      //  5        b
569 <      //  6        t
570 <      //  7        e
571 <      //  8        mu
572 <      //  9        tau
573 <      // 10        nu
574 <      // 11        g
575 <      // 12        gamma
576 <      // 13        Z
577 <      // 14        W
578 <      // 15        light meson
579 <      // 16        K meson
580 <      // 17        D meson
581 <      // 18        B meson
582 <      // 19        light baryon
583 <      // 20        strange baryon
584 <      // 21        charm baryon
585 <      // 22        bottom baryon
586 <      // 23        QCD string
587 <      // 24        other
588 <
589 <      vector<TString> labelArray;
590 <      labelArray.push_back("unmatched");
591 <      labelArray.push_back("u");
592 <      labelArray.push_back("d");
593 <      labelArray.push_back("s");
594 <      labelArray.push_back("c");
595 <      labelArray.push_back("b");
596 <      labelArray.push_back("t");
597 <      labelArray.push_back("e");
598 <      labelArray.push_back("#mu");
599 <      labelArray.push_back("#tau");
600 <      labelArray.push_back("#nu");
601 <      labelArray.push_back("g");
602 <      labelArray.push_back("#gamma");
603 <      labelArray.push_back("Z");
604 <      labelArray.push_back("W");
605 <      labelArray.push_back("light meson");
606 <      labelArray.push_back("K meson");
607 <      labelArray.push_back("D meson");
608 <      labelArray.push_back("B meson");
455 <      labelArray.push_back("light baryon");
456 <      labelArray.push_back("strange baryon");
457 <      labelArray.push_back("charm baryon");
458 <      labelArray.push_back("bottom baryon");
459 <      labelArray.push_back("QCD string");
460 <      labelArray.push_back("other");
461 <
462 <      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
463 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
464 <          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
465 <        }
466 <        else {
467 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
468 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
469 <        }
470 <      }
471 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
472 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
473 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
474 <      }
475 <
476 <    }
477 <
478 <    // Book a histogram for the number of each object type to be plotted.
479 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
480 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
481 <      string currentObject = objectsToPlot.at(currentObjectIndex);
482 <      int maxNum = 10;
483 <      if(currentObject == "mcparticles") maxNum = 50;
484 <      else if(currentObject == "primaryvertexs") maxNum = 50;
485 <
486 <      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
487 <      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
488 <      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
489 <      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
490 <      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
491 <      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
492 <      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
493 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
494 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
495 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
496 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
497 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
498 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
499 <      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
500 <      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
501 <      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
502 <      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
503 <      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
504 <      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
505 <
506 <      currentObject.at(0) = toupper(currentObject.at(0));
507 <      string histoName = "num" + currentObject;
508 <
509 <      if(histoName == "numPrimaryvertexs"){
510 <        string newHistoName = histoName + "BeforePileupCorrection";
511 <        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);
512 <        newHistoName = histoName + "AfterPileupCorrection";
513 <        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);
561 >      // Book a histogram for the number of each object type to be plotted.
562 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
563 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
564 >        string currentObject = objectsToPlot.at(currentObjectIndex);
565 >        int maxNum = 10;
566 >        if(currentObject == "mcparticles") maxNum = 50;
567 >        else if(currentObject == "primaryvertexs") maxNum = 50;
568 >
569 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
570 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
571 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
572 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
573 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
574 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
575 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
576 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
577 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
578 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
579 >        else if(currentObject == "photon-jet pairs")          currentObject = "photonJetPairs";
580 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
581 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
582 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
583 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
584 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
585 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
586 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
587 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
588 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
589 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
590 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
591 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
592 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
593 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
594 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
595 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
596 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
597 >
598 >        currentObject.at(0) = toupper(currentObject.at(0));
599 >        string histoName = "num" + currentObject;
600 >
601 >        if(histoName == "numPrimaryvertexs"){
602 >          string newHistoName = histoName + "BeforePileupCorrection";
603 >          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);
604 >          newHistoName = histoName + "AfterPileupCorrection";
605 >          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);
606 >        }
607 >        else
608 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
609        }
610 <      else
516 <        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
517 <    }
518 <   }//end of loop over directories
610 >    }//end of loop over directories
611      channels.push_back(tempChannel);
612      tempChannel.cuts.clear();
613    }//end loop over channels
# Line 528 | Line 620 | OSUAnalysis::OSUAnalysis (const edm::Par
620    sort( objectsToCut.begin(), objectsToCut.end() );
621    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
622  
623 +  produces<map<string, bool> > ("channelDecisions");
624 +
625 + } // end constructor OSUAnalysis::OSUAnalysis()
626  
532 }
627  
628   OSUAnalysis::~OSUAnalysis ()
629   {
630 +
631    // Destroying the CutFlow objects causes the cut flow numbers and time
632    // information to be printed to standard output.
633    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
634      delete cutFlows_.at(currentChannel);
635    }
636 +
637 +  cout << "=============================================" << endl;  
638 +  cout << "Successfully completed OSUAnalysis." << endl;  
639 +  cout << "=============================================" << endl;  
640 +
641   }
642  
643   void
644 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
644 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
645   {
546
646    // Retrieve necessary collections from the event.
647  
648    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 608 | Line 707 | OSUAnalysis::analyze (const edm::Event &
707  
708    //get pile-up event weight
709    if (doPileupReweighting_ && datasetType_ != "data") {
710 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  This will give an incorrect pile-up weight." << endl;  
711 < else
712 <    masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
710 >    //for "data" datasets, the numTruePV is always set to -1
711 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
712 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
713    }
714  
715    stopCTauScaleFactor_ = 1.0;
# Line 620 | Line 719 | else
719  
720    //loop over all channels
721  
722 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
723    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
724      channel currentChannel = channels.at(currentChannelIndex);
725  
# Line 627 | Line 727 | else
727      counterMap passingCounter;
728      cumulativeFlags.clear ();
729  
730 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
731 +         iter != BNTreeBranchVals_.end(); iter++) {
732 +      iter->second.clear();  // clear array
733 +    }
734 +
735      bool triggerDecision = true;
736 <    if(currentChannel.triggers.size() != 0){  //triggers specified
737 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
736 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
737 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
738        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
739      }
740  
# Line 640 | Line 745 | else
745          string currentObject = objectsToCut.at(currentObjectIndex);
746  
747          //initialize maps to get ready to set cuts
748 <        individualFlags[currentObject].push_back (vector<bool> ());
749 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
748 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
749 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
750  
751        }
752        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
# Line 676 | Line 781 | else
781                                                                     "muon-muon pairs");
782  
783          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
784 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
785 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
786 <                                                                   "muon-secondary muon pairs");
784 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
785 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
786 >                                                                             "muon-secondary muon pairs");
787 >
788 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
789 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
790 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
791 >                                                                             "muon-secondary jet pairs");
792 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
793 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
794 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
795 >                                                                             "photon-secondary jet pairs");
796 >
797 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
798 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
799 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
800 >                                                                             "electron-secondary jet pairs");
801  
802          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
803 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
804 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
805 <                                                                   "electron-secondary electron pairs");
803 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
804 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
805 >                                                                                     "electron-secondary electron pairs");
806  
807          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
808                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 694 | Line 813 | else
813                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
814                                                                         "electron-muon pairs");
815          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
816 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
817 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818 <                                                                           "jet-jet pairs");
816 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
817 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818 >                                                                 "jet-jet pairs");
819 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
820 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
821 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
822 >                                                                 "jet-secondary jet pairs");
823          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
824 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
826 <                                                                       "electron-jet pairs");
824 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
826 >                                                                      "electron-jet pairs");
827 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
828 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
829 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
830 >                                                                      "electron-photon pairs");
831 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
832 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
833 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
834 >                                                                      "photon-jet pairs");
835          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
836 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
837 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 <                                                                       "muon-jet pairs");
836 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
837 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 >                                                                  "muon-jet pairs");
839 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
840 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
841 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
842 >                                                                  "met-jet pairs");
843 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
844 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
845 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
846 >                                                                 "track-jet pairs");
847 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
848 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
849 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
850 >                                                                  "muon-photon pairs");
851          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
852                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
853                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 726 | Line 869 | else
869                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
870                                                                   "tau-tau pairs");
871          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
872 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
873 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
874 <                                                                 "tau-track pairs");
872 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
873 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
874 >                                                                   "tau-track pairs");
875          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
876                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
877                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 746 | Line 889 | else
889      }//end loop over all cuts
890      //use cumulative flags to apply cuts at event level
891  
749    bool eventPassedAllCuts = true;
892      //a vector to store cumulative cut descisions after each cut.
893      vector<bool> eventPassedPreviousCuts;
894 +    bool eventPassedAllCuts = true;
895      //apply trigger (true if none were specified)
896      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
897  
755
898      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
899  
900        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 760 | Line 902 | else
902        int numberPassing = 0;
903  
904        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
905 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
905 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
906        }
907        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
908        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 769 | Line 911 | else
911      }
912      double scaleFactor = masterScaleFactor;
913  
914 <    muonScaleFactor_ = electronScaleFactor_ = 1.0;
914 >    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
915      if(applyLeptonSF_ && datasetType_ != "data"){
916        if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
917 <        vector<bool> muonFlags;
917 >        flagPair muonFlags;
918          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
919            if (cumulativeFlags.at("muons").at(i).size()){
920              muonFlags = cumulativeFlags.at("muons").at(i);
# Line 780 | Line 922 | else
922            }
923          }
924          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
925 <          if(!muonFlags.at(muonIndex)) continue;
925 >          if(!muonFlags.at(muonIndex).second) continue;
926            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
927          }
928        }
929        if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
930 <        vector<bool> electronFlags;
930 >        flagPair electronFlags;
931          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
932            if (cumulativeFlags.at("electrons").at(i).size()){
933              electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 793 | Line 935 | else
935            }
936          }
937          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
938 <          if(!electronFlags.at(electronIndex)) continue;
938 >          if(!electronFlags.at(electronIndex).second) continue;
939            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
940          }
941        }
942      }
943 +    if(applyBtagSF_ && datasetType_ != "data"){
944 +     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
945 +       flagPair jetFlags;
946 +        vector<double> jetSFs;
947 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
948 +          if (cumulativeFlags.at("jets").at(i).size()){
949 +            jetFlags = cumulativeFlags.at("jets").at(i);
950 +            break;
951 +          }
952 +        }
953 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
954 +          if(!jetFlags.at(jetIndex).second) continue;
955 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
956 +          jetSFs.push_back(jetSFTmp);
957 +        }
958 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
959 +      }
960 +    }
961      scaleFactor *= muonScaleFactor_;
962      scaleFactor *= electronScaleFactor_;
963 <
963 >    scaleFactor *= bTagScaleFactor_;
964      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
805    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
965  
966      if (printEventInfo_) {
967        // Write information about event to screen, for testing purposes.
# Line 812 | Line 971 | else
971             << "  event=" << events->at(0).evt
972             << endl;
973      }
974 +
975 +
976      //filling histograms
977      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
978 <        uint currentDir;
979 <        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
980 <        else{
981 <          currentDir = currentCut;
982 <        }
983 <        if(eventPassedPreviousCuts.at(currentDir)){
978 >      uint currentDir;
979 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
980 >      else{
981 >        currentDir = currentCut;
982 >      }
983 >
984 >
985 >      if(eventPassedPreviousCuts.at(currentDir)){
986 >
987          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
988            histogram currentHistogram = histograms.at(histogramIndex);
989  
990 <      if(currentHistogram.inputVariables.size() == 1){
827 <        TH1D* histo;
828 <        histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
829 <        if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
830 <        else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
831 <        else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
832 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
833 <        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
834 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
835 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
836 <                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
837 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
838 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
839 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
840 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
841 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
842 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
843 <                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
844 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
845 <                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
846 <                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
847 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
848 <                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
849 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
850 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
851 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
852 <                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
853 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
854 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
855 <                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
856 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
857 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
858 <                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
859 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
860 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
861 <                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
862 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
863 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
864 <                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
865 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
866 <                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
867 <                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
868 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
869 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
870 <                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
871 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
872 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
873 <                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
874 <        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
875 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
876 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
877 <        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
878 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
879 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
880 <
881 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
882 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
883 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
884 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
885 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
886 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
887 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
888 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
889 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
890 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
891 <        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
892 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
893 <      }
894 <      else if(currentHistogram.inputVariables.size() == 2){
895 <        TH2D* histo;
896 <        histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
897 <        if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
898 <        else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
899 <        else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
900 <        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
901 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
902 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
903 <                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
904 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
905 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
906 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
907 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
908 <        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
909 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
910 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
911 <                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
912 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
913 <                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
914 <                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
915 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
916 <                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
917 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
918 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
919 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
920 <                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
921 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
922 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
923 <                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
924 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
925 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
926 <                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
927 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
928 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
929 <                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
930 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
931 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
932 <                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
933 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
934 <                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
935 <                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
936 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
937 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
938 <                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
939 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
940 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
941 <                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
942 <        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
943 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
944 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
945 <        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
946 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
947 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
948 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
949 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
950 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
951 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
952 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
953 <                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
954 <                                                                                         cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
955 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
956 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
957 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
958 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
959 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
960 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
961 <        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
962 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
963 <      }
964 <    }
990 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
991  
992 +          if(currentHistogram.inputVariables.size() == 1){
993 +            TH1D* histo;
994 +            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
995 +            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
996 +            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
997 +            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
998 +            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
999 +            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1000 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1001 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1002 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1003 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1004 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1005 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1006 +             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1007 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1008 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1009 +             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1010 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1011 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1012 +             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1013 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1014 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1015 +
1016 +            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1017 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1018 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1019 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1020 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1021 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1022 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1023 +             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1024 +                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1025 +                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1026 +
1027 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1028 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1029 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1030 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1031 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1032 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1033 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1034 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1035 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1036 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1037 +                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1038 +                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1039 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1040 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1041 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1042 +            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1043 +                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1044 +                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1045 +            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1046 +                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1047 +                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1048 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1049 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1050 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1051 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1052 +                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1053 +                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1054 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1055 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1056 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1057 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1058 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1059 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1060 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1061 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1062 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1063 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1064 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1065 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1066 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1067 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1068 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1069 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1070 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1071 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1072 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1073 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1074 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1075 +
1076 +            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1077 +            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1078 +            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1079 +            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1080 +            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1081 +            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1082 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1083 +            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1084 +            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1085 +            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1086 +            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1087 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1088 +          }
1089 +          else if(currentHistogram.inputVariables.size() == 2){
1090 +            TH2D* histo;
1091 +            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1092 +            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1093 +            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1094 +            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1095 +            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1096 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1097 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1098 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1099 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1100 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1101 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1102 +            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1103 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1104 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1105 +            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1106 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1107 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1108 +            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1109 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1110 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1111 +            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1112 +            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1113 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1114 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1115 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1116 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1117 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1118 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1119 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1120 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1121 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1122 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1123 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1124 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1125 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1126 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1127 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1128 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1129 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1130 +                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1131 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1132 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1133 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1134 +            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1135 +                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1136 +                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1137 +            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1138 +                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1139 +                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1140 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1141 +                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1142 +                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1143 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1144 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1145 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1146 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1147 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1148 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1149 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1150 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1151 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1152 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1153 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1154 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1155 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1156 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1157 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1158 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1159 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1160 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1161 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1162 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1163 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1164 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1165 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1166 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1167 +            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1168 +            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1169 +            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1170 +            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1171 +            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1172 +                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1173 +                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1174 +            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1175 +            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1176 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1177 +            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1178 +            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1179 +            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1180 +            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1181 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1182 +          }
1183  
1184 +        }
1185  
968    //fills histograms with the sizes of collections
969    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
970
971      string currentObject = objectsToPlot.at(currentObjectIndex);
972      string objectToPlot = "";
973
974      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
975      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
976      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
977      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
978      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
979      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
980      else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
981      else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
982      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
983      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
984      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
985      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
986      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
987      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
988      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
989      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
990      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
991      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
992      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
993      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
994      else objectToPlot = currentObject;
995
996      string tempCurrentObject = objectToPlot;
997      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
998      string histoName = "num" + tempCurrentObject;
999
1000      //set position of primary vertex in event, in order to calculate quantities relative to it
1001      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1002        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1003        int numToPlot = 0;
1004        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1005          if(lastCutFlags.at(currentFlag)) numToPlot++;
1006        }
1007        if(objectToPlot == "primaryvertexs"){
1008          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1009          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1010        }
1011        else {
1012          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1013        }
1014      }
1015      else if(objectToPlot == "jets")           oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1016      else if(objectToPlot == "secondaryJets")  oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1017      else if(objectToPlot == "muons")          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1018      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1019      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1020      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1021      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1022      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1023      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1024      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1025      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1026      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1027      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1028      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1029      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1030      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1031      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1032      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1033      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1034      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1035      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1036      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1037      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1038      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1039      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1040      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1041      else if(objectToPlot == "primaryvertexs"){
1042        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1043        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1044      }
1045      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
1186  
1187 <     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1187 >        //fills histograms with the sizes of collections
1188 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1189 >
1190 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1191 >          string objectToPlot = "";
1192 >
1193 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1194 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1195 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1196 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1197 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1198 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1199 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1200 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1201 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1202 >          else if(currentObject == "muon-photon pairs")                  objectToPlot = "muonPhotonPairs";
1203 >          else if(currentObject == "photon-jet pairs")                   objectToPlot = "photonJetPairs";
1204 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1205 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1206 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1207 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1208 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1209 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1210 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1211 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1212 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1213 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1214 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1215 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1216 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1217 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1218 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1219 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1220 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1221 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1222 >          else objectToPlot = currentObject;
1223 >
1224 >          string tempCurrentObject = objectToPlot;
1225 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1226 >          string histoName = "num" + tempCurrentObject;
1227 >
1228 >
1229 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1230 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1231 >            int numToPlot = 0;
1232 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1233 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1234 >            }
1235 >
1236 >            if(objectToPlot == "primaryvertexs"){
1237 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1238 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1239 >            }
1240 >            else {
1241 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1242 >            }
1243 >          }
1244 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1245 >
1246 >
1247 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1248 >    } // end loop over cuts
1249 >
1250 >    if (!useEDMFormat_ && eventPassedAllCuts){
1251 >      // Assign BNTree variables
1252 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1253 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1254 >        string coll = brSpecs.inputCollection;
1255 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1256 >
1257 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1258 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1259 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1260 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1261 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1262 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1263 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1264 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1265 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1266 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1267 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1268 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1269 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1270 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1271 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1272 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1273 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1274 >        else if(coll == "stops"
1275 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1276 >      } // end loop over branches
1277 >
1278 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1279 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1280      }
1281 <  }
1282 <  } //end loop over channel
1281 >
1282 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1283 >
1284 >  } // end loop over channel
1285  
1286    masterCutFlow_->fillCutFlow(masterScaleFactor);
1287  
1288 +  event.put (channelDecisions, "channelDecisions");
1289 +
1290   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1291  
1292  
# Line 1086 | Line 1322 | OSUAnalysis::evaluateComparison (string
1322   }
1323  
1324   bool
1325 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1325 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1326  
1327 +  //initialize to false until a chosen trigger is passed
1328    bool triggerDecision = false;
1329  
1330 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1331 <    {
1332 <      if(trigger->pass != 1) continue;
1333 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1334 <        {
1335 <          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1336 <            triggerDecision = true;
1337 <          }
1338 <        }
1330 >  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1331 >  //loop over all triggers defined in the event
1332 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1333 >
1334 >    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1335 >
1336 >    //we're only interested in triggers that actually passed
1337 >    if(trigger->pass != 1) continue;
1338 >
1339 >    //if the event passes one of the veto triggers, exit and return false
1340 >    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1341 >      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1342 >    }
1343 >    //if the event passes one of the chosen triggers, set triggerDecision to true
1344 >    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1345 >      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1346      }
1347 <  return triggerDecision;
1347 >  }
1348 >
1349 >  printAllTriggers_ = false;  // only print triggers once, not every event
1350  
1351 +  //if none of the veto triggers fired:
1352 +  //return the OR of all the chosen triggers
1353 +  if (triggersToTest.size() != 0) return triggerDecision;
1354 +  //or if no triggers were defined return true
1355 +  else return true;
1356   }
1357  
1358 +
1359   vector<string>
1360   OSUAnalysis::splitString (string inputString){
1361  
# Line 1265 | Line 1517 | OSUAnalysis::valueLookup (const BNjet* o
1517    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1518    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1519  
1520 +  //user defined variable
1521 +  else if(variable == "disappTrkLeadingJetID") {
1522 +    value = object->pt > 110
1523 +      && fabs(object->eta) < 2.4
1524 +      && object->chargedHadronEnergyFraction > 0.2
1525 +      && object->neutralHadronEnergyFraction < 0.7
1526 +      && object->chargedEmEnergyFraction < 0.5
1527 +      && object->neutralEmEnergyFraction < 0.7;
1528 +  }
1529 +
1530 +  else if(variable == "disappTrkSubLeadingJetID") {
1531 +    value = object->pt > 30
1532 +      && fabs(object->eta) < 4.5
1533 +      && object->neutralHadronEnergyFraction < 0.7
1534 +      && object->chargedEmEnergyFraction < 0.5;
1535 +  }
1536 +
1537 +  else if(variable == "dPhiMet") {
1538 +    if (const BNmet *met = chosenMET ()) {
1539 +      value = deltaPhi (object->phi, met->phi);
1540 +    } else value = -999;
1541 +  }
1542 +
1543  
1544    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1545  
1546    value = applyFunction(function, value);
1547  
1548    return value;
1549 < }
1549 > } // end jet valueLookup
1550  
1551  
1552   //!muon valueLookup
# Line 1431 | Line 1706 | OSUAnalysis::valueLookup (const BNmuon*
1706    else if(variable == "time_ndof") value = object->time_ndof;
1707  
1708    //user-defined variables
1709 +  else if(variable == "looseID") {
1710 +    value = object->pt > 10 &&
1711 +      (object->isGlobalMuon  > 0 ||
1712 +       object->isTrackerMuon > 0);
1713 +  }
1714    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1715    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1716    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
# Line 1558 | Line 1838 | OSUAnalysis::valueLookup (const BNmuon*
1838      value = object->isGlobalMuon > 0                \
1839        && object->isPFMuon > 0                        \
1840        && object->normalizedChi2 < 10                \
1841 <                                  && object->numberOfValidMuonHits > 0        \
1841 >      && object->numberOfValidMuonHits > 0        \
1842        && object->numberOfMatchedStations > 1        \
1843        && fabs(object->correctedD0Vertex) < 0.2        \
1844        && fabs(object->correctedDZ) < 0.5        \
# Line 1569 | Line 1849 | OSUAnalysis::valueLookup (const BNmuon*
1849      value = object->isGlobalMuon > 0                \
1850        && object->isPFMuon > 0                        \
1851        && object->normalizedChi2 < 10                \
1852 <                                  && object->numberOfValidMuonHits > 0        \
1852 >      && object->numberOfValidMuonHits > 0        \
1853        && object->numberOfMatchedStations > 1        \
1854        && object->numberOfValidPixelHits > 0        \
1855        && object->numberOfLayersWithMeasurement > 5;
# Line 1624 | Line 1904 | OSUAnalysis::valueLookup (const BNmuon*
1904      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1905      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1906      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1907 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1908 <         || fabs (object->correctedDZ / dzError) > 99.0;
1907 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1908 >      || fabs (object->correctedDZ / dzError) > 99.0;
1909      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1910    }
1911  
# Line 1636 | Line 1916 | OSUAnalysis::valueLookup (const BNmuon*
1916    value = applyFunction(function, value);
1917  
1918    return value;
1919 < }
1919 > } // end muon valueLookup
1920 >
1921  
1922   //!electron valueLookup
1923   double
# Line 1901 | Line 2182 | OSUAnalysis::valueLookup (const BNelectr
2182        }
2183    }
2184  
2185 +  else if(variable == "looseID"){
2186 +    value = object->pt > 10
2187 +      && object->mvaNonTrigV0 > 0;
2188 +      }
2189    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2190      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2191      else value = -999;
# Line 2024 | Line 2309 | OSUAnalysis::valueLookup (const BNelectr
2309      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2310      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2311      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2312 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2313 <         || fabs (object->correctedDZ / dzError) > 99.0;
2312 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2313 >      || fabs (object->correctedDZ / dzError) > 99.0;
2314      value = !value;
2315    }
2316  
# Line 2036 | Line 2321 | OSUAnalysis::valueLookup (const BNelectr
2321    value = applyFunction(function, value);
2322  
2323    return value;
2324 < }
2324 > } // end electron valueLookup
2325 >
2326  
2327   //!event valueLookup
2328   double
# Line 2117 | Line 2403 | OSUAnalysis::valueLookup (const BNevent*
2403    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2404    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2405    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2406 <
2406 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2407    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2408  
2409    value = applyFunction(function, value);
2410  
2411    return value;
2412 < }
2412 > } // end event valueLookup
2413 >
2414  
2415   //!tau valueLookup
2416   double
# Line 2171 | Line 2458 | OSUAnalysis::valueLookup (const BNtau* o
2458    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2459    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2460  
2461 <
2461 >  else if (variable == "looseHadronicID") {
2462 >    value = object->pt > 10
2463 >      && object->eta < 2.3
2464 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2465 >      && object->HPSdecayModeFinding > 0
2466 >      && object->HPSagainstElectronLoose > 0
2467 >      && object->HPSagainstMuonTight > 0;
2468 >  }
2469  
2470    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2471  
# Line 2223 | Line 2517 | OSUAnalysis::valueLookup (const BNtau* o
2517    value = applyFunction(function, value);
2518  
2519    return value;
2520 < }
2520 > } // end tau valueLookup
2521 >
2522  
2523   //!met valueLookup
2524   double
# Line 2296 | Line 2591 | OSUAnalysis::valueLookup (const BNmet* o
2591    value = applyFunction(function, value);
2592  
2593    return value;
2594 < }
2594 > } // end met valueLookup
2595 >
2596  
2597   //!track valueLookup
2598   double
# Line 2324 | Line 2620 | OSUAnalysis::valueLookup (const BNtrack*
2620    else if(variable == "numValidHits") value = object->numValidHits;
2621    else if(variable == "isHighPurity") value = object->isHighPurity;
2622  
2327
2623    //additional BNs info for disappTrks
2624 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2625 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2626 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2627 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2628 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2629 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2630 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2631 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2337 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2624 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2625 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2626 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2627 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2628 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2629 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2630 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2631 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2632    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2633 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2633 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2634 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2635 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2636 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2637 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2638 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2639 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2640 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2641 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2642 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2643 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2644 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2645 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2646 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2647 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2648 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2649 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2650 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2651  
2652    //user defined variables
2653    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;
2654    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2655 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2655 >  else if(variable == "depTrkRp5MinusPt"){
2656 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2657 >           value = 0;
2658 >         }
2659 >         else value =  (object->depTrkRp5 - object->pt);
2660 >  }
2661 >  else if(variable == "depTrkRp3MinusPt"){
2662 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2663 >      value = 0;
2664 >    }
2665 >    else value =  (object->depTrkRp3 - object->pt);
2666 >  }
2667 >
2668 >  else if(variable == "dPhiMet") {
2669 >    if (const BNmet *met = chosenMET ()) {
2670 >      value = deltaPhi (object->phi, met->phi);
2671 >    } else value = -999;
2672 >  }
2673 >  
2674 >  
2675    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2676    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2677    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2369 | Line 2699 | OSUAnalysis::valueLookup (const BNtrack*
2699        pt = object->pt;
2700      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2701    }
2702 +
2703 +
2704    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2705  
2706    else if(variable == "genMatchedPdgId"){
# Line 2421 | Line 2753 | OSUAnalysis::valueLookup (const BNtrack*
2753    value = applyFunction(function, value);
2754  
2755    return value;
2756 < }
2756 > } // end track valueLookup
2757 >
2758  
2759   //!genjet valueLookup
2760   double
# Line 2584 | Line 2917 | OSUAnalysis::valueLookup (const BNmcpart
2917    value = applyFunction(function, value);
2918  
2919    return value;
2920 < }
2920 > } // end mcparticle valueLookup
2921 >
2922  
2923   //!primaryvertex valueLookup
2924   double
# Line 2763 | Line 3097 | OSUAnalysis::valueLookup (const BNphoton
3097    value = applyFunction(function, value);
3098  
3099    return value;
3100 < }
3100 > } // end photon valueLookup
3101 >
3102  
3103   //!supercluster valueLookup
3104   double
# Line 2891 | Line 3226 | OSUAnalysis::valueLookup (const BNmuon*
3226    value = applyFunction(function, value);
3227  
3228    return value;
3229 + } // end muon-muon pair valueLookup
3230 +
3231 +
3232 + //!muon-photon pair valueLookup
3233 + double
3234 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3235 +
3236 +  double value = 0.0;
3237 +
3238 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3239 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3240 +  else if(variable == "photonEta") value = object2->eta;
3241 +  else if(variable == "muonEta") value = object1->eta;
3242 +  else if(variable == "photonPhi") value = object2->phi;
3243 +  else if(variable == "muonPhi") value = object1->phi;
3244 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3245 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3246 +  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3247 +  else if(variable == "invMass"){
3248 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3249 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3250 +    value = (fourVector1 + fourVector2).M();
3251 +  }
3252 +  else if(variable == "pt"){
3253 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3254 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3255 +    value = (fourVector1 + fourVector2).Pt();
3256 +  }
3257 +  else if(variable == "threeDAngle")
3258 +    {
3259 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3260 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3261 +      value = (threeVector1.Angle(threeVector2));
3262 +    }
3263 +  else if(variable == "alpha")
3264 +    {
3265 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3266 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3267 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3268 +      value = (pi-threeVector1.Angle(threeVector2));
3269 +    }
3270 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3271 +
3272 +  value = applyFunction(function, value);
3273 +
3274 +  return value;
3275 + }
3276 +
3277 + //!electron-photon pair valueLookup
3278 + double
3279 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3280 +
3281 +  double value = 0.0;
3282 +
3283 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3284 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3285 +  else if(variable == "photonEta") value = object2->eta;
3286 +  else if(variable == "electronEta") value = object1->eta;
3287 +  else if(variable == "photonPhi") value = object2->phi;
3288 +  else if(variable == "electronPhi") value = object1->phi;
3289 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3290 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3291 +  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3292 +  else if(variable == "invMass"){
3293 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3294 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3295 +    value = (fourVector1 + fourVector2).M();
3296 +  }
3297 +  else if(variable == "pt"){
3298 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3299 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3300 +    value = (fourVector1 + fourVector2).Pt();
3301 +  }
3302 +  else if(variable == "threeDAngle")
3303 +    {
3304 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3305 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3306 +      value = (threeVector1.Angle(threeVector2));
3307 +    }
3308 +  else if(variable == "alpha")
3309 +    {
3310 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3311 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3312 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3313 +      value = (pi-threeVector1.Angle(threeVector2));
3314 +    }
3315 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3316 +
3317 +  value = applyFunction(function, value);
3318 +
3319 +  return value;
3320   }
3321  
3322   //!electron-electron pair valueLookup
# Line 2948 | Line 3374 | OSUAnalysis::valueLookup (const BNelectr
3374  
3375    return value;
3376   }
3377 +
3378   //!electron-muon pair valueLookup
3379   double
3380   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3012 | Line 3439 | OSUAnalysis::valueLookup (const BNelectr
3439    value = applyFunction(function, value);
3440  
3441    return value;
3442 < }
3442 > } // end electron-muon pair valueLookup
3443 >
3444  
3445   //!electron-jet pair valueLookup
3446   double
# Line 3022 | Line 3450 | OSUAnalysis::valueLookup (const BNelectr
3450  
3451    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3452    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3453 +  else if(variable == "jetEta") value = object2->eta;
3454 +  else if(variable == "jetPhi") value = object2->phi;
3455 +  else if(variable == "electronEta") value = object1->eta;
3456 +  else if(variable == "electronPhi") value = object1->phi;
3457    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3458    else if(variable == "invMass"){
3459      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3049 | Line 3481 | OSUAnalysis::valueLookup (const BNelectr
3481    return value;
3482   }
3483  
3484 + //!photon-jet pair valueLookup
3485 + double
3486 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3487 +
3488 +  double value = 0.0;
3489 +
3490 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3491 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3492 +  else if(variable == "jetEta") value = object2->eta;
3493 +  else if(variable == "jetPhi") value = object2->phi;
3494 +  else if(variable == "photonEta") value = object1->eta;
3495 +  else if(variable == "photonPhi") value = object1->phi;
3496 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3497 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3498 +  else if(variable == "invMass"){
3499 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3500 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3501 +    value = (fourVector1 + fourVector2).M();
3502 +  }
3503 +  else if(variable == "pt"){
3504 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3505 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3506 +    value = (fourVector1 + fourVector2).Pt();
3507 +  }
3508 +  else if(variable == "threeDAngle")
3509 +    {
3510 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3511 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3512 +      value = (threeVector1.Angle(threeVector2));
3513 +    }
3514 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3515 +  value = applyFunction(function, value);
3516 +
3517 +  return value;
3518 + }
3519 +
3520 + // track-jet pair valueLookup
3521 + double
3522 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3523 +
3524 +  double value = 0.0;
3525 +
3526 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3527 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3528 +
3529 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3530 +  value = applyFunction(function, value);
3531 +
3532 +  return value;
3533 +
3534 + }
3535 +
3536 +
3537 +
3538 + // met-jet pair valueLookup
3539 + double
3540 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3541 +
3542 +  double value = 0.0;
3543 +
3544 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3545 +
3546 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3547 +  value = applyFunction(function, value);
3548 +
3549 +  return value;
3550 +
3551 + }  
3552 +
3553 +
3554 +
3555   //!muon-jet pair valueLookup
3556   double
3557   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3056 | Line 3559 | OSUAnalysis::valueLookup (const BNmuon*
3559    double value = 0.0;
3560  
3561    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3562 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3562 >  else if(variable == "jetEta") value = object2->eta;
3563 >  else if(variable == "jetPhi") value = object2->phi;
3564 >  else if(variable == "muonEta") value = object1->eta;
3565 >  else if(variable == "muonPhi") value = object1->phi;
3566 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3567    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3568    else if(variable == "invMass"){
3569      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3083 | Line 3590 | OSUAnalysis::valueLookup (const BNmuon*
3590  
3591    return value;
3592   }
3086
3593   //!jet-jet pair valueLookup
3594   double
3595   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3119 | Line 3625 | OSUAnalysis::valueLookup (const BNjet* o
3625  
3626    return value;
3627   }
3628 +
3629   //!electron-track pair valueLookup
3630   double
3631   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3386 | Line 3893 | OSUAnalysis::valueLookup (const BNstop*
3893      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3894        vertex_rank++;
3895        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3896 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3897 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3896 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3897 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3898  
3899        if(abs(dist) < abs(minDistToVertex)){
3900          value = vertex_rank;
# Line 3405 | Line 3912 | OSUAnalysis::valueLookup (const BNstop*
3912  
3913    return value;
3914  
3915 < }
3915 > } // end stop valueLookup
3916 >
3917  
3918  
3919  
# Line 3551 | Line 4059 | void OSUAnalysis::setObjectFlags(cut &cu
4059      string obj1, obj2;
4060      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4061      if (inputType==obj1 ||
4062 <          inputType==obj2) {
4062 >        inputType==obj2) {
4063        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4064        // and the inputType is a member of the pair.
4065        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3563 | Line 4071 | void OSUAnalysis::setObjectFlags(cut &cu
4071  
4072    for (uint object = 0; object != inputCollection->size(); object++){
4073  
4074 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4074 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4075 >    bool plotDecision = true;
4076  
4077      if(currentCut.inputCollection == inputType){
4078  
# Line 3575 | Line 4084 | void OSUAnalysis::setObjectFlags(cut &cu
4084          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4085  
4086        }
4087 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4087 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4088        else{
4089          bool tempDecision = true;
4090          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3584 | Line 4093 | void OSUAnalysis::setObjectFlags(cut &cu
4093            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4094              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4095          }
4096 <        decision = tempDecision;
4096 >        cutDecision = tempDecision;
4097        }
4098 +      //invert the cut for plotting if this cut is a veto
4099 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4100 +      else plotDecision = cutDecision;
4101      }
4102  
4103 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4103 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4104  
4105 <    //set flags for objects that pass each cut AND all the previous cuts
4106 <    bool previousCumulativeFlag = true;
4105 >    //set flags for objects that pass this cut AND all the previous cuts
4106 >    bool previousCumulativeCutFlag = true;
4107 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4108 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4109 >      else{ previousCumulativeCutFlag = false; break;}
4110 >    }
4111 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4112 >    bool previousCumulativePlotFlag = true;
4113      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4114 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4115 <      else{ previousCumulativeFlag = false; break;}
4114 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4115 >      else{ previousCumulativePlotFlag = false; break;}
4116      }
4117 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4117 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4118 >
4119 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4120  
4121    }
4122  
# Line 3605 | Line 4125 | void OSUAnalysis::setObjectFlags(cut &cu
4125  
4126   template <class InputCollection1, class InputCollection2>
4127   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4128 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4128 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4129  
4130  
4131    bool sameObjects = false;
# Line 3621 | Line 4141 | void OSUAnalysis::setObjectFlags(cut &cu
4141    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4142    if (currentCut.inputCollection == inputType) {
4143      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4144 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4145 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4144 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4145 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4146      }
4147      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4148        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4149 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4150 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4149 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4150 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4151        }
4152      }
4153    }
# Line 3640 | Line 4160 | void OSUAnalysis::setObjectFlags(cut &cu
4160        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4161  
4162  
4163 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4163 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4164 >      bool plotDecision = true;
4165  
4166        if(currentCut.inputCollection == inputType){
4167  
# Line 3652 | Line 4173 | void OSUAnalysis::setObjectFlags(cut &cu
4173            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4174          }
4175  
4176 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4176 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4177          else{
4178            bool tempDecision = subcutDecisions.at(0);
4179            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3661 | Line 4182 | void OSUAnalysis::setObjectFlags(cut &cu
4182              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4183                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4184            }
4185 <          decision = tempDecision;
4185 >          cutDecision = tempDecision;
4186          }
4187 +        //invert the cut for plotting if this cut is a veto
4188 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4189 +        else plotDecision = cutDecision;
4190 +      }
4191 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4192 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4193 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4194 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4195 +      }
4196 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4197 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4198 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4199        }
4200 <      // if (decision) isPassObj1.at(object1) = true;
4201 <      // if (decision) isPassObj2.at(object2) = true;
4202 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4203 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4204 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4205 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4200 >
4201 >      //set flags for objects that pass this cut AND all the previous cuts
4202 >      bool previousCumulativeCutFlag = true;
4203 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4204 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4205 >        else{ previousCumulativeCutFlag = false; break;}
4206        }
4207 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4208  
4209 <      //set flags for objects that pass each cut AND all the previous cuts
3676 <      bool previousCumulativeFlag = true;
4209 >      bool previousCumulativePlotFlag = true;
4210        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4211 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4212 <        else{ previousCumulativeFlag = false; break;}
4211 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4212 >        else{ previousCumulativePlotFlag = false; break;}
4213        }
4214 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4215 +      
4216        //apply flags for the components of the composite object as well
4217 <      bool currentCumulativeFlag = true;
4218 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4219 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4220 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4221 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4222 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4223 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4224 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4225 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4217 >      bool currentCumulativeCutFlag = true;
4218 >      bool currentCumulativePlotFlag = true;
4219 >
4220 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4221 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4222 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4223 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4224 >
4225 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4226 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4227 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4228 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4229 >
4230 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4231 >
4232 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4233 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4234 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4235 >      }
4236 >
4237 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4238 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4239 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4240        }
4241 +
4242        counter++;
4243  
4244      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3697 | Line 4247 | void OSUAnalysis::setObjectFlags(cut &cu
4247   }
4248  
4249  
4250 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4250 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4251    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4252    // all cuts up to currentCutIndex
4253    bool previousCumulativeFlag = true;
4254    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4255 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4255 >    bool tempFlag = false;
4256 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4257 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4258 >
4259 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4260      else {
4261        previousCumulativeFlag = false; break;
4262      }
# Line 3711 | Line 4265 | bool OSUAnalysis::getPreviousCumulativeF
4265   }
4266  
4267  
4268 +
4269 +
4270   template <class InputCollection>
4271 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4271 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4272 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4273 >
4274 >  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;
4275 >  for (uint object = 0; object != inputCollection->size(); object++) {
4276 >
4277 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4278 >
4279 >    string inputVariable = parameters.inputVariable;
4280 >    string function = "";
4281 >    string stringValue = "";
4282 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4283 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4284 >
4285 >  }
4286 > }
4287 >
4288 >
4289 > template <class InputCollection>
4290 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4291 >
4292  
4293    for (uint object = 0; object != inputCollection->size(); object++){
4294  
4295 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4295 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4296  
4297      string currentString = parameters.inputVariables.at(0);
4298      string inputVariable = "";
# Line 3733 | Line 4309 | void OSUAnalysis::fill1DHistogram(TH1* h
4309      string stringValue = "";
4310      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4311      histo->Fill(value,scaleFactor);
4312 +
4313      if (printEventInfo_) {
4314        // Write information about event to screen, for testing purposes.
4315        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
# Line 3742 | Line 4319 | void OSUAnalysis::fill1DHistogram(TH1* h
4319   }
4320  
4321   template <class InputCollection1, class InputCollection2>
4322 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4322 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4323  
4324    bool sameObjects = false;
4325    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3755 | Line 4332 | void OSUAnalysis::fill1DHistogram(TH1* h
4332  
4333        pairCounter++;
4334        //only take objects which have passed all cuts and pairs which have passed all cuts
4335 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4336 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4337 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4335 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4336 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4337 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4338  
4339        string currentString = parameters.inputVariables.at(0);
4340        string inputVariable = "";
# Line 3782 | Line 4359 | void OSUAnalysis::fill1DHistogram(TH1* h
4359  
4360  
4361   template <class InputCollection>
4362 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4362 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4363  
4364    for (uint object = 0; object != inputCollection->size(); object++){
4365  
4366 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4366 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4367  
4368      string stringValue = "";
4369      string currentString = parameters.inputVariables.at(0);
# Line 3823 | Line 4400 | void OSUAnalysis::fill2DHistogram(TH2* h
4400   }
4401  
4402   template <class InputCollection1, class InputCollection2>
4403 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4403 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4404  
4405    bool sameObjects = false;
4406    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3837 | Line 4414 | void OSUAnalysis::fill2DHistogram(TH2* h
4414        pairCounter++;
4415  
4416        //only take objects which have passed all cuts and pairs which have passed all cuts
4417 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4418 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4419 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4417 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4418 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4419 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4420  
4421        string stringValue = "";
4422        string currentString = parameters.inputVariables.at(0);
# Line 3999 | Line 4576 | OSUAnalysis::chosenVertex ()
4576   {
4577    const BNprimaryvertex *chosenVertex = 0;
4578    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4579 <    vector<bool> vertexFlags;
4579 >    flagPair vertexFlags;
4580      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4581        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4582          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4007 | Line 4584 | OSUAnalysis::chosenVertex ()
4584        }
4585      }
4586      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4587 <      if(!vertexFlags.at(vertexIndex)) continue;
4587 >      if(!vertexFlags.at(vertexIndex).first) continue;
4588        chosenVertex = & primaryvertexs->at(vertexIndex);
4589        break;
4590      }
# Line 4023 | Line 4600 | OSUAnalysis::chosenMET ()
4600   {
4601    const BNmet *chosenMET = 0;
4602    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4603 <    vector<bool> metFlags;
4603 >    flagPair metFlags;
4604      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4605        if (cumulativeFlags.at("mets").at(i).size()){
4606          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4031 | Line 4608 | OSUAnalysis::chosenMET ()
4608        }
4609      }
4610      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4611 <      if(!metFlags.at(metIndex)) continue;
4611 >      if(!metFlags.at(metIndex).first) continue;
4612        chosenMET = & mets->at(metIndex);
4613        break;
4614      }
# Line 4047 | Line 4624 | OSUAnalysis::chosenElectron ()
4624   {
4625    const BNelectron *chosenElectron = 0;
4626    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4627 <    vector<bool> electronFlags;
4627 >    flagPair electronFlags;
4628      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4629        if (cumulativeFlags.at("electrons").at(i).size()){
4630          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4055 | Line 4632 | OSUAnalysis::chosenElectron ()
4632        }
4633      }
4634      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4635 <      if(!electronFlags.at(electronIndex)) continue;
4635 >      if(!electronFlags.at(electronIndex).first) continue;
4636        chosenElectron = & electrons->at(electronIndex);
4637        break;
4638      }
# Line 4066 | Line 4643 | OSUAnalysis::chosenElectron ()
4643    return chosenElectron;
4644   }
4645  
4646 +
4647   const BNmuon *
4648   OSUAnalysis::chosenMuon ()
4649   {
4650    const BNmuon *chosenMuon = 0;
4651    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4652 <    vector<bool> muonFlags;
4652 >    flagPair muonFlags;
4653      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4654        if (cumulativeFlags.at("muons").at(i).size()){
4655          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4079 | Line 4657 | OSUAnalysis::chosenMuon ()
4657        }
4658      }
4659      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4660 <      if(!muonFlags.at(muonIndex)) continue;
4660 >      if(!muonFlags.at(muonIndex).first) continue;
4661        chosenMuon = & muons->at(muonIndex);
4662        break;
4663      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines