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

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc (file contents):
Revision 1.73 by lantonel, Thu May 30 18:09:58 2013 UTC vs.
Revision 1.114 by wulsin, Wed Jul 31 09:38:21 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")),
5    muons_ (cfg.getParameter<edm::InputTag> ("muons")),
6 +  secMuons_ (cfg.getParameter<edm::InputTag> ("secMuons")),
7    electrons_ (cfg.getParameter<edm::InputTag> ("electrons")),
8    events_ (cfg.getParameter<edm::InputTag> ("events")),
9    taus_ (cfg.getParameter<edm::InputTag> ("taus")),
# Line 28 | Line 28 | OSUAnalysis::OSUAnalysis (const edm::Par
28    datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
32 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
33    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
34    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
35    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
36 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
38 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
39 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
40    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
41    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
42 <  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
43 < {
42 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut")),
43 >  verbose_ (cfg.getParameter<int> ("verbose"))
44 > {
45  
46 <  TH1::SetDefaultSumw2 ();
46 >  if (verbose_) printEventInfo_ = true;  
47 >  if (verbose_) clog << "Beginning OSUAnalysis::OSUAnalysis constructor." << endl;  
48 >
49 >  TH1::SetDefaultSumw2();
50  
51    //create pile-up reweighting object, if necessary
52    if(datasetType_ != "data") {
# Line 46 | Line 55 | OSUAnalysis::OSUAnalysis (const edm::Par
55        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
56        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
57      }
58 +    if (applyBtagSF_){
59 +      bTagSFWeight_ = new BtagSFWeight;
60 +    }
61    }
62    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
63 <    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
63 >    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at(0), stopCTau_.at(1), stops_);
64  
65  
66    // Construct Cutflow Objects. These store the results of cut decisions and
# Line 58 | Line 70 | OSUAnalysis::OSUAnalysis (const edm::Par
70    //always get vertex collection so we can assign the primary vertex in the event
71    objectsToGet.push_back("primaryvertexs");
72    objectsToPlot.push_back("primaryvertexs");
73 <  objectsToCut.push_back("primaryvertexs");
73 >  objectsToFlag.push_back("primaryvertexs");
74  
75  
76    //always get the MC particles to do GEN-matching
# Line 67 | Line 79 | OSUAnalysis::OSUAnalysis (const edm::Par
79    //always get the event collection to do pile-up reweighting
80    objectsToGet.push_back("events");
81  
82 +
83 +  // Parse the tree variable definitions.
84 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
85 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
86 +    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; }
87 +    objectsToGet.push_back(tempInputCollection);
88 +    objectsToFlag.push_back(tempInputCollection);
89 +
90 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
91 +
92 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
93 +      BranchSpecs br;
94 +      br.inputCollection = tempInputCollection;
95 +      br.inputVariable = branchList.at(iBranch);
96 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
97 +      br.name = string(newName.Data());
98 +      treeBranches_.push_back(br);
99 +      if (verbose_>3) clog << "   Adding branch to BNTree: " << br.name << endl;  
100 +    }
101 +
102 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
103 +
104 +
105    //parse the histogram definitions
106    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
107  
108      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
109      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
110 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
111 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
112      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
113 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
114      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
115 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
116 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
117 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
118      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
119      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
120 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
121 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
122 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
123 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
124 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
125      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
126      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
127      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 89 | Line 135 | OSUAnalysis::OSUAnalysis (const edm::Par
135          objectsToGet.push_back(tempInputCollection);
136        }
137        objectsToPlot.push_back(tempInputCollection);
138 <      objectsToCut.push_back(tempInputCollection);
139 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
138 >      objectsToFlag.push_back(tempInputCollection);
139 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
140        string obj1;
141        string obj2;
142        getTwoObjs(tempInputCollection, obj1, obj2);
143        string obj2ToGet = getObjToGet(obj2);
144 <      objectsToCut.push_back(tempInputCollection);
145 <      objectsToCut.push_back(obj1);
146 <      objectsToCut.push_back(obj2);
144 >      objectsToFlag.push_back(tempInputCollection);
145 >      objectsToFlag.push_back(obj1);
146 >      objectsToFlag.push_back(obj2);
147        objectsToPlot.push_back(tempInputCollection);
148        objectsToPlot.push_back(obj1);
149        objectsToPlot.push_back(obj2);
150        objectsToGet.push_back(tempInputCollection);
151        objectsToGet.push_back(obj1);
152        objectsToGet.push_back(obj2ToGet);
153 <
154 <    }
155 <
156 <
153 >    } // end else
154 >    if (find(objectsToPlot.begin(), objectsToPlot.end(), "events") != objectsToPlot.end())
155 >      objectsToGet.push_back("jets");
156 >    
157 >    
158      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
159  
160      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
# Line 128 | Line 174 | OSUAnalysis::OSUAnalysis (const edm::Par
174        histograms.push_back(tempHistogram);
175  
176      }
177 <  }
177 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
178 >
179    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
180    sort( objectsToPlot.begin(), objectsToPlot.end() );
181    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 139 | Line 186 | OSUAnalysis::OSUAnalysis (const edm::Par
186    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
187  
188      string currentObject = objectsToPlot.at(currentObjectIndex);
189 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
189 >    if(currentObject != "muons" &&
190 >       currentObject != "secondary muons" &&
191 >       currentObject != "secondary electrons" &&
192 >       currentObject != "electrons" &&
193 >       currentObject != "taus" &&
194 >       currentObject != "tracks" &&
195 >       currentObject != "photons" &&
196 >       currentObject != "secondary photons"&&
197 >       currentObject != "superclusters")
198 >      continue;
199  
200      histogram tempIdHisto;
201      histogram tempMomIdHisto;
# Line 154 | Line 210 | OSUAnalysis::OSUAnalysis (const edm::Par
210      tempIdVsGmaIdHisto.inputCollection = currentObject;
211  
212      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
213 +    if(currentObject == "secondary photons") currentObject = "secondaryPhotons";
214      if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
215  
216      currentObject = currentObject.substr(0, currentObject.size()-1);
# Line 209 | Line 266 | OSUAnalysis::OSUAnalysis (const edm::Par
266      string channelName  (channels_.at(currentChannel).getParameter<string>("name"));
267      tempChannel.name = channelName;
268      TString channelLabel = channelName;
269 +    if (verbose_) clog << "Processing channel:  " << channelName << endl;  
270  
271      //set triggers for this channel
272      vector<string> triggerNames;
# Line 236 | Line 294 | OSUAnalysis::OSUAnalysis (const edm::Par
294      //create cutFlow for this channel
295      cutFlows_.push_back (new CutFlow (fs_, channelName));
296      vector<TFileDirectory> directories; //vector of directories in the output file.
297 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
298      vector<string> subSubDirNames;//subdirectories in each channel.
299      //get list of cuts for this channel
300      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 247 | Line 306 | OSUAnalysis::OSUAnalysis (const edm::Par
306        //store input collection for cut
307        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
308        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
309 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
310 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
311        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
312        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
313 +      if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
314 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
315 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
316 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
317        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
318        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
319 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
320 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
321 +      if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
322 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
323 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
324        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
325        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
326        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
327        tempCut.inputCollection = tempInputCollection;
328        if(tempInputCollection.find("pairs")==string::npos){ //just a single object
329          if(tempInputCollection.find("secondary")!=string::npos){//secondary object
330 <          int spaceIndex = tempInputCollection.find(" ");
331 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
332 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
330 >          if(tempInputCollection.find("secondary muons")!=string::npos){//treat secondary muons differently; allow for a different input collection
331 >            objectsToGet.push_back("secondary muons");  
332 >          } else {
333 >            int spaceIndex = tempInputCollection.find(" ");
334 >            int secondWordLength = tempInputCollection.size() - spaceIndex;
335 >            objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
336 >          }
337          }
338          else{
339            objectsToGet.push_back(tempInputCollection);
340          }
341          objectsToCut.push_back(tempInputCollection);
342 +        objectsToFlag.push_back(tempInputCollection);
343        }
344        else{//pair of objects, need to add them both to objectsToGet
345          string obj1;
# Line 274 | Line 349 | OSUAnalysis::OSUAnalysis (const edm::Par
349          objectsToCut.push_back(tempInputCollection);
350          objectsToCut.push_back(obj1);
351          objectsToCut.push_back(obj2);
352 +        objectsToFlag.push_back(tempInputCollection);
353 +        objectsToFlag.push_back(obj1);
354 +        objectsToFlag.push_back(obj2);
355          objectsToGet.push_back(tempInputCollection);
356          objectsToGet.push_back(obj1);
357          objectsToGet.push_back(obj2ToGet);
# Line 286 | Line 364 | OSUAnalysis::OSUAnalysis (const edm::Par
364        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
365        vector<string> cutStringVector = splitString(cutString);
366        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
367 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
367 >        clog << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
368          exit(0);
369        }
370        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
# Line 312 | Line 390 | OSUAnalysis::OSUAnalysis (const edm::Par
390        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
391        vector<string> numberRequiredVector = splitString(numberRequiredString);
392        if(numberRequiredVector.size()!=2){
393 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
393 >        clog << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
394          exit(0);
395        }
396  
# Line 320 | Line 398 | OSUAnalysis::OSUAnalysis (const edm::Par
398        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
399        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
400  
401 <      //Set up vectors to store the directories and subDIrectories for each channel.
401 >      //Set up vectors to store the directories and subDirectories for each channel.
402        string subSubDirName;
403        string tempCutName;
404        if(cuts_.at(currentCut).exists("alias")){
405          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
406 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
406 >        subSubDirName = "After " + tempCutName + " Cut Applied";
407        }
408        else{
409          //construct string for cutflow table
# Line 336 | Line 414 | OSUAnalysis::OSUAnalysis (const edm::Par
414          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
415        }
416  
417 +      tempCut.isVeto = false;
418 +      if(cuts_.at(currentCut).exists("isVeto")){
419 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
420 +        if (isVeto == true) tempCut.isVeto = true;
421 +      }
422        subSubDirNames.push_back(subSubDirName);
423        tempCut.name = tempCutName;
424 +      if (verbose_) clog << "Setting up cut, index: " << currentCut << ", input collection: " << tempInputCollection<< ", name: " << tempCut.name << endl;  
425  
426        tempChannel.cuts.push_back(tempCut);
427  
# Line 350 | Line 434 | OSUAnalysis::OSUAnalysis (const edm::Par
434      TFileDirectory subDir = fs_->mkdir( channelName );
435      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
436      if(GetPlotsAfterEachCut_){
437 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
438 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
439 <            directories.push_back(subSubDir);
440 <            map<string, TH1D*> oneDhistoMap;
441 <            oneDHistsTmp.push_back(oneDhistoMap);
442 <            map<string, TH2D*> twoDhistoMap;
443 <            twoDHistsTmp.push_back(twoDhistoMap);
437 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
438 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
439 >        directories.push_back(subSubDir);
440 >        map<string, TH1D*> oneDhistoMap;
441 >        oneDHistsTmp.push_back(oneDhistoMap);
442 >        map<string, TH2D*> twoDhistoMap;
443 >        twoDHistsTmp.push_back(twoDhistoMap);
444        }
445 +      treeDirectories.push_back(subDir);
446        oneDHists_.push_back(oneDHistsTmp);
447        twoDHists_.push_back(twoDHistsTmp);
448      }
449 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
450 <   else{
449 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
450 >    else{
451        map<string, TH1D*> oneDhistoMap;
452        oneDHistsTmp.push_back(oneDhistoMap);
453        map<string, TH2D*> twoDhistoMap;
# Line 370 | Line 455 | OSUAnalysis::OSUAnalysis (const edm::Par
455        oneDHists_.push_back(oneDHistsTmp);
456        twoDHists_.push_back(twoDHistsTmp);
457        directories.push_back(subDir);
458 <   }
458 >      treeDirectories.push_back(subDir);
459 >
460 >    }
461 >
462 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
463 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
464 >      BNTrees_.push_back(newTree);
465 >      BNTrees_.back()->Branch("event_runInt",  &BNTreeBranchVals_runInt_,  "event_runInt/I");      
466 >      BNTrees_.back()->Branch("event_lumiInt", &BNTreeBranchVals_lumiInt_, "event_lumiInt/I");      
467 >      BNTrees_.back()->Branch("event_evtLong", &BNTreeBranchVals_evtLong_, "event_evtLong/L");      
468 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
469 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
470 >        vector<float> newVec;
471 >        BNTreeBranchVals_[currentVar.name] = newVec;
472 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
473 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
474 >    }
475 >
476      //book all histograms included in the configuration
477      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
478 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
479 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
480 <      int numBinsElements = currentHistogram.bins.size();
481 <      int numInputVariables = currentHistogram.inputVariables.size();
482 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
483 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
484 <
485 <      if(numBinsElements == 1){
486 <        if(numBinEdgesX > 1){
487 <          if(numBinEdgesY > 1)
488 <            numBinsElements = 6;
478 >
479 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
480 >
481 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
482 >        int numBinsElements = currentHistogram.bins.size();
483 >        int numInputVariables = currentHistogram.inputVariables.size();
484 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
485 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
486 >
487 >        if(numBinsElements == 1){
488 >          if(numBinEdgesX > 1){
489 >            if(numBinEdgesY > 1)
490 >              numBinsElements = 6;
491 >            else
492 >              numBinsElements = 3;
493 >          }
494 >        }
495 >        if(numBinsElements != 3 && numBinsElements !=6){
496 >          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
497 >          exit(0);
498 >        }
499 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
500 >          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
501 >          exit(0);
502 >        }
503 >        else if(numBinsElements == 3){
504 >          if (currentHistogram.bins.size () == 3)
505 >            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));
506            else
507 <            numBinsElements = 3;
507 >            {
508 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
509 >            }
510          }
511 <      }
512 <      if(numBinsElements != 3 && numBinsElements !=6){
513 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
514 <        exit(0);
515 <      }
516 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
517 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
518 <        exit(0);
519 <      }
520 <      else if(numBinsElements == 3){
521 <        if (currentHistogram.bins.size () == 3)
522 <          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));
523 <        else
524 <          {
525 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
511 >        else if(numBinsElements == 6){
512 >          if (currentHistogram.bins.size () == 6)
513 >            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));
514 >          else
515 >            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 ());
516 >        }
517 >
518 >
519 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
520 >
521 >        // bin      particle type
522 >        // ---      -------------
523 >        //  0        unmatched
524 >        //  1        u
525 >        //  2        d
526 >        //  3        s
527 >        //  4        c
528 >        //  5        b
529 >        //  6        t
530 >        //  7        e
531 >        //  8        mu
532 >        //  9        tau
533 >        // 10        nu
534 >        // 11        g
535 >        // 12        gamma
536 >        // 13        Z
537 >        // 14        W
538 >        // 15        light meson
539 >        // 16        K meson
540 >        // 17        D meson
541 >        // 18        B meson
542 >        // 19        light baryon
543 >        // 20        strange baryon
544 >        // 21        charm baryon
545 >        // 22        bottom baryon
546 >        // 23        QCD string
547 >        // 24        other
548 >
549 >        vector<TString> labelArray;
550 >        labelArray.push_back("unmatched");
551 >        labelArray.push_back("u");
552 >        labelArray.push_back("d");
553 >        labelArray.push_back("s");
554 >        labelArray.push_back("c");
555 >        labelArray.push_back("b");
556 >        labelArray.push_back("t");
557 >        labelArray.push_back("e");
558 >        labelArray.push_back("#mu");
559 >        labelArray.push_back("#tau");
560 >        labelArray.push_back("#nu");
561 >        labelArray.push_back("g");
562 >        labelArray.push_back("#gamma");
563 >        labelArray.push_back("Z");
564 >        labelArray.push_back("W");
565 >        labelArray.push_back("light meson");
566 >        labelArray.push_back("K meson");
567 >        labelArray.push_back("D meson");
568 >        labelArray.push_back("B meson");
569 >        labelArray.push_back("light baryon");
570 >        labelArray.push_back("strange baryon");
571 >        labelArray.push_back("charm baryon");
572 >        labelArray.push_back("bottom baryon");
573 >        labelArray.push_back("QCD string");
574 >        labelArray.push_back("other");
575 >
576 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
577 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
578 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
579            }
580 <      }
581 <      else if(numBinsElements == 6){
582 <        if (currentHistogram.bins.size () == 6)
583 <          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));
584 <        else
585 <          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 ());
586 <      }
580 >          else {
581 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
582 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
583 >          }
584 >        }
585 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
586 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
587 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
588 >        }
589  
590 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
591  
415      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
592  
593 <      // bin      particle type
594 <      // ---      -------------
595 <      //  0        unmatched
596 <      //  1        u
597 <      //  2        d
598 <      //  3        s
599 <      //  4        c
600 <      //  5        b
601 <      //  6        t
602 <      //  7        e
603 <      //  8        mu
604 <      //  9        tau
605 <      // 10        nu
606 <      // 11        g
607 <      // 12        gamma
608 <      // 13        Z
609 <      // 14        W
610 <      // 15        light meson
611 <      // 16        K meson
612 <      // 17        D meson
613 <      // 18        B meson
614 <      // 19        light baryon
615 <      // 20        strange baryon
616 <      // 21        charm baryon
617 <      // 22        bottom baryon
618 <      // 23        QCD string
619 <      // 24        other
620 <
621 <      vector<TString> labelArray;
622 <      labelArray.push_back("unmatched");
623 <      labelArray.push_back("u");
624 <      labelArray.push_back("d");
625 <      labelArray.push_back("s");
626 <      labelArray.push_back("c");
627 <      labelArray.push_back("b");
628 <      labelArray.push_back("t");
629 <      labelArray.push_back("e");
630 <      labelArray.push_back("#mu");
631 <      labelArray.push_back("#tau");
632 <      labelArray.push_back("#nu");
633 <      labelArray.push_back("g");
634 <      labelArray.push_back("#gamma");
635 <      labelArray.push_back("Z");
636 <      labelArray.push_back("W");
637 <      labelArray.push_back("light meson");
638 <      labelArray.push_back("K meson");
639 <      labelArray.push_back("D meson");
640 <      labelArray.push_back("B meson");
641 <      labelArray.push_back("light baryon");
642 <      labelArray.push_back("strange baryon");
643 <      labelArray.push_back("charm baryon");
644 <      labelArray.push_back("bottom baryon");
645 <      labelArray.push_back("QCD string");
470 <      labelArray.push_back("other");
471 <
472 <      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
473 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
474 <          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
475 <        }
476 <        else {
477 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
478 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
479 <        }
480 <      }
481 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
482 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
484 <      }
485 <
486 <    }
487 <
488 <    // Book a histogram for the number of each object type to be plotted.
489 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
490 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
491 <      string currentObject = objectsToPlot.at(currentObjectIndex);
492 <      int maxNum = 10;
493 <      if(currentObject == "mcparticles") maxNum = 50;
494 <      else if(currentObject == "primaryvertexs") maxNum = 50;
495 <
496 <      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
497 <      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
498 <      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
499 <      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
500 <      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
501 <      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
502 <      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
503 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
504 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
505 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
506 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
507 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
508 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
509 <      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
510 <      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
511 <      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
512 <      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
513 <      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
514 <      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
515 <
516 <      currentObject.at(0) = toupper(currentObject.at(0));
517 <      string histoName = "num" + currentObject;
518 <
519 <      if(histoName == "numPrimaryvertexs"){
520 <        string newHistoName = histoName + "BeforePileupCorrection";
521 <        oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
522 <        newHistoName = histoName + "AfterPileupCorrection";
523 <        oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
593 >      // Book a histogram for the number of each object type to be plotted.
594 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
595 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
596 >        string currentObject = objectsToPlot.at(currentObjectIndex);
597 >        int maxNum = 10;
598 >        if(currentObject == "mcparticles") maxNum = 50;
599 >        else if(currentObject == "primaryvertexs") maxNum = 50;
600 >
601 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
602 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
603 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
604 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
605 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
606 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
607 >        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
608 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
609 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
610 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
611 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
612 >        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
613 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
614 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
615 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
616 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
617 >        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
618 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
619 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
620 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
621 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
622 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
623 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
624 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
625 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
626 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
627 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
628 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
629 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
630 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
631 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
632 >        else if(currentObject == "electron-mcparticle pairs")   currentObject = "electronMCparticlePairs";
633 >
634 >
635 >        currentObject.at(0) = toupper(currentObject.at(0));
636 >        string histoName = "num" + currentObject;
637 >
638 >        if(histoName == "numPrimaryvertexs"){
639 >          string newHistoName = histoName + "BeforePileupCorrection";
640 >          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);
641 >          newHistoName = histoName + "AfterPileupCorrection";
642 >          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);
643 >        }
644 >        else
645 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
646        }
647 <      else
648 <        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
649 <    }
650 <   }//end of loop over directories
647 >
648 >      if (verbose_) {
649 >        clog << "List of 1D histograms booked for channel " << channelName << " and directory " << currentDir << ":" << endl;
650 >        for(map<string, TH1D*>::iterator
651 >              iter = oneDHists_.at(currentChannel).at(currentDir).begin();
652 >            iter  != oneDHists_.at(currentChannel).at(currentDir).end();
653 >            iter++) {
654 >          clog << " " << iter->first
655 >               << ":  name=" << iter->second->GetName()
656 >               << ", title=" << iter->second->GetTitle()
657 >               << ", bins=(" << iter->second->GetNbinsX()
658 >               << "," << iter->second->GetXaxis()->GetXmin()
659 >               << "," << iter->second->GetXaxis()->GetXmax()
660 >               << ")" << endl;
661 >        }  
662 >        clog << "List of 2D histograms booked for channel " << channelName << " and directory " << currentDir << ":" << endl;
663 >        for(map<string, TH2D*>::iterator
664 >              iter = twoDHists_.at(currentChannel).at(currentDir).begin();
665 >            iter  != twoDHists_.at(currentChannel).at(currentDir).end();
666 >            iter++) {
667 >          clog << " " << iter->first
668 >               << ":  name=" << iter->second->GetName()
669 >               << ", title=" << iter->second->GetTitle()
670 >               << ", binsX=(" << iter->second->GetNbinsX()
671 >               << "," << iter->second->GetXaxis()->GetXmin()
672 >               << "," << iter->second->GetXaxis()->GetXmax()
673 >               << ")"
674 >               << ", binsY=(" << iter->second->GetNbinsY()
675 >               << "," << iter->second->GetYaxis()->GetXmin()
676 >               << "," << iter->second->GetYaxis()->GetXmax()
677 >               << ")"
678 >               << endl;
679 >        }  
680 >      }
681 >
682 >    }//end of loop over directories
683      channels.push_back(tempChannel);
684      tempChannel.cuts.clear();
685    }//end loop over channels
686  
687  
688 +  // Create the cutflow histogram and fill with 0 weight, in case no events are found in the input file.  
689 +  for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
690 +    channel currentChannel = channels.at(currentChannelIndex);
691 +    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
692 +      cutFlows_.at(currentChannelIndex)->at("trigger") = true;  
693 +    }
694 +    for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
695 +      cut currentCut = currentChannel.cuts.at(currentCutIndex);
696 +      cutFlows_.at(currentChannelIndex)->at (currentCut.name) = true;
697 +    }
698 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(0);  // fill cutflow with 0 weight, just to create the cutflow histograms  
699 +  }
700 +
701    //make unique vector of objects we need to get from the event
702    sort( objectsToGet.begin(), objectsToGet.end() );
703    objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
704    //make unique vector of objects we need to cut on
705    sort( objectsToCut.begin(), objectsToCut.end() );
706    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
707 +  //make unique vector of objects we need to set flags for
708 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
709 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
710  
711 +  // Move all paired objects to the end of the list, so that the flags for single objects are always set before those of paired objects.  
712 +  for (uint i=0; i<objectsToFlag.size(); i++) {
713 +    if (objectsToFlag.at(i).find("pairs")!=string::npos) { // if it contains "pairs"
714 +      objectsToFlag.push_back(objectsToFlag.at(i));  
715 +      objectsToFlag.erase(objectsToFlag.begin()+i);  
716 +    }
717 +  }
718 +
719 +  if (verbose_) {
720 +    clog << "List of channels:" << endl;
721 +    for (uint i=0; i<channels.size(); i++) {
722 +      clog << " " << channels.at(i).name << endl;
723 +    }
724 +    clog << "List of objects to get:" << endl;
725 +    for (uint i=0; i<objectsToGet.size(); i++) {
726 +      clog << " " << objectsToGet.at(i) << endl;
727 +    }
728 +    clog << "List of objects to plot:" << endl;
729 +    for (uint i=0; i<objectsToPlot.size(); i++) {
730 +      clog << " " << objectsToPlot.at(i) << endl;
731 +    }
732 +    clog << "List of objects to cut:" << endl;
733 +    for (uint i=0; i<objectsToCut.size(); i++) {
734 +      clog << " " << objectsToCut.at(i) << endl;
735 +    }
736 +    clog << "List of objects to flag:" << endl;
737 +    for (uint i=0; i<objectsToFlag.size(); i++) {
738 +      clog << " " << objectsToFlag.at(i) << endl;
739 +    }
740 +  }
741 +
742 +  produces<map<string, bool> > ("channelDecisions");
743 +
744 +  if (printEventInfo_) {
745 +    findEventsLog = new ofstream();  
746 +    findEventsLog->open("findEvents.txt");  
747 +    clog << "Listing run:lumi:event in file findEvents.txt for events that pass full selection (of any channel)." << endl;  
748 +  } else {
749 +    findEventsLog = 0;
750 +  }  
751 +
752 +  isFirstEvent_ = true;  
753 +
754 +  if (verbose_) clog << "Finished OSUAnalysis::OSUAnalysis constructor." << endl;  
755 +
756 +
757 +  } // end constructor OSUAnalysis::OSUAnalysis()
758  
542 }
759  
760   OSUAnalysis::~OSUAnalysis ()
761   {
762 +
763 +  if (verbose_) clog << "Beginning OSUAnalysis::OSUAnalysis destructor." << endl;  
764 +
765    // Destroying the CutFlow objects causes the cut flow numbers and time
766    // information to be printed to standard output.
767    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
768      delete cutFlows_.at(currentChannel);
769    }
770 +
771 +  if (printEventInfo_ && findEventsLog) findEventsLog->close();  
772 +
773 +  clog << "=============================================" << endl;  
774 +  clog << "Successfully completed OSUAnalysis." << endl;  
775 +  clog << "=============================================" << endl;  
776 +
777 +  if (verbose_) clog << "Finished OSUAnalysis::OSUAnalysis destructor." << endl;  
778 +
779   }
780  
781   void
782 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
782 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
783   {
556
784    // Retrieve necessary collections from the event.
785  
786 <  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
786 >  if (verbose_) clog << "Beginning OSUAnalysis::produce." << endl;  
787 >
788 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end()) {
789      event.getByLabel (triggers_, triggers);
790 +    if (!triggers.product()) cout << "ERROR:  could not get triggers input collection" << endl;  
791 +  }
792  
793 <  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
793 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end()) {
794      event.getByLabel (trigobjs_, trigobjs);
795 +    if (!trigobjs.product()) cout << "ERROR:  could not get trigobjs input collection" << endl;  
796 +  }
797  
798 <  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
798 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end()) {
799      event.getByLabel (jets_, jets);
800 +    if (!jets.product()) cout << "ERROR:  could not get jets input collection" << endl;  
801 +  }
802  
803 <  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
803 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end()) {
804      event.getByLabel (muons_, muons);
805 +    if (!muons.product()) cout << "ERROR:  could not get muons input collection" << endl;  
806 +  }
807  
808 <  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
808 >  if (find(objectsToGet.begin(), objectsToGet.end(), "secondary muons") != objectsToGet.end()) {
809 >    event.getByLabel (secMuons_, secMuons);
810 >    if (!secMuons.product()) cout << "ERROR:  could not get secMuons input collection" << endl;  
811 >  }
812 >
813 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end()) {
814      event.getByLabel (electrons_, electrons);
815 +    if (!electrons.product()) cout << "ERROR:  could not get electrons input collection" << endl;  
816 +  }
817  
818 <  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
818 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end()) {
819      event.getByLabel (events_, events);
820 +    if (!events.product()) cout << "ERROR:  could not get events input collection" << endl;  
821 +  }
822  
823 <  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
823 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end()) {
824      event.getByLabel (taus_, taus);
825 +    if (!taus.product()) cout << "ERROR:  could not get taus input collection" << endl;  
826 +  }
827  
828 <  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
828 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end()) {
829      event.getByLabel (mets_, mets);
830 +    if (!mets.product()) cout << "ERROR:  could not get mets input collection" << endl;  
831 +  }
832  
833 <  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
833 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end()) {
834      event.getByLabel (tracks_, tracks);
835 +    if (!tracks.product()) cout << "ERROR:  could not get tracks input collection" << endl;  
836 +  }
837  
838 <  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
838 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end()) {
839      event.getByLabel (genjets_, genjets);
840 +    if (!genjets.product()) cout << "ERROR:  could not get genjets input collection" << endl;  
841 +  }
842  
843 <  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
843 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end()) {
844      event.getByLabel (mcparticles_, mcparticles);
845 +    if (!mcparticles.product()) cout << "ERROR:  could not get mcparticles input collection" << endl;  
846 +  }
847  
848 <  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
848 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end()) {
849      event.getByLabel (primaryvertexs_, primaryvertexs);
850 +    if (!primaryvertexs.product()) cout << "ERROR:  could not get primaryvertexs input collection" << endl;  
851 +  }
852  
853 <  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
853 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end()) {
854      event.getByLabel (bxlumis_, bxlumis);
855 +    if (!bxlumis.product()) cout << "ERROR:  could not get bxlumis input collection" << endl;  
856 +  }
857  
858 <  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
858 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end()) {
859      event.getByLabel (photons_, photons);
860 +    if (!photons.product()) cout << "ERROR:  could not get photons input collection" << endl;  
861 +  }
862  
863 <  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
863 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end()) {
864      event.getByLabel (superclusters_, superclusters);
865 +    if (!superclusters.product()) cout << "ERROR:  could not get superclusters input collection" << endl;  
866 +  }
867  
868    if (datasetType_ == "signalMC"){
869 <    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
869 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end()) {
870        event.getByLabel (stops_, stops);
871 +      if (!stops.product()) cout << "ERROR:  could not get stops input collection" << endl;  
872 +    }
873    }
874  
875    if (useTrackCaloRhoCorr_) {
# Line 612 | Line 878 | OSUAnalysis::analyze (const edm::Event &
878      // For description of rho values for different jet reconstruction algorithms, see
879      // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
880      event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
881 +    if (!rhokt6CaloJetsHandle_.product()) cout << "ERROR:  could not get kt6CaloJets input collection" << endl;  
882    }
883  
884    double masterScaleFactor = 1.0;
# Line 619 | Line 886 | OSUAnalysis::analyze (const edm::Event &
886    //get pile-up event weight
887    if (doPileupReweighting_ && datasetType_ != "data") {
888      //for "data" datasets, the numTruePV is always set to -1
889 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
890 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
889 >    if (events->at(0).numTruePV < 0 && isFirstEvent_) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
890 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
891    }
892  
893    stopCTauScaleFactor_ = 1.0;
# Line 630 | Line 897 | OSUAnalysis::analyze (const edm::Event &
897  
898    //loop over all channels
899  
900 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
901    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
902      channel currentChannel = channels.at(currentChannelIndex);
903 +    if (verbose_>1) clog << " Processing channel " << currentChannel.name << endl;
904  
905      flagMap individualFlags;
906      counterMap passingCounter;
907      cumulativeFlags.clear ();
908  
909 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
910 +         iter != BNTreeBranchVals_.end(); iter++) {
911 +      iter->second.clear();  // clear array
912 +    }
913 +
914      bool triggerDecision = true;
915      if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
916        triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
# Line 646 | Line 920 | OSUAnalysis::analyze (const edm::Event &
920      //loop over all cuts
921      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
922        cut currentCut = currentChannel.cuts.at(currentCutIndex);
923 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
924 <        string currentObject = objectsToCut.at(currentObjectIndex);
923 >      if (verbose_>2) clog << "  Processing cut, index: " << currentCutIndex << ", input collection: " << currentCut.inputCollection << ", name: " << currentCut.name << endl;  
924 >
925 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
926 >        string currentObject = objectsToFlag.at(currentObjectIndex);
927  
928          //initialize maps to get ready to set cuts
929 <        individualFlags[currentObject].push_back (vector<bool> ());
930 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
929 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
930 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
931  
932        }
657      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
658        string currentObject = objectsToCut.at(currentObjectIndex);
659
660        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
661
933  
934 <        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
935 <        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
936 <        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
937 <        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
934 >      //set flags for all relevant objects
935 >      for(int currentObjectIndex = -1; currentObjectIndex != int(objectsToFlag.size()); currentObjectIndex++){
936 >        string currentObject;  
937 >        if (currentObjectIndex < 0) currentObject = currentCut.inputCollection;  // In the first loop, set the flags for the collection that the cut is acting on.  That way other paired collections can access the correct flag for the current cut.  
938 >        else currentObject = objectsToFlag.at(currentObjectIndex);
939 >        if (currentObjectIndex >= 0 && currentObject == currentCut.inputCollection) continue;  // Flags have already been set for the inputCollection object, so should not be set again.  
940 >
941 >        // single object collections
942 >        if     (currentObject == "jets")                setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
943 >        else if(currentObject == "secondary jets")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
944 >        else if(currentObject == "secondary photons")   setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
945 >        else if(currentObject == "muons")               setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
946 >        else if(currentObject == "secondary muons")     setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,secMuons.product(),"secondary muons");
947          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
948 <        else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
949 <        else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
950 <        else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
951 <        else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
952 <        else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
953 <        else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
954 <        else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
955 <        else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
956 <        else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
957 <        else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
958 <        else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
959 <        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
960 <
961 <
962 <
963 <        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
964 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
965 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
966 <                                                                   "muon-muon pairs");
967 <
968 <        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
969 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
970 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
971 <                                                                   "muon-secondary muon pairs");
972 <
973 <        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
974 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
975 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
976 <                                                                   "electron-secondary electron pairs");
977 <
978 <        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
979 <                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
980 <                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
981 <                                                                           "electron-electron pairs");
982 <        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
983 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
984 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
985 <                                                                       "electron-muon pairs");
986 <        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
987 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
988 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
989 <                                                                           "jet-jet pairs");
990 <        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
991 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
992 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
713 <                                                                       "electron-jet pairs");
714 <        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
715 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
716 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
717 <                                                                       "muon-jet pairs");
718 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
719 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
720 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
721 <                                                                     "track-event pairs");
722 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
723 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
724 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
725 <                                                                        "electron-track pairs");
726 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
727 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
728 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
729 <                                                                    "muon-track pairs");
730 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
731 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
732 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
733 <                                                                  "muon-tau pairs");
734 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
735 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
736 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
737 <                                                                 "tau-tau pairs");
738 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
739 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
740 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
741 <                                                                 "tau-track pairs");
742 <        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
743 <                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
744 <                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
745 <                                                                          "electron-trigobj pairs");
746 <        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
747 <                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
748 <                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
749 <                                                                      "muon-trigobj pairs");
948 >        else if(currentObject == "electrons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
949 >        else if(currentObject == "events")              setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
950 >        else if(currentObject == "taus")                setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
951 >        else if(currentObject == "mets")                setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
952 >        else if(currentObject == "tracks")              setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
953 >        else if(currentObject == "genjets")             setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
954 >        else if(currentObject == "mcparticles")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
955 >        else if(currentObject == "primaryvertexs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
956 >        else if(currentObject == "bxlumis")             setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
957 >        else if(currentObject == "photons")             setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
958 >        else if(currentObject == "superclusters")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
959 >        else if(currentObject == "trigobjs")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
960 >
961 >
962 >        // paired object collections  
963 >        else if(currentObject == "muon-muon pairs")                   setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), "muon-muon pairs");
964 >        else if(currentObject == "muon-secondary muon pairs")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),secMuons.product(), "muon-secondary muon pairs");
965 >
966 >        else if(currentObject == "muon-secondary photon pairs")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), "muon-secondary photon pairs");
967 >        else if(currentObject == "muon-secondary jet pairs")          setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), "muon-secondary jet pairs");
968 >        else if(currentObject == "photon-secondary jet pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), "photon-secondary jet pairs");
969 >        else if(currentObject == "electron-secondary jet pairs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), "electron-secondary jet pairs");
970 >        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), "electron-secondary electron pairs");
971 >
972 >        else if(currentObject == "electron-electron pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), "electron-electron pairs");
973 >        else if(currentObject == "electron-muon pairs")     setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), "electron-muon pairs");
974 >        else if(currentObject == "jet-jet pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), "jet-jet pairs");
975 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), "jet-secondary jet pairs");
976 >        else if(currentObject == "electron-jet pairs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), "electron-jet pairs");
977 >        else if(currentObject == "electron-photon pairs")   setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), "electron-photon pairs");
978 >        else if(currentObject == "photon-jet pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), "photon-jet pairs");
979 >        else if(currentObject == "muon-jet pairs")          setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), "muon-jet pairs");
980 >        else if(currentObject == "muon-event pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), "muon-event pairs");
981 >        else if(currentObject == "met-jet pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), "met-jet pairs");
982 >        else if(currentObject == "track-jet pairs")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), "track-jet pairs");
983 >        else if(currentObject == "muon-photon pairs")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), "muon-photon pairs");
984 >        else if(currentObject == "track-event pairs")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(), "track-event pairs");
985 >        else if(currentObject == "electron-track pairs")    setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),"electron-track pairs");
986 >        else if(currentObject == "muon-track pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),"muon-track pairs");
987 >        else if(currentObject == "muon-tau pairs")          setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),"muon-tau pairs");
988 >        else if(currentObject == "tau-tau pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),"tau-tau pairs");
989 >        else if(currentObject == "tau-track pairs")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),"tau-track pairs");
990 >        else if(currentObject == "electron-trigobj pairs")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),"electron-trigobj pairs");
991 >        else if(currentObject == "muon-trigobj pairs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),"muon-trigobj pairs");
992 >        else if(currentObject == "electron-mcparticle pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),mcparticles.product(),"electron-mcparticle pairs");
993  
994          if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
995        }
996  
997 +    }//end loop over all cuts
998  
999  
756    }//end loop over all cuts
757    //use cumulative flags to apply cuts at event level
1000  
1001 +    //use cumulative flags to apply cuts at event level
1002 +    vector<bool> eventPassedPreviousCuts;    //a vector to store cumulative cut descisions after each cut.
1003      bool eventPassedAllCuts = true;
1004 <    //a vector to store cumulative cut descisions after each cut.
761 <    vector<bool> eventPassedPreviousCuts;
762 <    //apply trigger (true if none were specified)
763 <    eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
764 <
1004 >    eventPassedAllCuts = eventPassedAllCuts && triggerDecision;    //apply trigger (true if none were specified)
1005  
1006      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
1007  
1008        //loop over all objects and count how many passed the cumulative selection up to this point
1009        cut currentCut = currentChannel.cuts.at(currentCutIndex);
1010        int numberPassing = 0;
1011 +      int numberPassingPrev = 0;  // number of objects that pass cuts up to the previous one
1012  
1013        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
1014 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
1014 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
1015 >      }
1016 >      bool cutDecision;
1017 >      if (!currentCut.isVeto) {
1018 >        cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
1019 >      } else {
1020 >        int prevCutIndex = currentCutIndex - 1;
1021 >        if (prevCutIndex<0) {
1022 >          numberPassingPrev = cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size();  // count all objects in collection if cut is the first
1023 >        } else {
1024 >          for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(prevCutIndex).size() ; object++){
1025 >            if (cumulativeFlags.at(currentCut.inputCollection).at(prevCutIndex).at(object).first) {
1026 >              numberPassingPrev++;
1027 >              if (verbose_>1) clog << " object passed previous cut" << endl;  
1028 >            }
1029 >          }  
1030 >        }  
1031 >        int numberFailCut = numberPassingPrev - numberPassing;
1032 >        cutDecision = evaluateComparison(numberFailCut,currentCut.eventComparativeOperator,currentCut.numberRequired);  
1033        }
1034 <      bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
1034 >
1035        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
1036        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
1037        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
1038 +      if (verbose_>1) clog << " Event passed cuts up to cut index " << currentCutIndex << endl;  
1039 +
1040      }
1041 +    //applying all appropriate scale factors
1042      double scaleFactor = masterScaleFactor;
1043 +    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
1044  
782    muonScaleFactor_ = electronScaleFactor_ = 1.0;
1045      if(applyLeptonSF_ && datasetType_ != "data"){
1046 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
1047 <        vector<bool> muonFlags;
1046 >      //only apply SFs if we've cut on this object
1047 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
1048 >        flagPair muonFlags;
1049 >        //get the last valid flags in the flag map
1050          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
1051            if (cumulativeFlags.at("muons").at(i).size()){
1052              muonFlags = cumulativeFlags.at("muons").at(i);
1053              break;
1054            }
1055          }
1056 +        //apply the weight for each of those objects
1057          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
1058 <          if(!muonFlags.at(muonIndex)) continue;
1058 >          if(!muonFlags.at(muonIndex).second) continue;
1059            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
1060          }
1061        }
1062 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
1063 <        vector<bool> electronFlags;
1062 >      //only apply SFs if we've cut on this object
1063 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
1064 >        flagPair electronFlags;
1065 >        //get the last valid flags in the flag map
1066          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
1067            if (cumulativeFlags.at("electrons").at(i).size()){
1068              electronFlags = cumulativeFlags.at("electrons").at(i);
1069              break;
1070            }
1071          }
1072 +        //apply the weight for each of those objects
1073          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
1074 <          if(!electronFlags.at(electronIndex)) continue;
1074 >          if(!electronFlags.at(electronIndex).second) continue;
1075            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
1076          }
1077        }
1078      }
1079 +    if(applyBtagSF_ && datasetType_ != "data"){
1080 +      //only apply SFs if we've cut on this object
1081 +      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
1082 +        flagPair jetFlags;
1083 +        vector<double> jetSFs;
1084 +        //get the last valid flags in the flag map
1085 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
1086 +          if (cumulativeFlags.at("jets").at(i).size()){
1087 +            jetFlags = cumulativeFlags.at("jets").at(i);
1088 +            break;
1089 +          }
1090 +        }
1091 +        //apply the weight for each of those objects
1092 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
1093 +          if(!jetFlags.at(jetIndex).second) continue;
1094 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
1095 +          jetSFs.push_back(jetSFTmp);
1096 +        }
1097 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
1098 +      }
1099 +    }
1100      scaleFactor *= muonScaleFactor_;
1101      scaleFactor *= electronScaleFactor_;
1102 <
1102 >    scaleFactor *= bTagScaleFactor_;
1103      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1104 +    if (verbose_>1) clog << " Scale factors applied:  "
1105 +                         << " muonScaleFactor_ = " << muonScaleFactor_
1106 +                         << ", electronScaleFactor_ = " << electronScaleFactor_
1107 +                         << ", bTagScaleFactor_ = " << bTagScaleFactor_
1108 +                         << ", total scale factor = " << scaleFactor
1109 +                         << endl;  
1110  
1111  
1112 <    if (printEventInfo_) {
1112 >    if (printEventInfo_ && eventPassedAllCuts) {
1113        // Write information about event to screen, for testing purposes.
1114 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1115 <           << ": run="  << events->at(0).run
1116 <           << "  lumi=" << events->at(0).lumi
1117 <           << "  event=" << events->at(0).evt
1114 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1115 >           << ":  run:lumi:evt=  "  << events->at(0).run
1116 >           << ":" << events->at(0).lumi
1117 >           << ":" << events->at(0).evt
1118             << endl;
1119 <    }
1119 >      if (findEventsLog) {
1120 >        (*findEventsLog) << events->at(0).run
1121 >                         << ":" << events->at(0).lumi
1122 >                         << ":" << events->at(0).evt << endl;
1123 >      }
1124  
1125 +    }
1126  
1127  
1128      //filling histograms
1129 <    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
1129 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the cuts in each channel; if GetPlotsAfterEachCut_ is false, only the last cut will be used.
1130 >
1131 >      if (verbose_>2) clog << "  Filling histograms for currentcut = " << currentCut << endl;  
1132  
1133        uint currentDir;
1134 <      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
1135 <      else currentDir = currentCut;
1134 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1135 >      else{
1136 >        currentDir = currentCut;
1137 >      }
1138  
835      if(!eventPassedPreviousCuts.at(currentDir)) continue;
1139  
1140 +      if(eventPassedPreviousCuts.at(currentDir)){
1141  
1142 <      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1143 <        histogram currentHistogram = histograms.at(histogramIndex);
1142 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1143 >          histogram currentHistogram = histograms.at(histogramIndex);
1144  
1145 <        if(currentHistogram.inputVariables.size() == 1){
1146 <          TH1D* histo;
1147 <          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1148 <
1149 <          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1150 <          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1151 <          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1152 <          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1153 <          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1154 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1155 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1156 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1157 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1158 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1159 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1160 <          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1161 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1162 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1163 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1164 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1165 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1166 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1167 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1168 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1169 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1170 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1171 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1172 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1173 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1174 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1175 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1176 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1177 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1178 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1179 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1180 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1181 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1182 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1183 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1184 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1185 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1186 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1187 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1188 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1189 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1190 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1191 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1192 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1193 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1194 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1195 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1196 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1197 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1198 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1199 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1200 <          
1201 <          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1202 <          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1203 <          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1204 <          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1205 <          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1206 <          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1207 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1208 <          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1209 <          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1210 <          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1211 <          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1212 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1213 <        }
1214 <        else if(currentHistogram.inputVariables.size() == 2){
1215 <          TH2D* histo;
1216 <          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1217 <
1218 <          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1219 <          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1220 <          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1221 <          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1222 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1223 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1224 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1225 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1226 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1227 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1228 <          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1229 <          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1230 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1231 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1232 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1233 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1234 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1235 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1236 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1237 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1238 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1239 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1240 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1241 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1242 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1243 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1244 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1245 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1246 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1247 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1248 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1249 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1250 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1251 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1252 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1253 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1254 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1255 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1256 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1257 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1258 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1259 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1260 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1261 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1262 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1263 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1264 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1265 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1266 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1267 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1268 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1269 <          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1270 <          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1271 <          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1272 <          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1273 <          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1274 <                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1275 <                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1276 <          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1277 <          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1278 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1279 <          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1280 <          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1281 <          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1282 <          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1283 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1284 <        }
1285 <      }
1145 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1146 >
1147 >          if (verbose_>1) clog << " Filling histogram " << currentHistogram.name << " for collection " << currentHistogram.inputCollection << endl;  
1148 >
1149 >          if(currentHistogram.inputVariables.size() == 1){
1150 >            TH1D* histo;
1151 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1152 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1153 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1154 >            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1155 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1156 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,secMuons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1157 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1158 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),
1159 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1160 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),secMuons.product(),
1161 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1162 >             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(),
1163 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1164 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(),
1165 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1166 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(),
1167 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1168 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(),
1169 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1170 >
1171 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1172 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1173 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1174 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),
1175 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1176 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),
1177 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1178 >
1179 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1180 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1181 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(),
1182 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1183 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(),
1184 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1185 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(),
1186 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1187 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(),
1188 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1189 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(),
1190 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1191 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(),
1192 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1193 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1194 >                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1195 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(),
1196 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1197 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(),
1198 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1199 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1200 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1201 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1202 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1203 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1204 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1205 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1206 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1207 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1208 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1209 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1210 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1211 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1212 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1213 >
1214 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1215 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1216 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1217 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1218 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1219 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1220 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1221 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1222 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1223 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1224 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1225 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1226 >          }
1227 >          else if(currentHistogram.inputVariables.size() == 2){
1228 >            TH2D* histo;
1229 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1230 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1231 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1232 >            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1233 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1234 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,secMuons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1235 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(),
1236 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1237 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),secMuons.product(),
1238 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1239 >            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(),
1240 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1241 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(),
1242 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1243 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(),
1244 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1245 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(),
1246 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1247 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1248 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1249 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1250 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1251 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(),
1252 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1253 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1254 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1255 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(),
1256 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1257 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(),
1258 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1259 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(),
1260 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1261 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(),
1262 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1263 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(),
1264 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1265 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(),
1266 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1267 >            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1268 >                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1269 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(),
1270 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1271 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(),
1272 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1273 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1274 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1275 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1276 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1277 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1278 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1279 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1280 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1281 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1282 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1283 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1284 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1285 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1286 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1287 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1288 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1289 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1290 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1291 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1292 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1293 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1294 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1295 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1296 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1297 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1298 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1299 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1300 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1301 >          }
1302  
1303 <      //fills histograms with the sizes of collections
1303 >        }
1304  
985      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
986        
987        string currentObject = objectsToPlot.at(currentObjectIndex);
988        string objectToPlot = "";
989        
990        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
991        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
992        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
993        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
994        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
995        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
996        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
997        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
998        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
999        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1000        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1001        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1002        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1003        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1004        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1005        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1006        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1007        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1008        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1009        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1010        else objectToPlot = currentObject;
1011        
1012        string tempCurrentObject = objectToPlot;
1013        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1014        string histoName = "num" + tempCurrentObject;
1015        
1305  
1306 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1306 >        //fills histograms with the sizes of collections
1307 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1308  
1309 <        //count the number of objects passing all cuts
1310 <        int numToPlot = 0;
1021 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1022 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1023 <        }
1309 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1310 >          string objectToPlot = "";
1311  
1312 <        if(objectToPlot == "primaryvertexs"){
1313 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1314 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1315 <        }
1316 <        else {
1317 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1318 <        }
1319 <      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1312 >          if (verbose_) clog << "Filling histogram of number of selected objects in collection: " << currentObject << endl;  
1313 >
1314 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1315 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1316 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1317 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1318 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1319 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1320 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1321 >          else if(currentObject == "muon-event pairs")                   objectToPlot = "muonEventPairs";
1322 >          else if(currentObject == "muon-photon pairs")                  objectToPlot = "muonPhotonPairs";
1323 >          else if(currentObject == "photon-jet pairs")                   objectToPlot = "photonJetPairs";
1324 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1325 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1326 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1327 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1328 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1329 >          else if(currentObject == "secondary photons")                  objectToPlot = "secondaryPhotons";
1330 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1331 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1332 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1333 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1334 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1335 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1336 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1337 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1338 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1339 >          else if(currentObject == "muon-secondary photon pairs")        objectToPlot = "muonSecondaryJetPairs";
1340 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1341 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1342 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1343 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1344 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1345 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1346 >          else if(currentObject == "electron-mcparticle pairs")          objectToPlot = "electronMCparticlePairs";
1347 >          else objectToPlot = currentObject;
1348 >
1349 >          string tempCurrentObject = objectToPlot;
1350 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1351 >          string histoName = "num" + tempCurrentObject;
1352 >
1353 >
1354 >          if(find(objectsToPlot.begin(), objectsToPlot.end(), currentObject) != objectsToPlot.end()) {
1355 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1356 >            int numToPlot = 0;
1357 >            for (uint iObj = 0; iObj != lastCutFlags.size(); iObj++){  // loop over all the objects  
1358 >              if(lastCutFlags.at(iObj).second) {
1359 >                numToPlot++;  
1360 >                if (verbose_>3) clog << "   Found object " << iObj << " in collection " << currentObject << " to plot." << endl;
1361 >              }
1362 >            }
1363 >
1364 >            if(objectToPlot == "primaryvertexs"){
1365 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1366 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1367 >            }
1368 >            else {
1369 >              if (printEventInfo_) clog << "Number of selected " << objectToPlot << " to plot:  " << numToPlot << endl;  
1370 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1371 >            }
1372 >          }
1373 >
1374 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1375 >
1376 >
1377 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1378 >    } // end loop over cuts
1379 >
1380 >    if (!useEDMFormat_ && eventPassedAllCuts){
1381 >      // Assign BNTree variables
1382 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1383 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1384 >        string coll = brSpecs.inputCollection;
1385 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1386 >
1387 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1388 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1389 >        else if(coll == "secondary photons")   assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1390 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1391 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,secMuons.product(),      cumulativeFlags.at(coll).back());
1392 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1393 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1394 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1395 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1396 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1397 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1398 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1399 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1400 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1401 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1402 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1403 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1404 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1405 >        else if(coll == "stops"
1406 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1407 >      } // end loop over branches
1408 >      // set the evtLong, runInt, and lumiInt variables separately, since they are not type float  
1409 >      BNTreeBranchVals_evtLong_ = events->at(0).evt;
1410 >      BNTreeBranchVals_runInt_  = events->at(0).run;
1411 >      BNTreeBranchVals_lumiInt_ = events->at(0).lumi;
1412 >
1413 >      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1414 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1415      }
1416  
1417 <  } //end loop over channel
1417 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1418 >
1419 >  } // end loop over channel
1420  
1421    masterCutFlow_->fillCutFlow(masterScaleFactor);
1422  
1423 < } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1423 >  event.put (channelDecisions, "channelDecisions");
1424 >
1425 >  isFirstEvent_ = false;  
1426 >
1427 >  if (verbose_) clog << "Finished OSUAnalysis::produce." << endl;  
1428 >
1429 > } // end void OSUAnalysis::produce (const edm::Event &event, const edm::EventSetup &setup)
1430  
1431  
1432  
# Line 1051 | Line 1441 | OSUAnalysis::evaluateComparison (double
1441    else if(comparison == "==") return testValue == cutValue;
1442    else if(comparison == "=") return testValue == cutValue;
1443    else if(comparison == "!=") return testValue != cutValue;
1444 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1444 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1445  
1446   }
1447  
# Line 1064 | Line 1454 | OSUAnalysis::evaluateComparison (string
1454    else if(comparison == "<")  return testValue <  cutValue;
1455    else if(comparison == "<=") return testValue <= cutValue;
1456    else if(comparison == "==") return testValue == cutValue;
1457 <  else if(comparison == "=") return testValue == cutValue;
1457 >  else if(comparison == "=")  return testValue == cutValue;
1458    else if(comparison == "!=") return testValue != cutValue;
1459 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1459 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1460  
1461   }
1462  
# Line 1076 | Line 1466 | OSUAnalysis::evaluateTriggers (vector<st
1466    //initialize to false until a chosen trigger is passed
1467    bool triggerDecision = false;
1468  
1469 +  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1470    //loop over all triggers defined in the event
1471    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1472  
1473 +    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1474 +
1475      //we're only interested in triggers that actually passed
1476      if(trigger->pass != 1) continue;
1477  
# Line 1089 | Line 1482 | OSUAnalysis::evaluateTriggers (vector<st
1482      //if the event passes one of the chosen triggers, set triggerDecision to true
1483      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1484        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1485 <    }  
1485 >    }
1486    }
1487 <  //if none of the veto triggers fired:
1487 >
1488 >  printAllTriggers_ = false;  // only print triggers once, not every event
1489 >
1490 >  //if none of the veto triggers fired:
1491    //return the OR of all the chosen triggers
1492    if (triggersToTest.size() != 0) return triggerDecision;
1493    //or if no triggers were defined return true
# Line 1260 | Line 1656 | OSUAnalysis::valueLookup (const BNjet* o
1656    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1657    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1658  
1659 +  //user defined variable
1660 +  else if(variable == "disappTrkLeadingJetID") {
1661 +    value = object->pt > 110
1662 +      && fabs(object->eta) < 2.4
1663 +      && object->chargedHadronEnergyFraction > 0.2
1664 +      && object->neutralHadronEnergyFraction < 0.7
1665 +      && object->chargedEmEnergyFraction < 0.5
1666 +      && object->neutralEmEnergyFraction < 0.7;
1667 +  }
1668  
1669 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1669 >  else if(variable == "disappTrkSubLeadingJetID") {
1670 >    value = object->pt > 30
1671 >      && fabs(object->eta) < 4.5
1672 >      && object->neutralHadronEnergyFraction < 0.7
1673 >      && object->chargedEmEnergyFraction < 0.5;
1674 >  }
1675 >
1676 >  else if(variable == "dPhiMet") {
1677 >    if (const BNmet *met = chosenMET ()) {
1678 >      value = deltaPhi (object->phi, met->phi);
1679 >    } else value = -999;
1680 >  }
1681 >
1682 >
1683 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1684  
1685    value = applyFunction(function, value);
1686  
1687    return value;
1688 < }
1688 > } // end jet valueLookup
1689  
1690  
1691   //!muon valueLookup
# Line 1363 | Line 1782 | OSUAnalysis::valueLookup (const BNmuon*
1782    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1783    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1784    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1785 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1786 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1787 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1788 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1789    else if(variable == "rhoPrime") value = object->rhoPrime;
1790    else if(variable == "AEffDr03") value = object->AEffDr03;
1791    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1370 | Line 1793 | OSUAnalysis::valueLookup (const BNmuon*
1793    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1794    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1795    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1796 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1797 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1798 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1799 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1800 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1801    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1802    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1803    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1426 | Line 1854 | OSUAnalysis::valueLookup (const BNmuon*
1854    else if(variable == "time_ndof") value = object->time_ndof;
1855  
1856    //user-defined variables
1857 +  else if(variable == "looseID") {
1858 +    value = object->pt > 10 &&
1859 +      (object->isGlobalMuon  > 0 ||
1860 +       object->isTrackerMuon > 0);
1861 +  }
1862    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1863    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1864    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1865    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1866 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1867    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1868    else if(variable == "metMT") {
1869      if (const BNmet *met = chosenMET ())
# Line 1553 | Line 1987 | OSUAnalysis::valueLookup (const BNmuon*
1987      value = object->isGlobalMuon > 0                \
1988        && object->isPFMuon > 0                        \
1989        && object->normalizedChi2 < 10                \
1990 <                                  && object->numberOfValidMuonHits > 0        \
1990 >      && object->numberOfValidMuonHits > 0        \
1991        && object->numberOfMatchedStations > 1        \
1992        && fabs(object->correctedD0Vertex) < 0.2        \
1993        && fabs(object->correctedDZ) < 0.5        \
# Line 1564 | Line 1998 | OSUAnalysis::valueLookup (const BNmuon*
1998      value = object->isGlobalMuon > 0                \
1999        && object->isPFMuon > 0                        \
2000        && object->normalizedChi2 < 10                \
2001 <                                  && object->numberOfValidMuonHits > 0        \
2001 >      && object->numberOfValidMuonHits > 0        \
2002        && object->numberOfMatchedStations > 1        \
2003        && object->numberOfValidPixelHits > 0        \
2004        && object->numberOfLayersWithMeasurement > 5;
# Line 1619 | Line 2053 | OSUAnalysis::valueLookup (const BNmuon*
2053      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2054      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2055      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2056 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2057 <         || fabs (object->correctedDZ / dzError) > 99.0;
2056 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2057 >      || fabs (object->correctedDZ / dzError) > 99.0;
2058      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
2059    }
2060  
2061  
2062  
2063 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2063 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2064  
2065    value = applyFunction(function, value);
2066  
2067    return value;
2068 < }
2068 > } // end muon valueLookup
2069 >
2070  
2071   //!electron valueLookup
2072   double
# Line 1800 | Line 2235 | OSUAnalysis::valueLookup (const BNelectr
2235    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2236    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2237    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2238 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2239 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2240    else if(variable == "metMT") {
2241      if (const BNmet *met = chosenMET ())
2242        {
# Line 1871 | Line 2308 | OSUAnalysis::valueLookup (const BNelectr
2308      else value = -999;
2309    }
2310  
2311 +  else if(variable == "looseID"){
2312 +    if (object->isEB)
2313 +      {
2314 +        value = fabs(object->delEtaIn) < 0.007 \
2315 +          && fabs (object->delPhiIn) < 0.15 \
2316 +          && object->scSigmaIEtaIEta < 0.01 \
2317 +          && object->hadOverEm < 0.12 \
2318 +          && fabs (object->correctedD0Vertex) < 0.02 \
2319 +          && fabs (object->correctedDZ) < 0.2 \
2320 +          && object->absInvEMinusInvPin < 0.05 \
2321 +          && object->passConvVeto;
2322 +      }
2323 +    else
2324 +      {
2325 +        value = fabs(object->delEtaIn) < 0.009 \
2326 +          && fabs (object->delPhiIn) < 0.10 \
2327 +          && object->scSigmaIEtaIEta < 0.03 \
2328 +          && object->hadOverEm < 0.10 \
2329 +          && fabs (object->correctedD0Vertex) < 0.02 \
2330 +          && fabs (object->correctedDZ) < 0.2 \
2331 +          && object->absInvEMinusInvPin < 0.05 \
2332 +          && object->passConvVeto;
2333 +      }
2334 +  }
2335 +
2336    else if(variable == "tightID"){
2337      if (object->isEB)
2338        {
# Line 1896 | Line 2358 | OSUAnalysis::valueLookup (const BNelectr
2358        }
2359    }
2360  
2361 +  else if(variable == "looseID_MVA"){
2362 +    value = object->pt > 10
2363 +      && object->mvaNonTrigV0 > 0;
2364 +      }
2365    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2366      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2367      else value = -999;
# Line 2019 | Line 2485 | OSUAnalysis::valueLookup (const BNelectr
2485      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2486      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2487      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2488 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2489 <         || fabs (object->correctedDZ / dzError) > 99.0;
2488 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2489 >      || fabs (object->correctedDZ / dzError) > 99.0;
2490      value = !value;
2491    }
2492  
2493  
2494  
2495 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2495 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2496  
2497    value = applyFunction(function, value);
2498  
2499    return value;
2500 < }
2500 > } // end electron valueLookup
2501 >
2502  
2503   //!event valueLookup
2504   double
# Line 2112 | Line 2579 | OSUAnalysis::valueLookup (const BNevent*
2579    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2580    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2581    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2582 +  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2583 +
2584 +  else if(variable == "unfilteredHt") value = getHt(jets.product());
2585 +  else if(variable == "ht") value = chosenHT ();
2586  
2587 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2587 >  else if(variable == "leadMuPairInvMass"){
2588 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2589 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2590 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2591 >    value = (p0 + p1).M ();
2592 >  }
2593 >  else if(variable == "leadMuPairPt"){
2594 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2595 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2596 >             pt1 (muPair.second->px, muPair.second->py);
2597 >    pt0 += pt1;
2598 >    value = pt0.Mod ();
2599 >  }
2600 >  else if(variable == "leadElPairInvMass"){
2601 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2602 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2603 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2604 >    value = (p0 + p1).M ();
2605 >  }
2606 >  else if(variable == "leadElPairPt"){
2607 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2608 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2609 >             pt1 (muPair.second->px, muPair.second->py);
2610 >    pt0 += pt1;
2611 >    value = pt0.Mod ();
2612 >  }
2613 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2614  
2615    value = applyFunction(function, value);
2616  
2617    return value;
2618 < }
2618 > } // end event valueLookup
2619 >
2620  
2621   //!tau valueLookup
2622   double
# Line 2166 | Line 2664 | OSUAnalysis::valueLookup (const BNtau* o
2664    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2665    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2666  
2667 <
2667 >  else if (variable == "looseHadronicID") {
2668 >    value = object->pt > 10
2669 >      && object->eta < 2.3
2670 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2671 >      && object->HPSdecayModeFinding > 0
2672 >      && object->HPSagainstElectronLoose > 0
2673 >      && object->HPSagainstMuonTight > 0;
2674 >  }
2675  
2676    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2677  
# Line 2213 | Line 2718 | OSUAnalysis::valueLookup (const BNtau* o
2718    }
2719  
2720  
2721 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2721 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2722  
2723    value = applyFunction(function, value);
2724  
2725    return value;
2726 < }
2726 > } // end tau valueLookup
2727 >
2728  
2729   //!met valueLookup
2730   double
# Line 2286 | Line 2792 | OSUAnalysis::valueLookup (const BNmet* o
2792    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2793    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2794  
2795 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2795 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2796  
2797    value = applyFunction(function, value);
2798  
2799    return value;
2800 < }
2800 > } // end met valueLookup
2801 >
2802  
2803   //!track valueLookup
2804   double
# Line 2319 | Line 2826 | OSUAnalysis::valueLookup (const BNtrack*
2826    else if(variable == "numValidHits") value = object->numValidHits;
2827    else if(variable == "isHighPurity") value = object->isHighPurity;
2828  
2322
2829    //additional BNs info for disappTrks
2830 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2831 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2832 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2833 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2834 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2835 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2836 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2837 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2332 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2830 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2831 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2832 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2833 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2834 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2835 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2836 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2837 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2838    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2839 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2839 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2840 >  else if(variable == "trkRelIsoRp3")     { value = (object->depTrkRp3 - object->pt) / object->pt; if (value<0) value = 0; }
2841 >  else if(variable == "trkRelIsoRp5")     { value = (object->depTrkRp5 - object->pt) / object->pt; if (value<0) value = 0; }
2842 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2843 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2844 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2845 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2846 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2847 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2848 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2849 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2850 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2851 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2852 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2853 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2854 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2855 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2856 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2857 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2858 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2859  
2860    //user defined variables
2861    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;
2862    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2863 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2863 >  else if(variable == "depTrkRp5MinusPt"){
2864 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2865 > //       clog << "Warning:  found track with depTrkRp5 < pt:  depTrkRp5=" << object->depTrkRp5
2866 > //         << "; pt=" << object->pt
2867 > //         << "; object->depTrkRp5 - object->pt = " << object->depTrkRp5 - object->pt
2868 > //         << endl;  
2869 >           value = 0;
2870 >         }
2871 >         else value =  (object->depTrkRp5 - object->pt);
2872 >  }
2873 >  else if(variable == "depTrkRp3MinusPt"){
2874 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2875 >      value = 0;
2876 >    }
2877 >    else value =  (object->depTrkRp3 - object->pt);
2878 >  }
2879 >
2880 >  else if(variable == "dPhiMet") {
2881 >    if (const BNmet *met = chosenMET ()) {
2882 >      value = deltaPhi (object->phi, met->phi);
2883 >    } else value = -999;
2884 >  }
2885 >  
2886 >  
2887    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2888    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2889    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2890    else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2891 +  else if(variable == "depTrkRp5RhoCorr")           value = getTrkDepTrkRp5RhoCorr(object);
2892 +  else if(variable == "depTrkRp3RhoCorr")           value = getTrkDepTrkRp3RhoCorr(object);
2893 +
2894 +  else if(variable == "depTrkRp5MinusPtRhoCorr")    {
2895 +    if ( (getTrkDepTrkRp5RhoCorr(object) - object->pt) < 0 ) value = 0;
2896 +    else {value = (getTrkDepTrkRp5RhoCorr(object) - object->pt );}
2897 +  }
2898 +  
2899 +  else if(variable == "depTrkRp3MinusPtRhoCorr")    
2900 +    {
2901 +      if ( (getTrkDepTrkRp3RhoCorr(object) - object->pt) < 0 ) value = 0;
2902 +      else {value = (getTrkDepTrkRp3RhoCorr(object) - object->pt );}
2903 +    }
2904 +
2905    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2906    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2907    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
# Line 2364 | Line 2925 | OSUAnalysis::valueLookup (const BNtrack*
2925        pt = object->pt;
2926      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2927    }
2928 +
2929 +  else if(variable == "deltaRMinSubLeadJet") {
2930 +    // calculate minimum deltaR between track and any other subleading jet  
2931 +    double trkJetDeltaRMin = 99.;  
2932 +    for (uint ijet = 0; ijet<jets->size(); ijet++) {
2933 +      string empty = "";  
2934 +      double isSubLeadingJet = valueLookup(&jets->at(ijet), "disappTrkSubLeadingJetID", "", empty);  
2935 +      if (!isSubLeadingJet) continue;  // only consider jets that pass the subleading jet ID criteria  
2936 +      double jetEta = valueLookup(&jets->at(ijet), "eta", "", empty);
2937 +      double jetPhi = valueLookup(&jets->at(ijet), "phi", "", empty);
2938 +      double trkJetDeltaR = deltaR(object->eta, object->phi, jetEta, jetPhi);  
2939 +      if (trkJetDeltaR < trkJetDeltaRMin) trkJetDeltaRMin = trkJetDeltaR;
2940 +    }
2941 +    value = trkJetDeltaRMin;  
2942 +  }  
2943 +  
2944    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2945  
2946    else if(variable == "genMatchedPdgId"){
# Line 2411 | Line 2988 | OSUAnalysis::valueLookup (const BNtrack*
2988  
2989  
2990  
2991 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2991 >  else{clog << "WARNING: invalid variable '" << variable << "' for BNtrack collection.\n"; value = -999;}
2992  
2993    value = applyFunction(function, value);
2994  
2995    return value;
2996 < }
2996 > } // end track valueLookup
2997 >
2998  
2999   //!genjet valueLookup
3000   double
# Line 2440 | Line 3018 | OSUAnalysis::valueLookup (const BNgenjet
3018    else if(variable == "charge") value = object->charge;
3019  
3020  
3021 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3021 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3022  
3023    value = applyFunction(function, value);
3024  
# Line 2574 | Line 3152 | OSUAnalysis::valueLookup (const BNmcpart
3152    }
3153  
3154  
3155 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3155 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3156  
3157    value = applyFunction(function, value);
3158  
3159    return value;
3160 < }
3160 > } // end mcparticle valueLookup
3161 >
3162  
3163   //!primaryvertex valueLookup
3164   double
# Line 2602 | Line 3181 | OSUAnalysis::valueLookup (const BNprimar
3181    else if(variable == "isGood") value = object->isGood;
3182  
3183  
3184 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3184 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3185  
3186    value = applyFunction(function, value);
3187  
# Line 2620 | Line 3199 | OSUAnalysis::valueLookup (const BNbxlumi
3199    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3200  
3201  
3202 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3202 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3203  
3204    value = applyFunction(function, value);
3205  
# Line 2753 | Line 3332 | OSUAnalysis::valueLookup (const BNphoton
3332    }
3333  
3334  
3335 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3335 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3336  
3337    value = applyFunction(function, value);
3338  
3339    return value;
3340 < }
3340 > } // end photon valueLookup
3341 >
3342  
3343   //!supercluster valueLookup
3344   double
# Line 2776 | Line 3356 | OSUAnalysis::valueLookup (const BNsuperc
3356    else if(variable == "theta") value = object->theta;
3357  
3358  
3359 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3359 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3360  
3361    value = applyFunction(function, value);
3362  
# Line 2810 | Line 3390 | OSUAnalysis::valueLookup (const BNtrigob
3390        stringValue = "none";  // stringValue should only be empty if value is filled
3391    }
3392  
3393 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3393 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3394  
3395    value = applyFunction(function, value);
3396  
# Line 2881 | Line 3461 | OSUAnalysis::valueLookup (const BNmuon*
3461        value = object2->correctedD0;
3462      }
3463  
3464 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3464 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3465 >
3466 >  value = applyFunction(function, value);
3467 >
3468 >  return value;
3469 > } // end muon-muon pair valueLookup
3470 >
3471 >
3472 > //!muon-photon pair valueLookup
3473 > double
3474 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3475 >
3476 >  double value = 0.0;
3477 >
3478 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3479 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3480 >  else if(variable == "photonEta") value = object2->eta;
3481 >  else if(variable == "photonPt") value = object2->pt;
3482 >  else if(variable == "muonEta") value = object1->eta;
3483 >  else if(variable == "photonPhi") value = object2->phi;
3484 >  else if(variable == "muonPhi") value = object1->phi;
3485 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3486 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3487 >  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3488 >  else if(variable == "invMass"){
3489 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3490 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3491 >    value = (fourVector1 + fourVector2).M();
3492 >  }
3493 >  else if(variable == "pt"){
3494 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3495 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3496 >    value = (fourVector1 + fourVector2).Pt();
3497 >  }
3498 >  else if(variable == "threeDAngle")
3499 >    {
3500 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3501 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3502 >      value = (threeVector1.Angle(threeVector2));
3503 >    }
3504 >  else if(variable == "alpha")
3505 >    {
3506 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3507 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3508 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3509 >      value = (pi-threeVector1.Angle(threeVector2));
3510 >    }
3511 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3512 >
3513 >  value = applyFunction(function, value);
3514 >
3515 >  return value;
3516 > }
3517 >
3518 > //!electron-photon pair valueLookup
3519 > double
3520 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3521 >
3522 >  double value = 0.0;
3523 >
3524 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3525 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3526 >  else if(variable == "photonEta") value = object2->eta;
3527 >  else if(variable == "photonPt") value = object2->pt;
3528 >  else if(variable == "electronEta") value = object1->eta;
3529 >  else if(variable == "photonPhi") value = object2->phi;
3530 >  else if(variable == "electronPhi") value = object1->phi;
3531 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3532 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3533 >  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3534 >  else if(variable == "invMass"){
3535 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3536 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3537 >    value = (fourVector1 + fourVector2).M();
3538 >  }
3539 >  else if(variable == "pt"){
3540 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3541 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3542 >    value = (fourVector1 + fourVector2).Pt();
3543 >  }
3544 >  else if(variable == "threeDAngle")
3545 >    {
3546 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3547 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3548 >      value = (threeVector1.Angle(threeVector2));
3549 >    }
3550 >  else if(variable == "alpha")
3551 >    {
3552 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3553 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3554 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3555 >      value = (pi-threeVector1.Angle(threeVector2));
3556 >    }
3557 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3558  
3559    value = applyFunction(function, value);
3560  
# Line 2937 | Line 3610 | OSUAnalysis::valueLookup (const BNelectr
3610      value = object2->correctedD0;
3611    }
3612  
3613 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3613 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3614  
3615    value = applyFunction(function, value);
3616  
3617    return value;
3618   }
3619 +
3620   //!electron-muon pair valueLookup
3621   double
3622   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3003 | Line 3677 | OSUAnalysis::valueLookup (const BNelectr
3677    else if(variable == "muonRelPFdBetaIso"){
3678      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3679    }
3680 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3680 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3681    value = applyFunction(function, value);
3682  
3683    return value;
3684 < }
3684 > } // end electron-muon pair valueLookup
3685  
3686 +
3687   //!electron-jet pair valueLookup
3688   double
3689   OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3017 | Line 3692 | OSUAnalysis::valueLookup (const BNelectr
3692  
3693    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3694    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3695 +  else if(variable == "jetEta") value = object2->eta;
3696 +  else if(variable == "jetPhi") value = object2->phi;
3697 +  else if(variable == "electronEta") value = object1->eta;
3698 +  else if(variable == "electronPhi") value = object1->phi;
3699    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3700    else if(variable == "invMass"){
3701      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3038 | Line 3717 | OSUAnalysis::valueLookup (const BNelectr
3717      value = object1->charge*object2->charge;
3718    }
3719  
3720 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3720 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3721 >  value = applyFunction(function, value);
3722 >
3723 >  return value;
3724 > }
3725 >
3726 > //!electron-mcparticle pair valueLookup
3727 > double
3728 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmcparticle* object2, string variable, string function, string &stringValue){
3729 >
3730 >  double value = 0.0;
3731 >
3732 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3733 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3734 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3735 >  else if(variable == "threeDAngle")
3736 >    {
3737 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3738 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3739 >      value = (threeVector1.Angle(threeVector2));
3740 >    }
3741 >  else if(variable == "chargeProduct"){
3742 >    value = object1->charge*object2->charge;
3743 >  }
3744 >
3745 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3746    value = applyFunction(function, value);
3747  
3748    return value;
3749   }
3750  
3751 +
3752 + //!photon-jet pair valueLookup
3753 + double
3754 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3755 +
3756 +  double value = 0.0;
3757 +
3758 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3759 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3760 +  else if(variable == "jetEta") value = object2->eta;
3761 +  else if(variable == "jetPhi") value = object2->phi;
3762 +  else if(variable == "photonEta") value = object1->eta;
3763 +  else if(variable == "photonPhi") value = object1->phi;
3764 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3765 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3766 +  else if(variable == "invMass"){
3767 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3768 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3769 +    value = (fourVector1 + fourVector2).M();
3770 +  }
3771 +  else if(variable == "pt"){
3772 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3773 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3774 +    value = (fourVector1 + fourVector2).Pt();
3775 +  }
3776 +  else if(variable == "threeDAngle")
3777 +    {
3778 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3779 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3780 +      value = (threeVector1.Angle(threeVector2));
3781 +    }
3782 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3783 +  value = applyFunction(function, value);
3784 +
3785 +  return value;
3786 + }
3787 +
3788 + // track-jet pair valueLookup
3789 + double
3790 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3791 +
3792 +  double value = 0.0;
3793 +
3794 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3795 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3796 +
3797 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3798 +  value = applyFunction(function, value);
3799 +
3800 +  return value;
3801 +
3802 + }
3803 +
3804 +
3805 +
3806 + // met-jet pair valueLookup
3807 + double
3808 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3809 +
3810 +  double value = 0.0;
3811 +
3812 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3813 +
3814 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3815 +  value = applyFunction(function, value);
3816 +
3817 +  return value;
3818 +
3819 + }  
3820 +
3821 +
3822 +
3823   //!muon-jet pair valueLookup
3824   double
3825   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3051 | Line 3827 | OSUAnalysis::valueLookup (const BNmuon*
3827    double value = 0.0;
3828  
3829    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3830 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3830 >  else if(variable == "jetEta") value = object2->eta;
3831 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3832 >  else if(variable == "jetPt") value = object2->pt;
3833 >  else if(variable == "jetPhi") value = object2->phi;
3834 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3835 >  else if(variable == "muonEta") value = object1->eta;
3836 >  else if(variable == "muonPt") value = object1->pt;
3837 >  else if(variable == "muonPhi") value = object1->phi;
3838 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3839    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3840    else if(variable == "invMass"){
3841      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3073 | Line 3857 | OSUAnalysis::valueLookup (const BNmuon*
3857      value = object1->charge*object2->charge;
3858    }
3859  
3860 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3860 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3861    value = applyFunction(function, value);
3862  
3863    return value;
3864   }
3865  
3866 + //!muon-event valueLookup
3867 + double
3868 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3869 +
3870 +  double value = 0.0;
3871 +
3872 +  if(variable == "muonEta") value = object1->eta;
3873 +  else if(variable == "muonPt") value = object1->pt;
3874 +  else if(variable == "muonPhi") value = object1->phi;
3875 +  else if(variable == "Ht") value = getHt(jets.product());
3876 +  else if(variable == "pthat")   value = object2->pthat;
3877 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3878 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3879 +  value = applyFunction(function, value);
3880 +
3881 +  return value;
3882 + }
3883   //!jet-jet pair valueLookup
3884   double
3885   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3087 | Line 3888 | OSUAnalysis::valueLookup (const BNjet* o
3888  
3889    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3890    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3891 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3891 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3892    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3893    else if(variable == "invMass"){
3894      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3109 | Line 3910 | OSUAnalysis::valueLookup (const BNjet* o
3910      value = object1->charge*object2->charge;
3911    }
3912  
3913 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3913 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3914    value = applyFunction(function, value);
3915  
3916    return value;
3917   }
3918 +
3919   //!electron-track pair valueLookup
3920   double
3921   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3133 | Line 3935 | OSUAnalysis::valueLookup (const BNelectr
3935    else if(variable == "chargeProduct"){
3936      value = object1->charge*object2->charge;
3937    }
3938 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3938 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3939    value = applyFunction(function, value);
3940    return value;
3941  
# Line 3161 | Line 3963 | OSUAnalysis::valueLookup (const BNmuon*
3963      value = object1->charge*object2->charge;
3964    }
3965  
3966 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3966 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3967    value = applyFunction(function, value);
3968    return value;
3969   }
# Line 3183 | Line 3985 | OSUAnalysis::valueLookup (const BNtau* o
3985      value = object1->charge*object2->charge;
3986    }
3987  
3988 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3988 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3989    value = applyFunction(function, value);
3990    return value;
3991   }
# Line 3205 | Line 4007 | OSUAnalysis::valueLookup (const BNmuon*
4007      value = object1->charge*object2->charge;
4008    }
4009  
4010 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4010 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4011    value = applyFunction(function, value);
4012    return value;
4013   }
# Line 3220 | Line 4022 | OSUAnalysis::valueLookup (const BNtau* o
4022      value = object1->charge*object2->charge;
4023    }
4024  
4025 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4025 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4026    value = applyFunction(function, value);
4027    return value;
4028   }
# Line 3240 | Line 4042 | OSUAnalysis::valueLookup (const BNtrack*
4042    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
4043    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
4044  
4045 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4045 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4046  
4047    value = applyFunction(function, value);
4048  
# Line 3262 | Line 4064 | OSUAnalysis::valueLookup (const BNelectr
4064        stringValue = "none";
4065    }
4066  
4067 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4067 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4068  
4069    value = applyFunction(function, value);
4070  
# Line 3278 | Line 4080 | OSUAnalysis::valueLookup (const BNmuon*
4080  
4081    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4082  
4083 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4083 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4084  
4085    value = applyFunction(function, value);
4086  
# Line 3381 | Line 4183 | OSUAnalysis::valueLookup (const BNstop*
4183      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4184        vertex_rank++;
4185        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4186 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
4187 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
4186 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4187 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
4188  
4189        if(abs(dist) < abs(minDistToVertex)){
4190          value = vertex_rank;
# Line 3391 | Line 4193 | OSUAnalysis::valueLookup (const BNstop*
4193      }
4194    }
4195  
4196 +  else if (variable == "decaysToTau"){
4197 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4198 +  }
4199 +
4200  
4201  
4202  
4203 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4203 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4204  
4205    value = applyFunction(function, value);
4206  
4207    return value;
4208  
4209 < }
4209 > } // end stop valueLookup
4210 >
4211  
4212  
4213  
# Line 3418 | Line 4225 | OSUAnalysis::getTrkIsIso (const BNtrack*
4225  
4226   }
4227  
4228 + //calculate the scalar sum of Jet Pt in the event.
4229 + double
4230 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4231 +  double Ht = 0;
4232 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4233 +    Ht += abs(jet->pt);
4234 +  }
4235 +  return Ht;
4236 + }
4237  
4238   double
4239   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3455 | Line 4271 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4271    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4272    if (!useTrackCaloRhoCorr_) return -99;
4273    // if (!rhokt6CaloJetsHandle_) {
4274 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4274 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4275    //   return -99;
4276    // }
4277    double radDeltaRCone = 0.5;
# Line 3466 | Line 4282 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4282  
4283   }
4284  
4285 + double
4286 + OSUAnalysis::getTrkDepTrkRp5RhoCorr(const BNtrack* track) {
4287 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.              
4288 +  if (!useTrackCaloRhoCorr_) return -99;
4289 +  // if (!rhokt6CaloJetsHandle_) {                                                                                                    
4290 +  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;                        
4291 +  //   return -99;                                                                                                                    
4292 +  // }                                                                                                                                
4293 +  double radDeltaRCone = 0.5;
4294 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.                                                                                                          
4295 +  double rawDepTrkRp5 = track->depTrkRp5;
4296 + double depTrkRp5RhoCorr = TMath::Max(0., rawDepTrkRp5 - rhoCorr_kt6CaloJets);
4297 + return depTrkRp5RhoCorr;
4298 +
4299 + }
4300 +
4301 + double
4302 + OSUAnalysis::getTrkDepTrkRp3RhoCorr(const BNtrack* track) {
4303 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.                                                
4304 +  if (!useTrackCaloRhoCorr_) return -99;
4305 +  // if (!rhokt6CaloJetsHandle_) {                                                                                                                                      
4306 +  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;                                                          
4307 +  //   return -99;                                                                                                                                                      
4308 +  // }                                                                                                                                                                  
4309 +  double radDeltaRCone = 0.3;
4310 + // Define effective area as pi*r^2, where r is radius of DeltaR cone
4311 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  
4312 +  double rawDepTrkRp3 = track->depTrkRp3;
4313 +  double depTrkRp3RhoCorr = TMath::Max(0., rawDepTrkRp3 - rhoCorr_kt6CaloJets);
4314 +  return depTrkRp3RhoCorr;
4315 +  
4316 + }
4317 +
4318  
4319  
4320  
# Line 3477 | Line 4326 | OSUAnalysis::WriteDeadEcal (){
4326    double etaEcal, phiEcal;
4327    ifstream DeadEcalFile(deadEcalFile_);
4328    if(!DeadEcalFile) {
4329 <    cout << "Error: DeadEcalFile has not been found." << endl;
4329 >    clog << "Error: DeadEcalFile has not been found." << endl;
4330      return;
4331    }
4332    if(DeadEcalVec.size()!= 0){
4333 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4333 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4334      return;
4335    }
4336    while(!DeadEcalFile.eof())
# Line 3492 | Line 4341 | OSUAnalysis::WriteDeadEcal (){
4341        newChan.phiEcal = phiEcal;
4342        DeadEcalVec.push_back(newChan);
4343      }
4344 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4344 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4345   }
4346  
4347   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3532 | Line 4381 | OSUAnalysis::applyFunction(string functi
4381    else if(function == "log") value = log10(value);
4382  
4383    else if(function == "") value = value;
4384 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4384 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4385  
4386    return value;
4387  
# Line 3542 | Line 4391 | OSUAnalysis::applyFunction(string functi
4391   template <class InputCollection>
4392   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
4393  
4394 +  if (verbose_>2) clog << "  Beginning setObjectFlags for cut " << currentCutIndex << ": " << currentCut.name
4395 +                       << ", inputType=" << inputType
4396 +                       << endl;  
4397    if (currentCut.inputCollection.find("pair")!=string::npos)  {
4398      string obj1, obj2;
4399      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4400 +    if (verbose_>2) clog << "  Two object types:  " << obj1 << ", " << obj2 << endl;
4401      if (inputType==obj1 ||
4402 <          inputType==obj2) {
4402 >        inputType==obj2) {
4403        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4404        // and the inputType is a member of the pair.
4405        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3556 | Line 4409 | void OSUAnalysis::setObjectFlags(cut &cu
4409      }
4410    }
4411  
4412 +  if (!inputCollection) cout << "ERROR:  invalid input collection for inputType=" << inputType << endl;  
4413 +
4414 +  if (verbose_>3) clog << "   Collection size:  " << inputCollection->size() << endl;
4415 +
4416    for (uint object = 0; object != inputCollection->size(); object++){
4417  
4418 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4418 >    if (verbose_>4) clog << "    Setting flags for object " << object << endl;
4419 >
4420 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4421 >    bool plotDecision = true;
4422  
4423      if(currentCut.inputCollection == inputType){
4424  
# Line 3570 | Line 4430 | void OSUAnalysis::setObjectFlags(cut &cu
4430          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4431  
4432        }
4433 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4433 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4434        else{
4435          bool tempDecision = true;
4436          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3579 | Line 4439 | void OSUAnalysis::setObjectFlags(cut &cu
4439            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4440              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4441          }
4442 <        decision = tempDecision;
4442 >        cutDecision = tempDecision;
4443        }
4444 +      //invert the cut if this cut is a veto
4445 +      if(currentCut.isVeto) cutDecision = !cutDecision;
4446 +      plotDecision = cutDecision;
4447      }
4448  
4449 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4449 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4450  
4451 <    //set flags for objects that pass each cut AND all the previous cuts
4452 <    bool previousCumulativeFlag = true;
4451 >    //set flags for objects that pass this cut AND all the previous cuts
4452 >    bool previousCumulativeCutFlag = true;
4453 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4454 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4455 >      else{ previousCumulativeCutFlag = false; break;}
4456 >    }
4457 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4458 >    bool previousCumulativePlotFlag = true;
4459      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4460 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4461 <      else{ previousCumulativeFlag = false; break;}
4460 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4461 >      else{ previousCumulativePlotFlag = false; break;}
4462      }
4463 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4463 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4464  
4465 <  }
4465 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4466  
4467 < }
4467 >  }  //   for (uint object = 0; object != inputCollection->size(); object++){
4468  
4469 + } // end void OSUAnalysis::setObjectFlags
4470  
3601 template <class InputCollection1, class InputCollection2>
3602 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
3603                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4471  
4472 + template <class InputCollection1, class InputCollection2>
4473 + void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags,
4474 +                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
4475 +  // This function sets the flags for the paired object collection.  
4476 +  // If the cut is applying on the given paired object collection, then the flags for the single object collections are also set.
4477 +  // If not, then the flags for the paired object collection are taken as the AND of the flags for each single object collection.  
4478 +
4479 +  if (verbose_>2) clog << "  Beginning setObjectFlags for cut=" << currentCut.name
4480 +                       << ", inputType=" << inputType
4481 +                       << endl;  
4482  
4483    bool sameObjects = false;
4484 <  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4484 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;  // FIXME:  is sameObjects just the not of isTwoTypesOfObject?  If so, it's redundant.  
4485  
4486    // Get the strings for the two objects that make up the pair.
4487    string obj1Type, obj2Type;
# Line 3616 | Line 4493 | void OSUAnalysis::setObjectFlags(cut &cu
4493    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4494    if (currentCut.inputCollection == inputType) {
4495      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4496 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4497 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4496 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4497 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4498      }
4499      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4500        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4501 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4502 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4501 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4502 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4503        }
4504      }
4505    }
# Line 3635 | Line 4512 | void OSUAnalysis::setObjectFlags(cut &cu
4512        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4513  
4514  
4515 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4515 >      bool cutDecision  = true;//object passes if this cut doesn't cut on that type of object
4516 >      bool plotDecision = true;
4517  
4518 +      // Determine whether each pair passes the cut, only if inputCollection is the same as the inputType.  
4519        if(currentCut.inputCollection == inputType){
4520  
4521          vector<bool> subcutDecisions;
4522          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4523            string stringValue = "";
4524            double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4525 +          if (verbose_>1) clog << currentCut.variables.at(subcutIndex) << " = " << value
4526 +                               << endl;  
4527            if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4528            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4529          }
4530  
4531 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4531 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4532          else{
4533            bool tempDecision = subcutDecisions.at(0);
4534            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3656 | Line 4537 | void OSUAnalysis::setObjectFlags(cut &cu
4537              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4538                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4539            }
4540 <          decision = tempDecision;
4540 >          cutDecision = tempDecision;
4541          }
4542 +        //invert the cut if this cut is a veto
4543 +        if (currentCut.isVeto) cutDecision = !cutDecision;
4544 +        plotDecision = cutDecision;
4545 +
4546 +        if (verbose_>1) clog << " cutDecision = " << cutDecision
4547 +                             << "; for currentCut.inputCollection = " << currentCut.inputCollection
4548 +                             << "; object1 (" << obj1Type << ") = " << object1
4549 +                             << "; object2 (" << obj2Type << ") = " << object2
4550 +                             << endl;  
4551 +        
4552 +        if (cutDecision) {  // only set the flags for the individual objects if the pair object is being cut on
4553 +          individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4554 +          individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4555 +        }
4556 +        if (plotDecision) {  // only set the flags for the individual objects if the pair object is being cut on
4557 +          individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4558 +          individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4559 +        }
4560 +        
4561 +
4562 +      } // if(currentCut.inputCollection == inputType){
4563 +
4564 +      // The individualFlags will be true if the inputCollection is not the same as the inputType.
4565 +      // They are also independent of the previous flags on the single objects.  
4566 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));  
4567 +
4568 +
4569 +
4570 +      // ************************************
4571 +      // Determine cumulative flags
4572 +      // ************************************
4573 +      // determine whether this paired object passes this cut AND all previous cuts
4574 +      bool previousCumulativeCutFlag = true;
4575 +      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4576 +        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4577 +        else{ previousCumulativeCutFlag = false; break;}
4578        }
4579 <      // if (decision) isPassObj1.at(object1) = true;
3663 <      // if (decision) isPassObj2.at(object2) = true;
3664 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3665 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3666 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3667 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3668 <      }
4579 >      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4580  
4581 <      //set flags for objects that pass each cut AND all the previous cuts
3671 <      bool previousCumulativeFlag = true;
4581 >      bool previousCumulativePlotFlag = true;
4582        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4583 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4584 <        else{ previousCumulativeFlag = false; break;}
4583 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4584 >        else{ previousCumulativePlotFlag = false; break;}
4585        }
4586 <      //apply flags for the components of the composite object as well
4587 <      bool currentCumulativeFlag = true;
4588 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4589 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4590 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4591 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4592 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4593 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4594 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4595 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4586 >      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4587 >      
4588 >      // Get the index for the flags of each of the single objects in the pair.  Usually this is the index of the previous cut, i.e., currentCutIndex-1.    
4589 >      int cutIdxFlagsObj1 = max(int(currentCutIndex-1),0);
4590 >      int cutIdxFlagsObj2 = max(int(currentCutIndex-1),0);
4591 >      // If the inputCollection of the cut is not equal to the inputType but the inputCollection includes objects that are contained in inputType, then use the currentCutIndex for those collections.
4592 >      // For example, if the inputType is jet-jet pairs, and the inputCollection is track-jet pairs, then use currentCutIndex for cutIdxFlagsObj{1,2}, i.e., for both jets.  
4593 >      // For example, if the inputType is jets, and the inputCollection is track-jet pairs, then use currentCutIndex for cutIdxFlagsObj2 (jets) and currentCutIndex-1 for cutIdxFlagsObj1 (tracks).  
4594 >      if (currentCut.inputCollection != inputType) {  
4595 >        if (currentCut.inputCollection.find(obj1Type)!=string::npos) cutIdxFlagsObj1 = currentCutIndex;
4596 >        if (currentCut.inputCollection.find(obj2Type)!=string::npos) cutIdxFlagsObj2 = currentCutIndex;
4597 >      }  
4598 >      flagPair flags1 = cumulativeFlags.at(obj1Type).at(cutIdxFlagsObj1);  // flag for input collection 1
4599 >      flagPair flags2 = cumulativeFlags.at(obj2Type).at(cutIdxFlagsObj2);  // flag for input collection 2
4600 >      
4601 >      // The cumulative flag is only true if the paired object cumulative flag is true, and if the single object cumulative flags are true.  
4602 >      bool currentCumulativeCutFlag = true;
4603 >      bool currentCumulativePlotFlag = true;
4604 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4605 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4606 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4607 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4608 >
4609 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4610 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4611 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4612 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4613 >
4614 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));  // Set the flag for the paired object
4615 >
4616 >
4617 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // Set the flags for the individual objects if the paired object is being cut on.  
4618 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first  = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4619 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first  = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4620 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4621 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4622 >
4623 >        if (verbose_>1) clog << " previousCumulativeCutFlag for object1 = " << getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object1, "cut") << endl;  
4624 >        if (verbose_>1) clog << " previousCumulativeCutFlag for object2 = " << getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut") << endl;  
4625 >
4626        }
4627 +
4628        counter++;
4629  
4630      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
4631    }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
4632  
4633 < }
4633 > } // end void OSUAnalysis::setObjectFlags
4634  
4635  
4636 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4636 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4637    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4638    // all cuts up to currentCutIndex
4639    bool previousCumulativeFlag = true;
4640    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4641 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4641 >    bool tempFlag = false;
4642 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4643 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4644 >
4645 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4646      else {
4647        previousCumulativeFlag = false; break;
4648      }
# Line 3706 | Line 4651 | bool OSUAnalysis::getPreviousCumulativeF
4651   }
4652  
4653  
4654 +
4655 +
4656 + template <class InputCollection>
4657 + void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4658 +  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4659 +
4660 +  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;
4661 +  for (uint object = 0; object != inputCollection->size(); object++) {
4662 +
4663 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4664 +
4665 +    string inputVariable = parameters.inputVariable;
4666 +    string function = "";
4667 +    string stringValue = "";
4668 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4669 +    BNTreeBranchVals_.at(parameters.name).push_back(value);
4670 +
4671 +  }
4672 + }
4673 +
4674 +
4675   template <class InputCollection>
4676 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4676 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4677 >
4678 >  if (verbose_>2) clog << "  Filling histogram for " << parameters.name << endl;  
4679  
4680    for (uint object = 0; object != inputCollection->size(); object++){
4681  
4682 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4682 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4683  
4684      string currentString = parameters.inputVariables.at(0);
4685      string inputVariable = "";
# Line 3728 | Line 4696 | void OSUAnalysis::fill1DHistogram(TH1* h
4696      string stringValue = "";
4697      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4698      histo->Fill(value,scaleFactor);
4699 +
4700      if (printEventInfo_) {
4701        // Write information about event to screen, for testing purposes.
4702 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4702 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << " (object number " << object << ")" << endl;
4703      }
4704  
4705    }
4706   }
4707  
4708   template <class InputCollection1, class InputCollection2>
4709 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4709 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2,
4710 >                                  flagPair pairFlags, double scaleFactor){
4711  
4712    bool sameObjects = false;
4713    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3749 | Line 4719 | void OSUAnalysis::fill1DHistogram(TH1* h
4719        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4720  
4721        pairCounter++;
4722 <      //only take objects which have passed all cuts and pairs which have passed all cuts
3753 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3754 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3755 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4722 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4723  
4724        string currentString = parameters.inputVariables.at(0);
4725        string inputVariable = "";
# Line 3770 | Line 4737 | void OSUAnalysis::fill1DHistogram(TH1* h
4737        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4738        histo->Fill(value,scaleFactor);
4739  
4740 +      if (printEventInfo_) {
4741 +        // Write information about event to screen, for testing purposes.
4742 +        clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value
4743 +             << " (object1 number " << object1 << "), "
4744 +             << " (object2 number " << object2 << ")"
4745 +             << endl;
4746 +      }
4747 +      
4748      }
4749    }
4750  
# Line 3777 | Line 4752 | void OSUAnalysis::fill1DHistogram(TH1* h
4752  
4753  
4754   template <class InputCollection>
4755 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4755 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4756  
4757    for (uint object = 0; object != inputCollection->size(); object++){
4758  
4759 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4759 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4760  
4761      string stringValue = "";
4762      string currentString = parameters.inputVariables.at(0);
# Line 3818 | Line 4793 | void OSUAnalysis::fill2DHistogram(TH2* h
4793   }
4794  
4795   template <class InputCollection1, class InputCollection2>
4796 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4796 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2,
4797 >                                  flagPair pairFlags, double scaleFactor){
4798  
4799    bool sameObjects = false;
4800    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3831 | Line 4807 | void OSUAnalysis::fill2DHistogram(TH2* h
4807  
4808        pairCounter++;
4809  
4810 <      //only take objects which have passed all cuts and pairs which have passed all cuts
3835 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3836 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3837 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4810 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4811  
4812        string stringValue = "";
4813        string currentString = parameters.inputVariables.at(0);
# Line 3882 | Line 4855 | int OSUAnalysis::getGenMatchedParticleIn
4855  
4856      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4857      if(currentDeltaR > 0.05) continue;
4858 <    //     cout << setprecision(3) << setw(20)
4858 >    //     clog << setprecision(3) << setw(20)
4859      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4860      //          << setw(20)
4861      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 3901 | Line 4874 | int OSUAnalysis::getGenMatchedParticleIn
4874      }
4875  
4876    }
4877 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4878 <  //   else cout << "no match found..." << endl;
4877 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4878 >  //   else clog << "no match found..." << endl;
4879    return bestMatchIndex;
4880  
4881   }
# Line 3994 | Line 4967 | OSUAnalysis::chosenVertex ()
4967   {
4968    const BNprimaryvertex *chosenVertex = 0;
4969    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4970 <    vector<bool> vertexFlags;
4970 >    flagPair vertexFlags;
4971      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4972        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4973          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4002 | Line 4975 | OSUAnalysis::chosenVertex ()
4975        }
4976      }
4977      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4978 <      if(!vertexFlags.at(vertexIndex)) continue;
4978 >      if(!vertexFlags.at(vertexIndex).first) continue;
4979        chosenVertex = & primaryvertexs->at(vertexIndex);
4980        break;
4981      }
# Line 4018 | Line 4991 | OSUAnalysis::chosenMET ()
4991   {
4992    const BNmet *chosenMET = 0;
4993    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4994 <    vector<bool> metFlags;
4994 >    flagPair metFlags;
4995      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4996        if (cumulativeFlags.at("mets").at(i).size()){
4997          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4026 | Line 4999 | OSUAnalysis::chosenMET ()
4999        }
5000      }
5001      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
5002 <      if(!metFlags.at(metIndex)) continue;
5002 >      if(!metFlags.at(metIndex).first) continue;
5003        chosenMET = & mets->at(metIndex);
5004        break;
5005      }
# Line 4042 | Line 5015 | OSUAnalysis::chosenElectron ()
5015   {
5016    const BNelectron *chosenElectron = 0;
5017    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
5018 <    vector<bool> electronFlags;
5018 >    flagPair electronFlags;
5019      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
5020        if (cumulativeFlags.at("electrons").at(i).size()){
5021          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4050 | Line 5023 | OSUAnalysis::chosenElectron ()
5023        }
5024      }
5025      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
5026 <      if(!electronFlags.at(electronIndex)) continue;
5026 >      if(!electronFlags.at(electronIndex).first) continue;
5027        chosenElectron = & electrons->at(electronIndex);
5028        break;
5029      }
# Line 4061 | Line 5034 | OSUAnalysis::chosenElectron ()
5034    return chosenElectron;
5035   }
5036  
5037 +
5038   const BNmuon *
5039   OSUAnalysis::chosenMuon ()
5040   {
5041    const BNmuon *chosenMuon = 0;
5042    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
5043 <    vector<bool> muonFlags;
5043 >    flagPair muonFlags;
5044      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
5045        if (cumulativeFlags.at("muons").at(i).size()){
5046          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4074 | Line 5048 | OSUAnalysis::chosenMuon ()
5048        }
5049      }
5050      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
5051 <      if(!muonFlags.at(muonIndex)) continue;
5051 >      if(!muonFlags.at(muonIndex).first) continue;
5052        chosenMuon = & muons->at(muonIndex);
5053        break;
5054      }
# Line 4085 | Line 5059 | OSUAnalysis::chosenMuon ()
5059    return chosenMuon;
5060   }
5061  
5062 + double
5063 + OSUAnalysis::chosenHT ()
5064 + {
5065 +  double chosenHT = 0.0;
5066 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
5067 +    flagPair jetFlags;
5068 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
5069 +      if (cumulativeFlags.at("jets").at(i).size()){
5070 +        jetFlags = cumulativeFlags.at("jets").at(i);
5071 +        break;
5072 +      }
5073 +    }
5074 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
5075 +      if(!jetFlags.at(jetIndex).first) continue;
5076 +      chosenHT += jets->at(jetIndex).pt;
5077 +    }
5078 +  }
5079 +
5080 +  return chosenHT;
5081 + }
5082 +
5083 + pair<const BNmuon *, const BNmuon *>
5084 + OSUAnalysis::leadMuonPair ()
5085 + {
5086 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
5087 +  leadMuonPair.first = leadMuonPair.second = 0;
5088 +
5089 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
5090 +    flagPair muonFlags;
5091 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
5092 +      if (cumulativeFlags.at("muons").at(i).size()){
5093 +        muonFlags = cumulativeFlags.at("muons").at(i);
5094 +        break;
5095 +      }
5096 +    }
5097 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
5098 +      if(!muonFlags.at(muonIndex0).first) continue;
5099 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
5100 +        if(!muonFlags.at(muonIndex1).first) continue;
5101 +        const BNmuon *mu0 = & muons->at(muonIndex0);
5102 +        const BNmuon *mu1 = & muons->at(muonIndex1);
5103 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
5104 +          leadMuonPair.first = mu0;
5105 +          leadMuonPair.second = mu1;
5106 +        }
5107 +        else{
5108 +          TVector2 newPt0 (mu0->px, mu0->py),
5109 +                   newPt1 (mu1->px, mu1->py),
5110 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
5111 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
5112 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
5113 +            {
5114 +              leadMuonPair.first = mu0;
5115 +              leadMuonPair.second = mu1;
5116 +            }
5117 +        }
5118 +      }
5119 +    }
5120 +  }
5121 +
5122 +  return leadMuonPair;
5123 + }
5124 +
5125 + pair<const BNelectron *, const BNelectron *>
5126 + OSUAnalysis::leadElectronPair ()
5127 + {
5128 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
5129 +  leadElectronPair.first = leadElectronPair.second = 0;
5130 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
5131 +    flagPair electronFlags;
5132 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
5133 +      if (cumulativeFlags.at("electrons").at(i).size()){
5134 +        electronFlags = cumulativeFlags.at("electrons").at(i);
5135 +        break;
5136 +      }
5137 +    }
5138 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
5139 +      if(!electronFlags.at(electronIndex0).first) continue;
5140 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
5141 +        if(!electronFlags.at(electronIndex1).first) continue;
5142 +        const BNelectron *el0 = & electrons->at(electronIndex0);
5143 +        const BNelectron *el1 = & electrons->at(electronIndex1);
5144 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
5145 +          leadElectronPair.first = el0;
5146 +          leadElectronPair.second = el1;
5147 +        }
5148 +        else{
5149 +          TVector2 newPt0 (el0->px, el0->py),
5150 +                   newPt1 (el1->px, el1->py),
5151 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
5152 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
5153 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
5154 +            {
5155 +              leadElectronPair.first = el0;
5156 +              leadElectronPair.second = el1;
5157 +            }
5158 +        }
5159 +      }
5160 +    }
5161 +  }
5162 +
5163 +  return leadElectronPair;
5164 + }
5165 +
5166   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines