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.100 by ahart, Tue Jul 16 19:48:04 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 <
494 <
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 <        }
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 >        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++){
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 < } // end constructor OSUAnalysis::OSUAnalysis()
639 > } // end constructor OSUAnalysis::OSUAnalysis()
640  
641  
642   OSUAnalysis::~OSUAnalysis ()
# Line 595 | Line 647 | OSUAnalysis::~OSUAnalysis ()
647    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
648      delete cutFlows_.at(currentChannel);
649    }
650 +
651 +  clog << "=============================================" << endl;  
652 +  clog << "Successfully completed OSUAnalysis." << endl;  
653 +  clog << "=============================================" << endl;  
654 +
655   }
656  
657   void
658 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
658 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
659   {
603
660    // Retrieve necessary collections from the event.
661  
662    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 666 | Line 722 | OSUAnalysis::analyze (const edm::Event &
722    //get pile-up event weight
723    if (doPileupReweighting_ && datasetType_ != "data") {
724      //for "data" datasets, the numTruePV is always set to -1
725 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
726 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
725 >    if (events->at(0).numTruePV < 0) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
726 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
727    }
728  
729    stopCTauScaleFactor_ = 1.0;
# Line 677 | Line 733 | OSUAnalysis::analyze (const edm::Event &
733  
734    //loop over all channels
735  
736 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
737    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
738      channel currentChannel = channels.at(currentChannelIndex);
739  
# Line 684 | Line 741 | OSUAnalysis::analyze (const edm::Event &
741      counterMap passingCounter;
742      cumulativeFlags.clear ();
743  
744 <    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
745 <         iter != BNTreeBranchVals_.end(); iter++) {
744 >    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
745 >         iter != BNTreeBranchVals_.end(); iter++) {
746        iter->second.clear();  // clear array
747      }
748  
# Line 698 | Line 755 | OSUAnalysis::analyze (const edm::Event &
755      //loop over all cuts
756      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
757        cut currentCut = currentChannel.cuts.at(currentCutIndex);
758 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
759 <        string currentObject = objectsToCut.at(currentObjectIndex);
758 >
759 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
760 >        string currentObject = objectsToFlag.at(currentObjectIndex);
761  
762          //initialize maps to get ready to set cuts
763 <        individualFlags[currentObject].push_back (vector<bool> ());
764 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
763 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
764 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
765  
766        }
767 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
768 <        string currentObject = objectsToCut.at(currentObjectIndex);
767 >
768 >      //set flags for all relevant objects
769 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
770 >        string currentObject = objectsToFlag.at(currentObjectIndex);
771  
772          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
773  
774  
775          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
776          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
777 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
778          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
779          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
780          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 738 | Line 799 | OSUAnalysis::analyze (const edm::Event &
799                                                                     "muon-muon pairs");
800  
801          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
802 <                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
803 <                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
804 <                                                                             "muon-secondary muon pairs");
802 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
803 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
804 >                                                                             "muon-secondary muon pairs");
805 >
806 >        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
807 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
808 >                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
809 >                                                                             "muon-secondary photon pairs");
810 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
811 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
812 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
813 >                                                                             "muon-secondary jet pairs");
814 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
815 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
816 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
817 >                                                                             "photon-secondary jet pairs");
818 >
819 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
820 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
821 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
822 >                                                                             "electron-secondary jet pairs");
823  
824          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
825 <                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
826 <                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
827 <                                                                                     "electron-secondary electron pairs");
825 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
826 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
827 >                                                                                     "electron-secondary electron pairs");
828  
829          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
830                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 756 | Line 835 | OSUAnalysis::analyze (const edm::Event &
835                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
836                                                                         "electron-muon pairs");
837          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
838 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
840 <                                                                 "jet-jet pairs");
838 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
840 >                                                                 "jet-jet pairs");
841 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
842 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
843 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
844 >                                                                 "jet-secondary jet pairs");
845          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
846 <                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
847 <                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
848 <                                                                      "electron-jet pairs");
846 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
847 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
848 >                                                                      "electron-jet pairs");
849 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
850 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
851 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
852 >                                                                      "electron-photon pairs");
853 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
854 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
855 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
856 >                                                                      "photon-jet pairs");
857          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
858 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
859 <                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
860 <                                                                  "muon-jet pairs");
858 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
859 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
860 >                                                                  "muon-jet pairs");
861 >        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
862 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
863 >                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
864 >                                                                  "muon-event pairs");
865 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
866 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
867 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
868 >                                                                  "met-jet pairs");
869 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
870 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
871 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
872 >                                                                 "track-jet pairs");
873 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
874 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
875 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
876 >                                                                  "muon-photon pairs");
877          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
878                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
879                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 788 | Line 895 | OSUAnalysis::analyze (const edm::Event &
895                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
896                                                                   "tau-tau pairs");
897          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
898 <                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
899 <                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
900 <                                                                   "tau-track pairs");
898 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
899 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
900 >                                                                   "tau-track pairs");
901          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
902                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
903                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 808 | Line 915 | OSUAnalysis::analyze (const edm::Event &
915      }//end loop over all cuts
916      //use cumulative flags to apply cuts at event level
917  
811    bool eventPassedAllCuts = true;
918      //a vector to store cumulative cut descisions after each cut.
919      vector<bool> eventPassedPreviousCuts;
920 +    bool eventPassedAllCuts = true;
921      //apply trigger (true if none were specified)
922      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
923  
# Line 821 | Line 928 | OSUAnalysis::analyze (const edm::Event &
928        int numberPassing = 0;
929  
930        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
931 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
931 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
932        }
933        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
934        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
935        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
936        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
937      }
938 +    //applying all appropriate scale factors
939      double scaleFactor = masterScaleFactor;
832
940      muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
941 +
942      if(applyLeptonSF_ && datasetType_ != "data"){
943 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
944 <        vector<bool> muonFlags;
943 >      //only apply SFs if we've cut on this object
944 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
945 >        flagPair muonFlags;
946 >        //get the last valid flags in the flag map
947          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
948            if (cumulativeFlags.at("muons").at(i).size()){
949              muonFlags = cumulativeFlags.at("muons").at(i);
950              break;
951            }
952          }
953 +        //apply the weight for each of those objects
954          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
955 <          if(!muonFlags.at(muonIndex)) continue;
955 >          if(!muonFlags.at(muonIndex).second) continue;
956            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
957          }
958        }
959 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
960 <        vector<bool> electronFlags;
959 >      //only apply SFs if we've cut on this object
960 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
961 >        flagPair electronFlags;
962 >        //get the last valid flags in the flag map
963          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
964            if (cumulativeFlags.at("electrons").at(i).size()){
965              electronFlags = cumulativeFlags.at("electrons").at(i);
966              break;
967            }
968          }
969 +        //apply the weight for each of those objects
970          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
971 <          if(!electronFlags.at(electronIndex)) continue;
971 >          if(!electronFlags.at(electronIndex).second) continue;
972            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
973          }
974        }
975      }
976      if(applyBtagSF_ && datasetType_ != "data"){
977 <     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
978 <        vector<bool> jetFlags;        
977 >      //only apply SFs if we've cut on this object
978 >      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
979 >        flagPair jetFlags;
980          vector<double> jetSFs;
981 +        //get the last valid flags in the flag map
982          for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
983 <          if (cumulativeFlags.at("jets").at(i).size()){            
983 >          if (cumulativeFlags.at("jets").at(i).size()){
984              jetFlags = cumulativeFlags.at("jets").at(i);
985 <            break;          
985 >            break;
986            }
987 <        }        
987 >        }
988 >        //apply the weight for each of those objects
989          for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
990 <          if(!jetFlags.at(jetIndex)) continue;          
991 <          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt);
990 >          if(!jetFlags.at(jetIndex).second) continue;
991 >          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
992            jetSFs.push_back(jetSFTmp);
993          }
994 <        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );    
994 >        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
995        }
996      }
997      scaleFactor *= muonScaleFactor_;
# Line 884 | Line 1001 | OSUAnalysis::analyze (const edm::Event &
1001  
1002      if (printEventInfo_) {
1003        // Write information about event to screen, for testing purposes.
1004 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1004 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1005             << ": run="  << events->at(0).run
1006             << "  lumi=" << events->at(0).lumi
1007             << "  event=" << events->at(0).evt
# Line 897 | Line 1014 | OSUAnalysis::analyze (const edm::Event &
1014        uint currentDir;
1015        if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1016        else{
1017 <        currentDir = currentCut;
1017 >        currentDir = currentCut;
1018        }
1019 +
1020 +
1021        if(eventPassedPreviousCuts.at(currentDir)){
1022  
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                                                                                          
1023          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1024            histogram currentHistogram = histograms.at(histogramIndex);
1025  
1026 <          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1026 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1027  
1028 <          if(currentHistogram.inputVariables.size() == 1){
1029 <            TH1D* histo;  
1030 <            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1031 <            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1032 <            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1033 <            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1034 <            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1035 <            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1036 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1037 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1038 <                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1039 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1040 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1041 <                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1042 <            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1043 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1044 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1045 <                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1046 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1047 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1048 <                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1049 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1050 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1051 <                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1052 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1053 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1054 <                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1055 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1056 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1057 <                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1058 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1059 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1060 <                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1061 <            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1062 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1063 <                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1064 <            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1065 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1066 <                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1067 <            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1068 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1069 <                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1070 <            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1071 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1072 <                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1073 <            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1074 <                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1075 <                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1076 <            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1077 <                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1078 <                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1079 <            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1080 <                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1081 <                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1082 <
1083 <            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1084 <            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1085 <            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1086 <            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1087 <            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1088 <            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1089 <            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1090 <            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1091 <            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1092 <            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1093 <            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1094 <            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1095 <          }
1096 <          else if(currentHistogram.inputVariables.size() == 2){
1097 <            TH2D* histo;
1098 <            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1099 <            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1100 <            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1101 <            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1102 <            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1103 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1104 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1105 <                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1106 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1107 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1108 <                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1109 <            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1110 <            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1111 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1112 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1113 <                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1114 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1115 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1116 <                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1117 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1118 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1119 <                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1120 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1121 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1122 <                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1123 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1124 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1125 <                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1126 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1127 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1128 <                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1129 <            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1130 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1131 <                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1132 <            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1133 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1134 <                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1135 <            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1136 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1137 <                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1138 <            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1139 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1140 <                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1141 <            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1142 <                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1143 <                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1144 <            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1145 <                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1146 <                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1147 <            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1148 <                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1149 <                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1150 <            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1151 <            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1152 <            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1153 <            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1154 <            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1155 <                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1156 <                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1157 <            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1158 <            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1159 <            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1160 <            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1161 <            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1162 <            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1163 <            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1164 <            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1165 <          }
1166 <          
1167 <        }
1168 <
1169 <
1170 <        //fills histograms with the sizes of collections
1171 <        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1172 <
1173 <          string currentObject = objectsToPlot.at(currentObjectIndex);
1174 <          string objectToPlot = "";
1175 <
1176 <          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1177 <          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1178 <          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1179 <          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1180 <          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1181 <          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1182 <          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1183 <          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1184 <          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1185 <          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1186 <          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1187 <          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1188 <          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1189 <          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1190 <          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1191 <          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1192 <          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1193 <          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1194 <          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1195 <          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1196 <          else objectToPlot = currentObject;
1197 <
1198 <          string tempCurrentObject = objectToPlot;
1199 <          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1200 <          string histoName = "num" + tempCurrentObject;
1201 <
1202 <          //set position of primary vertex in event, in order to calculate quantities relative to it
1203 <          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1204 <            vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1205 <            int numToPlot = 0;
1206 <            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1207 <              if(lastCutFlags.at(currentFlag)) numToPlot++;
1208 <            }
1209 <            if(objectToPlot == "primaryvertexs"){
1210 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1211 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1212 <            }
1213 <            else {
1214 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1215 <            }
1216 <          }
1217 <        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1218 <        
1219 <        if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }  
1220 <        BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts  
1221 <
1222 <      } // end if(eventPassedPreviousCuts.at(currentDir)){
1223 <    } // end loop over cuts
1224 <    
1225 <  } // end loop over channel
1028 >          if(currentHistogram.inputVariables.size() == 1){
1029 >            TH1D* histo;
1030 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1031 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1032 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1033 >            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1034 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1035 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1036 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1037 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1038 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1039 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1040 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1041 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1042 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1043 >             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1044 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1045 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1046 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1047 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1048 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1049 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1050 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1051 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1052 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1053 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1054 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1055 >
1056 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1057 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1058 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1059 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1060 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1061 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1062 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1063 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1064 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1065 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1066 >
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 == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1077 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1078 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1079 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1080 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1081 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1082 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1083 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1084 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1085 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1086 >                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1087 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1088 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1089 >                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1090 >                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1091 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1092 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1093 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1094 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1095 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1096 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1097 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1098 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1099 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1100 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1101 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1102 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1103 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1104 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1105 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1106 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1107 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1108 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1109 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1110 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1111 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1112 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1113 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1114 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1115 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1116 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1117 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1118 >
1119 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1120 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1121 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1122 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1123 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1124 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1125 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1126 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1127 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1128 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1129 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1130 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1131 >          }
1132 >          else if(currentHistogram.inputVariables.size() == 2){
1133 >            TH2D* histo;
1134 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1135 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1136 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1137 >            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1138 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1139 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1140 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1141 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1142 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1143 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1144 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1145 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1146 >            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1147 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1148 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1149 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1150 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1151 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1152 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1153 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1154 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1155 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1156 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1157 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1158 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1159 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1160 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1161 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1162 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1163 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1164 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1165 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1166 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1167 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1168 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1169 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1170 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1171 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1172 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1173 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1174 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1175 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1176 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1177 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1178 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1179 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1180 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1181 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1182 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1183 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1184 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1185 >                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1186 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1187 >            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1188 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1189 >                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1190 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1191 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1192 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1193 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1194 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1195 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1196 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1197 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1198 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1199 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1200 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1201 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1202 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1203 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1204 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1205 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1206 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1207 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1208 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1209 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1210 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1211 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1212 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1213 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1214 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1215 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1216 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1217 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1218 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1219 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1220 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1221 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1222 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1223 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1224 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1225 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1226 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1227 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1228 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1229 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1230 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1231 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1232 >          }
1233  
1234 +        }
1235 +
1236 +
1237 +        //fills histograms with the sizes of collections
1238 +        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1239 +
1240 +          string currentObject = objectsToPlot.at(currentObjectIndex);
1241 +          string objectToPlot = "";
1242 +
1243 +          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1244 +          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1245 +          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1246 +          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1247 +          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1248 +          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1249 +          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1250 +          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1251 +          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1252 +          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1253 +          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1254 +          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1255 +          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1256 +          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1257 +          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1258 +          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1259 +          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1260 +          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1261 +          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1262 +          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1263 +          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1264 +          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1265 +          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1266 +          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1267 +          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1268 +          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1269 +          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1270 +          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1271 +          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1272 +          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1273 +          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1274 +          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1275 +          else objectToPlot = currentObject;
1276 +
1277 +          string tempCurrentObject = objectToPlot;
1278 +          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1279 +          string histoName = "num" + tempCurrentObject;
1280 +
1281 +
1282 +          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1283 +            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1284 +            int numToPlot = 0;
1285 +            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1286 +              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1287 +            }
1288 +
1289 +            if(objectToPlot == "primaryvertexs"){
1290 +              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1291 +              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1292 +            }
1293 +            else {
1294 +              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1295 +            }
1296 +          }
1297 +        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1298 +
1299 +
1300 +      } // end if(eventPassedPreviousCuts.at(currentDir))
1301 +    } // end loop over cuts
1302 +
1303 +    if (!useEDMFormat_ && eventPassedAllCuts){
1304 +      // Assign BNTree variables
1305 +      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1306 +        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1307 +        string coll = brSpecs.inputCollection;
1308 +        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1309 +
1310 +        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1311 +        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1312 +        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1313 +        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1314 +        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1315 +        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1316 +        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1317 +        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1318 +        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1319 +        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1320 +        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1321 +        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1322 +        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1323 +        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1324 +        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1325 +        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1326 +        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1327 +        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1328 +        else if(coll == "stops"
1329 +                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1330 +      } // end loop over branches
1331 +
1332 +      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1333 +      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1334 +    }
1335 +
1336 +    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1337 +
1338 +  } // end loop over channel
1339  
1340    masterCutFlow_->fillCutFlow(masterScaleFactor);
1341  
1342 +  event.put (channelDecisions, "channelDecisions");
1343  
1344   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1345  
# Line 1151 | Line 1356 | OSUAnalysis::evaluateComparison (double
1356    else if(comparison == "==") return testValue == cutValue;
1357    else if(comparison == "=") return testValue == cutValue;
1358    else if(comparison == "!=") return testValue != cutValue;
1359 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1359 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1360  
1361   }
1362  
# Line 1166 | Line 1371 | OSUAnalysis::evaluateComparison (string
1371    else if(comparison == "==") return testValue == cutValue;
1372    else if(comparison == "=") return testValue == cutValue;
1373    else if(comparison == "!=") return testValue != cutValue;
1374 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1374 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1375  
1376   }
1377  
# Line 1176 | Line 1381 | OSUAnalysis::evaluateTriggers (vector<st
1381    //initialize to false until a chosen trigger is passed
1382    bool triggerDecision = false;
1383  
1384 <  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;  
1384 >  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1385    //loop over all triggers defined in the event
1386    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1387  
1388 <    if (printAllTriggers_) cout << "   " << trigger->name << endl;  
1388 >    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1389  
1390      //we're only interested in triggers that actually passed
1391      if(trigger->pass != 1) continue;
# Line 1192 | Line 1397 | OSUAnalysis::evaluateTriggers (vector<st
1397      //if the event passes one of the chosen triggers, set triggerDecision to true
1398      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1399        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1400 <    }  
1400 >    }
1401    }
1402  
1403 <  printAllTriggers_ = false;  // only print triggers once, not every event  
1403 >  printAllTriggers_ = false;  // only print triggers once, not every event
1404  
1405 <  //if none of the veto triggers fired:
1405 >  //if none of the veto triggers fired:
1406    //return the OR of all the chosen triggers
1407    if (triggersToTest.size() != 0) return triggerDecision;
1408    //or if no triggers were defined return true
# Line 1366 | Line 1571 | OSUAnalysis::valueLookup (const BNjet* o
1571    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1572    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1573  
1574 +  //user defined variable
1575 +  else if(variable == "disappTrkLeadingJetID") {
1576 +    value = object->pt > 110
1577 +      && fabs(object->eta) < 2.4
1578 +      && object->chargedHadronEnergyFraction > 0.2
1579 +      && object->neutralHadronEnergyFraction < 0.7
1580 +      && object->chargedEmEnergyFraction < 0.5
1581 +      && object->neutralEmEnergyFraction < 0.7;
1582 +  }
1583 +
1584 +  else if(variable == "disappTrkSubLeadingJetID") {
1585 +    value = object->pt > 30
1586 +      && fabs(object->eta) < 4.5
1587 +      && object->neutralHadronEnergyFraction < 0.7
1588 +      && object->chargedEmEnergyFraction < 0.5;
1589 +  }
1590 +
1591 +  else if(variable == "dPhiMet") {
1592 +    if (const BNmet *met = chosenMET ()) {
1593 +      value = deltaPhi (object->phi, met->phi);
1594 +    } else value = -999;
1595 +  }
1596  
1597 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1597 >
1598 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1599  
1600    value = applyFunction(function, value);
1601  
1602    return value;
1603 < }
1603 > } // end jet valueLookup
1604  
1605  
1606   //!muon valueLookup
# Line 1469 | Line 1697 | OSUAnalysis::valueLookup (const BNmuon*
1697    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1698    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1699    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1700 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1701 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1702 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1703 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1704    else if(variable == "rhoPrime") value = object->rhoPrime;
1705    else if(variable == "AEffDr03") value = object->AEffDr03;
1706    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1476 | Line 1708 | OSUAnalysis::valueLookup (const BNmuon*
1708    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1709    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1710    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1711 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1712 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1713 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1714 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1715 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1716    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1717    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1718    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1532 | Line 1769 | OSUAnalysis::valueLookup (const BNmuon*
1769    else if(variable == "time_ndof") value = object->time_ndof;
1770  
1771    //user-defined variables
1772 +  else if(variable == "looseID") {
1773 +    value = object->pt > 10 &&
1774 +      (object->isGlobalMuon  > 0 ||
1775 +       object->isTrackerMuon > 0);
1776 +  }
1777    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1778    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1779    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1780    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1781 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1782    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1783    else if(variable == "metMT") {
1784      if (const BNmet *met = chosenMET ())
# Line 1732 | Line 1975 | OSUAnalysis::valueLookup (const BNmuon*
1975  
1976  
1977  
1978 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1978 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1979  
1980    value = applyFunction(function, value);
1981  
1982    return value;
1983 < }
1983 > } // end muon valueLookup
1984 >
1985  
1986   //!electron valueLookup
1987   double
# Line 1906 | Line 2150 | OSUAnalysis::valueLookup (const BNelectr
2150    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2151    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2152    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2153 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2154 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2155    else if(variable == "metMT") {
2156      if (const BNmet *met = chosenMET ())
2157        {
# Line 1977 | Line 2223 | OSUAnalysis::valueLookup (const BNelectr
2223      else value = -999;
2224    }
2225  
2226 +  else if(variable == "looseID"){
2227 +    if (object->isEB)
2228 +      {
2229 +        value = fabs(object->delEtaIn) < 0.007 \
2230 +          && fabs (object->delPhiIn) < 0.15 \
2231 +          && object->scSigmaIEtaIEta < 0.01 \
2232 +          && object->hadOverEm < 0.12 \
2233 +          && fabs (object->correctedD0Vertex) < 0.02 \
2234 +          && fabs (object->correctedDZ) < 0.2 \
2235 +          && object->absInvEMinusInvPin < 0.05 \
2236 +          && object->passConvVeto;
2237 +      }
2238 +    else
2239 +      {
2240 +        value = fabs(object->delEtaIn) < 0.009 \
2241 +          && fabs (object->delPhiIn) < 0.10 \
2242 +          && object->scSigmaIEtaIEta < 0.03 \
2243 +          && object->hadOverEm < 0.10 \
2244 +          && fabs (object->correctedD0Vertex) < 0.02 \
2245 +          && fabs (object->correctedDZ) < 0.2 \
2246 +          && object->absInvEMinusInvPin < 0.05 \
2247 +          && object->passConvVeto;
2248 +      }
2249 +  }
2250 +
2251    else if(variable == "tightID"){
2252      if (object->isEB)
2253        {
# Line 2002 | Line 2273 | OSUAnalysis::valueLookup (const BNelectr
2273        }
2274    }
2275  
2276 +  else if(variable == "looseID"){
2277 +    value = object->pt > 10
2278 +      && object->mvaNonTrigV0 > 0;
2279 +      }
2280    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2281      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2282      else value = -999;
# Line 2132 | Line 2407 | OSUAnalysis::valueLookup (const BNelectr
2407  
2408  
2409  
2410 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2410 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2411  
2412    value = applyFunction(function, value);
2413  
2414    return value;
2415 < }
2415 > } // end electron valueLookup
2416 >
2417  
2418   //!event valueLookup
2419   double
# Line 2149 | Line 2425 | OSUAnalysis::valueLookup (const BNevent*
2425    else if(variable == "pthat") value = object->pthat;
2426    else if(variable == "qScale") value = object->qScale;
2427    else if(variable == "alphaQCD") value = object->alphaQCD;
2428 +  else if(variable == "Ht") value = getHt(jets.product());
2429    else if(variable == "alphaQED") value = object->alphaQED;
2430    else if(variable == "scalePDF") value = object->scalePDF;
2431    else if(variable == "x1") value = object->x1;
# Line 2219 | Line 2496 | OSUAnalysis::valueLookup (const BNevent*
2496    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2497    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2498    else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2499 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2499 >  else if(variable == "ht") value = chosenHT ();
2500 >  else if(variable == "leadMuPairInvMass"){
2501 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2502 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2503 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2504 >    value = (p0 + p1).M ();
2505 >  }
2506 >  else if(variable == "leadMuPairPt"){
2507 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2508 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2509 >             pt1 (muPair.second->px, muPair.second->py);
2510 >    pt0 += pt1;
2511 >    value = pt0.Mod ();
2512 >  }
2513 >  else if(variable == "leadElPairInvMass"){
2514 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2515 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2516 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2517 >    value = (p0 + p1).M ();
2518 >  }
2519 >  else if(variable == "leadElPairPt"){
2520 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2521 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2522 >             pt1 (muPair.second->px, muPair.second->py);
2523 >    pt0 += pt1;
2524 >    value = pt0.Mod ();
2525 >  }
2526 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2527  
2528    value = applyFunction(function, value);
2529  
2530    return value;
2531 < }
2531 > } // end event valueLookup
2532 >
2533  
2534   //!tau valueLookup
2535   double
# Line 2272 | Line 2577 | OSUAnalysis::valueLookup (const BNtau* o
2577    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2578    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2579  
2580 <
2580 >  else if (variable == "looseHadronicID") {
2581 >    value = object->pt > 10
2582 >      && object->eta < 2.3
2583 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2584 >      && object->HPSdecayModeFinding > 0
2585 >      && object->HPSagainstElectronLoose > 0
2586 >      && object->HPSagainstMuonTight > 0;
2587 >  }
2588  
2589    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2590  
# Line 2319 | Line 2631 | OSUAnalysis::valueLookup (const BNtau* o
2631    }
2632  
2633  
2634 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2634 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2635  
2636    value = applyFunction(function, value);
2637  
2638    return value;
2639 < }
2639 > } // end tau valueLookup
2640 >
2641  
2642   //!met valueLookup
2643   double
# Line 2392 | Line 2705 | OSUAnalysis::valueLookup (const BNmet* o
2705    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2706    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2707  
2708 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2708 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2709  
2710    value = applyFunction(function, value);
2711  
2712    return value;
2713 < }
2713 > } // end met valueLookup
2714 >
2715  
2716   //!track valueLookup
2717   double
# Line 2425 | Line 2739 | OSUAnalysis::valueLookup (const BNtrack*
2739    else if(variable == "numValidHits") value = object->numValidHits;
2740    else if(variable == "isHighPurity") value = object->isHighPurity;
2741  
2428
2742    //additional BNs info for disappTrks
2743 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2744 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2745 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2746 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2747 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2748 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2749 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2750 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2438 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2743 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2744 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2745 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2746 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2747 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2748 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2749 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2750 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2751    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2752 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2752 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2753 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2754 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2755 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2756 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2757 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2758 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2759 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2760 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2761 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2762 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2763 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2764 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2765 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2766 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2767 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2768 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2769 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2770  
2771    //user defined variables
2772    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;
2773    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2774 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2774 >  else if(variable == "depTrkRp5MinusPt"){
2775 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2776 >           value = 0;
2777 >         }
2778 >         else value =  (object->depTrkRp5 - object->pt);
2779 >  }
2780 >  else if(variable == "depTrkRp3MinusPt"){
2781 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2782 >      value = 0;
2783 >    }
2784 >    else value =  (object->depTrkRp3 - object->pt);
2785 >  }
2786 >
2787 >  else if(variable == "dPhiMet") {
2788 >    if (const BNmet *met = chosenMET ()) {
2789 >      value = deltaPhi (object->phi, met->phi);
2790 >    } else value = -999;
2791 >  }
2792 >  
2793 >  
2794    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2795    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2796    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2470 | Line 2818 | OSUAnalysis::valueLookup (const BNtrack*
2818        pt = object->pt;
2819      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2820    }
2821 +
2822 +
2823    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2824  
2825    else if(variable == "genMatchedPdgId"){
# Line 2517 | Line 2867 | OSUAnalysis::valueLookup (const BNtrack*
2867  
2868  
2869  
2870 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2870 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2871  
2872    value = applyFunction(function, value);
2873  
2874    return value;
2875 < }
2875 > } // end track valueLookup
2876 >
2877  
2878   //!genjet valueLookup
2879   double
# Line 2546 | Line 2897 | OSUAnalysis::valueLookup (const BNgenjet
2897    else if(variable == "charge") value = object->charge;
2898  
2899  
2900 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2900 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2901  
2902    value = applyFunction(function, value);
2903  
# Line 2680 | Line 3031 | OSUAnalysis::valueLookup (const BNmcpart
3031    }
3032  
3033  
3034 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3034 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3035  
3036    value = applyFunction(function, value);
3037  
3038    return value;
3039 < }
3039 > } // end mcparticle valueLookup
3040 >
3041  
3042   //!primaryvertex valueLookup
3043   double
# Line 2708 | Line 3060 | OSUAnalysis::valueLookup (const BNprimar
3060    else if(variable == "isGood") value = object->isGood;
3061  
3062  
3063 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3063 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3064  
3065    value = applyFunction(function, value);
3066  
# Line 2726 | Line 3078 | OSUAnalysis::valueLookup (const BNbxlumi
3078    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3079  
3080  
3081 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3081 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3082  
3083    value = applyFunction(function, value);
3084  
# Line 2859 | Line 3211 | OSUAnalysis::valueLookup (const BNphoton
3211    }
3212  
3213  
3214 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3214 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3215  
3216    value = applyFunction(function, value);
3217  
3218    return value;
3219 < }
3219 > } // end photon valueLookup
3220 >
3221  
3222   //!supercluster valueLookup
3223   double
# Line 2882 | Line 3235 | OSUAnalysis::valueLookup (const BNsuperc
3235    else if(variable == "theta") value = object->theta;
3236  
3237  
3238 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3238 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3239  
3240    value = applyFunction(function, value);
3241  
# Line 2916 | Line 3269 | OSUAnalysis::valueLookup (const BNtrigob
3269        stringValue = "none";  // stringValue should only be empty if value is filled
3270    }
3271  
3272 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3272 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3273  
3274    value = applyFunction(function, value);
3275  
# Line 2987 | Line 3340 | OSUAnalysis::valueLookup (const BNmuon*
3340        value = object2->correctedD0;
3341      }
3342  
3343 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3343 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3344 >
3345 >  value = applyFunction(function, value);
3346 >
3347 >  return value;
3348 > } // end muon-muon pair valueLookup
3349 >
3350 >
3351 > //!muon-photon pair valueLookup
3352 > double
3353 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3354 >
3355 >  double value = 0.0;
3356 >
3357 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3358 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3359 >  else if(variable == "photonEta") value = object2->eta;
3360 >  else if(variable == "photonPt") value = object2->pt;
3361 >  else if(variable == "muonEta") value = object1->eta;
3362 >  else if(variable == "photonPhi") value = object2->phi;
3363 >  else if(variable == "muonPhi") value = object1->phi;
3364 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3365 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3366 >  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3367 >  else if(variable == "invMass"){
3368 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3369 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3370 >    value = (fourVector1 + fourVector2).M();
3371 >  }
3372 >  else if(variable == "pt"){
3373 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3374 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3375 >    value = (fourVector1 + fourVector2).Pt();
3376 >  }
3377 >  else if(variable == "threeDAngle")
3378 >    {
3379 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3380 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3381 >      value = (threeVector1.Angle(threeVector2));
3382 >    }
3383 >  else if(variable == "alpha")
3384 >    {
3385 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3386 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3387 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3388 >      value = (pi-threeVector1.Angle(threeVector2));
3389 >    }
3390 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3391 >
3392 >  value = applyFunction(function, value);
3393 >
3394 >  return value;
3395 > }
3396 >
3397 > //!electron-photon pair valueLookup
3398 > double
3399 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3400 >
3401 >  double value = 0.0;
3402 >
3403 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3404 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3405 >  else if(variable == "photonEta") value = object2->eta;
3406 >  else if(variable == "photonPt") value = object2->pt;
3407 >  else if(variable == "electronEta") value = object1->eta;
3408 >  else if(variable == "photonPhi") value = object2->phi;
3409 >  else if(variable == "electronPhi") value = object1->phi;
3410 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3411 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3412 >  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3413 >  else if(variable == "invMass"){
3414 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3415 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3416 >    value = (fourVector1 + fourVector2).M();
3417 >  }
3418 >  else if(variable == "pt"){
3419 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3420 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3421 >    value = (fourVector1 + fourVector2).Pt();
3422 >  }
3423 >  else if(variable == "threeDAngle")
3424 >    {
3425 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3426 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3427 >      value = (threeVector1.Angle(threeVector2));
3428 >    }
3429 >  else if(variable == "alpha")
3430 >    {
3431 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3432 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3433 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3434 >      value = (pi-threeVector1.Angle(threeVector2));
3435 >    }
3436 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3437  
3438    value = applyFunction(function, value);
3439  
# Line 3043 | Line 3489 | OSUAnalysis::valueLookup (const BNelectr
3489      value = object2->correctedD0;
3490    }
3491  
3492 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3492 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3493  
3494    value = applyFunction(function, value);
3495  
3496    return value;
3497   }
3498 +
3499   //!electron-muon pair valueLookup
3500   double
3501   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3109 | Line 3556 | OSUAnalysis::valueLookup (const BNelectr
3556    else if(variable == "muonRelPFdBetaIso"){
3557      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3558    }
3559 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3559 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3560    value = applyFunction(function, value);
3561  
3562    return value;
3563 < }
3563 > } // end electron-muon pair valueLookup
3564 >
3565  
3566   //!electron-jet pair valueLookup
3567   double
# Line 3148 | Line 3596 | OSUAnalysis::valueLookup (const BNelectr
3596      value = object1->charge*object2->charge;
3597    }
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   }
3604  
3605 + //!photon-jet pair valueLookup
3606 + double
3607 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3608 +
3609 +  double value = 0.0;
3610 +
3611 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3612 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3613 +  else if(variable == "jetEta") value = object2->eta;
3614 +  else if(variable == "jetPhi") value = object2->phi;
3615 +  else if(variable == "photonEta") value = object1->eta;
3616 +  else if(variable == "photonPhi") value = object1->phi;
3617 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3618 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3619 +  else if(variable == "invMass"){
3620 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3621 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3622 +    value = (fourVector1 + fourVector2).M();
3623 +  }
3624 +  else if(variable == "pt"){
3625 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3626 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3627 +    value = (fourVector1 + fourVector2).Pt();
3628 +  }
3629 +  else if(variable == "threeDAngle")
3630 +    {
3631 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3632 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3633 +      value = (threeVector1.Angle(threeVector2));
3634 +    }
3635 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3636 +  value = applyFunction(function, value);
3637 +
3638 +  return value;
3639 + }
3640 +
3641 + // track-jet pair valueLookup
3642 + double
3643 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3644 +
3645 +  double value = 0.0;
3646 +
3647 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3648 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3649 +
3650 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3651 +  value = applyFunction(function, value);
3652 +
3653 +  return value;
3654 +
3655 + }
3656 +
3657 +
3658 +
3659 + // met-jet pair valueLookup
3660 + double
3661 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3662 +
3663 +  double value = 0.0;
3664 +
3665 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3666 +
3667 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3668 +  value = applyFunction(function, value);
3669 +
3670 +  return value;
3671 +
3672 + }  
3673 +
3674 +
3675 +
3676   //!muon-jet pair valueLookup
3677   double
3678   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3162 | Line 3681 | OSUAnalysis::valueLookup (const BNmuon*
3681  
3682    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3683    else if(variable == "jetEta") value = object2->eta;
3684 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3685 +  else if(variable == "jetPt") value = object2->pt;
3686    else if(variable == "jetPhi") value = object2->phi;
3687 +  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3688    else if(variable == "muonEta") value = object1->eta;
3689 +  else if(variable == "muonPt") value = object1->pt;
3690    else if(variable == "muonPhi") value = object1->phi;
3691 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3691 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3692    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3693    else if(variable == "invMass"){
3694      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3187 | Line 3710 | OSUAnalysis::valueLookup (const BNmuon*
3710      value = object1->charge*object2->charge;
3711    }
3712  
3713 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3713 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3714    value = applyFunction(function, value);
3715  
3716    return value;
3717   }
3718  
3719 + //!muon-event valueLookup
3720 + double
3721 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3722 +
3723 +  double value = 0.0;
3724 +
3725 +  if(variable == "muonEta") value = object1->eta;
3726 +  else if(variable == "muonPt") value = object1->pt;
3727 +  else if(variable == "muonPhi") value = object1->phi;
3728 +  else if(variable == "Ht") value = getHt(jets.product());
3729 +  else if(variable == "pthat")   value = object2->pthat;
3730 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3731 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3732 +  value = applyFunction(function, value);
3733 +
3734 +  return value;
3735 + }
3736   //!jet-jet pair valueLookup
3737   double
3738   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3201 | Line 3741 | OSUAnalysis::valueLookup (const BNjet* o
3741  
3742    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3743    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3744 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3744 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3745    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3746    else if(variable == "invMass"){
3747      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3223 | Line 3763 | OSUAnalysis::valueLookup (const BNjet* o
3763      value = object1->charge*object2->charge;
3764    }
3765  
3766 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3766 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3767    value = applyFunction(function, value);
3768  
3769    return value;
3770   }
3771 +
3772   //!electron-track pair valueLookup
3773   double
3774   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3247 | Line 3788 | OSUAnalysis::valueLookup (const BNelectr
3788    else if(variable == "chargeProduct"){
3789      value = object1->charge*object2->charge;
3790    }
3791 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3791 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3792    value = applyFunction(function, value);
3793    return value;
3794  
# Line 3275 | Line 3816 | OSUAnalysis::valueLookup (const BNmuon*
3816      value = object1->charge*object2->charge;
3817    }
3818  
3819 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3819 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3820    value = applyFunction(function, value);
3821    return value;
3822   }
# Line 3297 | Line 3838 | OSUAnalysis::valueLookup (const BNtau* o
3838      value = object1->charge*object2->charge;
3839    }
3840  
3841 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3841 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3842    value = applyFunction(function, value);
3843    return value;
3844   }
# Line 3319 | Line 3860 | OSUAnalysis::valueLookup (const BNmuon*
3860      value = object1->charge*object2->charge;
3861    }
3862  
3863 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3863 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3864    value = applyFunction(function, value);
3865    return value;
3866   }
# Line 3334 | Line 3875 | OSUAnalysis::valueLookup (const BNtau* o
3875      value = object1->charge*object2->charge;
3876    }
3877  
3878 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3878 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3879    value = applyFunction(function, value);
3880    return value;
3881   }
# Line 3354 | Line 3895 | OSUAnalysis::valueLookup (const BNtrack*
3895    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3896    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3897  
3898 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3898 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3899  
3900    value = applyFunction(function, value);
3901  
# Line 3376 | Line 3917 | OSUAnalysis::valueLookup (const BNelectr
3917        stringValue = "none";
3918    }
3919  
3920 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3920 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3921  
3922    value = applyFunction(function, value);
3923  
# Line 3392 | Line 3933 | OSUAnalysis::valueLookup (const BNmuon*
3933  
3934    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3935  
3936 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3936 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3937  
3938    value = applyFunction(function, value);
3939  
# Line 3495 | Line 4036 | OSUAnalysis::valueLookup (const BNstop*
4036      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4037        vertex_rank++;
4038        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4039 <                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4040 <                      (object->vz-vertex->z)*(object->vz-vertex->z));
4039 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4040 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
4041  
4042        if(abs(dist) < abs(minDistToVertex)){
4043          value = vertex_rank;
# Line 3505 | Line 4046 | OSUAnalysis::valueLookup (const BNstop*
4046      }
4047    }
4048  
4049 +  else if (variable == "decaysToTau"){
4050 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4051 +  }
4052  
4053  
4054  
4055 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4055 >
4056 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4057  
4058    value = applyFunction(function, value);
4059  
4060    return value;
4061  
4062 < }
4062 > } // end stop valueLookup
4063 >
4064  
4065  
4066  
# Line 3532 | Line 4078 | OSUAnalysis::getTrkIsIso (const BNtrack*
4078  
4079   }
4080  
4081 + //calculate the scalar sum of Jet Pt in the event.
4082 + double
4083 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4084 +  double Ht = 0;
4085 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4086 +    Ht += abs(jet->pt);
4087 +  }
4088 +  return Ht;
4089 + }
4090  
4091   double
4092   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3569 | Line 4124 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4124    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4125    if (!useTrackCaloRhoCorr_) return -99;
4126    // if (!rhokt6CaloJetsHandle_) {
4127 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4127 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4128    //   return -99;
4129    // }
4130    double radDeltaRCone = 0.5;
# Line 3591 | Line 4146 | OSUAnalysis::WriteDeadEcal (){
4146    double etaEcal, phiEcal;
4147    ifstream DeadEcalFile(deadEcalFile_);
4148    if(!DeadEcalFile) {
4149 <    cout << "Error: DeadEcalFile has not been found." << endl;
4149 >    clog << "Error: DeadEcalFile has not been found." << endl;
4150      return;
4151    }
4152    if(DeadEcalVec.size()!= 0){
4153 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4153 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4154      return;
4155    }
4156    while(!DeadEcalFile.eof())
# Line 3606 | Line 4161 | OSUAnalysis::WriteDeadEcal (){
4161        newChan.phiEcal = phiEcal;
4162        DeadEcalVec.push_back(newChan);
4163      }
4164 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4164 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4165   }
4166  
4167   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3646 | Line 4201 | OSUAnalysis::applyFunction(string functi
4201    else if(function == "log") value = log10(value);
4202  
4203    else if(function == "") value = value;
4204 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4204 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4205  
4206    return value;
4207  
# Line 3660 | Line 4215 | void OSUAnalysis::setObjectFlags(cut &cu
4215      string obj1, obj2;
4216      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4217      if (inputType==obj1 ||
4218 <        inputType==obj2) {
4218 >        inputType==obj2) {
4219        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4220        // and the inputType is a member of the pair.
4221        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3672 | Line 4227 | void OSUAnalysis::setObjectFlags(cut &cu
4227  
4228    for (uint object = 0; object != inputCollection->size(); object++){
4229  
4230 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4230 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4231 >    bool plotDecision = true;
4232  
4233      if(currentCut.inputCollection == inputType){
4234  
# Line 3684 | Line 4240 | void OSUAnalysis::setObjectFlags(cut &cu
4240          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4241  
4242        }
4243 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4243 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4244        else{
4245          bool tempDecision = true;
4246          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3693 | Line 4249 | void OSUAnalysis::setObjectFlags(cut &cu
4249            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4250              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4251          }
4252 <        decision = tempDecision;
4252 >        cutDecision = tempDecision;
4253        }
4254 +      //invert the cut for plotting if this cut is a veto
4255 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4256 +      else plotDecision = cutDecision;
4257      }
4258  
4259 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4259 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4260  
4261 <    //set flags for objects that pass each cut AND all the previous cuts
4262 <    bool previousCumulativeFlag = true;
4261 >    //set flags for objects that pass this cut AND all the previous cuts
4262 >    bool previousCumulativeCutFlag = true;
4263 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4264 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4265 >      else{ previousCumulativeCutFlag = false; break;}
4266 >    }
4267 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4268 >    bool previousCumulativePlotFlag = true;
4269      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4270 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4271 <      else{ previousCumulativeFlag = false; break;}
4270 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4271 >      else{ previousCumulativePlotFlag = false; break;}
4272      }
4273 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4273 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4274 >
4275 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4276  
4277    }
4278  
# Line 3714 | Line 4281 | void OSUAnalysis::setObjectFlags(cut &cu
4281  
4282   template <class InputCollection1, class InputCollection2>
4283   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4284 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4284 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4285  
4286  
4287    bool sameObjects = false;
# Line 3730 | Line 4297 | void OSUAnalysis::setObjectFlags(cut &cu
4297    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4298    if (currentCut.inputCollection == inputType) {
4299      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4300 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4301 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4300 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4301 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4302      }
4303      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4304        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4305 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4306 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4305 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4306 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4307        }
4308      }
4309    }
# Line 3749 | Line 4316 | void OSUAnalysis::setObjectFlags(cut &cu
4316        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4317  
4318  
4319 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4319 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4320 >      bool plotDecision = true;
4321  
4322        if(currentCut.inputCollection == inputType){
4323  
# Line 3761 | Line 4329 | void OSUAnalysis::setObjectFlags(cut &cu
4329            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4330          }
4331  
4332 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4332 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4333          else{
4334            bool tempDecision = subcutDecisions.at(0);
4335            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3770 | Line 4338 | void OSUAnalysis::setObjectFlags(cut &cu
4338              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4339                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4340            }
4341 <          decision = tempDecision;
4341 >          cutDecision = tempDecision;
4342          }
4343 +        //invert the cut for plotting if this cut is a veto
4344 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4345 +        else plotDecision = cutDecision;
4346 +      }
4347 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4348 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4349 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4350 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4351 +      }
4352 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4353 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4354 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4355        }
4356 <      // if (decision) isPassObj1.at(object1) = true;
4357 <      // if (decision) isPassObj2.at(object2) = true;
4358 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4359 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4360 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4361 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4356 >
4357 >      //set flags for objects that pass this cut AND all the previous cuts
4358 >      bool previousCumulativeCutFlag = true;
4359 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4360 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4361 >        else{ previousCumulativeCutFlag = false; break;}
4362        }
4363 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4364  
4365 <      //set flags for objects that pass each cut AND all the previous cuts
3785 <      bool previousCumulativeFlag = true;
4365 >      bool previousCumulativePlotFlag = true;
4366        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4367 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4368 <        else{ previousCumulativeFlag = false; break;}
4367 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4368 >        else{ previousCumulativePlotFlag = false; break;}
4369        }
4370 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4371 +      
4372        //apply flags for the components of the composite object as well
4373 <      bool currentCumulativeFlag = true;
4374 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4375 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4376 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4377 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4378 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4379 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4380 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4381 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4373 >      bool currentCumulativeCutFlag = true;
4374 >      bool currentCumulativePlotFlag = true;
4375 >
4376 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4377 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4378 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4379 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4380 >
4381 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4382 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4383 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4384 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4385 >
4386 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4387 >
4388 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4389 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4390 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4391 >      }
4392 >
4393 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4394 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4395 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4396        }
4397 +
4398        counter++;
4399  
4400      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3806 | Line 4403 | void OSUAnalysis::setObjectFlags(cut &cu
4403   }
4404  
4405  
4406 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4406 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4407    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4408    // all cuts up to currentCutIndex
4409    bool previousCumulativeFlag = true;
4410    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4411 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4411 >    bool tempFlag = false;
4412 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4413 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4414 >
4415 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4416      else {
4417        previousCumulativeFlag = false; break;
4418      }
# Line 3821 | Line 4422 | bool OSUAnalysis::getPreviousCumulativeF
4422  
4423  
4424  
4425 +
4426   template <class InputCollection>
4427 < void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, vector<bool> flags){
4428 <  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree  
4427 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4428 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4429  
4430 <  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;  
4431 <  for (uint object = 0; object != inputCollection->size(); object++) {  
4430 >  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;
4431 >  for (uint object = 0; object != inputCollection->size(); object++) {
4432  
4433 <    if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;  
4433 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4434  
4435 <    string inputVariable = parameters.inputVariable;
4435 >    string inputVariable = parameters.inputVariable;
4436      string function = "";
4437 <    string stringValue = "";  
4438 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
4439 <    BNTreeBranchVals_.at(parameters.name).push_back(value);  
4437 >    string stringValue = "";
4438 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4439 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4440  
4441    }
4442   }
4443  
4444  
4445   template <class InputCollection>
4446 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4446 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4447 >
4448  
4449    for (uint object = 0; object != inputCollection->size(); object++){
4450  
4451 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4451 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4452  
4453      string currentString = parameters.inputVariables.at(0);
4454      string inputVariable = "";
# Line 3857 | Line 4460 | void OSUAnalysis::fill1DHistogram(TH1* h
4460        function = currentString.substr(0,currentString.find("("));//function comes before the "("
4461        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4462        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4463 <    }  
4463 >    }
4464  
4465 <    string stringValue = "";  
4466 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
4467 <    histo->Fill(value,scaleFactor);  
4465 >    string stringValue = "";
4466 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4467 >    histo->Fill(value,scaleFactor);
4468  
4469      if (printEventInfo_) {
4470        // Write information about event to screen, for testing purposes.
4471 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4471 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4472      }
4473  
4474    }
4475   }
4476  
4477   template <class InputCollection1, class InputCollection2>
4478 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4478 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4479  
4480    bool sameObjects = false;
4481    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3885 | Line 4488 | void OSUAnalysis::fill1DHistogram(TH1* h
4488  
4489        pairCounter++;
4490        //only take objects which have passed all cuts and pairs which have passed all cuts
4491 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4492 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4493 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4491 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4492 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4493 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4494  
4495        string currentString = parameters.inputVariables.at(0);
4496        string inputVariable = "";
# Line 3912 | Line 4515 | void OSUAnalysis::fill1DHistogram(TH1* h
4515  
4516  
4517   template <class InputCollection>
4518 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4518 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4519  
4520    for (uint object = 0; object != inputCollection->size(); object++){
4521  
4522 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4522 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4523  
4524      string stringValue = "";
4525      string currentString = parameters.inputVariables.at(0);
# Line 3953 | Line 4556 | void OSUAnalysis::fill2DHistogram(TH2* h
4556   }
4557  
4558   template <class InputCollection1, class InputCollection2>
4559 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4559 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4560  
4561    bool sameObjects = false;
4562    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3967 | Line 4570 | void OSUAnalysis::fill2DHistogram(TH2* h
4570        pairCounter++;
4571  
4572        //only take objects which have passed all cuts and pairs which have passed all cuts
4573 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4574 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4575 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4573 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4574 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4575 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4576  
4577        string stringValue = "";
4578        string currentString = parameters.inputVariables.at(0);
# Line 4017 | Line 4620 | int OSUAnalysis::getGenMatchedParticleIn
4620  
4621      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4622      if(currentDeltaR > 0.05) continue;
4623 <    //     cout << setprecision(3) << setw(20)
4623 >    //     clog << setprecision(3) << setw(20)
4624      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4625      //          << setw(20)
4626      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 4036 | Line 4639 | int OSUAnalysis::getGenMatchedParticleIn
4639      }
4640  
4641    }
4642 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4643 <  //   else cout << "no match found..." << endl;
4642 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4643 >  //   else clog << "no match found..." << endl;
4644    return bestMatchIndex;
4645  
4646   }
# Line 4129 | Line 4732 | OSUAnalysis::chosenVertex ()
4732   {
4733    const BNprimaryvertex *chosenVertex = 0;
4734    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4735 <    vector<bool> vertexFlags;
4735 >    flagPair vertexFlags;
4736      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4737        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4738          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4137 | Line 4740 | OSUAnalysis::chosenVertex ()
4740        }
4741      }
4742      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4743 <      if(!vertexFlags.at(vertexIndex)) continue;
4743 >      if(!vertexFlags.at(vertexIndex).first) continue;
4744        chosenVertex = & primaryvertexs->at(vertexIndex);
4745        break;
4746      }
# Line 4153 | Line 4756 | OSUAnalysis::chosenMET ()
4756   {
4757    const BNmet *chosenMET = 0;
4758    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4759 <    vector<bool> metFlags;
4759 >    flagPair metFlags;
4760      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4761        if (cumulativeFlags.at("mets").at(i).size()){
4762          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4161 | Line 4764 | OSUAnalysis::chosenMET ()
4764        }
4765      }
4766      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4767 <      if(!metFlags.at(metIndex)) continue;
4767 >      if(!metFlags.at(metIndex).first) continue;
4768        chosenMET = & mets->at(metIndex);
4769        break;
4770      }
# Line 4177 | Line 4780 | OSUAnalysis::chosenElectron ()
4780   {
4781    const BNelectron *chosenElectron = 0;
4782    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4783 <    vector<bool> electronFlags;
4783 >    flagPair electronFlags;
4784      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4785        if (cumulativeFlags.at("electrons").at(i).size()){
4786          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4185 | Line 4788 | OSUAnalysis::chosenElectron ()
4788        }
4789      }
4790      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4791 <      if(!electronFlags.at(electronIndex)) continue;
4791 >      if(!electronFlags.at(electronIndex).first) continue;
4792        chosenElectron = & electrons->at(electronIndex);
4793        break;
4794      }
# Line 4196 | Line 4799 | OSUAnalysis::chosenElectron ()
4799    return chosenElectron;
4800   }
4801  
4802 +
4803   const BNmuon *
4804   OSUAnalysis::chosenMuon ()
4805   {
4806    const BNmuon *chosenMuon = 0;
4807    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4808 <    vector<bool> muonFlags;
4808 >    flagPair muonFlags;
4809      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4810        if (cumulativeFlags.at("muons").at(i).size()){
4811          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4209 | Line 4813 | OSUAnalysis::chosenMuon ()
4813        }
4814      }
4815      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4816 <      if(!muonFlags.at(muonIndex)) continue;
4816 >      if(!muonFlags.at(muonIndex).first) continue;
4817        chosenMuon = & muons->at(muonIndex);
4818        break;
4819      }
# Line 4220 | Line 4824 | OSUAnalysis::chosenMuon ()
4824    return chosenMuon;
4825   }
4826  
4827 + double
4828 + OSUAnalysis::chosenHT ()
4829 + {
4830 +  double chosenHT = 0.0;
4831 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
4832 +    flagPair jetFlags;
4833 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
4834 +      if (cumulativeFlags.at("jets").at(i).size()){
4835 +        jetFlags = cumulativeFlags.at("jets").at(i);
4836 +        break;
4837 +      }
4838 +    }
4839 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
4840 +      if(!jetFlags.at(jetIndex).first) continue;
4841 +      chosenHT += jets->at(jetIndex).pt;
4842 +    }
4843 +  }
4844 +
4845 +  return chosenHT;
4846 + }
4847 +
4848 + pair<const BNmuon *, const BNmuon *>
4849 + OSUAnalysis::leadMuonPair ()
4850 + {
4851 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
4852 +  leadMuonPair.first = leadMuonPair.second = 0;
4853 +
4854 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4855 +    flagPair muonFlags;
4856 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4857 +      if (cumulativeFlags.at("muons").at(i).size()){
4858 +        muonFlags = cumulativeFlags.at("muons").at(i);
4859 +        break;
4860 +      }
4861 +    }
4862 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
4863 +      if(!muonFlags.at(muonIndex0).first) continue;
4864 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
4865 +        if(!muonFlags.at(muonIndex1).first) continue;
4866 +        const BNmuon *mu0 = & muons->at(muonIndex0);
4867 +        const BNmuon *mu1 = & muons->at(muonIndex1);
4868 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
4869 +          leadMuonPair.first = mu0;
4870 +          leadMuonPair.second = mu1;
4871 +        }
4872 +        else{
4873 +          TVector2 newPt0 (mu0->px, mu0->py),
4874 +                   newPt1 (mu1->px, mu1->py),
4875 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
4876 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
4877 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4878 +            {
4879 +              leadMuonPair.first = mu0;
4880 +              leadMuonPair.second = mu1;
4881 +            }
4882 +        }
4883 +      }
4884 +    }
4885 +  }
4886 +
4887 +  return leadMuonPair;
4888 + }
4889 +
4890 + pair<const BNelectron *, const BNelectron *>
4891 + OSUAnalysis::leadElectronPair ()
4892 + {
4893 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
4894 +  leadElectronPair.first = leadElectronPair.second = 0;
4895 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4896 +    flagPair electronFlags;
4897 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4898 +      if (cumulativeFlags.at("electrons").at(i).size()){
4899 +        electronFlags = cumulativeFlags.at("electrons").at(i);
4900 +        break;
4901 +      }
4902 +    }
4903 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
4904 +      if(!electronFlags.at(electronIndex0).first) continue;
4905 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
4906 +        if(!electronFlags.at(electronIndex1).first) continue;
4907 +        const BNelectron *el0 = & electrons->at(electronIndex0);
4908 +        const BNelectron *el1 = & electrons->at(electronIndex1);
4909 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
4910 +          leadElectronPair.first = el0;
4911 +          leadElectronPair.second = el1;
4912 +        }
4913 +        else{
4914 +          TVector2 newPt0 (el0->px, el0->py),
4915 +                   newPt1 (el1->px, el1->py),
4916 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
4917 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
4918 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4919 +            {
4920 +              leadElectronPair.first = el0;
4921 +              leadElectronPair.second = el1;
4922 +            }
4923 +        }
4924 +      }
4925 +    }
4926 +  }
4927 +
4928 +  return leadElectronPair;
4929 + }
4930 +
4931   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines