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.83 by biliu, Wed Jun 5 03:18:56 2013 UTC vs.
Revision 1.107 by jbrinson, Tue Jul 23 08:51:35 2013 UTC

# Line 1 | Line 1
1   #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2
2   OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
3    // Retrieve parameters from the configuration file.
4    jets_ (cfg.getParameter<edm::InputTag> ("jets")),
# Line 28 | Line 27 | OSUAnalysis::OSUAnalysis (const edm::Par
27    datasetType_ (cfg.getParameter<string> ("datasetType")),
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
31    treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
32    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
33    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
34    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35    applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
36    minBtag_ (cfg.getParameter<int> ("minBtag")),
37  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
37    printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
38    printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
39    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
# Line 66 | Line 65 | OSUAnalysis::OSUAnalysis (const edm::Par
65    //always get vertex collection so we can assign the primary vertex in the event
66    objectsToGet.push_back("primaryvertexs");
67    objectsToPlot.push_back("primaryvertexs");
68 <  objectsToCut.push_back("primaryvertexs");
68 >  objectsToFlag.push_back("primaryvertexs");
69  
70  
71    //always get the MC particles to do GEN-matching
# Line 76 | Line 75 | OSUAnalysis::OSUAnalysis (const edm::Par
75    objectsToGet.push_back("events");
76  
77  
78 <  // Parse the tree variable definitions.    
79 <  for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
78 >  // Parse the tree variable definitions.
79 >  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
80      string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
81 <    if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }  
81 >    if(tempInputCollection.find("pairs")!=string::npos) { clog << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
82      objectsToGet.push_back(tempInputCollection);
83 <    objectsToCut.push_back(tempInputCollection);
83 >    objectsToFlag.push_back(tempInputCollection);
84  
85      vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
86  
87      for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
88        BranchSpecs br;
89        br.inputCollection = tempInputCollection;
90 <      br.inputVariable = branchList.at(iBranch);  
91 <      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);  
92 <      br.name = string(newName.Data());  
90 >      br.inputVariable = branchList.at(iBranch);
91 >      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
92 >      br.name = string(newName.Data());
93        treeBranches_.push_back(br);
94 <    }  
94 >    }
95  
96 <  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
96 >  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
97  
98  
99    //parse the histogram definitions
# Line 102 | Line 101 | OSUAnalysis::OSUAnalysis (const edm::Par
101  
102      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
103      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
104 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
105 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
106      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
107 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
108      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
109 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
110 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
111 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
112      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
113      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
114 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
115 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
116 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
119      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
120      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
121      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 119 | Line 129 | OSUAnalysis::OSUAnalysis (const edm::Par
129          objectsToGet.push_back(tempInputCollection);
130        }
131        objectsToPlot.push_back(tempInputCollection);
132 <      objectsToCut.push_back(tempInputCollection);
132 >      objectsToFlag.push_back(tempInputCollection);
133      } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
134        string obj1;
135        string obj2;
136        getTwoObjs(tempInputCollection, obj1, obj2);
137        string obj2ToGet = getObjToGet(obj2);
138 <      objectsToCut.push_back(tempInputCollection);
139 <      objectsToCut.push_back(obj1);
140 <      objectsToCut.push_back(obj2);
138 >      objectsToFlag.push_back(tempInputCollection);
139 >      objectsToFlag.push_back(obj1);
140 >      objectsToFlag.push_back(obj2);
141        objectsToPlot.push_back(tempInputCollection);
142        objectsToPlot.push_back(obj1);
143        objectsToPlot.push_back(obj2);
144        objectsToGet.push_back(tempInputCollection);
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147 <    } // end else
148 <
147 >    } // end else
148 >      if (find(objectsToPlot.begin(), objectsToPlot.end(), "events") != objectsToPlot.end())
149 >        objectsToGet.push_back("jets");
150  
151  
152      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 157 | Line 168 | OSUAnalysis::OSUAnalysis (const edm::Par
168        histograms.push_back(tempHistogram);
169  
170      }
171 <  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
171 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
172  
173    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
174    sort( objectsToPlot.begin(), objectsToPlot.end() );
# Line 169 | Line 180 | OSUAnalysis::OSUAnalysis (const edm::Par
180    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
181  
182      string currentObject = objectsToPlot.at(currentObjectIndex);
183 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
183 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "secondary photons"&& currentObject != "superclusters") continue;
184  
185      histogram tempIdHisto;
186      histogram tempMomIdHisto;
# Line 184 | Line 195 | OSUAnalysis::OSUAnalysis (const edm::Par
195      tempIdVsGmaIdHisto.inputCollection = currentObject;
196  
197      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
198 +    if(currentObject == "secondary photons") currentObject = "secondaryPhotons";
199      if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
200  
201      currentObject = currentObject.substr(0, currentObject.size()-1);
# Line 266 | Line 278 | OSUAnalysis::OSUAnalysis (const edm::Par
278      //create cutFlow for this channel
279      cutFlows_.push_back (new CutFlow (fs_, channelName));
280      vector<TFileDirectory> directories; //vector of directories in the output file.
281 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
282      vector<string> subSubDirNames;//subdirectories in each channel.
283      //get list of cuts for this channel
284      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 277 | Line 290 | OSUAnalysis::OSUAnalysis (const edm::Par
290        //store input collection for cut
291        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
292        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
293 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
294 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
295        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
296        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
297 +      if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
298 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
299 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
300 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
301        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
302        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
303 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
304 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
305 +      if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
306 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
307 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
308        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
309        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
310        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 295 | Line 319 | OSUAnalysis::OSUAnalysis (const edm::Par
319            objectsToGet.push_back(tempInputCollection);
320          }
321          objectsToCut.push_back(tempInputCollection);
322 +        objectsToFlag.push_back(tempInputCollection);
323        }
324        else{//pair of objects, need to add them both to objectsToGet
325          string obj1;
# Line 304 | Line 329 | OSUAnalysis::OSUAnalysis (const edm::Par
329          objectsToCut.push_back(tempInputCollection);
330          objectsToCut.push_back(obj1);
331          objectsToCut.push_back(obj2);
332 +        objectsToFlag.push_back(tempInputCollection);
333 +        objectsToFlag.push_back(obj1);
334 +        objectsToFlag.push_back(obj2);
335          objectsToGet.push_back(tempInputCollection);
336          objectsToGet.push_back(obj1);
337          objectsToGet.push_back(obj2ToGet);
# Line 316 | Line 344 | OSUAnalysis::OSUAnalysis (const edm::Par
344        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
345        vector<string> cutStringVector = splitString(cutString);
346        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
347 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
347 >        clog << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
348          exit(0);
349        }
350        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
# Line 342 | Line 370 | OSUAnalysis::OSUAnalysis (const edm::Par
370        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
371        vector<string> numberRequiredVector = splitString(numberRequiredString);
372        if(numberRequiredVector.size()!=2){
373 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
373 >        clog << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
374          exit(0);
375        }
376  
# Line 350 | Line 378 | OSUAnalysis::OSUAnalysis (const edm::Par
378        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
379        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
380  
381 <      //Set up vectors to store the directories and subDIrectories for each channel.
381 >      //Set up vectors to store the directories and subDirectories for each channel.
382        string subSubDirName;
383        string tempCutName;
384        if(cuts_.at(currentCut).exists("alias")){
385          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
386 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
386 >        subSubDirName = "After " + tempCutName + " Cut Applied";
387        }
388        else{
389          //construct string for cutflow table
# Line 366 | Line 394 | OSUAnalysis::OSUAnalysis (const edm::Par
394          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
395        }
396  
397 +      tempCut.isVeto = false;
398 +      if(cuts_.at(currentCut).exists("isVeto")){
399 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
400 +        if (isVeto == true) tempCut.isVeto = true;
401 +      }
402        subSubDirNames.push_back(subSubDirName);
403        tempCut.name = tempCutName;
404  
# Line 381 | Line 414 | OSUAnalysis::OSUAnalysis (const edm::Par
414      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
415      if(GetPlotsAfterEachCut_){
416        for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
417 <        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
418 <        directories.push_back(subSubDir);
419 <        map<string, TH1D*> oneDhistoMap;
420 <        oneDHistsTmp.push_back(oneDhistoMap);
421 <        map<string, TH2D*> twoDhistoMap;
422 <        twoDHistsTmp.push_back(twoDhistoMap);
417 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
418 >        directories.push_back(subSubDir);
419 >        map<string, TH1D*> oneDhistoMap;
420 >        oneDHistsTmp.push_back(oneDhistoMap);
421 >        map<string, TH2D*> twoDhistoMap;
422 >        twoDHistsTmp.push_back(twoDhistoMap);
423        }
424 +      treeDirectories.push_back(subDir);
425        oneDHists_.push_back(oneDHistsTmp);
426        twoDHists_.push_back(twoDHistsTmp);
427      }
# Line 400 | Line 434 | OSUAnalysis::OSUAnalysis (const edm::Par
434        oneDHists_.push_back(oneDHistsTmp);
435        twoDHists_.push_back(twoDHistsTmp);
436        directories.push_back(subDir);
437 +      treeDirectories.push_back(subDir);
438  
439      }
440  
441 +    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
442 +      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
443 +      BNTrees_.push_back(newTree);
444 +      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
445 +        BranchSpecs currentVar = treeBranches_.at(iBranch);
446 +        vector<float> newVec;
447 +        BNTreeBranchVals_[currentVar.name] = newVec;
448 +        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
449 +      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
450 +    }
451  
452      //book all histograms included in the configuration
453      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
409      
410      TTree* newTree = directories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));  
411      BNTrees_.push_back(newTree);      
412      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
413        BranchSpecs currentVar = treeBranches_.at(iBranch);
414        vector<float> newVec;  
415        BNTreeBranchVals_[currentVar.name] = newVec;  
416        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
417      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
454  
455        for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
456  
457 <        histogram currentHistogram = histograms.at(currentHistogramIndex);
458 <        int numBinsElements = currentHistogram.bins.size();
459 <        int numInputVariables = currentHistogram.inputVariables.size();
460 <        int numBinEdgesX = currentHistogram.variableBinsX.size();
461 <        int numBinEdgesY = currentHistogram.variableBinsY.size();
462 <        
463 <        if(numBinsElements == 1){
464 <          if(numBinEdgesX > 1){
465 <            if(numBinEdgesY > 1)
466 <              numBinsElements = 6;
467 <            else
468 <              numBinsElements = 3;
469 <          }
470 <        }
471 <        if(numBinsElements != 3 && numBinsElements !=6){
472 <          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
473 <          exit(0);
474 <        }
475 <        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
476 <          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
477 <          exit(0);
478 <        }
479 <        else if(numBinsElements == 3){
480 <          if (currentHistogram.bins.size () == 3)
481 <            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));
482 <          else
483 <            {
484 <              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
485 <            }
486 <        }
487 <        else if(numBinsElements == 6){
488 <          if (currentHistogram.bins.size () == 6)
489 <            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));
490 <          else
491 <            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 ());
492 <        }
493 <
458 <
459 <        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
460 <
461 <        // bin      particle type
462 <        // ---      -------------
463 <        //  0        unmatched
464 <        //  1        u
465 <        //  2        d
466 <        //  3        s
467 <        //  4        c
468 <        //  5        b
469 <        //  6        t
470 <        //  7        e
471 <        //  8        mu
472 <        //  9        tau
473 <        // 10        nu
474 <        // 11        g
475 <        // 12        gamma
476 <        // 13        Z
477 <        // 14        W
478 <        // 15        light meson
479 <        // 16        K meson
480 <        // 17        D meson
481 <        // 18        B meson
482 <        // 19        light baryon
483 <        // 20        strange baryon
484 <        // 21        charm baryon
485 <        // 22        bottom baryon
486 <        // 23        QCD string
487 <        // 24        other
488 <
489 <        vector<TString> labelArray;
490 <        labelArray.push_back("unmatched");
491 <        labelArray.push_back("u");
492 <        labelArray.push_back("d");
493 <        labelArray.push_back("s");
494 <        labelArray.push_back("c");
495 <        labelArray.push_back("b");
496 <        labelArray.push_back("t");
497 <        labelArray.push_back("e");
498 <        labelArray.push_back("#mu");
499 <        labelArray.push_back("#tau");
500 <        labelArray.push_back("#nu");
501 <        labelArray.push_back("g");
502 <        labelArray.push_back("#gamma");
503 <        labelArray.push_back("Z");
504 <        labelArray.push_back("W");
505 <        labelArray.push_back("light meson");
506 <        labelArray.push_back("K meson");
507 <        labelArray.push_back("D meson");
508 <        labelArray.push_back("B meson");
509 <        labelArray.push_back("light baryon");
510 <        labelArray.push_back("strange baryon");
511 <        labelArray.push_back("charm baryon");
512 <        labelArray.push_back("bottom baryon");
513 <        labelArray.push_back("QCD string");
514 <        labelArray.push_back("other");
515 <
516 <        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
517 <          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
518 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
519 <          }
520 <          else {
521 <            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
522 <            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
523 <          }
524 <        }
525 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
526 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
527 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
528 <        }
457 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
458 >        int numBinsElements = currentHistogram.bins.size();
459 >        int numInputVariables = currentHistogram.inputVariables.size();
460 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
461 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
462 >
463 >        if(numBinsElements == 1){
464 >          if(numBinEdgesX > 1){
465 >            if(numBinEdgesY > 1)
466 >              numBinsElements = 6;
467 >            else
468 >              numBinsElements = 3;
469 >          }
470 >        }
471 >        if(numBinsElements != 3 && numBinsElements !=6){
472 >          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
473 >          exit(0);
474 >        }
475 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
476 >          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
477 >          exit(0);
478 >        }
479 >        else if(numBinsElements == 3){
480 >          if (currentHistogram.bins.size () == 3)
481 >            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));
482 >          else
483 >            {
484 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
485 >            }
486 >        }
487 >        else if(numBinsElements == 6){
488 >          if (currentHistogram.bins.size () == 6)
489 >            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));
490 >          else
491 >            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 ());
492 >        }
493 >
494  
495 <      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
495 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
496 >
497 >        // bin      particle type
498 >        // ---      -------------
499 >        //  0        unmatched
500 >        //  1        u
501 >        //  2        d
502 >        //  3        s
503 >        //  4        c
504 >        //  5        b
505 >        //  6        t
506 >        //  7        e
507 >        //  8        mu
508 >        //  9        tau
509 >        // 10        nu
510 >        // 11        g
511 >        // 12        gamma
512 >        // 13        Z
513 >        // 14        W
514 >        // 15        light meson
515 >        // 16        K meson
516 >        // 17        D meson
517 >        // 18        B meson
518 >        // 19        light baryon
519 >        // 20        strange baryon
520 >        // 21        charm baryon
521 >        // 22        bottom baryon
522 >        // 23        QCD string
523 >        // 24        other
524 >
525 >        vector<TString> labelArray;
526 >        labelArray.push_back("unmatched");
527 >        labelArray.push_back("u");
528 >        labelArray.push_back("d");
529 >        labelArray.push_back("s");
530 >        labelArray.push_back("c");
531 >        labelArray.push_back("b");
532 >        labelArray.push_back("t");
533 >        labelArray.push_back("e");
534 >        labelArray.push_back("#mu");
535 >        labelArray.push_back("#tau");
536 >        labelArray.push_back("#nu");
537 >        labelArray.push_back("g");
538 >        labelArray.push_back("#gamma");
539 >        labelArray.push_back("Z");
540 >        labelArray.push_back("W");
541 >        labelArray.push_back("light meson");
542 >        labelArray.push_back("K meson");
543 >        labelArray.push_back("D meson");
544 >        labelArray.push_back("B meson");
545 >        labelArray.push_back("light baryon");
546 >        labelArray.push_back("strange baryon");
547 >        labelArray.push_back("charm baryon");
548 >        labelArray.push_back("bottom baryon");
549 >        labelArray.push_back("QCD string");
550 >        labelArray.push_back("other");
551 >
552 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
553 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
554 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
555 >          }
556 >          else {
557 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
558 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
559 >          }
560 >        }
561 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
562 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
563 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
564 >        }
565 >
566 >      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
567  
568  
569        // Book a histogram for the number of each object type to be plotted.
570        // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
571        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
572 <        string currentObject = objectsToPlot.at(currentObjectIndex);
573 <        int maxNum = 10;
574 <        if(currentObject == "mcparticles") maxNum = 50;
575 <        else if(currentObject == "primaryvertexs") maxNum = 50;
576 <
577 <        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
578 <        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
579 <        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
580 <        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
581 <        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
582 <        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
583 <        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
584 <        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
585 <        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
586 <        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
587 <        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
588 <        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
589 <        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
590 <        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
591 <        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
592 <        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
593 <        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
594 <        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
595 <        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
596 <
597 <        currentObject.at(0) = toupper(currentObject.at(0));
598 <        string histoName = "num" + currentObject;
599 <
600 <        if(histoName == "numPrimaryvertexs"){
601 <          string newHistoName = histoName + "BeforePileupCorrection";
602 <          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);
603 <          newHistoName = histoName + "AfterPileupCorrection";
604 <          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);
605 <        }
606 <        else
607 <          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
572 >        string currentObject = objectsToPlot.at(currentObjectIndex);
573 >        int maxNum = 10;
574 >        if(currentObject == "mcparticles") maxNum = 50;
575 >        else if(currentObject == "primaryvertexs") maxNum = 50;
576 >
577 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
578 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
579 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
580 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
581 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
582 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
583 >        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
584 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
585 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
586 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
587 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
588 >        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
589 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
590 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
591 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
592 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
593 >        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
594 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
595 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
596 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
597 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
598 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
599 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
600 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
601 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
602 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
603 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
604 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
605 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
606 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
607 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
608 >
609 >        currentObject.at(0) = toupper(currentObject.at(0));
610 >        string histoName = "num" + currentObject;
611 >
612 >        if(histoName == "numPrimaryvertexs"){
613 >          string newHistoName = histoName + "BeforePileupCorrection";
614 >          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);
615 >          newHistoName = histoName + "AfterPileupCorrection";
616 >          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);
617 >        }
618 >        else
619 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
620        }
621      }//end of loop over directories
622      channels.push_back(tempChannel);
# Line 582 | Line 630 | OSUAnalysis::OSUAnalysis (const edm::Par
630    //make unique vector of objects we need to cut on
631    sort( objectsToCut.begin(), objectsToCut.end() );
632    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
633 +  //make unique vector of objects we need to set flags for
634 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
635 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
636 +
637 +  produces<map<string, bool> > ("channelDecisions");
638 +
639 +  if (printEventInfo_) {
640 +    findEventsLog = new ofstream();  
641 +    findEventsLog->open("findEvents.txt");  
642 +    clog << "Listing run:lumi:event in file findEvents.txt for events that pass full selection (of any channel)." << endl;  
643 +  } else {
644 +    findEventsLog = 0;
645 +  }  
646  
647 +  isFirstEvent_ = true;  
648  
649 < } // end constructor OSUAnalysis::OSUAnalysis()
649 > } // end constructor OSUAnalysis::OSUAnalysis()
650  
651  
652   OSUAnalysis::~OSUAnalysis ()
# Line 595 | Line 657 | OSUAnalysis::~OSUAnalysis ()
657    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
658      delete cutFlows_.at(currentChannel);
659    }
660 +
661 +  if (printEventInfo_ && findEventsLog) findEventsLog->close();  
662 +
663 +  clog << "=============================================" << endl;  
664 +  clog << "Successfully completed OSUAnalysis." << endl;  
665 +  clog << "=============================================" << endl;  
666 +
667   }
668  
669   void
670 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
670 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
671   {
603
672    // Retrieve necessary collections from the event.
673  
674    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 666 | Line 734 | OSUAnalysis::analyze (const edm::Event &
734    //get pile-up event weight
735    if (doPileupReweighting_ && datasetType_ != "data") {
736      //for "data" datasets, the numTruePV is always set to -1
737 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
738 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
737 >    if (events->at(0).numTruePV < 0 && isFirstEvent_) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
738 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
739    }
740  
741    stopCTauScaleFactor_ = 1.0;
# Line 677 | Line 745 | OSUAnalysis::analyze (const edm::Event &
745  
746    //loop over all channels
747  
748 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
749    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
750      channel currentChannel = channels.at(currentChannelIndex);
751  
# Line 684 | Line 753 | OSUAnalysis::analyze (const edm::Event &
753      counterMap passingCounter;
754      cumulativeFlags.clear ();
755  
756 <    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
757 <         iter != BNTreeBranchVals_.end(); iter++) {
756 >    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
757 >         iter != BNTreeBranchVals_.end(); iter++) {
758        iter->second.clear();  // clear array
759      }
760  
# Line 698 | Line 767 | OSUAnalysis::analyze (const edm::Event &
767      //loop over all cuts
768      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
769        cut currentCut = currentChannel.cuts.at(currentCutIndex);
770 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
771 <        string currentObject = objectsToCut.at(currentObjectIndex);
770 >
771 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
772 >        string currentObject = objectsToFlag.at(currentObjectIndex);
773  
774          //initialize maps to get ready to set cuts
775 <        individualFlags[currentObject].push_back (vector<bool> ());
776 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
775 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
776 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
777  
778        }
779 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
780 <        string currentObject = objectsToCut.at(currentObjectIndex);
779 >
780 >      //set flags for all relevant objects
781 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
782 >        string currentObject = objectsToFlag.at(currentObjectIndex);
783  
784          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
785  
786  
787          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
788          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
789 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
790          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
791          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
792          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 738 | Line 811 | OSUAnalysis::analyze (const edm::Event &
811                                                                     "muon-muon pairs");
812  
813          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
814 <                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
815 <                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
816 <                                                                             "muon-secondary muon pairs");
814 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
815 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
816 >                                                                             "muon-secondary muon pairs");
817 >
818 >        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
819 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
820 >                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
821 >                                                                             "muon-secondary photon pairs");
822 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
823 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
824 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
825 >                                                                             "muon-secondary jet pairs");
826 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
827 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
828 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
829 >                                                                             "photon-secondary jet pairs");
830 >
831 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
832 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
833 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
834 >                                                                             "electron-secondary jet pairs");
835  
836          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
837 <                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
838 <                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
839 <                                                                                     "electron-secondary electron pairs");
837 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
838 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
839 >                                                                                     "electron-secondary electron pairs");
840  
841          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
842                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 756 | Line 847 | OSUAnalysis::analyze (const edm::Event &
847                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
848                                                                         "electron-muon pairs");
849          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
850 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
851 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
852 <                                                                 "jet-jet pairs");
850 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
851 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
852 >                                                                 "jet-jet pairs");
853 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
854 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
855 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
856 >                                                                 "jet-secondary jet pairs");
857          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
858 <                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
859 <                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
860 <                                                                      "electron-jet pairs");
858 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
859 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
860 >                                                                      "electron-jet pairs");
861 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
862 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
863 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
864 >                                                                      "electron-photon pairs");
865 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
866 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
867 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
868 >                                                                      "photon-jet pairs");
869          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
870 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
871 <                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
872 <                                                                  "muon-jet pairs");
870 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
871 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
872 >                                                                  "muon-jet pairs");
873 >        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
874 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
875 >                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
876 >                                                                  "muon-event pairs");
877 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
878 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
879 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
880 >                                                                  "met-jet pairs");
881 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
882 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
883 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
884 >                                                                 "track-jet pairs");
885 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
886 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
887 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
888 >                                                                  "muon-photon pairs");
889          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
890                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
891                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 788 | Line 907 | OSUAnalysis::analyze (const edm::Event &
907                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
908                                                                   "tau-tau pairs");
909          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
910 <                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
911 <                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
912 <                                                                   "tau-track pairs");
910 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
911 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
912 >                                                                   "tau-track pairs");
913          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
914                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
915                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 808 | Line 927 | OSUAnalysis::analyze (const edm::Event &
927      }//end loop over all cuts
928      //use cumulative flags to apply cuts at event level
929  
811    bool eventPassedAllCuts = true;
930      //a vector to store cumulative cut descisions after each cut.
931      vector<bool> eventPassedPreviousCuts;
932 +    bool eventPassedAllCuts = true;
933      //apply trigger (true if none were specified)
934      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
935  
# Line 821 | Line 940 | OSUAnalysis::analyze (const edm::Event &
940        int numberPassing = 0;
941  
942        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
943 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
943 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
944        }
945        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
946        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
947        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
948        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
949      }
950 +    //applying all appropriate scale factors
951      double scaleFactor = masterScaleFactor;
832
952      muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
953 +
954      if(applyLeptonSF_ && datasetType_ != "data"){
955 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
956 <        vector<bool> muonFlags;
955 >      //only apply SFs if we've cut on this object
956 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
957 >        flagPair muonFlags;
958 >        //get the last valid flags in the flag map
959          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
960            if (cumulativeFlags.at("muons").at(i).size()){
961              muonFlags = cumulativeFlags.at("muons").at(i);
962              break;
963            }
964          }
965 +        //apply the weight for each of those objects
966          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
967 <          if(!muonFlags.at(muonIndex)) continue;
967 >          if(!muonFlags.at(muonIndex).second) continue;
968            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
969          }
970        }
971 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
972 <        vector<bool> electronFlags;
971 >      //only apply SFs if we've cut on this object
972 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
973 >        flagPair electronFlags;
974 >        //get the last valid flags in the flag map
975          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
976            if (cumulativeFlags.at("electrons").at(i).size()){
977              electronFlags = cumulativeFlags.at("electrons").at(i);
978              break;
979            }
980          }
981 +        //apply the weight for each of those objects
982          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
983 <          if(!electronFlags.at(electronIndex)) continue;
983 >          if(!electronFlags.at(electronIndex).second) continue;
984            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
985          }
986        }
987      }
988      if(applyBtagSF_ && datasetType_ != "data"){
989 <     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
990 <        vector<bool> jetFlags;        
989 >      //only apply SFs if we've cut on this object
990 >      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
991 >        flagPair jetFlags;
992          vector<double> jetSFs;
993 +        //get the last valid flags in the flag map
994          for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
995 <          if (cumulativeFlags.at("jets").at(i).size()){            
995 >          if (cumulativeFlags.at("jets").at(i).size()){
996              jetFlags = cumulativeFlags.at("jets").at(i);
997 <            break;          
997 >            break;
998            }
999 <        }        
999 >        }
1000 >        //apply the weight for each of those objects
1001          for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
1002 <          if(!jetFlags.at(jetIndex)) continue;          
1003 <          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt);
1002 >          if(!jetFlags.at(jetIndex).second) continue;
1003 >          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
1004            jetSFs.push_back(jetSFTmp);
1005          }
1006 <        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );    
1006 >        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
1007        }
1008      }
1009      scaleFactor *= muonScaleFactor_;
# Line 882 | Line 1011 | OSUAnalysis::analyze (const edm::Event &
1011      scaleFactor *= bTagScaleFactor_;
1012      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1013  
1014 <    if (printEventInfo_) {
1014 >    if (printEventInfo_ && eventPassedAllCuts) {
1015        // Write information about event to screen, for testing purposes.
1016 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1017 <           << ": run="  << events->at(0).run
1018 <           << "  lumi=" << events->at(0).lumi
1019 <           << "  event=" << events->at(0).evt
1016 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1017 >           << ":  run:lumi:evt=  "  << events->at(0).run
1018 >           << ":" << events->at(0).lumi
1019 >           << ":" << events->at(0).evt
1020             << endl;
1021 +      if (findEventsLog) {
1022 +        (*findEventsLog) << events->at(0).run
1023 +                         << ":" << events->at(0).lumi
1024 +                         << ":" << events->at(0).evt << endl;
1025 +      }
1026 +
1027      }
1028  
1029  
# Line 897 | Line 1032 | OSUAnalysis::analyze (const edm::Event &
1032        uint currentDir;
1033        if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1034        else{
1035 <        currentDir = currentCut;
1035 >        currentDir = currentCut;
1036        }
1037 +
1038 +
1039        if(eventPassedPreviousCuts.at(currentDir)){
1040  
904        // Assign BNTree variables
905        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
906          BranchSpecs brSpecs = treeBranches_.at(iBranch);  
907          string coll = brSpecs.inputCollection;  
908          if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
909
910          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));            
911          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));
912          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));        
913          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));
914          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
915          else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
916          else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).at(currentDir));
917          else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).at(currentDir));
918          else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).at(currentDir));
919          else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).at(currentDir));
920          else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).at(currentDir));
921          else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).at(currentDir));
922          else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).at(currentDir));
923          else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).at(currentDir));
924          else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).at(currentDir));
925          else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).at(currentDir));
926          else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).at(currentDir));
927          else if(coll == "stops"
928                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).at(currentDir));
929        } // end loop over branches  
930                                                                                          
1041          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1042            histogram currentHistogram = histograms.at(histogramIndex);
1043  
1044 <          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1044 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1045  
1046 <          if(currentHistogram.inputVariables.size() == 1){
1047 <            TH1D* histo;  
1048 <            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1049 <            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1050 <            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1051 <            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1052 <            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1053 <            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1054 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1055 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1056 <                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1057 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1058 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1059 <                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1060 <            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1061 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1062 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1063 <                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1064 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1065 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1066 <                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1067 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1068 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1069 <                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1070 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1071 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1072 <                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1073 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1074 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1075 <                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1076 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1077 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1078 <                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1079 <            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1080 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1081 <                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1082 <            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1083 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1084 <                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1085 <            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1086 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1087 <                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1088 <            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1089 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1090 <                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1091 <            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1092 <                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1093 <                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1094 <            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1095 <                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1096 <                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1097 <            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1098 <                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1099 <                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1100 <
1101 <            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1102 <            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1103 <            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1104 <            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1105 <            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1106 <            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1107 <            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1108 <            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1109 <            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1110 <            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1111 <            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1112 <            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1113 <          }
1114 <          else if(currentHistogram.inputVariables.size() == 2){
1115 <            TH2D* histo;
1116 <            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1117 <            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1118 <            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1119 <            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1120 <            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1121 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1122 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1123 <                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1124 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1125 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1126 <                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1127 <            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1128 <            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1129 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1130 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1131 <                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1132 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1133 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1134 <                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1135 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1136 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1137 <                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1138 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1139 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1140 <                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1141 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1142 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1143 <                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1144 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1145 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1146 <                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1147 <            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1148 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1149 <                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1150 <            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1151 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1152 <                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1153 <            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1154 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1155 <                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1156 <            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1157 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1158 <                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1159 <            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1160 <                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1161 <                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1162 <            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1163 <                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1164 <                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1165 <            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1166 <                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1167 <                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1168 <            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1169 <            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1170 <            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1171 <            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1172 <            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1173 <                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1174 <                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1175 <            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1176 <            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1177 <            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1178 <            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1179 <            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1180 <            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1181 <            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1182 <            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1183 <          }
1184 <          
1185 <        }
1186 <
1187 <
1188 <        //fills histograms with the sizes of collections
1189 <        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1190 <
1191 <          string currentObject = objectsToPlot.at(currentObjectIndex);
1192 <          string objectToPlot = "";
1193 <
1194 <          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1195 <          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1196 <          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1197 <          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1198 <          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1199 <          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1200 <          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1201 <          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1202 <          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1203 <          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1204 <          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1205 <          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1206 <          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1207 <          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1208 <          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1209 <          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1210 <          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1211 <          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1212 <          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1213 <          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1214 <          else objectToPlot = currentObject;
1215 <
1216 <          string tempCurrentObject = objectToPlot;
1217 <          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1218 <          string histoName = "num" + tempCurrentObject;
1219 <
1220 <          //set position of primary vertex in event, in order to calculate quantities relative to it
1221 <          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1222 <            vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1223 <            int numToPlot = 0;
1224 <            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1225 <              if(lastCutFlags.at(currentFlag)) numToPlot++;
1226 <            }
1227 <            if(objectToPlot == "primaryvertexs"){
1228 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1229 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1230 <            }
1231 <            else {
1232 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1233 <            }
1234 <          }
1235 <        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1236 <        
1237 <        if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }  
1238 <        BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts  
1239 <
1240 <      } // end if(eventPassedPreviousCuts.at(currentDir)){
1241 <    } // end loop over cuts
1242 <    
1243 <  } // end loop over channel
1046 >          if(currentHistogram.inputVariables.size() == 1){
1047 >            TH1D* histo;
1048 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1049 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1050 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1051 >            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1052 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1053 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1054 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1055 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1056 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1057 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1058 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1059 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1060 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1061 >             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1062 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1063 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1064 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1065 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1066 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1067 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1068 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1069 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1070 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1071 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1072 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1073 >
1074 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1075 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1076 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1077 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1078 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1079 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1080 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1081 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1082 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1083 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1084 >
1085 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1086 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1087 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1088 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1089 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1090 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1091 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1092 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1093 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1094 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1095 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1096 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1097 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1098 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1099 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1100 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1101 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1102 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1103 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1104 >                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1105 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1106 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1107 >                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1108 >                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1109 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1110 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1111 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1112 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1113 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1114 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1115 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1116 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1117 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1118 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1119 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1120 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1121 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1122 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1123 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1124 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1125 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1126 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1127 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1128 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1129 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1130 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1131 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1132 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1133 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1134 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1135 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1136 >
1137 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1138 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1139 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1140 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1141 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1142 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1143 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1144 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1145 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1146 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1147 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1148 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1149 >          }
1150 >          else if(currentHistogram.inputVariables.size() == 2){
1151 >            TH2D* histo;
1152 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1153 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1154 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1155 >            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1156 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1157 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1158 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1159 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1160 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1161 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1162 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1163 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1164 >            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1165 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1166 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1167 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1168 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1169 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1170 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1171 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1172 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1173 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1174 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1175 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1176 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1177 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1178 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1179 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1180 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1181 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1182 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1183 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1184 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1185 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1186 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1187 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1188 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1189 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1190 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1191 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1192 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1193 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1194 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1195 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1196 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1197 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1198 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1199 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1200 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1201 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1202 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1203 >                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1204 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1205 >            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1206 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1207 >                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1208 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1209 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1210 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1211 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1212 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1213 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1214 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1215 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1216 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1217 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1218 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1219 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1220 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1221 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1222 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1223 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1224 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1225 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1226 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1227 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1228 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1229 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1230 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1231 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1232 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1233 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1234 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1235 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1236 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1237 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1238 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1239 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1240 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1241 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1242 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1243 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1244 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1245 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1246 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1247 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1248 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1249 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1250 >          }
1251 >
1252 >        }
1253 >
1254 >
1255 >        //fills histograms with the sizes of collections
1256 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1257 >
1258 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1259 >          string objectToPlot = "";
1260 >
1261 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1262 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1263 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1264 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1265 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1266 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1267 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1268 >          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1269 >          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1270 >          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1271 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1272 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1273 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1274 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1275 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1276 >          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1277 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1278 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1279 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1280 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1281 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1282 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1283 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1284 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1285 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1286 >          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1287 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1288 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1289 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1290 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1291 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1292 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1293 >          else objectToPlot = currentObject;
1294 >
1295 >          string tempCurrentObject = objectToPlot;
1296 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1297 >          string histoName = "num" + tempCurrentObject;
1298 >
1299 >
1300 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1301 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1302 >            int numToPlot = 0;
1303 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1304 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1305 >            }
1306 >
1307 >            if(objectToPlot == "primaryvertexs"){
1308 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1309 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1310 >            }
1311 >            else {
1312 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1313 >            }
1314 >          }
1315 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1316 >
1317 >
1318 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1319 >    } // end loop over cuts
1320 >
1321 >    if (!useEDMFormat_ && eventPassedAllCuts){
1322 >      // Assign BNTree variables
1323 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1324 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1325 >        string coll = brSpecs.inputCollection;
1326 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1327 >
1328 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1329 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1330 >        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1331 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1332 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1333 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1334 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1335 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1336 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1337 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1338 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1339 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1340 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1341 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1342 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1343 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1344 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1345 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1346 >        else if(coll == "stops"
1347 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1348 >      } // end loop over branches
1349  
1350 +      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1351 +      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1352 +    }
1353 +
1354 +    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1355 +
1356 +  } // end loop over channel
1357  
1358    masterCutFlow_->fillCutFlow(masterScaleFactor);
1359  
1360 +  event.put (channelDecisions, "channelDecisions");
1361 +
1362 +  isFirstEvent_ = false;  
1363  
1364 < } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1364 > } // end void OSUAnalysis::produce (const edm::Event &event, const edm::EventSetup &setup)
1365  
1366  
1367  
# Line 1151 | Line 1376 | OSUAnalysis::evaluateComparison (double
1376    else if(comparison == "==") return testValue == cutValue;
1377    else if(comparison == "=") return testValue == cutValue;
1378    else if(comparison == "!=") return testValue != cutValue;
1379 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1379 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1380  
1381   }
1382  
# Line 1166 | Line 1391 | OSUAnalysis::evaluateComparison (string
1391    else if(comparison == "==") return testValue == cutValue;
1392    else if(comparison == "=") return testValue == cutValue;
1393    else if(comparison == "!=") return testValue != cutValue;
1394 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1394 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1395  
1396   }
1397  
# Line 1176 | Line 1401 | OSUAnalysis::evaluateTriggers (vector<st
1401    //initialize to false until a chosen trigger is passed
1402    bool triggerDecision = false;
1403  
1404 <  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;  
1404 >  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1405    //loop over all triggers defined in the event
1406    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1407  
1408 <    if (printAllTriggers_) cout << "   " << trigger->name << endl;  
1408 >    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1409  
1410      //we're only interested in triggers that actually passed
1411      if(trigger->pass != 1) continue;
# Line 1192 | Line 1417 | OSUAnalysis::evaluateTriggers (vector<st
1417      //if the event passes one of the chosen triggers, set triggerDecision to true
1418      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1419        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1420 <    }  
1420 >    }
1421    }
1422  
1423 <  printAllTriggers_ = false;  // only print triggers once, not every event  
1423 >  printAllTriggers_ = false;  // only print triggers once, not every event
1424  
1425 <  //if none of the veto triggers fired:
1425 >  //if none of the veto triggers fired:
1426    //return the OR of all the chosen triggers
1427    if (triggersToTest.size() != 0) return triggerDecision;
1428    //or if no triggers were defined return true
# Line 1366 | Line 1591 | OSUAnalysis::valueLookup (const BNjet* o
1591    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1592    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1593  
1594 +  //user defined variable
1595 +  else if(variable == "disappTrkLeadingJetID") {
1596 +    value = object->pt > 110
1597 +      && fabs(object->eta) < 2.4
1598 +      && object->chargedHadronEnergyFraction > 0.2
1599 +      && object->neutralHadronEnergyFraction < 0.7
1600 +      && object->chargedEmEnergyFraction < 0.5
1601 +      && object->neutralEmEnergyFraction < 0.7;
1602 +  }
1603 +
1604 +  else if(variable == "disappTrkSubLeadingJetID") {
1605 +    value = object->pt > 30
1606 +      && fabs(object->eta) < 4.5
1607 +      && object->neutralHadronEnergyFraction < 0.7
1608 +      && object->chargedEmEnergyFraction < 0.5;
1609 +  }
1610 +
1611 +  else if(variable == "dPhiMet") {
1612 +    if (const BNmet *met = chosenMET ()) {
1613 +      value = deltaPhi (object->phi, met->phi);
1614 +    } else value = -999;
1615 +  }
1616 +
1617  
1618 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1618 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1619  
1620    value = applyFunction(function, value);
1621  
1622    return value;
1623 < }
1623 > } // end jet valueLookup
1624  
1625  
1626   //!muon valueLookup
# Line 1469 | Line 1717 | OSUAnalysis::valueLookup (const BNmuon*
1717    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1718    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1719    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1720 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1721 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1722 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1723 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1724    else if(variable == "rhoPrime") value = object->rhoPrime;
1725    else if(variable == "AEffDr03") value = object->AEffDr03;
1726    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1476 | Line 1728 | OSUAnalysis::valueLookup (const BNmuon*
1728    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1729    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1730    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1731 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1732 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1733 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1734 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1735 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1736    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1737    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1738    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1532 | Line 1789 | OSUAnalysis::valueLookup (const BNmuon*
1789    else if(variable == "time_ndof") value = object->time_ndof;
1790  
1791    //user-defined variables
1792 +  else if(variable == "looseID") {
1793 +    value = object->pt > 10 &&
1794 +      (object->isGlobalMuon  > 0 ||
1795 +       object->isTrackerMuon > 0);
1796 +  }
1797    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1798    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1799    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1800    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1801 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1802    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1803    else if(variable == "metMT") {
1804      if (const BNmet *met = chosenMET ())
# Line 1732 | Line 1995 | OSUAnalysis::valueLookup (const BNmuon*
1995  
1996  
1997  
1998 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1998 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1999  
2000    value = applyFunction(function, value);
2001  
2002    return value;
2003 < }
2003 > } // end muon valueLookup
2004 >
2005  
2006   //!electron valueLookup
2007   double
# Line 1906 | Line 2170 | OSUAnalysis::valueLookup (const BNelectr
2170    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2171    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2172    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2173 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2174 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2175    else if(variable == "metMT") {
2176      if (const BNmet *met = chosenMET ())
2177        {
# Line 1977 | Line 2243 | OSUAnalysis::valueLookup (const BNelectr
2243      else value = -999;
2244    }
2245  
2246 +  else if(variable == "looseID"){
2247 +    if (object->isEB)
2248 +      {
2249 +        value = fabs(object->delEtaIn) < 0.007 \
2250 +          && fabs (object->delPhiIn) < 0.15 \
2251 +          && object->scSigmaIEtaIEta < 0.01 \
2252 +          && object->hadOverEm < 0.12 \
2253 +          && fabs (object->correctedD0Vertex) < 0.02 \
2254 +          && fabs (object->correctedDZ) < 0.2 \
2255 +          && object->absInvEMinusInvPin < 0.05 \
2256 +          && object->passConvVeto;
2257 +      }
2258 +    else
2259 +      {
2260 +        value = fabs(object->delEtaIn) < 0.009 \
2261 +          && fabs (object->delPhiIn) < 0.10 \
2262 +          && object->scSigmaIEtaIEta < 0.03 \
2263 +          && object->hadOverEm < 0.10 \
2264 +          && fabs (object->correctedD0Vertex) < 0.02 \
2265 +          && fabs (object->correctedDZ) < 0.2 \
2266 +          && object->absInvEMinusInvPin < 0.05 \
2267 +          && object->passConvVeto;
2268 +      }
2269 +  }
2270 +
2271    else if(variable == "tightID"){
2272      if (object->isEB)
2273        {
# Line 2002 | Line 2293 | OSUAnalysis::valueLookup (const BNelectr
2293        }
2294    }
2295  
2296 +  else if(variable == "looseID_MVA"){
2297 +    value = object->pt > 10
2298 +      && object->mvaNonTrigV0 > 0;
2299 +      }
2300    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2301      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2302      else value = -999;
# Line 2132 | Line 2427 | OSUAnalysis::valueLookup (const BNelectr
2427  
2428  
2429  
2430 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2430 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2431  
2432    value = applyFunction(function, value);
2433  
2434    return value;
2435 < }
2435 > } // end electron valueLookup
2436 >
2437  
2438   //!event valueLookup
2439   double
# Line 2149 | Line 2445 | OSUAnalysis::valueLookup (const BNevent*
2445    else if(variable == "pthat") value = object->pthat;
2446    else if(variable == "qScale") value = object->qScale;
2447    else if(variable == "alphaQCD") value = object->alphaQCD;
2448 +  else if(variable == "Ht") value = getHt(jets.product());
2449    else if(variable == "alphaQED") value = object->alphaQED;
2450    else if(variable == "scalePDF") value = object->scalePDF;
2451    else if(variable == "x1") value = object->x1;
# Line 2219 | Line 2516 | OSUAnalysis::valueLookup (const BNevent*
2516    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2517    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2518    else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2519 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2519 >  else if(variable == "ht") value = chosenHT ();
2520 >  else if(variable == "leadMuPairInvMass"){
2521 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2522 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2523 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2524 >    value = (p0 + p1).M ();
2525 >  }
2526 >  else if(variable == "leadMuPairPt"){
2527 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2528 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2529 >             pt1 (muPair.second->px, muPair.second->py);
2530 >    pt0 += pt1;
2531 >    value = pt0.Mod ();
2532 >  }
2533 >  else if(variable == "leadElPairInvMass"){
2534 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2535 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2536 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2537 >    value = (p0 + p1).M ();
2538 >  }
2539 >  else if(variable == "leadElPairPt"){
2540 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2541 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2542 >             pt1 (muPair.second->px, muPair.second->py);
2543 >    pt0 += pt1;
2544 >    value = pt0.Mod ();
2545 >  }
2546 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2547  
2548    value = applyFunction(function, value);
2549  
2550    return value;
2551 < }
2551 > } // end event valueLookup
2552 >
2553  
2554   //!tau valueLookup
2555   double
# Line 2272 | Line 2597 | OSUAnalysis::valueLookup (const BNtau* o
2597    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2598    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2599  
2600 <
2600 >  else if (variable == "looseHadronicID") {
2601 >    value = object->pt > 10
2602 >      && object->eta < 2.3
2603 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2604 >      && object->HPSdecayModeFinding > 0
2605 >      && object->HPSagainstElectronLoose > 0
2606 >      && object->HPSagainstMuonTight > 0;
2607 >  }
2608  
2609    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2610  
# Line 2319 | Line 2651 | OSUAnalysis::valueLookup (const BNtau* o
2651    }
2652  
2653  
2654 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2654 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2655  
2656    value = applyFunction(function, value);
2657  
2658    return value;
2659 < }
2659 > } // end tau valueLookup
2660 >
2661  
2662   //!met valueLookup
2663   double
# Line 2392 | Line 2725 | OSUAnalysis::valueLookup (const BNmet* o
2725    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2726    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2727  
2728 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2728 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2729  
2730    value = applyFunction(function, value);
2731  
2732    return value;
2733 < }
2733 > } // end met valueLookup
2734 >
2735  
2736   //!track valueLookup
2737   double
# Line 2425 | Line 2759 | OSUAnalysis::valueLookup (const BNtrack*
2759    else if(variable == "numValidHits") value = object->numValidHits;
2760    else if(variable == "isHighPurity") value = object->isHighPurity;
2761  
2428
2762    //additional BNs info for disappTrks
2763 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2764 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2765 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2766 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2767 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2768 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2769 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2770 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2438 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2763 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2764 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2765 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2766 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2767 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2768 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2769 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2770 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2771    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2772 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2772 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2773 >  else if(variable == "trkRelIsoRp3")       value = (object->depTrkRp3 - object->pt) / object->pt;
2774 >  else if(variable == "trkRelIsoRp5")       value = (object->depTrkRp5 - object->pt) / object->pt;
2775 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2776 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2777 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2778 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2779 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2780 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2781 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2782 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2783 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2784 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2785 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2786 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2787 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2788 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2789 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2790 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2791 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2792  
2793    //user defined variables
2794    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;
2795    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2796 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2796 >  else if(variable == "depTrkRp5MinusPt"){
2797 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2798 > //       cout << "Warning:  found track with depTrkRp5 < pt:  depTrkRp5=" << object->depTrkRp5
2799 > //         << "; pt=" << object->pt
2800 > //         << "; object->depTrkRp5 - object->pt = " << object->depTrkRp5 - object->pt
2801 > //         << endl;  
2802 >           value = 0;
2803 >         }
2804 >         else value =  (object->depTrkRp5 - object->pt);
2805 >  }
2806 >  else if(variable == "depTrkRp3MinusPt"){
2807 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2808 >      value = 0;
2809 >    }
2810 >    else value =  (object->depTrkRp3 - object->pt);
2811 >  }
2812 >
2813 >  else if(variable == "dPhiMet") {
2814 >    if (const BNmet *met = chosenMET ()) {
2815 >      value = deltaPhi (object->phi, met->phi);
2816 >    } else value = -999;
2817 >  }
2818 >  
2819 >  
2820    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2821    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2822    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2823    else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2824 +  else if(variable == "depTrkRp5RhoCorr")           value = getTrkDepTrkRp5RhoCorr(object);
2825 +  else if(variable == "depTrkRp3RhoCorr")           value = getTrkDepTrkRp3RhoCorr(object);
2826 +
2827 +  else if(variable == "depTrkRp5MinusPtRhoCorr")    {
2828 +    if ( (getTrkDepTrkRp5RhoCorr(object) - object->pt) < 0 ) value = 0;
2829 +    else {value = (getTrkDepTrkRp5RhoCorr(object) - object->pt );}
2830 +  }
2831 +  
2832 +  else if(variable == "depTrkRp3MinusPtRhoCorr")    
2833 +    {
2834 +      if ( (getTrkDepTrkRp3RhoCorr(object) - object->pt) < 0 ) value = 0;
2835 +      else {value = (getTrkDepTrkRp3RhoCorr(object) - object->pt );}
2836 +    }
2837 +
2838    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2839    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2840    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
# Line 2470 | Line 2858 | OSUAnalysis::valueLookup (const BNtrack*
2858        pt = object->pt;
2859      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2860    }
2861 +
2862 +
2863    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2864  
2865    else if(variable == "genMatchedPdgId"){
# Line 2517 | Line 2907 | OSUAnalysis::valueLookup (const BNtrack*
2907  
2908  
2909  
2910 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2910 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2911  
2912    value = applyFunction(function, value);
2913  
2914    return value;
2915 < }
2915 > } // end track valueLookup
2916 >
2917  
2918   //!genjet valueLookup
2919   double
# Line 2546 | Line 2937 | OSUAnalysis::valueLookup (const BNgenjet
2937    else if(variable == "charge") value = object->charge;
2938  
2939  
2940 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2940 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2941  
2942    value = applyFunction(function, value);
2943  
# Line 2680 | Line 3071 | OSUAnalysis::valueLookup (const BNmcpart
3071    }
3072  
3073  
3074 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3074 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3075  
3076    value = applyFunction(function, value);
3077  
3078    return value;
3079 < }
3079 > } // end mcparticle valueLookup
3080 >
3081  
3082   //!primaryvertex valueLookup
3083   double
# Line 2708 | Line 3100 | OSUAnalysis::valueLookup (const BNprimar
3100    else if(variable == "isGood") value = object->isGood;
3101  
3102  
3103 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3103 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3104  
3105    value = applyFunction(function, value);
3106  
# Line 2726 | Line 3118 | OSUAnalysis::valueLookup (const BNbxlumi
3118    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3119  
3120  
3121 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3121 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3122  
3123    value = applyFunction(function, value);
3124  
# Line 2859 | Line 3251 | OSUAnalysis::valueLookup (const BNphoton
3251    }
3252  
3253  
3254 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3254 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3255  
3256    value = applyFunction(function, value);
3257  
3258    return value;
3259 < }
3259 > } // end photon valueLookup
3260 >
3261  
3262   //!supercluster valueLookup
3263   double
# Line 2882 | Line 3275 | OSUAnalysis::valueLookup (const BNsuperc
3275    else if(variable == "theta") value = object->theta;
3276  
3277  
3278 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3278 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3279  
3280    value = applyFunction(function, value);
3281  
# Line 2916 | Line 3309 | OSUAnalysis::valueLookup (const BNtrigob
3309        stringValue = "none";  // stringValue should only be empty if value is filled
3310    }
3311  
3312 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3312 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3313  
3314    value = applyFunction(function, value);
3315  
# Line 2987 | Line 3380 | OSUAnalysis::valueLookup (const BNmuon*
3380        value = object2->correctedD0;
3381      }
3382  
3383 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3383 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3384 >
3385 >  value = applyFunction(function, value);
3386 >
3387 >  return value;
3388 > } // end muon-muon pair valueLookup
3389 >
3390 >
3391 > //!muon-photon pair valueLookup
3392 > double
3393 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3394 >
3395 >  double value = 0.0;
3396 >
3397 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3398 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3399 >  else if(variable == "photonEta") value = object2->eta;
3400 >  else if(variable == "photonPt") value = object2->pt;
3401 >  else if(variable == "muonEta") value = object1->eta;
3402 >  else if(variable == "photonPhi") value = object2->phi;
3403 >  else if(variable == "muonPhi") value = object1->phi;
3404 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3405 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3406 >  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3407 >  else if(variable == "invMass"){
3408 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3409 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3410 >    value = (fourVector1 + fourVector2).M();
3411 >  }
3412 >  else if(variable == "pt"){
3413 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3414 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3415 >    value = (fourVector1 + fourVector2).Pt();
3416 >  }
3417 >  else if(variable == "threeDAngle")
3418 >    {
3419 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3420 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3421 >      value = (threeVector1.Angle(threeVector2));
3422 >    }
3423 >  else if(variable == "alpha")
3424 >    {
3425 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3426 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3427 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3428 >      value = (pi-threeVector1.Angle(threeVector2));
3429 >    }
3430 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3431 >
3432 >  value = applyFunction(function, value);
3433 >
3434 >  return value;
3435 > }
3436 >
3437 > //!electron-photon pair valueLookup
3438 > double
3439 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3440 >
3441 >  double value = 0.0;
3442 >
3443 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3444 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3445 >  else if(variable == "photonEta") value = object2->eta;
3446 >  else if(variable == "photonPt") value = object2->pt;
3447 >  else if(variable == "electronEta") value = object1->eta;
3448 >  else if(variable == "photonPhi") value = object2->phi;
3449 >  else if(variable == "electronPhi") value = object1->phi;
3450 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3451 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3452 >  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3453 >  else if(variable == "invMass"){
3454 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3455 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3456 >    value = (fourVector1 + fourVector2).M();
3457 >  }
3458 >  else if(variable == "pt"){
3459 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3460 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3461 >    value = (fourVector1 + fourVector2).Pt();
3462 >  }
3463 >  else if(variable == "threeDAngle")
3464 >    {
3465 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3466 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3467 >      value = (threeVector1.Angle(threeVector2));
3468 >    }
3469 >  else if(variable == "alpha")
3470 >    {
3471 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3472 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3473 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3474 >      value = (pi-threeVector1.Angle(threeVector2));
3475 >    }
3476 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3477  
3478    value = applyFunction(function, value);
3479  
# Line 3043 | Line 3529 | OSUAnalysis::valueLookup (const BNelectr
3529      value = object2->correctedD0;
3530    }
3531  
3532 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3532 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3533  
3534    value = applyFunction(function, value);
3535  
3536    return value;
3537   }
3538 +
3539   //!electron-muon pair valueLookup
3540   double
3541   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3109 | Line 3596 | OSUAnalysis::valueLookup (const BNelectr
3596    else if(variable == "muonRelPFdBetaIso"){
3597      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3598    }
3599 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3599 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3600    value = applyFunction(function, value);
3601  
3602    return value;
3603 < }
3603 > } // end electron-muon pair valueLookup
3604 >
3605  
3606   //!electron-jet pair valueLookup
3607   double
# Line 3148 | Line 3636 | OSUAnalysis::valueLookup (const BNelectr
3636      value = object1->charge*object2->charge;
3637    }
3638  
3639 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3639 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3640 >  value = applyFunction(function, value);
3641 >
3642 >  return value;
3643 > }
3644 >
3645 > //!photon-jet pair valueLookup
3646 > double
3647 > OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3648 >
3649 >  double value = 0.0;
3650 >
3651 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3652 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3653 >  else if(variable == "jetEta") value = object2->eta;
3654 >  else if(variable == "jetPhi") value = object2->phi;
3655 >  else if(variable == "photonEta") value = object1->eta;
3656 >  else if(variable == "photonPhi") value = object1->phi;
3657 >  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3658 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3659 >  else if(variable == "invMass"){
3660 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3661 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3662 >    value = (fourVector1 + fourVector2).M();
3663 >  }
3664 >  else if(variable == "pt"){
3665 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3666 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3667 >    value = (fourVector1 + fourVector2).Pt();
3668 >  }
3669 >  else if(variable == "threeDAngle")
3670 >    {
3671 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3672 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3673 >      value = (threeVector1.Angle(threeVector2));
3674 >    }
3675 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3676 >  value = applyFunction(function, value);
3677 >
3678 >  return value;
3679 > }
3680 >
3681 > // track-jet pair valueLookup
3682 > double
3683 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3684 >
3685 >  double value = 0.0;
3686 >
3687 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3688 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3689 >
3690 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3691    value = applyFunction(function, value);
3692  
3693    return value;
3694 +
3695   }
3696  
3697 +
3698 +
3699 + // met-jet pair valueLookup
3700 + double
3701 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3702 +
3703 +  double value = 0.0;
3704 +
3705 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3706 +
3707 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3708 +  value = applyFunction(function, value);
3709 +
3710 +  return value;
3711 +
3712 + }  
3713 +
3714 +
3715 +
3716   //!muon-jet pair valueLookup
3717   double
3718   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3162 | Line 3721 | OSUAnalysis::valueLookup (const BNmuon*
3721  
3722    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3723    else if(variable == "jetEta") value = object2->eta;
3724 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3725 +  else if(variable == "jetPt") value = object2->pt;
3726    else if(variable == "jetPhi") value = object2->phi;
3727 +  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3728    else if(variable == "muonEta") value = object1->eta;
3729 +  else if(variable == "muonPt") value = object1->pt;
3730    else if(variable == "muonPhi") value = object1->phi;
3731 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3731 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3732    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3733    else if(variable == "invMass"){
3734      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3187 | Line 3750 | OSUAnalysis::valueLookup (const BNmuon*
3750      value = object1->charge*object2->charge;
3751    }
3752  
3753 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3753 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3754    value = applyFunction(function, value);
3755  
3756    return value;
3757   }
3758  
3759 + //!muon-event valueLookup
3760 + double
3761 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3762 +
3763 +  double value = 0.0;
3764 +
3765 +  if(variable == "muonEta") value = object1->eta;
3766 +  else if(variable == "muonPt") value = object1->pt;
3767 +  else if(variable == "muonPhi") value = object1->phi;
3768 +  else if(variable == "Ht") value = getHt(jets.product());
3769 +  else if(variable == "pthat")   value = object2->pthat;
3770 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3771 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3772 +  value = applyFunction(function, value);
3773 +
3774 +  return value;
3775 + }
3776   //!jet-jet pair valueLookup
3777   double
3778   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3201 | Line 3781 | OSUAnalysis::valueLookup (const BNjet* o
3781  
3782    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3783    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3784 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3784 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3785    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3786    else if(variable == "invMass"){
3787      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3223 | Line 3803 | OSUAnalysis::valueLookup (const BNjet* o
3803      value = object1->charge*object2->charge;
3804    }
3805  
3806 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3806 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3807    value = applyFunction(function, value);
3808  
3809    return value;
3810   }
3811 +
3812   //!electron-track pair valueLookup
3813   double
3814   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3247 | Line 3828 | OSUAnalysis::valueLookup (const BNelectr
3828    else if(variable == "chargeProduct"){
3829      value = object1->charge*object2->charge;
3830    }
3831 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3831 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3832    value = applyFunction(function, value);
3833    return value;
3834  
# Line 3275 | Line 3856 | OSUAnalysis::valueLookup (const BNmuon*
3856      value = object1->charge*object2->charge;
3857    }
3858  
3859 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3859 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3860    value = applyFunction(function, value);
3861    return value;
3862   }
# Line 3297 | Line 3878 | OSUAnalysis::valueLookup (const BNtau* o
3878      value = object1->charge*object2->charge;
3879    }
3880  
3881 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3881 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3882    value = applyFunction(function, value);
3883    return value;
3884   }
# Line 3319 | Line 3900 | OSUAnalysis::valueLookup (const BNmuon*
3900      value = object1->charge*object2->charge;
3901    }
3902  
3903 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3903 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3904    value = applyFunction(function, value);
3905    return value;
3906   }
# Line 3334 | Line 3915 | OSUAnalysis::valueLookup (const BNtau* o
3915      value = object1->charge*object2->charge;
3916    }
3917  
3918 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3918 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3919    value = applyFunction(function, value);
3920    return value;
3921   }
# Line 3354 | Line 3935 | OSUAnalysis::valueLookup (const BNtrack*
3935    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3936    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3937  
3938 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3938 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3939  
3940    value = applyFunction(function, value);
3941  
# Line 3376 | Line 3957 | OSUAnalysis::valueLookup (const BNelectr
3957        stringValue = "none";
3958    }
3959  
3960 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3960 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3961  
3962    value = applyFunction(function, value);
3963  
# Line 3392 | Line 3973 | OSUAnalysis::valueLookup (const BNmuon*
3973  
3974    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3975  
3976 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3976 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3977  
3978    value = applyFunction(function, value);
3979  
# Line 3495 | Line 4076 | OSUAnalysis::valueLookup (const BNstop*
4076      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4077        vertex_rank++;
4078        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4079 <                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4080 <                      (object->vz-vertex->z)*(object->vz-vertex->z));
4079 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4080 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
4081  
4082        if(abs(dist) < abs(minDistToVertex)){
4083          value = vertex_rank;
# Line 3505 | Line 4086 | OSUAnalysis::valueLookup (const BNstop*
4086      }
4087    }
4088  
4089 +  else if (variable == "decaysToTau"){
4090 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4091 +  }
4092  
4093  
4094  
4095 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4095 >
4096 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4097  
4098    value = applyFunction(function, value);
4099  
4100    return value;
4101  
4102 < }
4102 > } // end stop valueLookup
4103 >
4104  
4105  
4106  
# Line 3532 | Line 4118 | OSUAnalysis::getTrkIsIso (const BNtrack*
4118  
4119   }
4120  
4121 + //calculate the scalar sum of Jet Pt in the event.
4122 + double
4123 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4124 +  double Ht = 0;
4125 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4126 +    Ht += abs(jet->pt);
4127 +  }
4128 +  return Ht;
4129 + }
4130  
4131   double
4132   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3569 | Line 4164 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4164    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4165    if (!useTrackCaloRhoCorr_) return -99;
4166    // if (!rhokt6CaloJetsHandle_) {
4167 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4167 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4168    //   return -99;
4169    // }
4170    double radDeltaRCone = 0.5;
# Line 3580 | Line 4175 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4175  
4176   }
4177  
4178 + double
4179 + OSUAnalysis::getTrkDepTrkRp5RhoCorr(const BNtrack* track) {
4180 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.              
4181 +  if (!useTrackCaloRhoCorr_) return -99;
4182 +  // if (!rhokt6CaloJetsHandle_) {                                                                                                    
4183 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;                        
4184 +  //   return -99;                                                                                                                    
4185 +  // }                                                                                                                                
4186 +  double radDeltaRCone = 0.5;
4187 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.                                                                                                          
4188 +  double rawDepTrkRp5 = track->depTrkRp5;
4189 + double depTrkRp5RhoCorr = TMath::Max(0., rawDepTrkRp5 - rhoCorr_kt6CaloJets);
4190 + return depTrkRp5RhoCorr;
4191 +
4192 + }
4193 +
4194 + double
4195 + OSUAnalysis::getTrkDepTrkRp3RhoCorr(const BNtrack* track) {
4196 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.                                                
4197 +  if (!useTrackCaloRhoCorr_) return -99;
4198 +  // if (!rhokt6CaloJetsHandle_) {                                                                                                                                      
4199 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;                                                          
4200 +  //   return -99;                                                                                                                                                      
4201 +  // }                                                                                                                                                                  
4202 +  double radDeltaRCone = 0.3;
4203 + // Define effective area as pi*r^2, where r is radius of DeltaR cone
4204 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  
4205 +  double rawDepTrkRp3 = track->depTrkRp3;
4206 +  double depTrkRp3RhoCorr = TMath::Max(0., rawDepTrkRp3 - rhoCorr_kt6CaloJets);
4207 +  return depTrkRp3RhoCorr;
4208 +  
4209 + }
4210 +
4211  
4212  
4213  
# Line 3591 | Line 4219 | OSUAnalysis::WriteDeadEcal (){
4219    double etaEcal, phiEcal;
4220    ifstream DeadEcalFile(deadEcalFile_);
4221    if(!DeadEcalFile) {
4222 <    cout << "Error: DeadEcalFile has not been found." << endl;
4222 >    clog << "Error: DeadEcalFile has not been found." << endl;
4223      return;
4224    }
4225    if(DeadEcalVec.size()!= 0){
4226 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4226 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4227      return;
4228    }
4229    while(!DeadEcalFile.eof())
# Line 3606 | Line 4234 | OSUAnalysis::WriteDeadEcal (){
4234        newChan.phiEcal = phiEcal;
4235        DeadEcalVec.push_back(newChan);
4236      }
4237 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4237 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4238   }
4239  
4240   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3646 | Line 4274 | OSUAnalysis::applyFunction(string functi
4274    else if(function == "log") value = log10(value);
4275  
4276    else if(function == "") value = value;
4277 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4277 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4278  
4279    return value;
4280  
# Line 3660 | Line 4288 | void OSUAnalysis::setObjectFlags(cut &cu
4288      string obj1, obj2;
4289      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4290      if (inputType==obj1 ||
4291 <        inputType==obj2) {
4291 >        inputType==obj2) {
4292        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4293        // and the inputType is a member of the pair.
4294        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3672 | Line 4300 | void OSUAnalysis::setObjectFlags(cut &cu
4300  
4301    for (uint object = 0; object != inputCollection->size(); object++){
4302  
4303 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4303 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4304 >    bool plotDecision = true;
4305  
4306      if(currentCut.inputCollection == inputType){
4307  
# Line 3684 | Line 4313 | void OSUAnalysis::setObjectFlags(cut &cu
4313          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4314  
4315        }
4316 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4316 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4317        else{
4318          bool tempDecision = true;
4319          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3693 | Line 4322 | void OSUAnalysis::setObjectFlags(cut &cu
4322            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4323              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4324          }
4325 <        decision = tempDecision;
4325 >        cutDecision = tempDecision;
4326        }
4327 +      //invert the cut for plotting if this cut is a veto
4328 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4329 +      else plotDecision = cutDecision;
4330      }
4331  
4332 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4332 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4333  
4334 <    //set flags for objects that pass each cut AND all the previous cuts
4335 <    bool previousCumulativeFlag = true;
4334 >    //set flags for objects that pass this cut AND all the previous cuts
4335 >    bool previousCumulativeCutFlag = true;
4336      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4337 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4338 <      else{ previousCumulativeFlag = false; break;}
4337 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4338 >      else{ previousCumulativeCutFlag = false; break;}
4339      }
4340 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4340 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4341 >    bool previousCumulativePlotFlag = true;
4342 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4343 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4344 >      else{ previousCumulativePlotFlag = false; break;}
4345 >    }
4346 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4347 >
4348 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4349  
4350    }
4351  
# Line 3714 | Line 4354 | void OSUAnalysis::setObjectFlags(cut &cu
4354  
4355   template <class InputCollection1, class InputCollection2>
4356   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4357 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4357 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4358  
4359  
4360    bool sameObjects = false;
# Line 3730 | Line 4370 | void OSUAnalysis::setObjectFlags(cut &cu
4370    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4371    if (currentCut.inputCollection == inputType) {
4372      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4373 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4374 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4373 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4374 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4375      }
4376      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4377        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4378 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4379 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4378 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4379 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4380        }
4381      }
4382    }
# Line 3749 | Line 4389 | void OSUAnalysis::setObjectFlags(cut &cu
4389        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4390  
4391  
4392 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4392 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4393 >      bool plotDecision = true;
4394  
4395        if(currentCut.inputCollection == inputType){
4396  
# Line 3761 | Line 4402 | void OSUAnalysis::setObjectFlags(cut &cu
4402            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4403          }
4404  
4405 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4405 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4406          else{
4407            bool tempDecision = subcutDecisions.at(0);
4408            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3770 | Line 4411 | void OSUAnalysis::setObjectFlags(cut &cu
4411              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4412                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4413            }
4414 <          decision = tempDecision;
4414 >          cutDecision = tempDecision;
4415          }
4416 +        //invert the cut for plotting if this cut is a veto
4417 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4418 +        else plotDecision = cutDecision;
4419 +      }
4420 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4421 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4422 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4423 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4424 +      }
4425 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4426 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4427 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4428        }
4429 <      // if (decision) isPassObj1.at(object1) = true;
4430 <      // if (decision) isPassObj2.at(object2) = true;
4431 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4432 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4433 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4434 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4429 >
4430 >      //set flags for objects that pass this cut AND all the previous cuts
4431 >      bool previousCumulativeCutFlag = true;
4432 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4433 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4434 >        else{ previousCumulativeCutFlag = false; break;}
4435        }
4436 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4437  
4438 <      //set flags for objects that pass each cut AND all the previous cuts
3785 <      bool previousCumulativeFlag = true;
4438 >      bool previousCumulativePlotFlag = true;
4439        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4440 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4441 <        else{ previousCumulativeFlag = false; break;}
4440 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4441 >        else{ previousCumulativePlotFlag = false; break;}
4442        }
4443 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4444 +      
4445        //apply flags for the components of the composite object as well
4446 <      bool currentCumulativeFlag = true;
4447 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4448 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4449 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4450 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4451 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4452 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4453 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4454 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4446 >      bool currentCumulativeCutFlag = true;
4447 >      bool currentCumulativePlotFlag = true;
4448 >
4449 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4450 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4451 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4452 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4453 >
4454 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4455 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4456 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4457 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4458 >
4459 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4460 >
4461 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4462 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4463 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4464 >      }
4465 >
4466 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4467 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4468 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4469        }
4470 +
4471        counter++;
4472  
4473      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3806 | Line 4476 | void OSUAnalysis::setObjectFlags(cut &cu
4476   }
4477  
4478  
4479 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4479 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4480    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4481    // all cuts up to currentCutIndex
4482    bool previousCumulativeFlag = true;
4483    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4484 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4484 >    bool tempFlag = false;
4485 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4486 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4487 >
4488 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4489      else {
4490        previousCumulativeFlag = false; break;
4491      }
# Line 3821 | Line 4495 | bool OSUAnalysis::getPreviousCumulativeF
4495  
4496  
4497  
4498 +
4499   template <class InputCollection>
4500 < void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, vector<bool> flags){
4501 <  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree  
4500 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4501 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4502  
4503 <  if (BNTreeBranchVals_.count(parameters.name)==0) cout << "Error[assignTreeBranch]:  trying to assign value to " << parameters.name << " that does not have a branch set up.  Will likely seg fault." << endl;  
4504 <  for (uint object = 0; object != inputCollection->size(); object++) {  
4503 >  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;
4504 >  for (uint object = 0; object != inputCollection->size(); object++) {
4505  
4506 <    if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;  
4506 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4507  
4508 <    string inputVariable = parameters.inputVariable;
4508 >    string inputVariable = parameters.inputVariable;
4509      string function = "";
4510 <    string stringValue = "";  
4511 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
4512 <    BNTreeBranchVals_.at(parameters.name).push_back(value);  
4510 >    string stringValue = "";
4511 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4512 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4513  
4514    }
4515   }
4516  
4517  
4518   template <class InputCollection>
4519 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4519 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4520 >
4521  
4522    for (uint object = 0; object != inputCollection->size(); object++){
4523  
4524 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4524 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4525  
4526      string currentString = parameters.inputVariables.at(0);
4527      string inputVariable = "";
# Line 3857 | Line 4533 | void OSUAnalysis::fill1DHistogram(TH1* h
4533        function = currentString.substr(0,currentString.find("("));//function comes before the "("
4534        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4535        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4536 <    }  
4536 >    }
4537  
4538 <    string stringValue = "";  
4539 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
4540 <    histo->Fill(value,scaleFactor);  
4538 >    string stringValue = "";
4539 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4540 >    histo->Fill(value,scaleFactor);
4541  
4542      if (printEventInfo_) {
4543        // Write information about event to screen, for testing purposes.
4544 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4544 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4545      }
4546  
4547    }
4548   }
4549  
4550   template <class InputCollection1, class InputCollection2>
4551 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4551 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4552  
4553    bool sameObjects = false;
4554    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3885 | Line 4561 | void OSUAnalysis::fill1DHistogram(TH1* h
4561  
4562        pairCounter++;
4563        //only take objects which have passed all cuts and pairs which have passed all cuts
4564 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4565 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4566 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4564 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4565 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4566 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4567  
4568        string currentString = parameters.inputVariables.at(0);
4569        string inputVariable = "";
# Line 3912 | Line 4588 | void OSUAnalysis::fill1DHistogram(TH1* h
4588  
4589  
4590   template <class InputCollection>
4591 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4591 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4592  
4593    for (uint object = 0; object != inputCollection->size(); object++){
4594  
4595 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4595 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4596  
4597      string stringValue = "";
4598      string currentString = parameters.inputVariables.at(0);
# Line 3953 | Line 4629 | void OSUAnalysis::fill2DHistogram(TH2* h
4629   }
4630  
4631   template <class InputCollection1, class InputCollection2>
4632 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4632 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4633  
4634    bool sameObjects = false;
4635    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3967 | Line 4643 | void OSUAnalysis::fill2DHistogram(TH2* h
4643        pairCounter++;
4644  
4645        //only take objects which have passed all cuts and pairs which have passed all cuts
4646 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4647 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4648 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4646 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4647 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4648 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4649  
4650        string stringValue = "";
4651        string currentString = parameters.inputVariables.at(0);
# Line 4017 | Line 4693 | int OSUAnalysis::getGenMatchedParticleIn
4693  
4694      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4695      if(currentDeltaR > 0.05) continue;
4696 <    //     cout << setprecision(3) << setw(20)
4696 >    //     clog << setprecision(3) << setw(20)
4697      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4698      //          << setw(20)
4699      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 4036 | Line 4712 | int OSUAnalysis::getGenMatchedParticleIn
4712      }
4713  
4714    }
4715 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4716 <  //   else cout << "no match found..." << endl;
4715 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4716 >  //   else clog << "no match found..." << endl;
4717    return bestMatchIndex;
4718  
4719   }
# Line 4129 | Line 4805 | OSUAnalysis::chosenVertex ()
4805   {
4806    const BNprimaryvertex *chosenVertex = 0;
4807    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4808 <    vector<bool> vertexFlags;
4808 >    flagPair vertexFlags;
4809      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4810        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4811          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4137 | Line 4813 | OSUAnalysis::chosenVertex ()
4813        }
4814      }
4815      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4816 <      if(!vertexFlags.at(vertexIndex)) continue;
4816 >      if(!vertexFlags.at(vertexIndex).first) continue;
4817        chosenVertex = & primaryvertexs->at(vertexIndex);
4818        break;
4819      }
# Line 4153 | Line 4829 | OSUAnalysis::chosenMET ()
4829   {
4830    const BNmet *chosenMET = 0;
4831    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4832 <    vector<bool> metFlags;
4832 >    flagPair metFlags;
4833      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4834        if (cumulativeFlags.at("mets").at(i).size()){
4835          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4161 | Line 4837 | OSUAnalysis::chosenMET ()
4837        }
4838      }
4839      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4840 <      if(!metFlags.at(metIndex)) continue;
4840 >      if(!metFlags.at(metIndex).first) continue;
4841        chosenMET = & mets->at(metIndex);
4842        break;
4843      }
# Line 4177 | Line 4853 | OSUAnalysis::chosenElectron ()
4853   {
4854    const BNelectron *chosenElectron = 0;
4855    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4856 <    vector<bool> electronFlags;
4856 >    flagPair electronFlags;
4857      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4858        if (cumulativeFlags.at("electrons").at(i).size()){
4859          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4185 | Line 4861 | OSUAnalysis::chosenElectron ()
4861        }
4862      }
4863      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4864 <      if(!electronFlags.at(electronIndex)) continue;
4864 >      if(!electronFlags.at(electronIndex).first) continue;
4865        chosenElectron = & electrons->at(electronIndex);
4866        break;
4867      }
# Line 4196 | Line 4872 | OSUAnalysis::chosenElectron ()
4872    return chosenElectron;
4873   }
4874  
4875 +
4876   const BNmuon *
4877   OSUAnalysis::chosenMuon ()
4878   {
4879    const BNmuon *chosenMuon = 0;
4880    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4881 <    vector<bool> muonFlags;
4881 >    flagPair muonFlags;
4882      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4883        if (cumulativeFlags.at("muons").at(i).size()){
4884          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4209 | Line 4886 | OSUAnalysis::chosenMuon ()
4886        }
4887      }
4888      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4889 <      if(!muonFlags.at(muonIndex)) continue;
4889 >      if(!muonFlags.at(muonIndex).first) continue;
4890        chosenMuon = & muons->at(muonIndex);
4891        break;
4892      }
# Line 4220 | Line 4897 | OSUAnalysis::chosenMuon ()
4897    return chosenMuon;
4898   }
4899  
4900 + double
4901 + OSUAnalysis::chosenHT ()
4902 + {
4903 +  double chosenHT = 0.0;
4904 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
4905 +    flagPair jetFlags;
4906 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
4907 +      if (cumulativeFlags.at("jets").at(i).size()){
4908 +        jetFlags = cumulativeFlags.at("jets").at(i);
4909 +        break;
4910 +      }
4911 +    }
4912 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
4913 +      if(!jetFlags.at(jetIndex).first) continue;
4914 +      chosenHT += jets->at(jetIndex).pt;
4915 +    }
4916 +  }
4917 +
4918 +  return chosenHT;
4919 + }
4920 +
4921 + pair<const BNmuon *, const BNmuon *>
4922 + OSUAnalysis::leadMuonPair ()
4923 + {
4924 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
4925 +  leadMuonPair.first = leadMuonPair.second = 0;
4926 +
4927 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4928 +    flagPair muonFlags;
4929 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4930 +      if (cumulativeFlags.at("muons").at(i).size()){
4931 +        muonFlags = cumulativeFlags.at("muons").at(i);
4932 +        break;
4933 +      }
4934 +    }
4935 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
4936 +      if(!muonFlags.at(muonIndex0).first) continue;
4937 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
4938 +        if(!muonFlags.at(muonIndex1).first) continue;
4939 +        const BNmuon *mu0 = & muons->at(muonIndex0);
4940 +        const BNmuon *mu1 = & muons->at(muonIndex1);
4941 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
4942 +          leadMuonPair.first = mu0;
4943 +          leadMuonPair.second = mu1;
4944 +        }
4945 +        else{
4946 +          TVector2 newPt0 (mu0->px, mu0->py),
4947 +                   newPt1 (mu1->px, mu1->py),
4948 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
4949 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
4950 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4951 +            {
4952 +              leadMuonPair.first = mu0;
4953 +              leadMuonPair.second = mu1;
4954 +            }
4955 +        }
4956 +      }
4957 +    }
4958 +  }
4959 +
4960 +  return leadMuonPair;
4961 + }
4962 +
4963 + pair<const BNelectron *, const BNelectron *>
4964 + OSUAnalysis::leadElectronPair ()
4965 + {
4966 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
4967 +  leadElectronPair.first = leadElectronPair.second = 0;
4968 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4969 +    flagPair electronFlags;
4970 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4971 +      if (cumulativeFlags.at("electrons").at(i).size()){
4972 +        electronFlags = cumulativeFlags.at("electrons").at(i);
4973 +        break;
4974 +      }
4975 +    }
4976 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
4977 +      if(!electronFlags.at(electronIndex0).first) continue;
4978 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
4979 +        if(!electronFlags.at(electronIndex1).first) continue;
4980 +        const BNelectron *el0 = & electrons->at(electronIndex0);
4981 +        const BNelectron *el1 = & electrons->at(electronIndex1);
4982 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
4983 +          leadElectronPair.first = el0;
4984 +          leadElectronPair.second = el1;
4985 +        }
4986 +        else{
4987 +          TVector2 newPt0 (el0->px, el0->py),
4988 +                   newPt1 (el1->px, el1->py),
4989 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
4990 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
4991 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4992 +            {
4993 +              leadElectronPair.first = el0;
4994 +              leadElectronPair.second = el1;
4995 +            }
4996 +        }
4997 +      }
4998 +    }
4999 +  }
5000 +
5001 +  return leadElectronPair;
5002 + }
5003 +
5004   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines