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.78 by wulsin, Fri May 31 14:07:11 2013 UTC vs.
Revision 1.105 by wulsin, Mon Jul 22 16:33:25 2013 UTC

# Line 1 | Line 1
1   #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2
2   OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
3    // Retrieve parameters from the configuration file.
4    jets_ (cfg.getParameter<edm::InputTag> ("jets")),
# Line 28 | Line 27 | OSUAnalysis::OSUAnalysis (const edm::Par
27    datasetType_ (cfg.getParameter<string> ("datasetType")),
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
31    treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
32    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
33    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
34    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
36 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
37 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
38 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
39    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
40    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
41    GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
42 < {
42 > {
43  
44    TH1::SetDefaultSumw2 ();
45  
# Line 47 | Line 50 | OSUAnalysis::OSUAnalysis (const edm::Par
50        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
51        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
52      }
53 +    if (applyBtagSF_){
54 +      bTagSFWeight_ = new BtagSFWeight;
55 +    }
56    }
57    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
58      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 59 | 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 69 | 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 95 | 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 112 | 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 150 | 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 162 | 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 177 | 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 259 | 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 270 | 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 288 | 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 297 | 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 309 | 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 335 | 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 343 | 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 359 | 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 374 | 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 393 | 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.
402      
403      TTree* newTree = directories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));  
404      BNTrees_.push_back(newTree);      
405      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
406        BranchSpecs currentVar = treeBranches_.at(iBranch);
407        vector<float> newVec;  
408        BNTreeBranchVals_[currentVar.name] = newVec;  
409        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
410      } // 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 <
451 <
452 <        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
453 <
454 <        // bin      particle type
455 <        // ---      -------------
456 <        //  0        unmatched
457 <        //  1        u
458 <        //  2        d
459 <        //  3        s
460 <        //  4        c
461 <        //  5        b
462 <        //  6        t
463 <        //  7        e
464 <        //  8        mu
465 <        //  9        tau
466 <        // 10        nu
467 <        // 11        g
468 <        // 12        gamma
469 <        // 13        Z
470 <        // 14        W
471 <        // 15        light meson
472 <        // 16        K meson
473 <        // 17        D meson
474 <        // 18        B meson
475 <        // 19        light baryon
476 <        // 20        strange baryon
477 <        // 21        charm baryon
478 <        // 22        bottom baryon
479 <        // 23        QCD string
480 <        // 24        other
481 <
482 <        vector<TString> labelArray;
483 <        labelArray.push_back("unmatched");
484 <        labelArray.push_back("u");
485 <        labelArray.push_back("d");
486 <        labelArray.push_back("s");
487 <        labelArray.push_back("c");
488 <        labelArray.push_back("b");
489 <        labelArray.push_back("t");
490 <        labelArray.push_back("e");
491 <        labelArray.push_back("#mu");
492 <        labelArray.push_back("#tau");
493 <        labelArray.push_back("#nu");
494 <        labelArray.push_back("g");
495 <        labelArray.push_back("#gamma");
496 <        labelArray.push_back("Z");
497 <        labelArray.push_back("W");
498 <        labelArray.push_back("light meson");
499 <        labelArray.push_back("K meson");
500 <        labelArray.push_back("D meson");
501 <        labelArray.push_back("B meson");
502 <        labelArray.push_back("light baryon");
503 <        labelArray.push_back("strange baryon");
504 <        labelArray.push_back("charm baryon");
505 <        labelArray.push_back("bottom baryon");
506 <        labelArray.push_back("QCD string");
507 <        labelArray.push_back("other");
508 <
509 <        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
510 <          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
511 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
512 <          }
513 <          else {
514 <            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
515 <            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
516 <          }
517 <        }
518 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
519 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
520 <          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
521 <        }
457 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
458 >        int numBinsElements = currentHistogram.bins.size();
459 >        int numInputVariables = currentHistogram.inputVariables.size();
460 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
461 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
462 >
463 >        if(numBinsElements == 1){
464 >          if(numBinEdgesX > 1){
465 >            if(numBinEdgesY > 1)
466 >              numBinsElements = 6;
467 >            else
468 >              numBinsElements = 3;
469 >          }
470 >        }
471 >        if(numBinsElements != 3 && numBinsElements !=6){
472 >          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
473 >          exit(0);
474 >        }
475 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
476 >          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
477 >          exit(0);
478 >        }
479 >        else if(numBinsElements == 3){
480 >          if (currentHistogram.bins.size () == 3)
481 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
482 >          else
483 >            {
484 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
485 >            }
486 >        }
487 >        else if(numBinsElements == 6){
488 >          if (currentHistogram.bins.size () == 6)
489 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
490 >          else
491 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
492 >        }
493 >
494  
495 <      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
495 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
496 >
497 >        // bin      particle type
498 >        // ---      -------------
499 >        //  0        unmatched
500 >        //  1        u
501 >        //  2        d
502 >        //  3        s
503 >        //  4        c
504 >        //  5        b
505 >        //  6        t
506 >        //  7        e
507 >        //  8        mu
508 >        //  9        tau
509 >        // 10        nu
510 >        // 11        g
511 >        // 12        gamma
512 >        // 13        Z
513 >        // 14        W
514 >        // 15        light meson
515 >        // 16        K meson
516 >        // 17        D meson
517 >        // 18        B meson
518 >        // 19        light baryon
519 >        // 20        strange baryon
520 >        // 21        charm baryon
521 >        // 22        bottom baryon
522 >        // 23        QCD string
523 >        // 24        other
524 >
525 >        vector<TString> labelArray;
526 >        labelArray.push_back("unmatched");
527 >        labelArray.push_back("u");
528 >        labelArray.push_back("d");
529 >        labelArray.push_back("s");
530 >        labelArray.push_back("c");
531 >        labelArray.push_back("b");
532 >        labelArray.push_back("t");
533 >        labelArray.push_back("e");
534 >        labelArray.push_back("#mu");
535 >        labelArray.push_back("#tau");
536 >        labelArray.push_back("#nu");
537 >        labelArray.push_back("g");
538 >        labelArray.push_back("#gamma");
539 >        labelArray.push_back("Z");
540 >        labelArray.push_back("W");
541 >        labelArray.push_back("light meson");
542 >        labelArray.push_back("K meson");
543 >        labelArray.push_back("D meson");
544 >        labelArray.push_back("B meson");
545 >        labelArray.push_back("light baryon");
546 >        labelArray.push_back("strange baryon");
547 >        labelArray.push_back("charm baryon");
548 >        labelArray.push_back("bottom baryon");
549 >        labelArray.push_back("QCD string");
550 >        labelArray.push_back("other");
551 >
552 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
553 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
554 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
555 >          }
556 >          else {
557 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
558 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
559 >          }
560 >        }
561 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
562 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
563 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
564 >        }
565 >
566 >      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
567  
568  
569        // Book a histogram for the number of each object type to be plotted.
570        // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
571        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
572 <        string currentObject = objectsToPlot.at(currentObjectIndex);
573 <        int maxNum = 10;
574 <        if(currentObject == "mcparticles") maxNum = 50;
575 <        else if(currentObject == "primaryvertexs") maxNum = 50;
576 <
577 <        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
578 <        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
579 <        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
580 <        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
581 <        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
582 <        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
583 <        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
584 <        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
585 <        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
586 <        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
587 <        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
588 <        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
589 <        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
590 <        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
591 <        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
592 <        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
593 <        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
594 <        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
595 <        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
596 <
597 <        currentObject.at(0) = toupper(currentObject.at(0));
598 <        string histoName = "num" + currentObject;
599 <
600 <        if(histoName == "numPrimaryvertexs"){
601 <          string newHistoName = histoName + "BeforePileupCorrection";
602 <          oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
603 <          newHistoName = histoName + "AfterPileupCorrection";
604 <          oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
605 <        }
606 <        else
607 <          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
572 >        string currentObject = objectsToPlot.at(currentObjectIndex);
573 >        int maxNum = 10;
574 >        if(currentObject == "mcparticles") maxNum = 50;
575 >        else if(currentObject == "primaryvertexs") maxNum = 50;
576 >
577 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
578 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
579 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
580 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
581 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
582 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
583 >        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
584 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
585 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
586 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
587 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
588 >        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
589 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
590 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
591 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
592 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
593 >        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
594 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
595 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
596 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
597 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
598 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
599 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
600 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
601 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
602 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
603 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
604 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
605 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
606 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
607 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
608 >
609 >        currentObject.at(0) = toupper(currentObject.at(0));
610 >        string histoName = "num" + currentObject;
611 >
612 >        if(histoName == "numPrimaryvertexs"){
613 >          string newHistoName = histoName + "BeforePileupCorrection";
614 >          oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
615 >          newHistoName = histoName + "AfterPileupCorrection";
616 >          oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
617 >        }
618 >        else
619 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
620        }
621      }//end of loop over directories
622      channels.push_back(tempChannel);
# Line 575 | Line 630 | OSUAnalysis::OSUAnalysis (const edm::Par
630    //make unique vector of objects we need to cut on
631    sort( objectsToCut.begin(), objectsToCut.end() );
632    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
633 +  //make unique vector of objects we need to set flags for
634 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
635 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
636  
637 +  produces<map<string, bool> > ("channelDecisions");
638 +
639 +  if (printEventInfo_) {
640 +    findEventsLog = new ofstream();  
641 +    findEventsLog->open("findEvents.txt");  
642 +    clog << "Listing run:lumi:event in file findEvents.txt for events that pass full selection (of any channel)." << endl;  
643 +  }
644 +
645 +  isFirstEvent_ = true;  
646 +
647 + } // end constructor OSUAnalysis::OSUAnalysis()
648  
580 }
649  
650   OSUAnalysis::~OSUAnalysis ()
651   {
652 +
653    // Destroying the CutFlow objects causes the cut flow numbers and time
654    // information to be printed to standard output.
655    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
656      delete cutFlows_.at(currentChannel);
657    }
658 +
659 +  if (printEventInfo_ && findEventsLog) findEventsLog->close();  
660 +
661 +  clog << "=============================================" << endl;  
662 +  clog << "Successfully completed OSUAnalysis." << endl;  
663 +  clog << "=============================================" << endl;  
664 +
665   }
666  
667   void
668 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
668 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
669   {
594
670    // Retrieve necessary collections from the event.
671  
672    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 657 | Line 732 | OSUAnalysis::analyze (const edm::Event &
732    //get pile-up event weight
733    if (doPileupReweighting_ && datasetType_ != "data") {
734      //for "data" datasets, the numTruePV is always set to -1
735 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
736 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
735 >    if (events->at(0).numTruePV < 0 && isFirstEvent_) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
736 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
737    }
738  
739    stopCTauScaleFactor_ = 1.0;
# Line 668 | Line 743 | OSUAnalysis::analyze (const edm::Event &
743  
744    //loop over all channels
745  
746 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
747    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
748      channel currentChannel = channels.at(currentChannelIndex);
749  
# Line 675 | Line 751 | OSUAnalysis::analyze (const edm::Event &
751      counterMap passingCounter;
752      cumulativeFlags.clear ();
753  
754 <    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
755 <         iter != BNTreeBranchVals_.end(); iter++) {
754 >    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
755 >         iter != BNTreeBranchVals_.end(); iter++) {
756        iter->second.clear();  // clear array
757      }
758  
# Line 689 | Line 765 | OSUAnalysis::analyze (const edm::Event &
765      //loop over all cuts
766      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
767        cut currentCut = currentChannel.cuts.at(currentCutIndex);
768 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
769 <        string currentObject = objectsToCut.at(currentObjectIndex);
768 >
769 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
770 >        string currentObject = objectsToFlag.at(currentObjectIndex);
771  
772          //initialize maps to get ready to set cuts
773 <        individualFlags[currentObject].push_back (vector<bool> ());
774 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
773 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
774 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
775  
776        }
777 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
778 <        string currentObject = objectsToCut.at(currentObjectIndex);
777 >
778 >      //set flags for all relevant objects
779 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
780 >        string currentObject = objectsToFlag.at(currentObjectIndex);
781  
782          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
783  
784  
785          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
786          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
787 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
788          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
789          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
790          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 729 | Line 809 | OSUAnalysis::analyze (const edm::Event &
809                                                                     "muon-muon pairs");
810  
811          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
812 <                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
813 <                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
814 <                                                                             "muon-secondary muon pairs");
812 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
813 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
814 >                                                                             "muon-secondary muon pairs");
815 >
816 >        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
817 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
818 >                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
819 >                                                                             "muon-secondary photon pairs");
820 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
821 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
822 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
823 >                                                                             "muon-secondary jet pairs");
824 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
825 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
826 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
827 >                                                                             "photon-secondary jet pairs");
828 >
829 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
830 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
831 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
832 >                                                                             "electron-secondary jet pairs");
833  
834          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
835 <                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
836 <                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
837 <                                                                                     "electron-secondary electron pairs");
835 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
836 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
837 >                                                                                     "electron-secondary electron pairs");
838  
839          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
840                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 747 | Line 845 | OSUAnalysis::analyze (const edm::Event &
845                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
846                                                                         "electron-muon pairs");
847          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
848 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
849 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
850 <                                                                 "jet-jet pairs");
848 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
849 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
850 >                                                                 "jet-jet pairs");
851 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
852 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
853 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
854 >                                                                 "jet-secondary jet pairs");
855          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
856 <                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
857 <                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
858 <                                                                      "electron-jet pairs");
856 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
857 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
858 >                                                                      "electron-jet pairs");
859 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
860 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
861 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
862 >                                                                      "electron-photon pairs");
863 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
864 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
865 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
866 >                                                                      "photon-jet pairs");
867          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
868 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
869 <                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
870 <                                                                  "muon-jet pairs");
868 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
869 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
870 >                                                                  "muon-jet pairs");
871 >        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
872 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
873 >                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
874 >                                                                  "muon-event pairs");
875 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
876 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
877 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
878 >                                                                  "met-jet pairs");
879 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
880 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
881 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
882 >                                                                 "track-jet pairs");
883 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
884 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
885 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
886 >                                                                  "muon-photon pairs");
887          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
888                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
889                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 779 | Line 905 | OSUAnalysis::analyze (const edm::Event &
905                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
906                                                                   "tau-tau pairs");
907          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
908 <                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
909 <                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
910 <                                                                   "tau-track pairs");
908 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
909 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
910 >                                                                   "tau-track pairs");
911          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
912                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
913                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 799 | Line 925 | OSUAnalysis::analyze (const edm::Event &
925      }//end loop over all cuts
926      //use cumulative flags to apply cuts at event level
927  
802    bool eventPassedAllCuts = true;
928      //a vector to store cumulative cut descisions after each cut.
929      vector<bool> eventPassedPreviousCuts;
930 +    bool eventPassedAllCuts = true;
931      //apply trigger (true if none were specified)
932      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
933  
# Line 812 | Line 938 | OSUAnalysis::analyze (const edm::Event &
938        int numberPassing = 0;
939  
940        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
941 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
941 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
942        }
943        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
944        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
945        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
946        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
947      }
948 +    //applying all appropriate scale factors
949      double scaleFactor = masterScaleFactor;
950 +    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
951  
824    muonScaleFactor_ = electronScaleFactor_ = 1.0;
952      if(applyLeptonSF_ && datasetType_ != "data"){
953 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
954 <        vector<bool> muonFlags;
953 >      //only apply SFs if we've cut on this object
954 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
955 >        flagPair muonFlags;
956 >        //get the last valid flags in the flag map
957          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
958            if (cumulativeFlags.at("muons").at(i).size()){
959              muonFlags = cumulativeFlags.at("muons").at(i);
960              break;
961            }
962          }
963 +        //apply the weight for each of those objects
964          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
965 <          if(!muonFlags.at(muonIndex)) continue;
965 >          if(!muonFlags.at(muonIndex).second) continue;
966            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
967          }
968        }
969 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
970 <        vector<bool> electronFlags;
969 >      //only apply SFs if we've cut on this object
970 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
971 >        flagPair electronFlags;
972 >        //get the last valid flags in the flag map
973          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
974            if (cumulativeFlags.at("electrons").at(i).size()){
975              electronFlags = cumulativeFlags.at("electrons").at(i);
976              break;
977            }
978          }
979 +        //apply the weight for each of those objects
980          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
981 <          if(!electronFlags.at(electronIndex)) continue;
981 >          if(!electronFlags.at(electronIndex).second) continue;
982            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
983          }
984        }
985      }
986 +    if(applyBtagSF_ && datasetType_ != "data"){
987 +      //only apply SFs if we've cut on this object
988 +      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
989 +        flagPair jetFlags;
990 +        vector<double> jetSFs;
991 +        //get the last valid flags in the flag map
992 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
993 +          if (cumulativeFlags.at("jets").at(i).size()){
994 +            jetFlags = cumulativeFlags.at("jets").at(i);
995 +            break;
996 +          }
997 +        }
998 +        //apply the weight for each of those objects
999 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
1000 +          if(!jetFlags.at(jetIndex).second) continue;
1001 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
1002 +          jetSFs.push_back(jetSFTmp);
1003 +        }
1004 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
1005 +      }
1006 +    }
1007      scaleFactor *= muonScaleFactor_;
1008      scaleFactor *= electronScaleFactor_;
1009 <
1009 >    scaleFactor *= bTagScaleFactor_;
1010      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1011  
1012 <    if (printEventInfo_) {
1012 >    if (printEventInfo_ && eventPassedAllCuts) {
1013        // Write information about event to screen, for testing purposes.
1014 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1015 <           << ": run="  << events->at(0).run
1016 <           << "  lumi=" << events->at(0).lumi
1017 <           << "  event=" << events->at(0).evt
1014 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1015 >           << ":  run:lumi:evt=  "  << events->at(0).run
1016 >           << ":" << events->at(0).lumi
1017 >           << ":" << events->at(0).evt
1018             << endl;
1019 +      if (findEventsLog) {
1020 +        (*findEventsLog) << events->at(0).run
1021 +                         << ":" << events->at(0).lumi
1022 +                         << ":" << events->at(0).evt << endl;
1023 +      }
1024 +
1025      }
1026  
1027  
1028      //filling histograms
1029      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
1030        uint currentDir;
1031 <      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
1031 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1032        else{
1033 <        currentDir = currentCut;
1033 >        currentDir = currentCut;
1034        }
1035 +
1036 +
1037        if(eventPassedPreviousCuts.at(currentDir)){
1038  
877        // Assign BNTree variables
878        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
879          BranchSpecs brSpecs = treeBranches_.at(iBranch);  
880          string coll = brSpecs.inputCollection;  
881          if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
882
883          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));            
884          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));
885          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));        
886          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));
887          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
888          else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
889          else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).at(currentDir));
890          else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).at(currentDir));
891          else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).at(currentDir));
892          else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).at(currentDir));
893          else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).at(currentDir));
894          else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).at(currentDir));
895          else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).at(currentDir));
896          else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).at(currentDir));
897          else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).at(currentDir));
898          else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).at(currentDir));
899          else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).at(currentDir));
900          else if(coll == "stops"
901                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).at(currentDir));
902        } // end loop over branches  
903                                                                                          
1039          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1040            histogram currentHistogram = histograms.at(histogramIndex);
1041  
1042 <          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1042 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1043 >
1044 >          if(currentHistogram.inputVariables.size() == 1){
1045 >            TH1D* histo;
1046 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1047 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1048 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1049 >            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1050 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1051 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1052 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1053 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1054 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1055 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1056 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1057 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1058 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1059 >             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1060 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1061 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1062 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1063 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1064 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1065 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1066 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1067 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1068 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1069 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1070 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1071 >
1072 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1073 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1074 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1075 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1076 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1077 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1078 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1079 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1080 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1081 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1082 >
1083 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1084 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1085 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1086 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1087 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1088 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1089 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1090 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1091 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1092 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1093 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1094 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1095 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1096 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1097 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1098 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1099 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1100 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1101 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1102 >                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1103 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1104 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1105 >                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1106 >                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1107 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1108 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1109 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1110 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1111 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1112 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1113 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1114 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1115 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1116 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1117 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1118 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1119 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1120 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1121 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1122 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1123 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1124 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1125 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1126 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1127 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1128 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1129 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1130 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1131 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1132 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1133 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1134 >
1135 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1136 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1137 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1138 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1139 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1140 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1141 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1142 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1143 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1144 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1145 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1146 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1147 >          }
1148 >          else if(currentHistogram.inputVariables.size() == 2){
1149 >            TH2D* histo;
1150 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1151 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1152 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1153 >            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1154 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1155 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1156 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1157 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1158 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1159 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1160 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1161 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1162 >            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1163 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1164 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1165 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1166 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1167 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1168 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1169 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1170 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1171 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1172 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1173 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1174 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1175 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1176 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1177 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1178 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1179 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1180 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1181 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1182 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1183 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1184 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1185 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1186 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1187 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1188 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1189 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1190 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1191 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1192 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1193 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1194 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1195 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1196 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1197 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1198 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1199 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1200 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1201 >                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1202 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1203 >            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1204 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1205 >                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1206 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1207 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1208 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1209 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1210 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1211 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1212 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1213 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1214 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1215 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1216 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1217 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1218 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1219 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1220 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1221 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1222 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1223 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1224 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1225 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1226 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1227 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1228 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1229 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1230 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1231 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1232 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1233 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1234 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1235 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1236 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1237 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1238 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1239 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1240 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1241 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1242 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1243 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1244 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1245 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1246 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1247 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1248 >          }
1249 >
1250 >        }
1251 >
1252 >
1253 >        //fills histograms with the sizes of collections
1254 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1255 >
1256 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1257 >          string objectToPlot = "";
1258 >
1259 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1260 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1261 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1262 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1263 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1264 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1265 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1266 >          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1267 >          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1268 >          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1269 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1270 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1271 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1272 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1273 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1274 >          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1275 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1276 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1277 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1278 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1279 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1280 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1281 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1282 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1283 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1284 >          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1285 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1286 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1287 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1288 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1289 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1290 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1291 >          else objectToPlot = currentObject;
1292 >
1293 >          string tempCurrentObject = objectToPlot;
1294 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1295 >          string histoName = "num" + tempCurrentObject;
1296 >
1297 >
1298 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1299 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1300 >            int numToPlot = 0;
1301 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1302 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1303 >            }
1304 >
1305 >            if(objectToPlot == "primaryvertexs"){
1306 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1307 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1308 >            }
1309 >            else {
1310 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1311 >            }
1312 >          }
1313 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1314 >
1315  
1316 <          if(currentHistogram.inputVariables.size() == 1){
1317 <            TH1D* histo;  
911 <            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
912 <            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
913 <            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
914 <            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
915 <            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
916 <            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
917 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
918 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
919 <                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
920 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
921 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
922 <                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
923 <            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
924 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
925 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
926 <                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
927 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
928 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
929 <                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
930 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
931 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
932 <                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
933 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
934 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
935 <                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
936 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
937 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
938 <                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
939 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
940 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
941 <                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
942 <            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
943 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
944 <                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
945 <            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
946 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
947 <                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
948 <            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
949 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
950 <                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
951 <            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
952 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
953 <                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
954 <            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
955 <                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
956 <                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
957 <            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
958 <                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
959 <                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
960 <            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
961 <                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
962 <                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
963 <
964 <            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
965 <            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
966 <            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
967 <            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
968 <            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
969 <            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
970 <            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
971 <            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
972 <            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
973 <            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
974 <            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
975 <            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
976 <          }
977 <          else if(currentHistogram.inputVariables.size() == 2){
978 <            TH2D* histo;
979 <            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
980 <            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
981 <            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
982 <            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
983 <            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
984 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
985 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
986 <                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
987 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
988 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
989 <                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
990 <            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
991 <            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
992 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
993 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
994 <                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
995 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
996 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
997 <                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
998 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
999 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1000 <                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1001 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1002 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1003 <                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1004 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1005 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1006 <                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1007 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1008 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1009 <                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1010 <            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1011 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1012 <                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1013 <            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1014 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1015 <                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1016 <            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1017 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1018 <                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1019 <            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1020 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1021 <                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1022 <            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1023 <                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1024 <                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1025 <            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1026 <                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1027 <                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1028 <            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1029 <                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1030 <                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1031 <            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1032 <            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1033 <            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1034 <            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1035 <            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1036 <                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1037 <                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1038 <            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1039 <            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1040 <            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1041 <            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1042 <            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1043 <            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1044 <            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1045 <            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1046 <          }
1047 <          
1048 <        }
1049 <
1050 <
1051 <        //fills histograms with the sizes of collections
1052 <        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1053 <
1054 <          string currentObject = objectsToPlot.at(currentObjectIndex);
1055 <          string objectToPlot = "";
1056 <
1057 <          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1058 <          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1059 <          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1060 <          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1061 <          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1062 <          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1063 <          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1064 <          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1065 <          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1066 <          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1067 <          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1068 <          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1069 <          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1070 <          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1071 <          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1072 <          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1073 <          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1074 <          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1075 <          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1076 <          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1077 <          else objectToPlot = currentObject;
1078 <
1079 <          string tempCurrentObject = objectToPlot;
1080 <          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1081 <          string histoName = "num" + tempCurrentObject;
1082 <
1083 <          //set position of primary vertex in event, in order to calculate quantities relative to it
1084 <          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1085 <            vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1086 <            int numToPlot = 0;
1087 <            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1088 <              if(lastCutFlags.at(currentFlag)) numToPlot++;
1089 <            }
1090 <            if(objectToPlot == "primaryvertexs"){
1091 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1092 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1093 <            }
1094 <            else {
1095 <              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1096 <            }
1097 <          }
1098 <        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1099 <      } // end if(eventPassedPreviousCuts.at(currentDir)){
1100 <    } // end loop over cuts
1316 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1317 >    } // end loop over cuts
1318  
1319 <    BNTrees_.at(currentChannelIndex)->Fill();  
1319 >    if (!useEDMFormat_ && eventPassedAllCuts){
1320 >      // Assign BNTree variables
1321 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1322 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1323 >        string coll = brSpecs.inputCollection;
1324 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1325 >
1326 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1327 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1328 >        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1329 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1330 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1331 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1332 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1333 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1334 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1335 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1336 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1337 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1338 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1339 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1340 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1341 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1342 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1343 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1344 >        else if(coll == "stops"
1345 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1346 >      } // end loop over branches
1347 >
1348 >      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1349 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1350 >    }
1351 >
1352 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1353  
1354    } // end loop over channel
1355  
1356    masterCutFlow_->fillCutFlow(masterScaleFactor);
1357  
1358 +  event.put (channelDecisions, "channelDecisions");
1359  
1360 < } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1360 >  isFirstEvent_ = false;  
1361 >
1362 > } // end void OSUAnalysis::produce (const edm::Event &event, const edm::EventSetup &setup)
1363  
1364  
1365  
# Line 1121 | Line 1374 | OSUAnalysis::evaluateComparison (double
1374    else if(comparison == "==") return testValue == cutValue;
1375    else if(comparison == "=") return testValue == cutValue;
1376    else if(comparison == "!=") return testValue != cutValue;
1377 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1377 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1378  
1379   }
1380  
# Line 1136 | Line 1389 | OSUAnalysis::evaluateComparison (string
1389    else if(comparison == "==") return testValue == cutValue;
1390    else if(comparison == "=") return testValue == cutValue;
1391    else if(comparison == "!=") return testValue != cutValue;
1392 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1392 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1393  
1394   }
1395  
# Line 1146 | Line 1399 | OSUAnalysis::evaluateTriggers (vector<st
1399    //initialize to false until a chosen trigger is passed
1400    bool triggerDecision = false;
1401  
1402 +  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1403    //loop over all triggers defined in the event
1404    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1405  
1406 +    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1407 +
1408      //we're only interested in triggers that actually passed
1409      if(trigger->pass != 1) continue;
1410  
# Line 1159 | Line 1415 | OSUAnalysis::evaluateTriggers (vector<st
1415      //if the event passes one of the chosen triggers, set triggerDecision to true
1416      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1417        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1418 <    }  
1418 >    }
1419    }
1420 <  //if none of the veto triggers fired:
1420 >
1421 >  printAllTriggers_ = false;  // only print triggers once, not every event
1422 >
1423 >  //if none of the veto triggers fired:
1424    //return the OR of all the chosen triggers
1425    if (triggersToTest.size() != 0) return triggerDecision;
1426    //or if no triggers were defined return true
# Line 1330 | Line 1589 | OSUAnalysis::valueLookup (const BNjet* o
1589    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1590    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1591  
1592 +  //user defined variable
1593 +  else if(variable == "disappTrkLeadingJetID") {
1594 +    value = object->pt > 110
1595 +      && fabs(object->eta) < 2.4
1596 +      && object->chargedHadronEnergyFraction > 0.2
1597 +      && object->neutralHadronEnergyFraction < 0.7
1598 +      && object->chargedEmEnergyFraction < 0.5
1599 +      && object->neutralEmEnergyFraction < 0.7;
1600 +  }
1601  
1602 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1602 >  else if(variable == "disappTrkSubLeadingJetID") {
1603 >    value = object->pt > 30
1604 >      && fabs(object->eta) < 4.5
1605 >      && object->neutralHadronEnergyFraction < 0.7
1606 >      && object->chargedEmEnergyFraction < 0.5;
1607 >  }
1608 >
1609 >  else if(variable == "dPhiMet") {
1610 >    if (const BNmet *met = chosenMET ()) {
1611 >      value = deltaPhi (object->phi, met->phi);
1612 >    } else value = -999;
1613 >  }
1614 >
1615 >
1616 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1617  
1618    value = applyFunction(function, value);
1619  
1620    return value;
1621 < }
1621 > } // end jet valueLookup
1622  
1623  
1624   //!muon valueLookup
# Line 1433 | Line 1715 | OSUAnalysis::valueLookup (const BNmuon*
1715    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1716    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1717    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1718 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1719 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1720 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1721 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1722    else if(variable == "rhoPrime") value = object->rhoPrime;
1723    else if(variable == "AEffDr03") value = object->AEffDr03;
1724    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1440 | Line 1726 | OSUAnalysis::valueLookup (const BNmuon*
1726    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1727    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1728    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1729 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1730 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1731 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1732 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1733 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1734    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1735    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1736    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1496 | Line 1787 | OSUAnalysis::valueLookup (const BNmuon*
1787    else if(variable == "time_ndof") value = object->time_ndof;
1788  
1789    //user-defined variables
1790 +  else if(variable == "looseID") {
1791 +    value = object->pt > 10 &&
1792 +      (object->isGlobalMuon  > 0 ||
1793 +       object->isTrackerMuon > 0);
1794 +  }
1795    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1796    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1797    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1798    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1799 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1800    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1801    else if(variable == "metMT") {
1802      if (const BNmet *met = chosenMET ())
# Line 1696 | Line 1993 | OSUAnalysis::valueLookup (const BNmuon*
1993  
1994  
1995  
1996 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1996 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1997  
1998    value = applyFunction(function, value);
1999  
2000    return value;
2001 < }
2001 > } // end muon valueLookup
2002 >
2003  
2004   //!electron valueLookup
2005   double
# Line 1870 | Line 2168 | OSUAnalysis::valueLookup (const BNelectr
2168    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2169    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2170    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2171 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2172 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2173    else if(variable == "metMT") {
2174      if (const BNmet *met = chosenMET ())
2175        {
# Line 1941 | Line 2241 | OSUAnalysis::valueLookup (const BNelectr
2241      else value = -999;
2242    }
2243  
2244 +  else if(variable == "looseID"){
2245 +    if (object->isEB)
2246 +      {
2247 +        value = fabs(object->delEtaIn) < 0.007 \
2248 +          && fabs (object->delPhiIn) < 0.15 \
2249 +          && object->scSigmaIEtaIEta < 0.01 \
2250 +          && object->hadOverEm < 0.12 \
2251 +          && fabs (object->correctedD0Vertex) < 0.02 \
2252 +          && fabs (object->correctedDZ) < 0.2 \
2253 +          && object->absInvEMinusInvPin < 0.05 \
2254 +          && object->passConvVeto;
2255 +      }
2256 +    else
2257 +      {
2258 +        value = fabs(object->delEtaIn) < 0.009 \
2259 +          && fabs (object->delPhiIn) < 0.10 \
2260 +          && object->scSigmaIEtaIEta < 0.03 \
2261 +          && object->hadOverEm < 0.10 \
2262 +          && fabs (object->correctedD0Vertex) < 0.02 \
2263 +          && fabs (object->correctedDZ) < 0.2 \
2264 +          && object->absInvEMinusInvPin < 0.05 \
2265 +          && object->passConvVeto;
2266 +      }
2267 +  }
2268 +
2269    else if(variable == "tightID"){
2270      if (object->isEB)
2271        {
# Line 1966 | Line 2291 | OSUAnalysis::valueLookup (const BNelectr
2291        }
2292    }
2293  
2294 +  else if(variable == "looseID_MVA"){
2295 +    value = object->pt > 10
2296 +      && object->mvaNonTrigV0 > 0;
2297 +      }
2298    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2299      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2300      else value = -999;
# Line 2096 | Line 2425 | OSUAnalysis::valueLookup (const BNelectr
2425  
2426  
2427  
2428 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2428 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2429  
2430    value = applyFunction(function, value);
2431  
2432    return value;
2433 < }
2433 > } // end electron valueLookup
2434 >
2435  
2436   //!event valueLookup
2437   double
# Line 2113 | Line 2443 | OSUAnalysis::valueLookup (const BNevent*
2443    else if(variable == "pthat") value = object->pthat;
2444    else if(variable == "qScale") value = object->qScale;
2445    else if(variable == "alphaQCD") value = object->alphaQCD;
2446 +  else if(variable == "Ht") value = getHt(jets.product());
2447    else if(variable == "alphaQED") value = object->alphaQED;
2448    else if(variable == "scalePDF") value = object->scalePDF;
2449    else if(variable == "x1") value = object->x1;
# Line 2182 | Line 2513 | OSUAnalysis::valueLookup (const BNevent*
2513    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2514    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2515    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2516 <
2517 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2516 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2517 >  else if(variable == "ht") value = chosenHT ();
2518 >  else if(variable == "leadMuPairInvMass"){
2519 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2520 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2521 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2522 >    value = (p0 + p1).M ();
2523 >  }
2524 >  else if(variable == "leadMuPairPt"){
2525 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2526 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2527 >             pt1 (muPair.second->px, muPair.second->py);
2528 >    pt0 += pt1;
2529 >    value = pt0.Mod ();
2530 >  }
2531 >  else if(variable == "leadElPairInvMass"){
2532 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2533 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2534 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2535 >    value = (p0 + p1).M ();
2536 >  }
2537 >  else if(variable == "leadElPairPt"){
2538 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2539 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2540 >             pt1 (muPair.second->px, muPair.second->py);
2541 >    pt0 += pt1;
2542 >    value = pt0.Mod ();
2543 >  }
2544 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2545  
2546    value = applyFunction(function, value);
2547  
2548    return value;
2549 < }
2549 > } // end event valueLookup
2550 >
2551  
2552   //!tau valueLookup
2553   double
# Line 2236 | Line 2595 | OSUAnalysis::valueLookup (const BNtau* o
2595    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2596    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2597  
2598 <
2598 >  else if (variable == "looseHadronicID") {
2599 >    value = object->pt > 10
2600 >      && object->eta < 2.3
2601 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2602 >      && object->HPSdecayModeFinding > 0
2603 >      && object->HPSagainstElectronLoose > 0
2604 >      && object->HPSagainstMuonTight > 0;
2605 >  }
2606  
2607    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2608  
# Line 2283 | Line 2649 | OSUAnalysis::valueLookup (const BNtau* o
2649    }
2650  
2651  
2652 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2652 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2653  
2654    value = applyFunction(function, value);
2655  
2656    return value;
2657 < }
2657 > } // end tau valueLookup
2658 >
2659  
2660   //!met valueLookup
2661   double
# Line 2356 | Line 2723 | OSUAnalysis::valueLookup (const BNmet* o
2723    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2724    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2725  
2726 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2726 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2727  
2728    value = applyFunction(function, value);
2729  
2730    return value;
2731 < }
2731 > } // end met valueLookup
2732 >
2733  
2734   //!track valueLookup
2735   double
# Line 2389 | Line 2757 | OSUAnalysis::valueLookup (const BNtrack*
2757    else if(variable == "numValidHits") value = object->numValidHits;
2758    else if(variable == "isHighPurity") value = object->isHighPurity;
2759  
2392
2760    //additional BNs info for disappTrks
2761 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2762 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2763 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2764 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2765 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2766 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2767 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2768 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2402 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2761 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2762 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2763 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2764 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2765 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2766 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2767 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2768 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2769    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2770 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2770 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2771 >  else if(variable == "trkRelIsoRp3")       value = (object->depTrkRp3 - object->pt) / object->pt;
2772 >  else if(variable == "trkRelIsoRp5")       value = (object->depTrkRp5 - object->pt) / object->pt;
2773 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2774 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2775 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2776 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2777 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2778 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2779 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2780 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2781 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2782 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2783 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2784 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2785 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2786 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2787 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2788 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2789 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2790  
2791    //user defined variables
2792    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;
2793    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2794 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2794 >  else if(variable == "depTrkRp5MinusPt"){
2795 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2796 > //       cout << "Warning:  found track with depTrkRp5 < pt:  depTrkRp5=" << object->depTrkRp5
2797 > //         << "; pt=" << object->pt
2798 > //         << "; object->depTrkRp5 - object->pt = " << object->depTrkRp5 - object->pt
2799 > //         << endl;  
2800 >           value = 0;
2801 >         }
2802 >         else value =  (object->depTrkRp5 - object->pt);
2803 >  }
2804 >  else if(variable == "depTrkRp3MinusPt"){
2805 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2806 >      value = 0;
2807 >    }
2808 >    else value =  (object->depTrkRp3 - object->pt);
2809 >  }
2810 >
2811 >  else if(variable == "dPhiMet") {
2812 >    if (const BNmet *met = chosenMET ()) {
2813 >      value = deltaPhi (object->phi, met->phi);
2814 >    } else value = -999;
2815 >  }
2816 >  
2817 >  
2818    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2819    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2820    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2434 | Line 2842 | OSUAnalysis::valueLookup (const BNtrack*
2842        pt = object->pt;
2843      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2844    }
2845 +
2846 +
2847    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2848  
2849    else if(variable == "genMatchedPdgId"){
# Line 2481 | Line 2891 | OSUAnalysis::valueLookup (const BNtrack*
2891  
2892  
2893  
2894 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2894 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2895  
2896    value = applyFunction(function, value);
2897  
2898    return value;
2899 < }
2899 > } // end track valueLookup
2900 >
2901  
2902   //!genjet valueLookup
2903   double
# Line 2510 | Line 2921 | OSUAnalysis::valueLookup (const BNgenjet
2921    else if(variable == "charge") value = object->charge;
2922  
2923  
2924 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2924 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2925  
2926    value = applyFunction(function, value);
2927  
# Line 2644 | Line 3055 | OSUAnalysis::valueLookup (const BNmcpart
3055    }
3056  
3057  
3058 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3058 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3059  
3060    value = applyFunction(function, value);
3061  
3062    return value;
3063 < }
3063 > } // end mcparticle valueLookup
3064 >
3065  
3066   //!primaryvertex valueLookup
3067   double
# Line 2672 | Line 3084 | OSUAnalysis::valueLookup (const BNprimar
3084    else if(variable == "isGood") value = object->isGood;
3085  
3086  
3087 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3087 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3088  
3089    value = applyFunction(function, value);
3090  
# Line 2690 | Line 3102 | OSUAnalysis::valueLookup (const BNbxlumi
3102    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3103  
3104  
3105 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3105 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3106  
3107    value = applyFunction(function, value);
3108  
# Line 2823 | Line 3235 | OSUAnalysis::valueLookup (const BNphoton
3235    }
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  
3242    return value;
3243 < }
3243 > } // end photon valueLookup
3244 >
3245  
3246   //!supercluster valueLookup
3247   double
# Line 2846 | Line 3259 | OSUAnalysis::valueLookup (const BNsuperc
3259    else if(variable == "theta") value = object->theta;
3260  
3261  
3262 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3262 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3263  
3264    value = applyFunction(function, value);
3265  
# Line 2880 | Line 3293 | OSUAnalysis::valueLookup (const BNtrigob
3293        stringValue = "none";  // stringValue should only be empty if value is filled
3294    }
3295  
3296 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3296 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3297  
3298    value = applyFunction(function, value);
3299  
# Line 2951 | Line 3364 | OSUAnalysis::valueLookup (const BNmuon*
3364        value = object2->correctedD0;
3365      }
3366  
3367 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3367 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3368 >
3369 >  value = applyFunction(function, value);
3370 >
3371 >  return value;
3372 > } // end muon-muon pair valueLookup
3373 >
3374 >
3375 > //!muon-photon pair valueLookup
3376 > double
3377 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3378 >
3379 >  double value = 0.0;
3380 >
3381 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3382 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3383 >  else if(variable == "photonEta") value = object2->eta;
3384 >  else if(variable == "photonPt") value = object2->pt;
3385 >  else if(variable == "muonEta") value = object1->eta;
3386 >  else if(variable == "photonPhi") value = object2->phi;
3387 >  else if(variable == "muonPhi") value = object1->phi;
3388 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3389 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3390 >  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3391 >  else if(variable == "invMass"){
3392 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3393 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3394 >    value = (fourVector1 + fourVector2).M();
3395 >  }
3396 >  else if(variable == "pt"){
3397 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3398 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3399 >    value = (fourVector1 + fourVector2).Pt();
3400 >  }
3401 >  else if(variable == "threeDAngle")
3402 >    {
3403 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3404 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3405 >      value = (threeVector1.Angle(threeVector2));
3406 >    }
3407 >  else if(variable == "alpha")
3408 >    {
3409 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3410 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3411 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3412 >      value = (pi-threeVector1.Angle(threeVector2));
3413 >    }
3414 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3415 >
3416 >  value = applyFunction(function, value);
3417 >
3418 >  return value;
3419 > }
3420 >
3421 > //!electron-photon pair valueLookup
3422 > double
3423 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3424 >
3425 >  double value = 0.0;
3426 >
3427 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3428 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3429 >  else if(variable == "photonEta") value = object2->eta;
3430 >  else if(variable == "photonPt") value = object2->pt;
3431 >  else if(variable == "electronEta") value = object1->eta;
3432 >  else if(variable == "photonPhi") value = object2->phi;
3433 >  else if(variable == "electronPhi") value = object1->phi;
3434 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3435 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3436 >  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3437 >  else if(variable == "invMass"){
3438 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3439 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3440 >    value = (fourVector1 + fourVector2).M();
3441 >  }
3442 >  else if(variable == "pt"){
3443 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3444 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3445 >    value = (fourVector1 + fourVector2).Pt();
3446 >  }
3447 >  else if(variable == "threeDAngle")
3448 >    {
3449 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3450 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3451 >      value = (threeVector1.Angle(threeVector2));
3452 >    }
3453 >  else if(variable == "alpha")
3454 >    {
3455 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3456 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3457 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3458 >      value = (pi-threeVector1.Angle(threeVector2));
3459 >    }
3460 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3461  
3462    value = applyFunction(function, value);
3463  
# Line 3007 | Line 3513 | OSUAnalysis::valueLookup (const BNelectr
3513      value = object2->correctedD0;
3514    }
3515  
3516 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3516 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3517  
3518    value = applyFunction(function, value);
3519  
3520    return value;
3521   }
3522 +
3523   //!electron-muon pair valueLookup
3524   double
3525   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3073 | Line 3580 | OSUAnalysis::valueLookup (const BNelectr
3580    else if(variable == "muonRelPFdBetaIso"){
3581      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3582    }
3583 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3583 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3584    value = applyFunction(function, value);
3585  
3586    return value;
3587 < }
3587 > } // end electron-muon pair valueLookup
3588 >
3589  
3590   //!electron-jet pair valueLookup
3591   double
# Line 3087 | Line 3595 | OSUAnalysis::valueLookup (const BNelectr
3595  
3596    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3597    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3598 +  else if(variable == "jetEta") value = object2->eta;
3599 +  else if(variable == "jetPhi") value = object2->phi;
3600 +  else if(variable == "electronEta") value = object1->eta;
3601 +  else if(variable == "electronPhi") value = object1->phi;
3602    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3603    else if(variable == "invMass"){
3604      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3108 | Line 3620 | OSUAnalysis::valueLookup (const BNelectr
3620      value = object1->charge*object2->charge;
3621    }
3622  
3623 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3623 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3624    value = applyFunction(function, value);
3625  
3626    return value;
3627   }
3628  
3629 + //!photon-jet pair valueLookup
3630 + double
3631 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3632 +
3633 +  double value = 0.0;
3634 +
3635 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3636 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3637 +  else if(variable == "jetEta") value = object2->eta;
3638 +  else if(variable == "jetPhi") value = object2->phi;
3639 +  else if(variable == "photonEta") value = object1->eta;
3640 +  else if(variable == "photonPhi") value = object1->phi;
3641 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3642 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3643 +  else if(variable == "invMass"){
3644 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3645 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3646 +    value = (fourVector1 + fourVector2).M();
3647 +  }
3648 +  else if(variable == "pt"){
3649 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3650 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3651 +    value = (fourVector1 + fourVector2).Pt();
3652 +  }
3653 +  else if(variable == "threeDAngle")
3654 +    {
3655 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3656 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3657 +      value = (threeVector1.Angle(threeVector2));
3658 +    }
3659 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3660 +  value = applyFunction(function, value);
3661 +
3662 +  return value;
3663 + }
3664 +
3665 + // track-jet pair valueLookup
3666 + double
3667 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3668 +
3669 +  double value = 0.0;
3670 +
3671 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3672 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3673 +
3674 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3675 +  value = applyFunction(function, value);
3676 +
3677 +  return value;
3678 +
3679 + }
3680 +
3681 +
3682 +
3683 + // met-jet pair valueLookup
3684 + double
3685 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3686 +
3687 +  double value = 0.0;
3688 +
3689 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3690 +
3691 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3692 +  value = applyFunction(function, value);
3693 +
3694 +  return value;
3695 +
3696 + }  
3697 +
3698 +
3699 +
3700   //!muon-jet pair valueLookup
3701   double
3702   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3121 | Line 3704 | OSUAnalysis::valueLookup (const BNmuon*
3704    double value = 0.0;
3705  
3706    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3707 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3707 >  else if(variable == "jetEta") value = object2->eta;
3708 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3709 >  else if(variable == "jetPt") value = object2->pt;
3710 >  else if(variable == "jetPhi") value = object2->phi;
3711 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3712 >  else if(variable == "muonEta") value = object1->eta;
3713 >  else if(variable == "muonPt") value = object1->pt;
3714 >  else if(variable == "muonPhi") value = object1->phi;
3715 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3716    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3717    else if(variable == "invMass"){
3718      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3143 | Line 3734 | OSUAnalysis::valueLookup (const BNmuon*
3734      value = object1->charge*object2->charge;
3735    }
3736  
3737 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3737 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3738    value = applyFunction(function, value);
3739  
3740    return value;
3741   }
3742  
3743 + //!muon-event valueLookup
3744 + double
3745 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3746 +
3747 +  double value = 0.0;
3748 +
3749 +  if(variable == "muonEta") value = object1->eta;
3750 +  else if(variable == "muonPt") value = object1->pt;
3751 +  else if(variable == "muonPhi") value = object1->phi;
3752 +  else if(variable == "Ht") value = getHt(jets.product());
3753 +  else if(variable == "pthat")   value = object2->pthat;
3754 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3755 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3756 +  value = applyFunction(function, value);
3757 +
3758 +  return value;
3759 + }
3760   //!jet-jet pair valueLookup
3761   double
3762   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3157 | Line 3765 | OSUAnalysis::valueLookup (const BNjet* o
3765  
3766    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3767    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3768 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3768 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3769    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3770    else if(variable == "invMass"){
3771      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3179 | Line 3787 | OSUAnalysis::valueLookup (const BNjet* o
3787      value = object1->charge*object2->charge;
3788    }
3789  
3790 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3790 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3791    value = applyFunction(function, value);
3792  
3793    return value;
3794   }
3795 +
3796   //!electron-track pair valueLookup
3797   double
3798   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3203 | Line 3812 | OSUAnalysis::valueLookup (const BNelectr
3812    else if(variable == "chargeProduct"){
3813      value = object1->charge*object2->charge;
3814    }
3815 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3815 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3816    value = applyFunction(function, value);
3817    return value;
3818  
# Line 3231 | Line 3840 | OSUAnalysis::valueLookup (const BNmuon*
3840      value = object1->charge*object2->charge;
3841    }
3842  
3843 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3843 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3844    value = applyFunction(function, value);
3845    return value;
3846   }
# Line 3253 | Line 3862 | OSUAnalysis::valueLookup (const BNtau* o
3862      value = object1->charge*object2->charge;
3863    }
3864  
3865 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3865 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3866    value = applyFunction(function, value);
3867    return value;
3868   }
# Line 3275 | Line 3884 | OSUAnalysis::valueLookup (const BNmuon*
3884      value = object1->charge*object2->charge;
3885    }
3886  
3887 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3887 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3888    value = applyFunction(function, value);
3889    return value;
3890   }
# Line 3290 | Line 3899 | OSUAnalysis::valueLookup (const BNtau* o
3899      value = object1->charge*object2->charge;
3900    }
3901  
3902 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3902 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3903    value = applyFunction(function, value);
3904    return value;
3905   }
# Line 3310 | Line 3919 | OSUAnalysis::valueLookup (const BNtrack*
3919    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3920    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3921  
3922 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3922 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3923  
3924    value = applyFunction(function, value);
3925  
# Line 3332 | Line 3941 | OSUAnalysis::valueLookup (const BNelectr
3941        stringValue = "none";
3942    }
3943  
3944 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3944 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3945  
3946    value = applyFunction(function, value);
3947  
# Line 3348 | Line 3957 | OSUAnalysis::valueLookup (const BNmuon*
3957  
3958    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3959  
3960 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3960 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3961  
3962    value = applyFunction(function, value);
3963  
# Line 3451 | Line 4060 | OSUAnalysis::valueLookup (const BNstop*
4060      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4061        vertex_rank++;
4062        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4063 <                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4064 <                      (object->vz-vertex->z)*(object->vz-vertex->z));
4063 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
4064 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
4065  
4066        if(abs(dist) < abs(minDistToVertex)){
4067          value = vertex_rank;
# Line 3461 | Line 4070 | OSUAnalysis::valueLookup (const BNstop*
4070      }
4071    }
4072  
4073 +  else if (variable == "decaysToTau"){
4074 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4075 +  }
4076 +
4077  
4078  
4079  
4080 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4080 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4081  
4082    value = applyFunction(function, value);
4083  
4084    return value;
4085  
4086 < }
4086 > } // end stop valueLookup
4087 >
4088  
4089  
4090  
# Line 3488 | Line 4102 | OSUAnalysis::getTrkIsIso (const BNtrack*
4102  
4103   }
4104  
4105 + //calculate the scalar sum of Jet Pt in the event.
4106 + double
4107 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4108 +  double Ht = 0;
4109 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4110 +    Ht += abs(jet->pt);
4111 +  }
4112 +  return Ht;
4113 + }
4114  
4115   double
4116   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3525 | Line 4148 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4148    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4149    if (!useTrackCaloRhoCorr_) return -99;
4150    // if (!rhokt6CaloJetsHandle_) {
4151 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4151 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4152    //   return -99;
4153    // }
4154    double radDeltaRCone = 0.5;
# Line 3547 | Line 4170 | OSUAnalysis::WriteDeadEcal (){
4170    double etaEcal, phiEcal;
4171    ifstream DeadEcalFile(deadEcalFile_);
4172    if(!DeadEcalFile) {
4173 <    cout << "Error: DeadEcalFile has not been found." << endl;
4173 >    clog << "Error: DeadEcalFile has not been found." << endl;
4174      return;
4175    }
4176    if(DeadEcalVec.size()!= 0){
4177 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4177 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4178      return;
4179    }
4180    while(!DeadEcalFile.eof())
# Line 3562 | Line 4185 | OSUAnalysis::WriteDeadEcal (){
4185        newChan.phiEcal = phiEcal;
4186        DeadEcalVec.push_back(newChan);
4187      }
4188 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4188 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4189   }
4190  
4191   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3602 | Line 4225 | OSUAnalysis::applyFunction(string functi
4225    else if(function == "log") value = log10(value);
4226  
4227    else if(function == "") value = value;
4228 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4228 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4229  
4230    return value;
4231  
# Line 3616 | Line 4239 | void OSUAnalysis::setObjectFlags(cut &cu
4239      string obj1, obj2;
4240      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4241      if (inputType==obj1 ||
4242 <        inputType==obj2) {
4242 >        inputType==obj2) {
4243        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4244        // and the inputType is a member of the pair.
4245        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3628 | Line 4251 | void OSUAnalysis::setObjectFlags(cut &cu
4251  
4252    for (uint object = 0; object != inputCollection->size(); object++){
4253  
4254 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4254 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4255 >    bool plotDecision = true;
4256  
4257      if(currentCut.inputCollection == inputType){
4258  
# Line 3640 | Line 4264 | void OSUAnalysis::setObjectFlags(cut &cu
4264          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4265  
4266        }
4267 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4267 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4268        else{
4269          bool tempDecision = true;
4270          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3649 | Line 4273 | void OSUAnalysis::setObjectFlags(cut &cu
4273            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4274              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4275          }
4276 <        decision = tempDecision;
4276 >        cutDecision = tempDecision;
4277        }
4278 +      //invert the cut for plotting if this cut is a veto
4279 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4280 +      else plotDecision = cutDecision;
4281      }
4282  
4283 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4283 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4284  
4285 <    //set flags for objects that pass each cut AND all the previous cuts
4286 <    bool previousCumulativeFlag = true;
4285 >    //set flags for objects that pass this cut AND all the previous cuts
4286 >    bool previousCumulativeCutFlag = true;
4287 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4288 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4289 >      else{ previousCumulativeCutFlag = false; break;}
4290 >    }
4291 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4292 >    bool previousCumulativePlotFlag = true;
4293      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4294 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4295 <      else{ previousCumulativeFlag = false; break;}
4294 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4295 >      else{ previousCumulativePlotFlag = false; break;}
4296      }
4297 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4297 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4298 >
4299 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4300  
4301    }
4302  
# Line 3670 | Line 4305 | void OSUAnalysis::setObjectFlags(cut &cu
4305  
4306   template <class InputCollection1, class InputCollection2>
4307   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4308 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4308 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4309  
4310  
4311    bool sameObjects = false;
# Line 3686 | Line 4321 | void OSUAnalysis::setObjectFlags(cut &cu
4321    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4322    if (currentCut.inputCollection == inputType) {
4323      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4324 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4325 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4324 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4325 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4326      }
4327      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4328        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4329 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4330 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4329 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4330 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4331        }
4332      }
4333    }
# Line 3705 | Line 4340 | void OSUAnalysis::setObjectFlags(cut &cu
4340        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4341  
4342  
4343 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4343 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4344 >      bool plotDecision = true;
4345  
4346        if(currentCut.inputCollection == inputType){
4347  
# Line 3717 | Line 4353 | void OSUAnalysis::setObjectFlags(cut &cu
4353            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4354          }
4355  
4356 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4356 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4357          else{
4358            bool tempDecision = subcutDecisions.at(0);
4359            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3726 | Line 4362 | void OSUAnalysis::setObjectFlags(cut &cu
4362              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4363                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4364            }
4365 <          decision = tempDecision;
4365 >          cutDecision = tempDecision;
4366          }
4367 +        //invert the cut for plotting if this cut is a veto
4368 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4369 +        else plotDecision = cutDecision;
4370 +      }
4371 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4372 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4373 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4374 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4375 +      }
4376 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4377 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4378 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4379        }
4380 <      // if (decision) isPassObj1.at(object1) = true;
4381 <      // if (decision) isPassObj2.at(object2) = true;
4382 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4383 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4384 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4385 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4380 >
4381 >      //set flags for objects that pass this cut AND all the previous cuts
4382 >      bool previousCumulativeCutFlag = true;
4383 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4384 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4385 >        else{ previousCumulativeCutFlag = false; break;}
4386        }
4387 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4388  
4389 <      //set flags for objects that pass each cut AND all the previous cuts
3741 <      bool previousCumulativeFlag = true;
4389 >      bool previousCumulativePlotFlag = true;
4390        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4391 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4392 <        else{ previousCumulativeFlag = false; break;}
4391 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4392 >        else{ previousCumulativePlotFlag = false; break;}
4393        }
4394 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4395 +      
4396        //apply flags for the components of the composite object as well
4397 <      bool currentCumulativeFlag = true;
4398 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4399 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4400 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4401 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4402 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4403 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4404 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4405 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4397 >      bool currentCumulativeCutFlag = true;
4398 >      bool currentCumulativePlotFlag = true;
4399 >
4400 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4401 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4402 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4403 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4404 >
4405 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4406 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4407 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4408 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4409 >
4410 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4411 >
4412 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4413 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4414 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4415        }
4416 +
4417 +      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4418 +        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4419 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4420 +      }
4421 +
4422        counter++;
4423  
4424      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3762 | Line 4427 | void OSUAnalysis::setObjectFlags(cut &cu
4427   }
4428  
4429  
4430 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4430 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4431    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4432    // all cuts up to currentCutIndex
4433    bool previousCumulativeFlag = true;
4434    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4435 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4435 >    bool tempFlag = false;
4436 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4437 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4438 >
4439 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4440      else {
4441        previousCumulativeFlag = false; break;
4442      }
# Line 3777 | Line 4446 | bool OSUAnalysis::getPreviousCumulativeF
4446  
4447  
4448  
4449 +
4450   template <class InputCollection>
4451 < void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, vector<bool> flags){
4452 <  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree  
4451 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4452 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4453  
4454 <  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;  
4455 <  for (uint object = 0; object != inputCollection->size(); object++) {  
4454 >  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;
4455 >  for (uint object = 0; object != inputCollection->size(); object++) {
4456  
4457 <    if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;  
4457 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4458  
4459 <    string inputVariable = parameters.inputVariable;
4459 >    string inputVariable = parameters.inputVariable;
4460      string function = "";
4461 <    string stringValue = "";  
4462 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
4463 <    BNTreeBranchVals_.at(parameters.name).push_back(value);  
4461 >    string stringValue = "";
4462 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4463 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4464  
4465    }
4466   }
4467  
4468  
4469   template <class InputCollection>
4470 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4470 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4471 >
4472  
4473    for (uint object = 0; object != inputCollection->size(); object++){
4474  
4475 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4475 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4476  
4477      string currentString = parameters.inputVariables.at(0);
4478      string inputVariable = "";
# Line 3813 | Line 4484 | void OSUAnalysis::fill1DHistogram(TH1* h
4484        function = currentString.substr(0,currentString.find("("));//function comes before the "("
4485        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4486        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4487 <    }  
4487 >    }
4488  
4489 <    string stringValue = "";  
4490 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
4491 <    histo->Fill(value,scaleFactor);  
4489 >    string stringValue = "";
4490 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4491 >    histo->Fill(value,scaleFactor);
4492  
4493      if (printEventInfo_) {
4494        // Write information about event to screen, for testing purposes.
4495 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4495 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4496      }
4497  
4498    }
4499   }
4500  
4501   template <class InputCollection1, class InputCollection2>
4502 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4502 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4503  
4504    bool sameObjects = false;
4505    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3841 | Line 4512 | void OSUAnalysis::fill1DHistogram(TH1* h
4512  
4513        pairCounter++;
4514        //only take objects which have passed all cuts and pairs which have passed all cuts
4515 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4516 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4517 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4515 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4516 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4517 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4518  
4519        string currentString = parameters.inputVariables.at(0);
4520        string inputVariable = "";
# Line 3868 | Line 4539 | void OSUAnalysis::fill1DHistogram(TH1* h
4539  
4540  
4541   template <class InputCollection>
4542 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4542 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4543  
4544    for (uint object = 0; object != inputCollection->size(); object++){
4545  
4546 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4546 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4547  
4548      string stringValue = "";
4549      string currentString = parameters.inputVariables.at(0);
# Line 3909 | Line 4580 | void OSUAnalysis::fill2DHistogram(TH2* h
4580   }
4581  
4582   template <class InputCollection1, class InputCollection2>
4583 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4583 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4584  
4585    bool sameObjects = false;
4586    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3923 | Line 4594 | void OSUAnalysis::fill2DHistogram(TH2* h
4594        pairCounter++;
4595  
4596        //only take objects which have passed all cuts and pairs which have passed all cuts
4597 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4598 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4599 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4597 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4598 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4599 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4600  
4601        string stringValue = "";
4602        string currentString = parameters.inputVariables.at(0);
# Line 3973 | Line 4644 | int OSUAnalysis::getGenMatchedParticleIn
4644  
4645      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4646      if(currentDeltaR > 0.05) continue;
4647 <    //     cout << setprecision(3) << setw(20)
4647 >    //     clog << setprecision(3) << setw(20)
4648      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4649      //          << setw(20)
4650      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 3992 | Line 4663 | int OSUAnalysis::getGenMatchedParticleIn
4663      }
4664  
4665    }
4666 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4667 <  //   else cout << "no match found..." << endl;
4666 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4667 >  //   else clog << "no match found..." << endl;
4668    return bestMatchIndex;
4669  
4670   }
# Line 4085 | Line 4756 | OSUAnalysis::chosenVertex ()
4756   {
4757    const BNprimaryvertex *chosenVertex = 0;
4758    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4759 <    vector<bool> vertexFlags;
4759 >    flagPair vertexFlags;
4760      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4761        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4762          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4093 | Line 4764 | OSUAnalysis::chosenVertex ()
4764        }
4765      }
4766      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4767 <      if(!vertexFlags.at(vertexIndex)) continue;
4767 >      if(!vertexFlags.at(vertexIndex).first) continue;
4768        chosenVertex = & primaryvertexs->at(vertexIndex);
4769        break;
4770      }
# Line 4109 | Line 4780 | OSUAnalysis::chosenMET ()
4780   {
4781    const BNmet *chosenMET = 0;
4782    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4783 <    vector<bool> metFlags;
4783 >    flagPair metFlags;
4784      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4785        if (cumulativeFlags.at("mets").at(i).size()){
4786          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4117 | Line 4788 | OSUAnalysis::chosenMET ()
4788        }
4789      }
4790      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4791 <      if(!metFlags.at(metIndex)) continue;
4791 >      if(!metFlags.at(metIndex).first) continue;
4792        chosenMET = & mets->at(metIndex);
4793        break;
4794      }
# Line 4133 | Line 4804 | OSUAnalysis::chosenElectron ()
4804   {
4805    const BNelectron *chosenElectron = 0;
4806    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4807 <    vector<bool> electronFlags;
4807 >    flagPair electronFlags;
4808      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4809        if (cumulativeFlags.at("electrons").at(i).size()){
4810          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4141 | Line 4812 | OSUAnalysis::chosenElectron ()
4812        }
4813      }
4814      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4815 <      if(!electronFlags.at(electronIndex)) continue;
4815 >      if(!electronFlags.at(electronIndex).first) continue;
4816        chosenElectron = & electrons->at(electronIndex);
4817        break;
4818      }
# Line 4152 | Line 4823 | OSUAnalysis::chosenElectron ()
4823    return chosenElectron;
4824   }
4825  
4826 +
4827   const BNmuon *
4828   OSUAnalysis::chosenMuon ()
4829   {
4830    const BNmuon *chosenMuon = 0;
4831    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4832 <    vector<bool> muonFlags;
4832 >    flagPair muonFlags;
4833      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4834        if (cumulativeFlags.at("muons").at(i).size()){
4835          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4165 | Line 4837 | OSUAnalysis::chosenMuon ()
4837        }
4838      }
4839      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4840 <      if(!muonFlags.at(muonIndex)) continue;
4840 >      if(!muonFlags.at(muonIndex).first) continue;
4841        chosenMuon = & muons->at(muonIndex);
4842        break;
4843      }
# Line 4176 | Line 4848 | OSUAnalysis::chosenMuon ()
4848    return chosenMuon;
4849   }
4850  
4851 + double
4852 + OSUAnalysis::chosenHT ()
4853 + {
4854 +  double chosenHT = 0.0;
4855 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
4856 +    flagPair jetFlags;
4857 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
4858 +      if (cumulativeFlags.at("jets").at(i).size()){
4859 +        jetFlags = cumulativeFlags.at("jets").at(i);
4860 +        break;
4861 +      }
4862 +    }
4863 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
4864 +      if(!jetFlags.at(jetIndex).first) continue;
4865 +      chosenHT += jets->at(jetIndex).pt;
4866 +    }
4867 +  }
4868 +
4869 +  return chosenHT;
4870 + }
4871 +
4872 + pair<const BNmuon *, const BNmuon *>
4873 + OSUAnalysis::leadMuonPair ()
4874 + {
4875 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
4876 +  leadMuonPair.first = leadMuonPair.second = 0;
4877 +
4878 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4879 +    flagPair muonFlags;
4880 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4881 +      if (cumulativeFlags.at("muons").at(i).size()){
4882 +        muonFlags = cumulativeFlags.at("muons").at(i);
4883 +        break;
4884 +      }
4885 +    }
4886 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
4887 +      if(!muonFlags.at(muonIndex0).first) continue;
4888 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
4889 +        if(!muonFlags.at(muonIndex1).first) continue;
4890 +        const BNmuon *mu0 = & muons->at(muonIndex0);
4891 +        const BNmuon *mu1 = & muons->at(muonIndex1);
4892 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
4893 +          leadMuonPair.first = mu0;
4894 +          leadMuonPair.second = mu1;
4895 +        }
4896 +        else{
4897 +          TVector2 newPt0 (mu0->px, mu0->py),
4898 +                   newPt1 (mu1->px, mu1->py),
4899 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
4900 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
4901 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4902 +            {
4903 +              leadMuonPair.first = mu0;
4904 +              leadMuonPair.second = mu1;
4905 +            }
4906 +        }
4907 +      }
4908 +    }
4909 +  }
4910 +
4911 +  return leadMuonPair;
4912 + }
4913 +
4914 + pair<const BNelectron *, const BNelectron *>
4915 + OSUAnalysis::leadElectronPair ()
4916 + {
4917 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
4918 +  leadElectronPair.first = leadElectronPair.second = 0;
4919 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4920 +    flagPair electronFlags;
4921 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4922 +      if (cumulativeFlags.at("electrons").at(i).size()){
4923 +        electronFlags = cumulativeFlags.at("electrons").at(i);
4924 +        break;
4925 +      }
4926 +    }
4927 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
4928 +      if(!electronFlags.at(electronIndex0).first) continue;
4929 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
4930 +        if(!electronFlags.at(electronIndex1).first) continue;
4931 +        const BNelectron *el0 = & electrons->at(electronIndex0);
4932 +        const BNelectron *el1 = & electrons->at(electronIndex1);
4933 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
4934 +          leadElectronPair.first = el0;
4935 +          leadElectronPair.second = el1;
4936 +        }
4937 +        else{
4938 +          TVector2 newPt0 (el0->px, el0->py),
4939 +                   newPt1 (el1->px, el1->py),
4940 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
4941 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
4942 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4943 +            {
4944 +              leadElectronPair.first = el0;
4945 +              leadElectronPair.second = el1;
4946 +            }
4947 +        }
4948 +      }
4949 +    }
4950 +  }
4951 +
4952 +  return leadElectronPair;
4953 + }
4954 +
4955   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines