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.98 by ahart, Thu Jul 11 16:21:11 2013 UTC

# Line 1 | Line 1
1   #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2
2   OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
3    // Retrieve parameters from the configuration file.
4    jets_ (cfg.getParameter<edm::InputTag> ("jets")),
# Line 28 | Line 27 | OSUAnalysis::OSUAnalysis (const edm::Par
27    datasetType_ (cfg.getParameter<string> ("datasetType")),
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
31 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
32    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
33    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
34    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
36 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
37 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
38 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
39    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
40    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
41    GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
42 < {
42 > {
43  
44    TH1::SetDefaultSumw2 ();
45  
# Line 46 | Line 50 | OSUAnalysis::OSUAnalysis (const edm::Par
50        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
51        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
52      }
53 +    if (applyBtagSF_){
54 +      bTagSFWeight_ = new BtagSFWeight;
55 +    }
56    }
57    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
58      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 57 | Line 64 | OSUAnalysis::OSUAnalysis (const edm::Par
64  
65    //always get vertex collection so we can assign the primary vertex in the event
66    objectsToGet.push_back("primaryvertexs");
60
61  //always make the plot of number of primary vertices (to check pile-up reweighting)
67    objectsToPlot.push_back("primaryvertexs");
68 +  objectsToFlag.push_back("primaryvertexs");
69 +
70  
71    //always get the MC particles to do GEN-matching
72    objectsToGet.push_back("mcparticles");
# Line 67 | Line 74 | OSUAnalysis::OSUAnalysis (const edm::Par
74    //always get the event collection to do pile-up reweighting
75    objectsToGet.push_back("events");
76  
77 +
78 +  // Parse the tree variable definitions.
79 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
80 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
81 +    if(tempInputCollection.find("pairs")!=string::npos) { clog << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
82 +    objectsToGet.push_back(tempInputCollection);
83 +    objectsToFlag.push_back(tempInputCollection);
84 +
85 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
86 +
87 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
88 +      BranchSpecs br;
89 +      br.inputCollection = tempInputCollection;
90 +      br.inputVariable = branchList.at(iBranch);
91 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
92 +      br.name = string(newName.Data());
93 +      treeBranches_.push_back(br);
94 +    }
95 +
96 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
97 +
98 +
99    //parse the histogram definitions
100    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
101  
102      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
103      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
104 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
105 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
106      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
107 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
108      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
109 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
110 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
111 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
112      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
113      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
114 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
115 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
116 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
119      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
120      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
121      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 89 | Line 129 | OSUAnalysis::OSUAnalysis (const edm::Par
129          objectsToGet.push_back(tempInputCollection);
130        }
131        objectsToPlot.push_back(tempInputCollection);
132 <      objectsToCut.push_back(tempInputCollection);
133 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
132 >      objectsToFlag.push_back(tempInputCollection);
133 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
134        string obj1;
135        string obj2;
136        getTwoObjs(tempInputCollection, obj1, obj2);
137        string obj2ToGet = getObjToGet(obj2);
138 <      objectsToCut.push_back(tempInputCollection);
139 <      objectsToCut.push_back(obj1);
140 <      objectsToCut.push_back(obj2);
138 >      objectsToFlag.push_back(tempInputCollection);
139 >      objectsToFlag.push_back(obj1);
140 >      objectsToFlag.push_back(obj2);
141        objectsToPlot.push_back(tempInputCollection);
142        objectsToPlot.push_back(obj1);
143        objectsToPlot.push_back(obj2);
144        objectsToGet.push_back(tempInputCollection);
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147 +    } // end else
148 +
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 138 | Line 179 | OSUAnalysis::OSUAnalysis (const edm::Par
179    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
180  
181      string currentObject = objectsToPlot.at(currentObjectIndex);
182 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
182 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "secondary photons"&& currentObject != "superclusters") continue;
183  
184      histogram tempIdHisto;
185      histogram tempMomIdHisto;
# Line 153 | Line 194 | OSUAnalysis::OSUAnalysis (const edm::Par
194      tempIdVsGmaIdHisto.inputCollection = currentObject;
195  
196      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
197 +    if(currentObject == "secondary photons") currentObject = "secondaryPhotons";
198      if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
199  
200      currentObject = currentObject.substr(0, currentObject.size()-1);
# Line 212 | Line 254 | OSUAnalysis::OSUAnalysis (const edm::Par
254      //set triggers for this channel
255      vector<string> triggerNames;
256      triggerNames.clear();
257 +    vector<string> triggerToVetoNames;
258 +    triggerToVetoNames.clear();
259 +
260      tempChannel.triggers.clear();
261 +    tempChannel.triggersToVeto.clear();
262      if(channels_.at(currentChannel).exists("triggers")){
263        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
264        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
265          tempChannel.triggers.push_back(triggerNames.at(trigger));
266        objectsToGet.push_back("triggers");
267      }
268 <
268 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
269 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
270 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
271 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
272 >      objectsToGet.push_back("triggers");
273 >    }
274  
275  
276  
277      //create cutFlow for this channel
278      cutFlows_.push_back (new CutFlow (fs_, channelName));
279      vector<TFileDirectory> directories; //vector of directories in the output file.
280 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
281      vector<string> subSubDirNames;//subdirectories in each channel.
282      //get list of cuts for this channel
283      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 237 | Line 289 | OSUAnalysis::OSUAnalysis (const edm::Par
289        //store input collection for cut
290        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
291        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
292 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
293 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
294        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
295        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
296 +      if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
297 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
298 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
299 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
300        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
301        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
302 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
303 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
304 +      if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
305 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
306 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
307        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
308        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
309        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 255 | Line 318 | OSUAnalysis::OSUAnalysis (const edm::Par
318            objectsToGet.push_back(tempInputCollection);
319          }
320          objectsToCut.push_back(tempInputCollection);
321 +        objectsToFlag.push_back(tempInputCollection);
322        }
323        else{//pair of objects, need to add them both to objectsToGet
324          string obj1;
# Line 264 | Line 328 | OSUAnalysis::OSUAnalysis (const edm::Par
328          objectsToCut.push_back(tempInputCollection);
329          objectsToCut.push_back(obj1);
330          objectsToCut.push_back(obj2);
331 +        objectsToFlag.push_back(tempInputCollection);
332 +        objectsToFlag.push_back(obj1);
333 +        objectsToFlag.push_back(obj2);
334          objectsToGet.push_back(tempInputCollection);
335          objectsToGet.push_back(obj1);
336          objectsToGet.push_back(obj2ToGet);
# Line 276 | Line 343 | OSUAnalysis::OSUAnalysis (const edm::Par
343        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
344        vector<string> cutStringVector = splitString(cutString);
345        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
346 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
346 >        clog << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
347          exit(0);
348        }
349        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
# Line 302 | Line 369 | OSUAnalysis::OSUAnalysis (const edm::Par
369        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
370        vector<string> numberRequiredVector = splitString(numberRequiredString);
371        if(numberRequiredVector.size()!=2){
372 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
372 >        clog << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
373          exit(0);
374        }
375  
# Line 310 | Line 377 | OSUAnalysis::OSUAnalysis (const edm::Par
377        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
378        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
379  
380 <      //Set up vectors to store the directories and subDIrectories for each channel.
380 >      //Set up vectors to store the directories and subDirectories for each channel.
381        string subSubDirName;
382        string tempCutName;
383        if(cuts_.at(currentCut).exists("alias")){
384          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
385 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
385 >        subSubDirName = "After " + tempCutName + " Cut Applied";
386        }
387        else{
388          //construct string for cutflow table
# Line 326 | Line 393 | OSUAnalysis::OSUAnalysis (const edm::Par
393          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
394        }
395  
396 +      tempCut.isVeto = false;
397 +      if(cuts_.at(currentCut).exists("isVeto")){
398 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
399 +        if (isVeto == true) tempCut.isVeto = true;
400 +      }
401        subSubDirNames.push_back(subSubDirName);
402        tempCut.name = tempCutName;
403  
# Line 340 | Line 412 | OSUAnalysis::OSUAnalysis (const edm::Par
412      TFileDirectory subDir = fs_->mkdir( channelName );
413      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
414      if(GetPlotsAfterEachCut_){
415 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
416 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
417 <            directories.push_back(subSubDir);
418 <            map<string, TH1D*> oneDhistoMap;
419 <            oneDHistsTmp.push_back(oneDhistoMap);
420 <            map<string, TH2D*> twoDhistoMap;
421 <            twoDHistsTmp.push_back(twoDhistoMap);
415 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
416 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
417 >        directories.push_back(subSubDir);
418 >        map<string, TH1D*> oneDhistoMap;
419 >        oneDHistsTmp.push_back(oneDhistoMap);
420 >        map<string, TH2D*> twoDhistoMap;
421 >        twoDHistsTmp.push_back(twoDhistoMap);
422        }
423 +      treeDirectories.push_back(subDir);
424        oneDHists_.push_back(oneDHistsTmp);
425        twoDHists_.push_back(twoDHistsTmp);
426      }
427 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
428 <   else{
427 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
428 >    else{
429        map<string, TH1D*> oneDhistoMap;
430        oneDHistsTmp.push_back(oneDhistoMap);
431        map<string, TH2D*> twoDhistoMap;
# Line 360 | Line 433 | OSUAnalysis::OSUAnalysis (const edm::Par
433        oneDHists_.push_back(oneDHistsTmp);
434        twoDHists_.push_back(twoDHistsTmp);
435        directories.push_back(subDir);
436 <   }
436 >      treeDirectories.push_back(subDir);
437 >
438 >    }
439 >
440 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
441 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
442 >      BNTrees_.push_back(newTree);
443 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
444 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
445 >        vector<float> newVec;
446 >        BNTreeBranchVals_[currentVar.name] = newVec;
447 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
448 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
449 >    }
450 >
451      //book all histograms included in the configuration
452      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
453 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
454 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
455 <      int numBinsElements = currentHistogram.bins.size();
456 <      int numInputVariables = currentHistogram.inputVariables.size();
457 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
458 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
459 <
460 <      if(numBinsElements == 1){
461 <        if(numBinEdgesX > 1){
462 <          if(numBinEdgesY > 1)
463 <            numBinsElements = 6;
453 >
454 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
455 >
456 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
457 >        int numBinsElements = currentHistogram.bins.size();
458 >        int numInputVariables = currentHistogram.inputVariables.size();
459 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
460 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
461 >
462 >        if(numBinsElements == 1){
463 >          if(numBinEdgesX > 1){
464 >            if(numBinEdgesY > 1)
465 >              numBinsElements = 6;
466 >            else
467 >              numBinsElements = 3;
468 >          }
469 >        }
470 >        if(numBinsElements != 3 && numBinsElements !=6){
471 >          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
472 >          exit(0);
473 >        }
474 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
475 >          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
476 >          exit(0);
477 >        }
478 >        else if(numBinsElements == 3){
479 >          if (currentHistogram.bins.size () == 3)
480 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
481            else
482 <            numBinsElements = 3;
482 >            {
483 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
484 >            }
485          }
486 <      }
487 <      if(numBinsElements != 3 && numBinsElements !=6){
488 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
489 <        exit(0);
490 <      }
491 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
492 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
493 <        exit(0);
494 <      }
495 <      else if(numBinsElements == 3){
496 <        if (currentHistogram.bins.size () == 3)
497 <          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
498 <        else
499 <          {
500 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
486 >        else if(numBinsElements == 6){
487 >          if (currentHistogram.bins.size () == 6)
488 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
489 >          else
490 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
491 >        }
492 >
493 >
494 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
495 >
496 >        // bin      particle type
497 >        // ---      -------------
498 >        //  0        unmatched
499 >        //  1        u
500 >        //  2        d
501 >        //  3        s
502 >        //  4        c
503 >        //  5        b
504 >        //  6        t
505 >        //  7        e
506 >        //  8        mu
507 >        //  9        tau
508 >        // 10        nu
509 >        // 11        g
510 >        // 12        gamma
511 >        // 13        Z
512 >        // 14        W
513 >        // 15        light meson
514 >        // 16        K meson
515 >        // 17        D meson
516 >        // 18        B meson
517 >        // 19        light baryon
518 >        // 20        strange baryon
519 >        // 21        charm baryon
520 >        // 22        bottom baryon
521 >        // 23        QCD string
522 >        // 24        other
523 >
524 >        vector<TString> labelArray;
525 >        labelArray.push_back("unmatched");
526 >        labelArray.push_back("u");
527 >        labelArray.push_back("d");
528 >        labelArray.push_back("s");
529 >        labelArray.push_back("c");
530 >        labelArray.push_back("b");
531 >        labelArray.push_back("t");
532 >        labelArray.push_back("e");
533 >        labelArray.push_back("#mu");
534 >        labelArray.push_back("#tau");
535 >        labelArray.push_back("#nu");
536 >        labelArray.push_back("g");
537 >        labelArray.push_back("#gamma");
538 >        labelArray.push_back("Z");
539 >        labelArray.push_back("W");
540 >        labelArray.push_back("light meson");
541 >        labelArray.push_back("K meson");
542 >        labelArray.push_back("D meson");
543 >        labelArray.push_back("B meson");
544 >        labelArray.push_back("light baryon");
545 >        labelArray.push_back("strange baryon");
546 >        labelArray.push_back("charm baryon");
547 >        labelArray.push_back("bottom baryon");
548 >        labelArray.push_back("QCD string");
549 >        labelArray.push_back("other");
550 >
551 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
552 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
553 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
554            }
555 <      }
556 <      else if(numBinsElements == 6){
557 <        if (currentHistogram.bins.size () == 6)
558 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
559 <        else
560 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
561 <      }
555 >          else {
556 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
557 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
558 >          }
559 >        }
560 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
561 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
562 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
563 >        }
564  
565 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
566  
405      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
567  
568 <      // bin      particle type
569 <      // ---      -------------
570 <      //  0        unmatched
571 <      //  1        u
572 <      //  2        d
573 <      //  3        s
574 <      //  4        c
575 <      //  5        b
576 <      //  6        t
577 <      //  7        e
578 <      //  8        mu
579 <      //  9        tau
580 <      // 10        nu
581 <      // 11        g
582 <      // 12        gamma
583 <      // 13        Z
584 <      // 14        W
585 <      // 15        light meson
586 <      // 16        K meson
587 <      // 17        D meson
588 <      // 18        B meson
589 <      // 19        light baryon
590 <      // 20        strange baryon
591 <      // 21        charm baryon
592 <      // 22        bottom baryon
593 <      // 23        QCD string
594 <      // 24        other
595 <
596 <      vector<TString> labelArray;
597 <      labelArray.push_back("unmatched");
598 <      labelArray.push_back("u");
599 <      labelArray.push_back("d");
600 <      labelArray.push_back("s");
601 <      labelArray.push_back("c");
602 <      labelArray.push_back("b");
603 <      labelArray.push_back("t");
604 <      labelArray.push_back("e");
605 <      labelArray.push_back("#mu");
606 <      labelArray.push_back("#tau");
607 <      labelArray.push_back("#nu");
608 <      labelArray.push_back("g");
609 <      labelArray.push_back("#gamma");
610 <      labelArray.push_back("Z");
611 <      labelArray.push_back("W");
612 <      labelArray.push_back("light meson");
613 <      labelArray.push_back("K meson");
614 <      labelArray.push_back("D meson");
615 <      labelArray.push_back("B meson");
616 <      labelArray.push_back("light baryon");
617 <      labelArray.push_back("strange baryon");
618 <      labelArray.push_back("charm baryon");
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);
568 >      // Book a histogram for the number of each object type to be plotted.
569 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
570 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
571 >        string currentObject = objectsToPlot.at(currentObjectIndex);
572 >        int maxNum = 10;
573 >        if(currentObject == "mcparticles") maxNum = 50;
574 >        else if(currentObject == "primaryvertexs") maxNum = 50;
575 >
576 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
577 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
578 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
579 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
580 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
581 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
582 >        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
583 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
584 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
585 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
586 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
587 >        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
588 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
589 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
590 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
591 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
592 >        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
593 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
594 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
595 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
596 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
597 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
598 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
599 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
600 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
601 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
602 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
603 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
604 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
605 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
606 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
607 >
608 >        currentObject.at(0) = toupper(currentObject.at(0));
609 >        string histoName = "num" + currentObject;
610 >
611 >        if(histoName == "numPrimaryvertexs"){
612 >          string newHistoName = histoName + "BeforePileupCorrection";
613 >          oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
614 >          newHistoName = histoName + "AfterPileupCorrection";
615 >          oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
616 >        }
617 >        else
618 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
619        }
620 <      else
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
620 >    }//end of loop over directories
621      channels.push_back(tempChannel);
622      tempChannel.cuts.clear();
623    }//end loop over channels
# Line 527 | Line 629 | OSUAnalysis::OSUAnalysis (const edm::Par
629    //make unique vector of objects we need to cut on
630    sort( objectsToCut.begin(), objectsToCut.end() );
631    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
632 +  //make unique vector of objects we need to set flags for
633 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
634 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
635  
636 +  produces<map<string, bool> > ("channelDecisions");
637 +
638 + } // end constructor OSUAnalysis::OSUAnalysis()
639  
532 }
640  
641   OSUAnalysis::~OSUAnalysis ()
642   {
643 +
644    // Destroying the CutFlow objects causes the cut flow numbers and time
645    // information to be printed to standard output.
646    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
647      delete cutFlows_.at(currentChannel);
648    }
649 +
650 +  clog << "=============================================" << endl;  
651 +  clog << "Successfully completed OSUAnalysis." << endl;  
652 +  clog << "=============================================" << endl;  
653 +
654   }
655  
656   void
657 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
657 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
658   {
546
659    // Retrieve necessary collections from the event.
660  
661    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 608 | Line 720 | OSUAnalysis::analyze (const edm::Event &
720  
721    //get pile-up event weight
722    if (doPileupReweighting_ && datasetType_ != "data") {
723 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  This will give an incorrect pile-up weight." << endl;  
724 < else
725 <    masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
723 >    //for "data" datasets, the numTruePV is always set to -1
724 >    if (events->at(0).numTruePV < 0) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
725 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
726    }
727  
728    stopCTauScaleFactor_ = 1.0;
# Line 620 | Line 732 | else
732  
733    //loop over all channels
734  
735 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
736    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
737      channel currentChannel = channels.at(currentChannelIndex);
738  
# Line 627 | Line 740 | else
740      counterMap passingCounter;
741      cumulativeFlags.clear ();
742  
743 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
744 +         iter != BNTreeBranchVals_.end(); iter++) {
745 +      iter->second.clear();  // clear array
746 +    }
747 +
748      bool triggerDecision = true;
749 <    if(currentChannel.triggers.size() != 0){  //triggers specified
750 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
749 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
750 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
751        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
752      }
753  
754      //loop over all cuts
755      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
756        cut currentCut = currentChannel.cuts.at(currentCutIndex);
757 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
758 <        string currentObject = objectsToCut.at(currentObjectIndex);
757 >
758 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
759 >        string currentObject = objectsToFlag.at(currentObjectIndex);
760  
761          //initialize maps to get ready to set cuts
762 <        individualFlags[currentObject].push_back (vector<bool> ());
763 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
762 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
763 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
764  
765        }
766 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
767 <        string currentObject = objectsToCut.at(currentObjectIndex);
766 >
767 >      //set flags for all relevant objects
768 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
769 >        string currentObject = objectsToFlag.at(currentObjectIndex);
770  
771          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
772  
773  
774          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
775          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
776 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
777          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
778          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
779          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 676 | Line 798 | else
798                                                                     "muon-muon pairs");
799  
800          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
801 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
802 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
803 <                                                                   "muon-secondary muon pairs");
801 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
802 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
803 >                                                                             "muon-secondary muon pairs");
804 >
805 >        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
806 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
807 >                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
808 >                                                                             "muon-secondary photon pairs");
809 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
810 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
811 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
812 >                                                                             "muon-secondary jet pairs");
813 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
814 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
815 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
816 >                                                                             "photon-secondary jet pairs");
817 >
818 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
819 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
820 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
821 >                                                                             "electron-secondary jet pairs");
822  
823          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
824 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
826 <                                                                   "electron-secondary electron pairs");
824 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
826 >                                                                                     "electron-secondary electron pairs");
827  
828          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
829                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 694 | Line 834 | else
834                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
835                                                                         "electron-muon pairs");
836          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
837 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 <                                                                           "jet-jet pairs");
837 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 >                                                                 "jet-jet pairs");
840 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
841 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
842 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
843 >                                                                 "jet-secondary jet pairs");
844          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
845 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
846 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
847 <                                                                       "electron-jet pairs");
845 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
846 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
847 >                                                                      "electron-jet pairs");
848 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
849 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
850 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
851 >                                                                      "electron-photon pairs");
852 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
853 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
854 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
855 >                                                                      "photon-jet pairs");
856          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
857 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
858 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
859 <                                                                       "muon-jet pairs");
857 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
858 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
859 >                                                                  "muon-jet pairs");
860 >        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
861 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
862 >                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
863 >                                                                  "muon-event pairs");
864 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
865 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
866 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
867 >                                                                  "met-jet pairs");
868 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
869 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
870 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
871 >                                                                 "track-jet pairs");
872 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
873 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
874 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
875 >                                                                  "muon-photon pairs");
876          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
877                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
878                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 726 | Line 894 | else
894                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
895                                                                   "tau-tau pairs");
896          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
897 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
898 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
899 <                                                                 "tau-track pairs");
897 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
898 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
899 >                                                                   "tau-track pairs");
900          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
901                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
902                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 746 | Line 914 | else
914      }//end loop over all cuts
915      //use cumulative flags to apply cuts at event level
916  
749    bool eventPassedAllCuts = true;
917      //a vector to store cumulative cut descisions after each cut.
918      vector<bool> eventPassedPreviousCuts;
919 +    bool eventPassedAllCuts = true;
920      //apply trigger (true if none were specified)
921      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
922  
755
923      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
924  
925        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 760 | Line 927 | else
927        int numberPassing = 0;
928  
929        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
930 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
930 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
931        }
932        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
933        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
934        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
935        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
936      }
937 +    //applying all appropriate scale factors
938      double scaleFactor = masterScaleFactor;
939 +    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
940  
772    muonScaleFactor_ = electronScaleFactor_ = 1.0;
941      if(applyLeptonSF_ && datasetType_ != "data"){
942 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
943 <        vector<bool> muonFlags;
942 >      //only apply SFs if we've cut on this object
943 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
944 >        flagPair muonFlags;
945 >        //get the last valid flags in the flag map
946          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
947            if (cumulativeFlags.at("muons").at(i).size()){
948              muonFlags = cumulativeFlags.at("muons").at(i);
949              break;
950            }
951          }
952 +        //apply the weight for each of those objects
953          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
954 <          if(!muonFlags.at(muonIndex)) continue;
954 >          if(!muonFlags.at(muonIndex).second) continue;
955            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
956          }
957        }
958 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
959 <        vector<bool> electronFlags;
958 >      //only apply SFs if we've cut on this object
959 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
960 >        flagPair electronFlags;
961 >        //get the last valid flags in the flag map
962          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
963            if (cumulativeFlags.at("electrons").at(i).size()){
964              electronFlags = cumulativeFlags.at("electrons").at(i);
965              break;
966            }
967          }
968 +        //apply the weight for each of those objects
969          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
970 <          if(!electronFlags.at(electronIndex)) continue;
970 >          if(!electronFlags.at(electronIndex).second) continue;
971            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
972          }
973        }
974      }
975 +    if(applyBtagSF_ && datasetType_ != "data"){
976 +      //only apply SFs if we've cut on this object
977 +      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
978 +        flagPair jetFlags;
979 +        vector<double> jetSFs;
980 +        //get the last valid flags in the flag map
981 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
982 +          if (cumulativeFlags.at("jets").at(i).size()){
983 +            jetFlags = cumulativeFlags.at("jets").at(i);
984 +            break;
985 +          }
986 +        }
987 +        //apply the weight for each of those objects
988 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
989 +          if(!jetFlags.at(jetIndex).second) continue;
990 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
991 +          jetSFs.push_back(jetSFTmp);
992 +        }
993 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
994 +      }
995 +    }
996      scaleFactor *= muonScaleFactor_;
997      scaleFactor *= electronScaleFactor_;
998 <
998 >    scaleFactor *= bTagScaleFactor_;
999      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
805    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
1000  
1001      if (printEventInfo_) {
1002        // Write information about event to screen, for testing purposes.
1003 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1003 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1004             << ": run="  << events->at(0).run
1005             << "  lumi=" << events->at(0).lumi
1006             << "  event=" << events->at(0).evt
1007             << endl;
1008      }
1009 +
1010 +
1011      //filling histograms
1012      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
1013 <        uint currentDir;
1014 <        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
1015 <        else{
1016 <          currentDir = currentCut;
1017 <        }
1018 <        if(eventPassedPreviousCuts.at(currentDir)){
1013 >      uint currentDir;
1014 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1015 >      else{
1016 >        currentDir = currentCut;
1017 >      }
1018 >
1019 >
1020 >      if(eventPassedPreviousCuts.at(currentDir)){
1021 >
1022          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1023            histogram currentHistogram = histograms.at(histogramIndex);
1024  
1025 <      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 <    }
1025 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1026  
1027 +          if(currentHistogram.inputVariables.size() == 1){
1028 +            TH1D* histo;
1029 +            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1030 +            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1031 +            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1032 +            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1033 +            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1034 +            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1035 +            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1036 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1037 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1038 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1039 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1040 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1041 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1042 +             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1043 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1044 +                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1045 +             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1046 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1047 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1048 +             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1049 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1050 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1051 +             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1052 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1053 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1054 +
1055 +            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1056 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1057 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1058 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1059 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1060 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1061 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1062 +             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1063 +                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1064 +                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1065 +
1066 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1067 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1068 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1069 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1070 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1071 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1072 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1073 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1074 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1075 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1076 +                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1077 +                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1078 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1079 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1080 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1081 +            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1082 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1083 +                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1084 +            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1085 +                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1086 +                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1087 +            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1088 +                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1089 +                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1090 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1091 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1092 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1093 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1094 +                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1095 +                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1096 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1097 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1098 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1099 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1100 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1101 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1102 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1103 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1104 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1105 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1106 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1107 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1108 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1109 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1110 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1111 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1112 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1113 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1114 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1115 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1116 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1117 +
1118 +            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1119 +            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1120 +            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1121 +            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1122 +            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1123 +            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1124 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1125 +            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1126 +            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1127 +            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1128 +            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1129 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1130 +          }
1131 +          else if(currentHistogram.inputVariables.size() == 2){
1132 +            TH2D* histo;
1133 +            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1134 +            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1135 +            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1136 +            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1137 +            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1138 +            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1139 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1140 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1141 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1142 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1143 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1144 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1145 +            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1146 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1147 +                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1148 +            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1149 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1150 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1151 +            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1152 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1153 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1154 +            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1155 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1156 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1157 +            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1158 +            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1159 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1160 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1161 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1162 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1163 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1164 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1165 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1166 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1167 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1168 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1169 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1170 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1171 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1172 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1173 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1174 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1175 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1176 +                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1177 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1178 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1179 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1180 +            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1181 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1182 +                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1183 +            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1184 +                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1185 +                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1186 +            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1187 +                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1188 +                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1189 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1190 +                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1191 +                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1192 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1193 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1194 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1195 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1196 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1197 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1198 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1199 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1200 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1201 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1202 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1203 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1204 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1205 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1206 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1207 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1208 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1209 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1210 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1211 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1212 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1213 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1214 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1215 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1216 +            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1217 +            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1218 +            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1219 +            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1220 +            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1221 +                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1222 +                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1223 +            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1224 +            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1225 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1226 +            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1227 +            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1228 +            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1229 +            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1230 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1231 +          }
1232  
1233 +        }
1234  
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);
1235  
1236 <     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1236 >        //fills histograms with the sizes of collections
1237 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1238 >
1239 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1240 >          string objectToPlot = "";
1241 >
1242 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1243 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1244 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1245 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1246 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1247 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1248 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1249 >          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1250 >          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1251 >          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1252 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1253 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1254 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1255 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1256 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1257 >          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1258 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1259 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1260 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1261 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1262 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1263 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1264 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1265 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1266 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1267 >          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1268 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1269 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1270 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1271 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1272 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1273 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1274 >          else objectToPlot = currentObject;
1275 >
1276 >          string tempCurrentObject = objectToPlot;
1277 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1278 >          string histoName = "num" + tempCurrentObject;
1279 >
1280 >
1281 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1282 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1283 >            int numToPlot = 0;
1284 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1285 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1286 >            }
1287 >
1288 >            if(objectToPlot == "primaryvertexs"){
1289 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1290 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1291 >            }
1292 >            else {
1293 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1294 >            }
1295 >          }
1296 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1297 >
1298 >
1299 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1300 >    } // end loop over cuts
1301 >
1302 >    if (!useEDMFormat_ && eventPassedAllCuts){
1303 >      // Assign BNTree variables
1304 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1305 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1306 >        string coll = brSpecs.inputCollection;
1307 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1308 >
1309 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1310 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1311 >        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1312 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1313 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1314 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1315 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1316 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1317 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1318 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1319 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1320 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1321 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1322 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1323 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1324 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1325 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1326 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1327 >        else if(coll == "stops"
1328 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1329 >      } // end loop over branches
1330 >
1331 >      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1332 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1333      }
1334 <  }
1335 <  } //end loop over channel
1334 >
1335 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1336 >
1337 >  } // end loop over channel
1338  
1339    masterCutFlow_->fillCutFlow(masterScaleFactor);
1340  
1341 +  event.put (channelDecisions, "channelDecisions");
1342 +
1343   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1344  
1345  
# Line 1066 | Line 1355 | OSUAnalysis::evaluateComparison (double
1355    else if(comparison == "==") return testValue == cutValue;
1356    else if(comparison == "=") return testValue == cutValue;
1357    else if(comparison == "!=") return testValue != cutValue;
1358 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1358 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1359  
1360   }
1361  
# Line 1081 | Line 1370 | OSUAnalysis::evaluateComparison (string
1370    else if(comparison == "==") return testValue == cutValue;
1371    else if(comparison == "=") return testValue == cutValue;
1372    else if(comparison == "!=") return testValue != cutValue;
1373 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1373 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1374  
1375   }
1376  
1377   bool
1378 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1378 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1379  
1380 +  //initialize to false until a chosen trigger is passed
1381    bool triggerDecision = false;
1382  
1383 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1384 <    {
1385 <      if(trigger->pass != 1) continue;
1386 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1387 <        {
1388 <          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1389 <            triggerDecision = true;
1390 <          }
1391 <        }
1383 >  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1384 >  //loop over all triggers defined in the event
1385 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1386 >
1387 >    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1388 >
1389 >    //we're only interested in triggers that actually passed
1390 >    if(trigger->pass != 1) continue;
1391 >
1392 >    //if the event passes one of the veto triggers, exit and return false
1393 >    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1394 >      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1395 >    }
1396 >    //if the event passes one of the chosen triggers, set triggerDecision to true
1397 >    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1398 >      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1399      }
1400 <  return triggerDecision;
1400 >  }
1401  
1402 +  printAllTriggers_ = false;  // only print triggers once, not every event
1403 +
1404 +  //if none of the veto triggers fired:
1405 +  //return the OR of all the chosen triggers
1406 +  if (triggersToTest.size() != 0) return triggerDecision;
1407 +  //or if no triggers were defined return true
1408 +  else return true;
1409   }
1410  
1411 +
1412   vector<string>
1413   OSUAnalysis::splitString (string inputString){
1414  
# Line 1265 | Line 1570 | OSUAnalysis::valueLookup (const BNjet* o
1570    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1571    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1572  
1573 +  //user defined variable
1574 +  else if(variable == "disappTrkLeadingJetID") {
1575 +    value = object->pt > 110
1576 +      && fabs(object->eta) < 2.4
1577 +      && object->chargedHadronEnergyFraction > 0.2
1578 +      && object->neutralHadronEnergyFraction < 0.7
1579 +      && object->chargedEmEnergyFraction < 0.5
1580 +      && object->neutralEmEnergyFraction < 0.7;
1581 +  }
1582 +
1583 +  else if(variable == "disappTrkSubLeadingJetID") {
1584 +    value = object->pt > 30
1585 +      && fabs(object->eta) < 4.5
1586 +      && object->neutralHadronEnergyFraction < 0.7
1587 +      && object->chargedEmEnergyFraction < 0.5;
1588 +  }
1589 +
1590 +  else if(variable == "dPhiMet") {
1591 +    if (const BNmet *met = chosenMET ()) {
1592 +      value = deltaPhi (object->phi, met->phi);
1593 +    } else value = -999;
1594 +  }
1595 +
1596  
1597 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1597 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1598  
1599    value = applyFunction(function, value);
1600  
1601    return value;
1602 < }
1602 > } // end jet valueLookup
1603  
1604  
1605   //!muon valueLookup
# Line 1368 | Line 1696 | OSUAnalysis::valueLookup (const BNmuon*
1696    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1697    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1698    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1699 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1700 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1701 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1702 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1703    else if(variable == "rhoPrime") value = object->rhoPrime;
1704    else if(variable == "AEffDr03") value = object->AEffDr03;
1705    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1375 | Line 1707 | OSUAnalysis::valueLookup (const BNmuon*
1707    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1708    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1709    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1710 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1711 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1712 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1713 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1714 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1715    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1716    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1717    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1431 | Line 1768 | OSUAnalysis::valueLookup (const BNmuon*
1768    else if(variable == "time_ndof") value = object->time_ndof;
1769  
1770    //user-defined variables
1771 +  else if(variable == "looseID") {
1772 +    value = object->pt > 10 &&
1773 +      (object->isGlobalMuon  > 0 ||
1774 +       object->isTrackerMuon > 0);
1775 +  }
1776    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1777    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1778    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1779    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1780 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1781    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1782    else if(variable == "metMT") {
1783      if (const BNmet *met = chosenMET ())
# Line 1558 | Line 1901 | OSUAnalysis::valueLookup (const BNmuon*
1901      value = object->isGlobalMuon > 0                \
1902        && object->isPFMuon > 0                        \
1903        && object->normalizedChi2 < 10                \
1904 <                                  && object->numberOfValidMuonHits > 0        \
1904 >      && object->numberOfValidMuonHits > 0        \
1905        && object->numberOfMatchedStations > 1        \
1906        && fabs(object->correctedD0Vertex) < 0.2        \
1907        && fabs(object->correctedDZ) < 0.5        \
# Line 1569 | Line 1912 | OSUAnalysis::valueLookup (const BNmuon*
1912      value = object->isGlobalMuon > 0                \
1913        && object->isPFMuon > 0                        \
1914        && object->normalizedChi2 < 10                \
1915 <                                  && object->numberOfValidMuonHits > 0        \
1915 >      && object->numberOfValidMuonHits > 0        \
1916        && object->numberOfMatchedStations > 1        \
1917        && object->numberOfValidPixelHits > 0        \
1918        && object->numberOfLayersWithMeasurement > 5;
# Line 1624 | Line 1967 | OSUAnalysis::valueLookup (const BNmuon*
1967      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1968      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1969      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1970 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1971 <         || fabs (object->correctedDZ / dzError) > 99.0;
1970 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1971 >      || fabs (object->correctedDZ / dzError) > 99.0;
1972      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1973    }
1974  
1975  
1976  
1977 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1977 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1978  
1979    value = applyFunction(function, value);
1980  
1981    return value;
1982 < }
1982 > } // end muon valueLookup
1983 >
1984  
1985   //!electron valueLookup
1986   double
# Line 1805 | Line 2149 | OSUAnalysis::valueLookup (const BNelectr
2149    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2150    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2151    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2152 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2153 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2154    else if(variable == "metMT") {
2155      if (const BNmet *met = chosenMET ())
2156        {
# Line 1876 | Line 2222 | OSUAnalysis::valueLookup (const BNelectr
2222      else value = -999;
2223    }
2224  
2225 +  else if(variable == "looseID"){
2226 +    if (object->isEB)
2227 +      {
2228 +        value = fabs(object->delEtaIn) < 0.007 \
2229 +          && fabs (object->delPhiIn) < 0.15 \
2230 +          && object->scSigmaIEtaIEta < 0.01 \
2231 +          && object->hadOverEm < 0.12 \
2232 +          && fabs (object->correctedD0Vertex) < 0.02 \
2233 +          && fabs (object->correctedDZ) < 0.2 \
2234 +          && object->absInvEMinusInvPin < 0.05 \
2235 +          && object->passConvVeto;
2236 +      }
2237 +    else
2238 +      {
2239 +        value = fabs(object->delEtaIn) < 0.009 \
2240 +          && fabs (object->delPhiIn) < 0.10 \
2241 +          && object->scSigmaIEtaIEta < 0.03 \
2242 +          && object->hadOverEm < 0.10 \
2243 +          && fabs (object->correctedD0Vertex) < 0.02 \
2244 +          && fabs (object->correctedDZ) < 0.2 \
2245 +          && object->absInvEMinusInvPin < 0.05 \
2246 +          && object->passConvVeto;
2247 +      }
2248 +  }
2249 +
2250    else if(variable == "tightID"){
2251      if (object->isEB)
2252        {
# Line 1901 | Line 2272 | OSUAnalysis::valueLookup (const BNelectr
2272        }
2273    }
2274  
2275 +  else if(variable == "looseID"){
2276 +    value = object->pt > 10
2277 +      && object->mvaNonTrigV0 > 0;
2278 +      }
2279    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2280      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2281      else value = -999;
# Line 2024 | Line 2399 | OSUAnalysis::valueLookup (const BNelectr
2399      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2400      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2401      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2402 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2403 <         || fabs (object->correctedDZ / dzError) > 99.0;
2402 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2403 >      || fabs (object->correctedDZ / dzError) > 99.0;
2404      value = !value;
2405    }
2406  
2407  
2408  
2409 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2409 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2410  
2411    value = applyFunction(function, value);
2412  
2413    return value;
2414 < }
2414 > } // end electron valueLookup
2415 >
2416  
2417   //!event valueLookup
2418   double
# Line 2117 | Line 2493 | OSUAnalysis::valueLookup (const BNevent*
2493    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2494    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2495    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2496 <
2497 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2496 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2497 >  else if(variable == "ht") value = chosenHT ();
2498 >  else if(variable == "leadMuPairInvMass"){
2499 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2500 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2501 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2502 >    value = (p0 + p1).M ();
2503 >  }
2504 >  else if(variable == "leadMuPairPt"){
2505 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2506 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2507 >             pt1 (muPair.second->px, muPair.second->py);
2508 >    pt0 += pt1;
2509 >    value = pt0.Mod ();
2510 >  }
2511 >  else if(variable == "leadElPairInvMass"){
2512 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2513 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2514 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2515 >    value = (p0 + p1).M ();
2516 >  }
2517 >  else if(variable == "leadElPairPt"){
2518 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2519 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2520 >             pt1 (muPair.second->px, muPair.second->py);
2521 >    pt0 += pt1;
2522 >    value = pt0.Mod ();
2523 >  }
2524 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2525  
2526    value = applyFunction(function, value);
2527  
2528    return value;
2529 < }
2529 > } // end event valueLookup
2530 >
2531  
2532   //!tau valueLookup
2533   double
# Line 2171 | Line 2575 | OSUAnalysis::valueLookup (const BNtau* o
2575    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2576    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2577  
2578 <
2578 >  else if (variable == "looseHadronicID") {
2579 >    value = object->pt > 10
2580 >      && object->eta < 2.3
2581 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2582 >      && object->HPSdecayModeFinding > 0
2583 >      && object->HPSagainstElectronLoose > 0
2584 >      && object->HPSagainstMuonTight > 0;
2585 >  }
2586  
2587    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2588  
# Line 2218 | Line 2629 | OSUAnalysis::valueLookup (const BNtau* o
2629    }
2630  
2631  
2632 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2632 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2633  
2634    value = applyFunction(function, value);
2635  
2636    return value;
2637 < }
2637 > } // end tau valueLookup
2638 >
2639  
2640   //!met valueLookup
2641   double
# Line 2291 | Line 2703 | OSUAnalysis::valueLookup (const BNmet* o
2703    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2704    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2705  
2706 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2706 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2707  
2708    value = applyFunction(function, value);
2709  
2710    return value;
2711 < }
2711 > } // end met valueLookup
2712 >
2713  
2714   //!track valueLookup
2715   double
# Line 2324 | Line 2737 | OSUAnalysis::valueLookup (const BNtrack*
2737    else if(variable == "numValidHits") value = object->numValidHits;
2738    else if(variable == "isHighPurity") value = object->isHighPurity;
2739  
2327
2740    //additional BNs info for disappTrks
2741 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2742 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2743 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2744 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2745 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2746 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2747 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2748 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2337 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2741 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2742 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2743 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2744 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2745 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2746 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2747 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2748 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2749    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2750 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2750 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2751 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2752 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2753 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2754 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2755 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2756 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2757 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2758 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2759 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2760 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2761 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2762 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2763 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2764 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2765 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2766 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2767 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2768  
2769    //user defined variables
2770    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;
2771    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2772 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2772 >  else if(variable == "depTrkRp5MinusPt"){
2773 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2774 >           value = 0;
2775 >         }
2776 >         else value =  (object->depTrkRp5 - object->pt);
2777 >  }
2778 >  else if(variable == "depTrkRp3MinusPt"){
2779 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2780 >      value = 0;
2781 >    }
2782 >    else value =  (object->depTrkRp3 - object->pt);
2783 >  }
2784 >
2785 >  else if(variable == "dPhiMet") {
2786 >    if (const BNmet *met = chosenMET ()) {
2787 >      value = deltaPhi (object->phi, met->phi);
2788 >    } else value = -999;
2789 >  }
2790 >  
2791 >  
2792    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2793    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2794    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2369 | Line 2816 | OSUAnalysis::valueLookup (const BNtrack*
2816        pt = object->pt;
2817      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2818    }
2819 +
2820 +
2821    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2822  
2823    else if(variable == "genMatchedPdgId"){
# Line 2416 | Line 2865 | OSUAnalysis::valueLookup (const BNtrack*
2865  
2866  
2867  
2868 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2868 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2869  
2870    value = applyFunction(function, value);
2871  
2872    return value;
2873 < }
2873 > } // end track valueLookup
2874 >
2875  
2876   //!genjet valueLookup
2877   double
# Line 2445 | Line 2895 | OSUAnalysis::valueLookup (const BNgenjet
2895    else if(variable == "charge") value = object->charge;
2896  
2897  
2898 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2898 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2899  
2900    value = applyFunction(function, value);
2901  
# Line 2579 | Line 3029 | OSUAnalysis::valueLookup (const BNmcpart
3029    }
3030  
3031  
3032 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3032 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3033  
3034    value = applyFunction(function, value);
3035  
3036    return value;
3037 < }
3037 > } // end mcparticle valueLookup
3038 >
3039  
3040   //!primaryvertex valueLookup
3041   double
# Line 2607 | Line 3058 | OSUAnalysis::valueLookup (const BNprimar
3058    else if(variable == "isGood") value = object->isGood;
3059  
3060  
3061 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3061 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3062  
3063    value = applyFunction(function, value);
3064  
# Line 2625 | Line 3076 | OSUAnalysis::valueLookup (const BNbxlumi
3076    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3077  
3078  
3079 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3079 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3080  
3081    value = applyFunction(function, value);
3082  
# Line 2758 | Line 3209 | OSUAnalysis::valueLookup (const BNphoton
3209    }
3210  
3211  
3212 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3212 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3213  
3214    value = applyFunction(function, value);
3215  
3216    return value;
3217 < }
3217 > } // end photon valueLookup
3218 >
3219  
3220   //!supercluster valueLookup
3221   double
# Line 2781 | Line 3233 | OSUAnalysis::valueLookup (const BNsuperc
3233    else if(variable == "theta") value = object->theta;
3234  
3235  
3236 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3236 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3237  
3238    value = applyFunction(function, value);
3239  
# Line 2815 | Line 3267 | OSUAnalysis::valueLookup (const BNtrigob
3267        stringValue = "none";  // stringValue should only be empty if value is filled
3268    }
3269  
3270 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3270 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3271  
3272    value = applyFunction(function, value);
3273  
# Line 2886 | Line 3338 | OSUAnalysis::valueLookup (const BNmuon*
3338        value = object2->correctedD0;
3339      }
3340  
3341 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3341 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3342 >
3343 >  value = applyFunction(function, value);
3344 >
3345 >  return value;
3346 > } // end muon-muon pair valueLookup
3347 >
3348 >
3349 > //!muon-photon pair valueLookup
3350 > double
3351 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3352 >
3353 >  double value = 0.0;
3354 >
3355 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3356 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3357 >  else if(variable == "photonEta") value = object2->eta;
3358 >  else if(variable == "photonPt") value = object2->pt;
3359 >  else if(variable == "muonEta") value = object1->eta;
3360 >  else if(variable == "photonPhi") value = object2->phi;
3361 >  else if(variable == "muonPhi") value = object1->phi;
3362 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3363 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3364 >  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3365 >  else if(variable == "invMass"){
3366 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3367 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3368 >    value = (fourVector1 + fourVector2).M();
3369 >  }
3370 >  else if(variable == "pt"){
3371 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3372 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3373 >    value = (fourVector1 + fourVector2).Pt();
3374 >  }
3375 >  else if(variable == "threeDAngle")
3376 >    {
3377 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3378 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3379 >      value = (threeVector1.Angle(threeVector2));
3380 >    }
3381 >  else if(variable == "alpha")
3382 >    {
3383 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3384 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3385 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3386 >      value = (pi-threeVector1.Angle(threeVector2));
3387 >    }
3388 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3389 >
3390 >  value = applyFunction(function, value);
3391 >
3392 >  return value;
3393 > }
3394 >
3395 > //!electron-photon pair valueLookup
3396 > double
3397 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3398 >
3399 >  double value = 0.0;
3400 >
3401 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3402 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3403 >  else if(variable == "photonEta") value = object2->eta;
3404 >  else if(variable == "photonPt") value = object2->pt;
3405 >  else if(variable == "electronEta") value = object1->eta;
3406 >  else if(variable == "photonPhi") value = object2->phi;
3407 >  else if(variable == "electronPhi") value = object1->phi;
3408 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3409 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3410 >  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3411 >  else if(variable == "invMass"){
3412 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3413 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3414 >    value = (fourVector1 + fourVector2).M();
3415 >  }
3416 >  else if(variable == "pt"){
3417 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3418 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3419 >    value = (fourVector1 + fourVector2).Pt();
3420 >  }
3421 >  else if(variable == "threeDAngle")
3422 >    {
3423 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3424 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3425 >      value = (threeVector1.Angle(threeVector2));
3426 >    }
3427 >  else if(variable == "alpha")
3428 >    {
3429 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3430 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3431 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3432 >      value = (pi-threeVector1.Angle(threeVector2));
3433 >    }
3434 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3435  
3436    value = applyFunction(function, value);
3437  
# Line 2942 | Line 3487 | OSUAnalysis::valueLookup (const BNelectr
3487      value = object2->correctedD0;
3488    }
3489  
3490 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3490 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3491  
3492    value = applyFunction(function, value);
3493  
3494    return value;
3495   }
3496 +
3497   //!electron-muon pair valueLookup
3498   double
3499   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3008 | Line 3554 | OSUAnalysis::valueLookup (const BNelectr
3554    else if(variable == "muonRelPFdBetaIso"){
3555      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3556    }
3557 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3557 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3558    value = applyFunction(function, value);
3559  
3560    return value;
3561 < }
3561 > } // end electron-muon pair valueLookup
3562 >
3563  
3564   //!electron-jet pair valueLookup
3565   double
# Line 3022 | Line 3569 | OSUAnalysis::valueLookup (const BNelectr
3569  
3570    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3571    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3572 +  else if(variable == "jetEta") value = object2->eta;
3573 +  else if(variable == "jetPhi") value = object2->phi;
3574 +  else if(variable == "electronEta") value = object1->eta;
3575 +  else if(variable == "electronPhi") value = object1->phi;
3576    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3577    else if(variable == "invMass"){
3578      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3043 | Line 3594 | OSUAnalysis::valueLookup (const BNelectr
3594      value = object1->charge*object2->charge;
3595    }
3596  
3597 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3597 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3598    value = applyFunction(function, value);
3599  
3600    return value;
3601   }
3602  
3603 + //!photon-jet pair valueLookup
3604 + double
3605 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3606 +
3607 +  double value = 0.0;
3608 +
3609 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3610 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3611 +  else if(variable == "jetEta") value = object2->eta;
3612 +  else if(variable == "jetPhi") value = object2->phi;
3613 +  else if(variable == "photonEta") value = object1->eta;
3614 +  else if(variable == "photonPhi") value = object1->phi;
3615 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3616 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3617 +  else if(variable == "invMass"){
3618 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3619 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3620 +    value = (fourVector1 + fourVector2).M();
3621 +  }
3622 +  else if(variable == "pt"){
3623 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3624 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3625 +    value = (fourVector1 + fourVector2).Pt();
3626 +  }
3627 +  else if(variable == "threeDAngle")
3628 +    {
3629 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3630 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3631 +      value = (threeVector1.Angle(threeVector2));
3632 +    }
3633 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3634 +  value = applyFunction(function, value);
3635 +
3636 +  return value;
3637 + }
3638 +
3639 + // track-jet pair valueLookup
3640 + double
3641 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3642 +
3643 +  double value = 0.0;
3644 +
3645 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3646 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3647 +
3648 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3649 +  value = applyFunction(function, value);
3650 +
3651 +  return value;
3652 +
3653 + }
3654 +
3655 +
3656 +
3657 + // met-jet pair valueLookup
3658 + double
3659 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3660 +
3661 +  double value = 0.0;
3662 +
3663 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3664 +
3665 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3666 +  value = applyFunction(function, value);
3667 +
3668 +  return value;
3669 +
3670 + }  
3671 +
3672 +
3673 +
3674   //!muon-jet pair valueLookup
3675   double
3676   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3056 | Line 3678 | OSUAnalysis::valueLookup (const BNmuon*
3678    double value = 0.0;
3679  
3680    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3681 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3681 >  else if(variable == "jetEta") value = object2->eta;
3682 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3683 >  else if(variable == "jetPt") value = object2->pt;
3684 >  else if(variable == "jetPhi") value = object2->phi;
3685 >  else if(variable == "muonEta") value = object1->eta;
3686 >  else if(variable == "muonPt") value = object1->pt;
3687 >  else if(variable == "muonPhi") value = object1->phi;
3688 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3689    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3690    else if(variable == "invMass"){
3691      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3078 | Line 3707 | OSUAnalysis::valueLookup (const BNmuon*
3707      value = object1->charge*object2->charge;
3708    }
3709  
3710 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3710 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3711    value = applyFunction(function, value);
3712  
3713    return value;
3714   }
3715  
3716 + //!muon-event valueLookup
3717 + double
3718 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3719 +
3720 +  double value = 0.0;
3721 +
3722 +  if(variable == "muonEta") value = object1->eta;
3723 +  else if(variable == "muonPt") value = object1->pt;
3724 +  else if(variable == "muonPhi") value = object1->phi;
3725 +  else if(variable == "pthat")   value = object2->pthat;
3726 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3727 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3728 +  value = applyFunction(function, value);
3729 +
3730 +  return value;
3731 + }
3732   //!jet-jet pair valueLookup
3733   double
3734   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3114 | Line 3759 | OSUAnalysis::valueLookup (const BNjet* o
3759      value = object1->charge*object2->charge;
3760    }
3761  
3762 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3762 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3763    value = applyFunction(function, value);
3764  
3765    return value;
3766   }
3767 +
3768   //!electron-track pair valueLookup
3769   double
3770   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3138 | Line 3784 | OSUAnalysis::valueLookup (const BNelectr
3784    else if(variable == "chargeProduct"){
3785      value = object1->charge*object2->charge;
3786    }
3787 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3787 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3788    value = applyFunction(function, value);
3789    return value;
3790  
# Line 3166 | Line 3812 | OSUAnalysis::valueLookup (const BNmuon*
3812      value = object1->charge*object2->charge;
3813    }
3814  
3815 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3815 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3816    value = applyFunction(function, value);
3817    return value;
3818   }
# Line 3188 | Line 3834 | OSUAnalysis::valueLookup (const BNtau* o
3834      value = object1->charge*object2->charge;
3835    }
3836  
3837 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3837 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3838    value = applyFunction(function, value);
3839    return value;
3840   }
# Line 3210 | Line 3856 | OSUAnalysis::valueLookup (const BNmuon*
3856      value = object1->charge*object2->charge;
3857    }
3858  
3859 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3859 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3860    value = applyFunction(function, value);
3861    return value;
3862   }
# Line 3225 | Line 3871 | OSUAnalysis::valueLookup (const BNtau* o
3871      value = object1->charge*object2->charge;
3872    }
3873  
3874 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3874 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3875    value = applyFunction(function, value);
3876    return value;
3877   }
# Line 3245 | Line 3891 | OSUAnalysis::valueLookup (const BNtrack*
3891    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3892    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3893  
3894 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3894 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3895  
3896    value = applyFunction(function, value);
3897  
# Line 3267 | Line 3913 | OSUAnalysis::valueLookup (const BNelectr
3913        stringValue = "none";
3914    }
3915  
3916 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3916 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3917  
3918    value = applyFunction(function, value);
3919  
# Line 3283 | Line 3929 | OSUAnalysis::valueLookup (const BNmuon*
3929  
3930    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3931  
3932 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3932 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3933  
3934    value = applyFunction(function, value);
3935  
# Line 3386 | Line 4032 | OSUAnalysis::valueLookup (const BNstop*
4032      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4033        vertex_rank++;
4034        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4035 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
4036 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
4035 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4036 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
4037  
4038        if(abs(dist) < abs(minDistToVertex)){
4039          value = vertex_rank;
# Line 3399 | Line 4045 | OSUAnalysis::valueLookup (const BNstop*
4045  
4046  
4047  
4048 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4048 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4049  
4050    value = applyFunction(function, value);
4051  
4052    return value;
4053  
4054 < }
4054 > } // end stop valueLookup
4055 >
4056  
4057  
4058  
# Line 3460 | Line 4107 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4107    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4108    if (!useTrackCaloRhoCorr_) return -99;
4109    // if (!rhokt6CaloJetsHandle_) {
4110 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4110 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4111    //   return -99;
4112    // }
4113    double radDeltaRCone = 0.5;
# Line 3482 | Line 4129 | OSUAnalysis::WriteDeadEcal (){
4129    double etaEcal, phiEcal;
4130    ifstream DeadEcalFile(deadEcalFile_);
4131    if(!DeadEcalFile) {
4132 <    cout << "Error: DeadEcalFile has not been found." << endl;
4132 >    clog << "Error: DeadEcalFile has not been found." << endl;
4133      return;
4134    }
4135    if(DeadEcalVec.size()!= 0){
4136 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4136 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4137      return;
4138    }
4139    while(!DeadEcalFile.eof())
# Line 3497 | Line 4144 | OSUAnalysis::WriteDeadEcal (){
4144        newChan.phiEcal = phiEcal;
4145        DeadEcalVec.push_back(newChan);
4146      }
4147 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4147 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4148   }
4149  
4150   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3537 | Line 4184 | OSUAnalysis::applyFunction(string functi
4184    else if(function == "log") value = log10(value);
4185  
4186    else if(function == "") value = value;
4187 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4187 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4188  
4189    return value;
4190  
# Line 3551 | Line 4198 | void OSUAnalysis::setObjectFlags(cut &cu
4198      string obj1, obj2;
4199      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4200      if (inputType==obj1 ||
4201 <          inputType==obj2) {
4201 >        inputType==obj2) {
4202        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4203        // and the inputType is a member of the pair.
4204        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3563 | Line 4210 | void OSUAnalysis::setObjectFlags(cut &cu
4210  
4211    for (uint object = 0; object != inputCollection->size(); object++){
4212  
4213 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4213 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4214 >    bool plotDecision = true;
4215  
4216      if(currentCut.inputCollection == inputType){
4217  
# Line 3575 | Line 4223 | void OSUAnalysis::setObjectFlags(cut &cu
4223          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4224  
4225        }
4226 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4226 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4227        else{
4228          bool tempDecision = true;
4229          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3584 | Line 4232 | void OSUAnalysis::setObjectFlags(cut &cu
4232            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4233              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4234          }
4235 <        decision = tempDecision;
4235 >        cutDecision = tempDecision;
4236        }
4237 +      //invert the cut for plotting if this cut is a veto
4238 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4239 +      else plotDecision = cutDecision;
4240      }
4241  
4242 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4242 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4243  
4244 <    //set flags for objects that pass each cut AND all the previous cuts
4245 <    bool previousCumulativeFlag = true;
4244 >    //set flags for objects that pass this cut AND all the previous cuts
4245 >    bool previousCumulativeCutFlag = true;
4246      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4247 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4248 <      else{ previousCumulativeFlag = false; break;}
4247 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4248 >      else{ previousCumulativeCutFlag = false; break;}
4249      }
4250 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4250 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4251 >    bool previousCumulativePlotFlag = true;
4252 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4253 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4254 >      else{ previousCumulativePlotFlag = false; break;}
4255 >    }
4256 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4257 >
4258 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4259  
4260    }
4261  
# Line 3605 | Line 4264 | void OSUAnalysis::setObjectFlags(cut &cu
4264  
4265   template <class InputCollection1, class InputCollection2>
4266   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4267 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4267 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4268  
4269  
4270    bool sameObjects = false;
# Line 3621 | Line 4280 | void OSUAnalysis::setObjectFlags(cut &cu
4280    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4281    if (currentCut.inputCollection == inputType) {
4282      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4283 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4284 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4283 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4284 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4285      }
4286      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4287        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4288 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4289 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4288 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4289 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4290        }
4291      }
4292    }
# Line 3640 | Line 4299 | void OSUAnalysis::setObjectFlags(cut &cu
4299        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4300  
4301  
4302 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4302 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4303 >      bool plotDecision = true;
4304  
4305        if(currentCut.inputCollection == inputType){
4306  
# Line 3652 | Line 4312 | void OSUAnalysis::setObjectFlags(cut &cu
4312            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4313          }
4314  
4315 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4315 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4316          else{
4317            bool tempDecision = subcutDecisions.at(0);
4318            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3661 | Line 4321 | void OSUAnalysis::setObjectFlags(cut &cu
4321              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4322                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4323            }
4324 <          decision = tempDecision;
4324 >          cutDecision = tempDecision;
4325          }
4326 +        //invert the cut for plotting if this cut is a veto
4327 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4328 +        else plotDecision = cutDecision;
4329 +      }
4330 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4331 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4332 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4333 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4334 +      }
4335 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4336 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4337 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4338        }
4339 <      // if (decision) isPassObj1.at(object1) = true;
4340 <      // if (decision) isPassObj2.at(object2) = true;
4341 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4342 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4343 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4344 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4339 >
4340 >      //set flags for objects that pass this cut AND all the previous cuts
4341 >      bool previousCumulativeCutFlag = true;
4342 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4343 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4344 >        else{ previousCumulativeCutFlag = false; break;}
4345        }
4346 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4347  
4348 <      //set flags for objects that pass each cut AND all the previous cuts
3676 <      bool previousCumulativeFlag = true;
4348 >      bool previousCumulativePlotFlag = true;
4349        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4350 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4351 <        else{ previousCumulativeFlag = false; break;}
4350 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4351 >        else{ previousCumulativePlotFlag = false; break;}
4352        }
4353 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4354 +      
4355        //apply flags for the components of the composite object as well
4356 <      bool currentCumulativeFlag = true;
4357 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4358 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4359 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4360 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4361 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4362 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4363 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4364 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4356 >      bool currentCumulativeCutFlag = true;
4357 >      bool currentCumulativePlotFlag = true;
4358 >
4359 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4360 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4361 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4362 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4363 >
4364 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4365 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4366 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4367 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4368 >
4369 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4370 >
4371 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4372 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4373 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4374        }
4375 +
4376 +      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4377 +        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4378 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4379 +      }
4380 +
4381        counter++;
4382  
4383      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3697 | Line 4386 | void OSUAnalysis::setObjectFlags(cut &cu
4386   }
4387  
4388  
4389 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4389 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4390    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4391    // all cuts up to currentCutIndex
4392    bool previousCumulativeFlag = true;
4393    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4394 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4394 >    bool tempFlag = false;
4395 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4396 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4397 >
4398 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4399      else {
4400        previousCumulativeFlag = false; break;
4401      }
# Line 3711 | Line 4404 | bool OSUAnalysis::getPreviousCumulativeF
4404   }
4405  
4406  
4407 +
4408 +
4409 + template <class InputCollection>
4410 + void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4411 +  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4412 +
4413 +  if (BNTreeBranchVals_.count(parameters.name)==0) clog << "Error[assignTreeBranch]:  trying to assign value to " << parameters.name << " that does not have a branch set up.  Will likely seg fault." << endl;
4414 +  for (uint object = 0; object != inputCollection->size(); object++) {
4415 +
4416 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4417 +
4418 +    string inputVariable = parameters.inputVariable;
4419 +    string function = "";
4420 +    string stringValue = "";
4421 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4422 +    BNTreeBranchVals_.at(parameters.name).push_back(value);
4423 +
4424 +  }
4425 + }
4426 +
4427 +
4428   template <class InputCollection>
4429 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4429 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4430 >
4431  
4432    for (uint object = 0; object != inputCollection->size(); object++){
4433  
4434 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4434 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4435  
4436      string currentString = parameters.inputVariables.at(0);
4437      string inputVariable = "";
# Line 3733 | Line 4448 | void OSUAnalysis::fill1DHistogram(TH1* h
4448      string stringValue = "";
4449      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4450      histo->Fill(value,scaleFactor);
4451 +
4452      if (printEventInfo_) {
4453        // Write information about event to screen, for testing purposes.
4454 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4454 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4455      }
4456  
4457    }
4458   }
4459  
4460   template <class InputCollection1, class InputCollection2>
4461 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4461 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4462  
4463    bool sameObjects = false;
4464    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3755 | Line 4471 | void OSUAnalysis::fill1DHistogram(TH1* h
4471  
4472        pairCounter++;
4473        //only take objects which have passed all cuts and pairs which have passed all cuts
4474 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4475 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4476 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4474 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4475 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4476 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4477  
4478        string currentString = parameters.inputVariables.at(0);
4479        string inputVariable = "";
# Line 3782 | Line 4498 | void OSUAnalysis::fill1DHistogram(TH1* h
4498  
4499  
4500   template <class InputCollection>
4501 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4501 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4502  
4503    for (uint object = 0; object != inputCollection->size(); object++){
4504  
4505 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4505 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4506  
4507      string stringValue = "";
4508      string currentString = parameters.inputVariables.at(0);
# Line 3823 | Line 4539 | void OSUAnalysis::fill2DHistogram(TH2* h
4539   }
4540  
4541   template <class InputCollection1, class InputCollection2>
4542 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4542 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4543  
4544    bool sameObjects = false;
4545    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3837 | Line 4553 | void OSUAnalysis::fill2DHistogram(TH2* h
4553        pairCounter++;
4554  
4555        //only take objects which have passed all cuts and pairs which have passed all cuts
4556 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4557 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4558 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4556 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4557 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4558 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4559  
4560        string stringValue = "";
4561        string currentString = parameters.inputVariables.at(0);
# Line 3887 | Line 4603 | int OSUAnalysis::getGenMatchedParticleIn
4603  
4604      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4605      if(currentDeltaR > 0.05) continue;
4606 <    //     cout << setprecision(3) << setw(20)
4606 >    //     clog << setprecision(3) << setw(20)
4607      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4608      //          << setw(20)
4609      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 3906 | Line 4622 | int OSUAnalysis::getGenMatchedParticleIn
4622      }
4623  
4624    }
4625 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4626 <  //   else cout << "no match found..." << endl;
4625 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4626 >  //   else clog << "no match found..." << endl;
4627    return bestMatchIndex;
4628  
4629   }
# Line 3999 | Line 4715 | OSUAnalysis::chosenVertex ()
4715   {
4716    const BNprimaryvertex *chosenVertex = 0;
4717    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4718 <    vector<bool> vertexFlags;
4718 >    flagPair vertexFlags;
4719      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4720        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4721          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4007 | Line 4723 | OSUAnalysis::chosenVertex ()
4723        }
4724      }
4725      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4726 <      if(!vertexFlags.at(vertexIndex)) continue;
4726 >      if(!vertexFlags.at(vertexIndex).first) continue;
4727        chosenVertex = & primaryvertexs->at(vertexIndex);
4728        break;
4729      }
# Line 4023 | Line 4739 | OSUAnalysis::chosenMET ()
4739   {
4740    const BNmet *chosenMET = 0;
4741    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4742 <    vector<bool> metFlags;
4742 >    flagPair metFlags;
4743      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4744        if (cumulativeFlags.at("mets").at(i).size()){
4745          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4031 | Line 4747 | OSUAnalysis::chosenMET ()
4747        }
4748      }
4749      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4750 <      if(!metFlags.at(metIndex)) continue;
4750 >      if(!metFlags.at(metIndex).first) continue;
4751        chosenMET = & mets->at(metIndex);
4752        break;
4753      }
# Line 4047 | Line 4763 | OSUAnalysis::chosenElectron ()
4763   {
4764    const BNelectron *chosenElectron = 0;
4765    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4766 <    vector<bool> electronFlags;
4766 >    flagPair electronFlags;
4767      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4768        if (cumulativeFlags.at("electrons").at(i).size()){
4769          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4055 | Line 4771 | OSUAnalysis::chosenElectron ()
4771        }
4772      }
4773      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4774 <      if(!electronFlags.at(electronIndex)) continue;
4774 >      if(!electronFlags.at(electronIndex).first) continue;
4775        chosenElectron = & electrons->at(electronIndex);
4776        break;
4777      }
# Line 4066 | Line 4782 | OSUAnalysis::chosenElectron ()
4782    return chosenElectron;
4783   }
4784  
4785 +
4786   const BNmuon *
4787   OSUAnalysis::chosenMuon ()
4788   {
4789    const BNmuon *chosenMuon = 0;
4790    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4791 <    vector<bool> muonFlags;
4791 >    flagPair muonFlags;
4792      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4793        if (cumulativeFlags.at("muons").at(i).size()){
4794          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4079 | Line 4796 | OSUAnalysis::chosenMuon ()
4796        }
4797      }
4798      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4799 <      if(!muonFlags.at(muonIndex)) continue;
4799 >      if(!muonFlags.at(muonIndex).first) continue;
4800        chosenMuon = & muons->at(muonIndex);
4801        break;
4802      }
# Line 4090 | Line 4807 | OSUAnalysis::chosenMuon ()
4807    return chosenMuon;
4808   }
4809  
4810 + double
4811 + OSUAnalysis::chosenHT ()
4812 + {
4813 +  double chosenHT = 0.0;
4814 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
4815 +    flagPair jetFlags;
4816 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
4817 +      if (cumulativeFlags.at("jets").at(i).size()){
4818 +        jetFlags = cumulativeFlags.at("jets").at(i);
4819 +        break;
4820 +      }
4821 +    }
4822 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
4823 +      if(!jetFlags.at(jetIndex).first) continue;
4824 +      chosenHT += jets->at(jetIndex).pt;
4825 +    }
4826 +  }
4827 +
4828 +  return chosenHT;
4829 + }
4830 +
4831 + pair<const BNmuon *, const BNmuon *>
4832 + OSUAnalysis::leadMuonPair ()
4833 + {
4834 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
4835 +  leadMuonPair.first = leadMuonPair.second = 0;
4836 +
4837 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4838 +    flagPair muonFlags;
4839 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4840 +      if (cumulativeFlags.at("muons").at(i).size()){
4841 +        muonFlags = cumulativeFlags.at("muons").at(i);
4842 +        break;
4843 +      }
4844 +    }
4845 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
4846 +      if(!muonFlags.at(muonIndex0).first) continue;
4847 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
4848 +        if(!muonFlags.at(muonIndex1).first) continue;
4849 +        const BNmuon *mu0 = & muons->at(muonIndex0);
4850 +        const BNmuon *mu1 = & muons->at(muonIndex1);
4851 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
4852 +          leadMuonPair.first = mu0;
4853 +          leadMuonPair.second = mu1;
4854 +        }
4855 +        else{
4856 +          TVector2 newPt0 (mu0->px, mu0->py),
4857 +                   newPt1 (mu1->px, mu1->py),
4858 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
4859 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
4860 +          newPt0 += newPt1;
4861 +          oldPt0 += oldPt1;
4862 +          if(newPt0.Mod() > oldPt0.Mod())
4863 +            {
4864 +              leadMuonPair.first = mu0;
4865 +              leadMuonPair.second = mu1;
4866 +            }
4867 +        }
4868 +      }
4869 +    }
4870 +  }
4871 +
4872 +  return leadMuonPair;
4873 + }
4874 +
4875 + pair<const BNelectron *, const BNelectron *>
4876 + OSUAnalysis::leadElectronPair ()
4877 + {
4878 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
4879 +  leadElectronPair.first = leadElectronPair.second = 0;
4880 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4881 +    flagPair electronFlags;
4882 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4883 +      if (cumulativeFlags.at("electrons").at(i).size()){
4884 +        electronFlags = cumulativeFlags.at("electrons").at(i);
4885 +        break;
4886 +      }
4887 +    }
4888 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
4889 +      if(!electronFlags.at(electronIndex0).first) continue;
4890 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
4891 +        if(!electronFlags.at(electronIndex1).first) continue;
4892 +        const BNelectron *el0 = & electrons->at(electronIndex0);
4893 +        const BNelectron *el1 = & electrons->at(electronIndex1);
4894 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
4895 +          leadElectronPair.first = el0;
4896 +          leadElectronPair.second = el1;
4897 +        }
4898 +        else{
4899 +          TVector2 newPt0 (el0->px, el0->py),
4900 +                   newPt1 (el1->px, el1->py),
4901 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
4902 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
4903 +          newPt0 += newPt1;
4904 +          oldPt0 += oldPt1;
4905 +          if(newPt0.Mod() > oldPt0.Mod())
4906 +            {
4907 +              leadElectronPair.first = el0;
4908 +              leadElectronPair.second = el1;
4909 +            }
4910 +        }
4911 +      }
4912 +    }
4913 +  }
4914 +
4915 +  return leadElectronPair;
4916 + }
4917 +
4918   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines