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.56 by ahart, Sun May 5 23:41:30 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 17 | Line 16 | OSUAnalysis::OSUAnalysis (const edm::Par
16    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
17    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19 <  puFile_ (cfg.getParameter<std::string> ("puFile")),
20 <  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
21 <  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
22 <  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
23 <  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
24 <  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
25 <  dataset_ (cfg.getParameter<std::string> ("dataset")),
26 <  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
19 >  trigobjs_ (cfg.getParameter<edm::InputTag> ("trigobjs")),
20 >  puFile_ (cfg.getParameter<string> ("puFile")),
21 >  deadEcalFile_ (cfg.getParameter<string> ("deadEcalFile")),
22 >  muonSFFile_ (cfg.getParameter<string> ("muonSFFile")),
23 >  dataPU_ (cfg.getParameter<string> ("dataPU")),
24 >  electronSFID_ (cfg.getParameter<string> ("electronSFID")),
25 >  muonSF_ (cfg.getParameter<string> ("muonSF")),
26 >  dataset_ (cfg.getParameter<string> ("dataset")),
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 <
42 < {
40 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
41 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
42 > {
43  
44    TH1::SetDefaultSumw2 ();
45  
# Line 45 | 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 53 | Line 61 | OSUAnalysis::OSUAnalysis (const edm::Par
61    // Construct Cutflow Objects. These store the results of cut decisions and
62    // handle filling cut flow histograms.
63    masterCutFlow_ = new CutFlow (fs_);
56  std::vector<TFileDirectory> directories;
64  
65    //always get vertex collection so we can assign the primary vertex in the event
66    objectsToGet.push_back("primaryvertexs");
60
61  //always make the plot of number of primary vertices (to check pile-up reweighting)
67    objectsToPlot.push_back("primaryvertexs");
68 +  objectsToFlag.push_back("primaryvertexs");
69 +
70  
71    //always get the MC particles to do GEN-matching
72    objectsToGet.push_back("mcparticles");
# Line 67 | Line 74 | OSUAnalysis::OSUAnalysis (const edm::Par
74    //always get the event collection to do pile-up reweighting
75    objectsToGet.push_back("events");
76  
77 +
78 +  // Parse the tree variable definitions.
79 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
80 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
81 +    if(tempInputCollection.find("pairs")!=string::npos) { clog << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
82 +    objectsToGet.push_back(tempInputCollection);
83 +    objectsToFlag.push_back(tempInputCollection);
84 +
85 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
86 +
87 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
88 +      BranchSpecs br;
89 +      br.inputCollection = tempInputCollection;
90 +      br.inputVariable = branchList.at(iBranch);
91 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
92 +      br.name = string(newName.Data());
93 +      treeBranches_.push_back(br);
94 +    }
95 +
96 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
97 +
98 +
99    //parse the histogram definitions
100    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
101  
102      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
103      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
104 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
105 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
106      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
107 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
108      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
109 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
110 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
111 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
112      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
113      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
114 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
115 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
116 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
119      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
120 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
121 <      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
122 <        int spaceIndex = tempInputCollection.find(" ");
123 <        int secondWordLength = tempInputCollection.size() - spaceIndex;
124 <        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
120 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
121 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
122 >    if(tempInputCollection.find("pairs")==string::npos){ //just a single object
123 >      if(tempInputCollection.find("secondary")!=string::npos){//secondary object
124 >        int spaceIndex = tempInputCollection.find(" ");
125 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
126 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
127        }
128        else{
129 <        objectsToGet.push_back(tempInputCollection);
129 >        objectsToGet.push_back(tempInputCollection);
130        }
131        objectsToPlot.push_back(tempInputCollection);
132 <      objectsToCut.push_back(tempInputCollection);
133 <    }
134 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
93 <      string obj1;
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);  
137 >      string obj2ToGet = getObjToGet(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);  
143 >      objectsToPlot.push_back(obj2);
144        objectsToGet.push_back(tempInputCollection);
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147 +    } // end else
148 +      if (find(objectsToPlot.begin(), objectsToPlot.end(), "events") != objectsToPlot.end())
149 +        objectsToGet.push_back("jets");
150  
107    }
151  
152      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
153  
# Line 125 | Line 168 | OSUAnalysis::OSUAnalysis (const edm::Par
168        histograms.push_back(tempHistogram);
169  
170      }
171 <  }
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() );
175    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 136 | 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 151 | 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 168 | Line 213 | OSUAnalysis::OSUAnalysis (const edm::Par
213      tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
214  
215  
216 <    int maxNum = 24;
216 >    int maxNum = 25;
217      vector<double> binVector;
218      binVector.push_back(maxNum);
219      binVector.push_back(0);
# Line 210 | Line 255 | OSUAnalysis::OSUAnalysis (const edm::Par
255      //set triggers for this channel
256      vector<string> triggerNames;
257      triggerNames.clear();
258 +    vector<string> triggerToVetoNames;
259 +    triggerToVetoNames.clear();
260 +
261      tempChannel.triggers.clear();
262 +    tempChannel.triggersToVeto.clear();
263      if(channels_.at(currentChannel).exists("triggers")){
264        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
265        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
266          tempChannel.triggers.push_back(triggerNames.at(trigger));
267        objectsToGet.push_back("triggers");
268      }
269 <
269 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
270 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
271 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
272 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
273 >      objectsToGet.push_back("triggers");
274 >    }
275  
276  
277  
278      //create cutFlow for this channel
279      cutFlows_.push_back (new CutFlow (fs_, channelName));
280 <
281 <    //book a directory in the output file with the name of the channel
282 <    TFileDirectory subDir = fs_->mkdir( channelName );
229 <    directories.push_back(subDir);
230 <
231 <    std::map<std::string, TH1D*> oneDhistoMap;
232 <    oneDHists_.push_back(oneDhistoMap);
233 <    std::map<std::string, TH2D*> twoDhistoMap;
234 <    twoDHists_.push_back(twoDhistoMap);
235 <
236 <
237 <
238 <    //book all histograms included in the configuration
239 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
240 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
241 <      int numBinsElements = currentHistogram.bins.size();
242 <      int numInputVariables = currentHistogram.inputVariables.size();
243 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
244 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
245 <
246 <      if(numBinsElements == 1){
247 <        if(numBinEdgesX > 1){
248 <          if(numBinEdgesY > 1)
249 <            numBinsElements = 6;
250 <          else
251 <            numBinsElements = 3;
252 <        }
253 <      }
254 <      if(numBinsElements != 3 && numBinsElements !=6){
255 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
256 <        exit(0);
257 <      }
258 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
259 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
260 <        exit(0);
261 <      }
262 <      else if(numBinsElements == 3){
263 <        if (currentHistogram.bins.size () == 3)
264 <          oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
265 <        else
266 <          {
267 <            oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
268 <          }
269 <      }
270 <      else if(numBinsElements == 6){
271 <        if (currentHistogram.bins.size () == 6)
272 <          twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).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));
273 <        else
274 <          twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
275 <      }
276 <
277 <
278 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
279 <
280 <      // bin      particle type
281 <      // ---      -------------
282 <      //  0        unmatched
283 <      //  1        u
284 <      //  2        d
285 <      //  3        s
286 <      //  4        c
287 <      //  5        b
288 <      //  6        t
289 <      //  7        e
290 <      //  8        mu
291 <      //  9        tau
292 <      // 10        nu
293 <      // 11        g
294 <      // 12        gamma
295 <      // 13        Z
296 <      // 14        W
297 <      // 15        light meson
298 <      // 16        K meson
299 <      // 17        D meson
300 <      // 18        B meson
301 <      // 19        light baryon
302 <      // 20        strange baryon
303 <      // 21        charm baryon
304 <      // 22        bottom baryon
305 <      // 23        other
306 <
307 <      vector<TString> labelArray;
308 <      labelArray.push_back("unmatched");
309 <      labelArray.push_back("u");
310 <      labelArray.push_back("d");
311 <      labelArray.push_back("s");
312 <      labelArray.push_back("c");
313 <      labelArray.push_back("b");
314 <      labelArray.push_back("t");
315 <      labelArray.push_back("e");
316 <      labelArray.push_back("#mu");
317 <      labelArray.push_back("#tau");
318 <      labelArray.push_back("#nu");
319 <      labelArray.push_back("g");
320 <      labelArray.push_back("#gamma");
321 <      labelArray.push_back("Z");
322 <      labelArray.push_back("W");
323 <      labelArray.push_back("light meson");
324 <      labelArray.push_back("K meson");
325 <      labelArray.push_back("D meson");
326 <      labelArray.push_back("B meson");
327 <      labelArray.push_back("light baryon");
328 <      labelArray.push_back("strange baryon");
329 <      labelArray.push_back("charm baryon");
330 <      labelArray.push_back("bottom baryon");
331 <      labelArray.push_back("other");
332 <
333 <      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
334 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
335 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
336 <        }
337 <        else {
338 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
339 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
340 <        }
341 <      }
342 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
343 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
344 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
345 <      }
346 <
347 <    }
348 <
349 <    // Book a histogram for the number of each object type to be plotted.  
350 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
351 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
352 <      string currentObject = objectsToPlot.at(currentObjectIndex);
353 <      int maxNum = 10;
354 <      if(currentObject == "mcparticles") maxNum = 50;
355 <      else if(currentObject == "primaryvertexs") maxNum = 50;
356 <
357 <      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
358 <      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
359 <      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
360 <      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
361 <      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
362 <      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
363 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
364 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
365 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
366 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
367 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
368 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
369 <      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
370 <      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
371 <      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
372 <      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
373 <
374 <      currentObject.at(0) = toupper(currentObject.at(0));  
375 <      string histoName = "num" + currentObject;
376 <
377 <      if(histoName == "numPrimaryvertexs"){
378 <        string newHistoName = histoName + "BeforePileupCorrection";
379 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
380 <        newHistoName = histoName + "AfterPileupCorrection";
381 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
382 <      }
383 <      else
384 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
385 <    }
386 <
387 <
388 <
389 <
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"));
285  
286 +
287      //loop over and parse all cuts
288      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
289        cut tempCut;
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";
311        tempCut.inputCollection = tempInputCollection;
312 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
313 <        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
314 <          int spaceIndex = tempInputCollection.find(" ");
315 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
316 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
317 <        }
318 <        else{
319 <          objectsToGet.push_back(tempInputCollection);
320 <        }
321 <        objectsToCut.push_back(tempInputCollection);
312 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
313 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
314 >          int spaceIndex = tempInputCollection.find(" ");
315 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
316 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
317 >        }
318 >        else{
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;
326 <        string obj2;
327 <        getTwoObjs(tempInputCollection, obj1, obj2);
328 <        string obj2ToGet = getObjToGet(obj2);  
325 >        string obj1;
326 >        string obj2;
327 >        getTwoObjs(tempInputCollection, obj1, obj2);
328 >        string obj2ToGet = getObjToGet(obj2);
329          objectsToCut.push_back(tempInputCollection);
330          objectsToCut.push_back(obj1);
331 <        objectsToCut.push_back(obj2);  
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 431 | Line 342 | OSUAnalysis::OSUAnalysis (const edm::Par
342  
343        //split cut string into parts and store them
344        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
345 <      std::vector<string> cutStringVector = splitString(cutString);
345 >      vector<string> cutStringVector = splitString(cutString);
346        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
347 <        std::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;
351        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
352          int indexOffset = 4 * subcutIndex;
353          string currentVariableString = cutStringVector.at(indexOffset);
354 <        if(currentVariableString.find("(")==std::string::npos){
354 >        if(currentVariableString.find("(")==string::npos){
355            tempCut.functions.push_back("");//no function was specified
356            tempCut.variables.push_back(currentVariableString);// variable to cut on
357          }
# Line 451 | Line 362 | OSUAnalysis::OSUAnalysis (const edm::Par
362          }
363          tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
364          tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
365 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
366          if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
367        }
368  
369        //get number of objects required to pass cut for event to pass
370        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
371 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
371 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
372        if(numberRequiredVector.size()!=2){
373 <        std::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 466 | 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 <
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 " + tempCutName + " Cut Applied";
387        }
388        else{
389          //construct string for cutflow table
# Line 477 | Line 391 | OSUAnalysis::OSUAnalysis (const edm::Par
391          string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
392          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
393          tempCutName = cutName;
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  
405        tempChannel.cuts.push_back(tempCut);
# Line 485 | Line 407 | OSUAnalysis::OSUAnalysis (const edm::Par
407  
408      }//end loop over cuts
409  
410 +    vector<map<string, TH1D*>> oneDHistsTmp;
411 +    vector<map<string, TH2D*>> twoDHistsTmp;
412 +    //book a directory in the output file with the name of the channel
413 +    TFileDirectory subDir = fs_->mkdir( channelName );
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);
423 +      }
424 +      treeDirectories.push_back(subDir);
425 +      oneDHists_.push_back(oneDHistsTmp);
426 +      twoDHists_.push_back(twoDHistsTmp);
427 +    }
428 +    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
429 +    else{
430 +      map<string, TH1D*> oneDhistoMap;
431 +      oneDHistsTmp.push_back(oneDhistoMap);
432 +      map<string, TH2D*> twoDhistoMap;
433 +      twoDHistsTmp.push_back(twoDhistoMap);
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.
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 +          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
473 +          exit(0);
474 +        }
475 +        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
476 +          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
477 +          exit(0);
478 +        }
479 +        else if(numBinsElements == 3){
480 +          if (currentHistogram.bins.size () == 3)
481 +            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
482 +          else
483 +            {
484 +              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
485 +            }
486 +        }
487 +        else if(numBinsElements == 6){
488 +          if (currentHistogram.bins.size () == 6)
489 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
490 +          else
491 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
492 +        }
493 +
494 +
495 +        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
496 +
497 +        // bin      particle type
498 +        // ---      -------------
499 +        //  0        unmatched
500 +        //  1        u
501 +        //  2        d
502 +        //  3        s
503 +        //  4        c
504 +        //  5        b
505 +        //  6        t
506 +        //  7        e
507 +        //  8        mu
508 +        //  9        tau
509 +        // 10        nu
510 +        // 11        g
511 +        // 12        gamma
512 +        // 13        Z
513 +        // 14        W
514 +        // 15        light meson
515 +        // 16        K meson
516 +        // 17        D meson
517 +        // 18        B meson
518 +        // 19        light baryon
519 +        // 20        strange baryon
520 +        // 21        charm baryon
521 +        // 22        bottom baryon
522 +        // 23        QCD string
523 +        // 24        other
524 +
525 +        vector<TString> labelArray;
526 +        labelArray.push_back("unmatched");
527 +        labelArray.push_back("u");
528 +        labelArray.push_back("d");
529 +        labelArray.push_back("s");
530 +        labelArray.push_back("c");
531 +        labelArray.push_back("b");
532 +        labelArray.push_back("t");
533 +        labelArray.push_back("e");
534 +        labelArray.push_back("#mu");
535 +        labelArray.push_back("#tau");
536 +        labelArray.push_back("#nu");
537 +        labelArray.push_back("g");
538 +        labelArray.push_back("#gamma");
539 +        labelArray.push_back("Z");
540 +        labelArray.push_back("W");
541 +        labelArray.push_back("light meson");
542 +        labelArray.push_back("K meson");
543 +        labelArray.push_back("D meson");
544 +        labelArray.push_back("B meson");
545 +        labelArray.push_back("light baryon");
546 +        labelArray.push_back("strange baryon");
547 +        labelArray.push_back("charm baryon");
548 +        labelArray.push_back("bottom baryon");
549 +        labelArray.push_back("QCD string");
550 +        labelArray.push_back("other");
551 +
552 +        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
553 +          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
554 +            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
555 +          }
556 +          else {
557 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
558 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
559 +          }
560 +        }
561 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
562 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
563 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
564 +        }
565 +
566 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
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 == "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);
623      tempChannel.cuts.clear();
490
624    }//end loop over channels
625  
626  
# Line 497 | 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  
502 }
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   {
516
670    // Retrieve necessary collections from the event.
671  
672 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
672 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
673      event.getByLabel (triggers_, triggers);
674  
675 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
675 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
676 >    event.getByLabel (trigobjs_, trigobjs);
677 >
678 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
679      event.getByLabel (jets_, jets);
680  
681 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
681 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
682      event.getByLabel (muons_, muons);
683  
684 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
684 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
685      event.getByLabel (electrons_, electrons);
686  
687 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
687 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
688      event.getByLabel (events_, events);
689  
690 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
690 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
691      event.getByLabel (taus_, taus);
692  
693 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
693 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
694      event.getByLabel (mets_, mets);
695  
696 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
696 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
697      event.getByLabel (tracks_, tracks);
698  
699 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
699 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
700      event.getByLabel (genjets_, genjets);
701  
702 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
702 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
703      event.getByLabel (mcparticles_, mcparticles);
704  
705 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
705 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
706      event.getByLabel (primaryvertexs_, primaryvertexs);
707  
708 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
708 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
709      event.getByLabel (bxlumis_, bxlumis);
710  
711 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
711 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
712      event.getByLabel (photons_, photons);
713  
714 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
714 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
715      event.getByLabel (superclusters_, superclusters);
716  
717    if (datasetType_ == "signalMC"){
718 <    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
718 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
719        event.getByLabel (stops_, stops);
720    }
721  
722 <  if (useTrackCaloRhoCorr_) {  
723 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
724 <    // This rho collection is not available in all BEANs.  
722 >  if (useTrackCaloRhoCorr_) {
723 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
724 >    // This rho collection is not available in all BEANs.
725      // For description of rho values for different jet reconstruction algorithms, see
726 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
727 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
726 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
727 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
728    }
729  
730 <  double scaleFactor = 1.0;
730 >  double masterScaleFactor = 1.0;
731 >
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 && 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;
740 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
741 >    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
742 >  masterScaleFactor *= stopCTauScaleFactor_;
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 582 | 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++) {
756 +      iter->second.clear();  // clear array
757 +    }
758 +
759      bool triggerDecision = true;
760 <    if(currentChannel.triggers.size() != 0){  //triggers specified
761 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
760 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
761 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
762        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
763      }
764  
765      //loop over all cuts
592
766      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
767        cut currentCut = currentChannel.cuts.at(currentCutIndex);
768  
769 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
770 <        string currentObject = objectsToCut.at(currentObjectIndex);
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        }
604      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
605        string currentObject = objectsToCut.at(currentObjectIndex);
606
607        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
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 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
782 >        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
783  
612        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
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");
791          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 624 | Line 799 | OSUAnalysis::analyze (const edm::Event &
799          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
800          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
801          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
802 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
803  
804  
805  
# Line 633 | 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 651 | 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");
871 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
872 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
873 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
874 <                                                                     "track-event pairs");
875 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
876 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
877 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
878 <                                                                        "electron-track pairs");
879 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
880 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
881 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
882 <                                                                    "muon-track pairs");
883 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
884 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
885 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
886 <                                                                  "muon-tau pairs");
887 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
888 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
889 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
890 <                                                                 "tau-tau pairs");
891 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
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),
890 >                                                                     "track-event pairs");
891 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
892 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
893 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
894 >                                                                        "electron-track pairs");
895 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
896 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
897 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
898 >                                                                    "muon-track pairs");
899 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
900 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
901 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
902 >                                                                  "muon-tau pairs");
903 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
904 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
905                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
906 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
907 <                                                                 "tau-track pairs");
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");
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),
914 >                                                                          "electron-trigobj pairs");
915 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
916 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
917 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
918 >                                                                      "muon-trigobj pairs");
919  
920 <        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
920 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
921        }
922  
923  
924  
925      }//end loop over all cuts
696
697
926      //use cumulative flags to apply cuts at event level
927  
928 +    //a vector to store cumulative cut descisions after each cut.
929 +    vector<bool> eventPassedPreviousCuts;
930      bool eventPassedAllCuts = true;
701
931      //apply trigger (true if none were specified)
932      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
933  
705
934      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
935  
936        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 710 | 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 <
946 >      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
947      }
948 <
949 <  //get pile-up event weight
950 <  if (datasetType_ != "data"){
951 <    if(doPileupReweighting_) scaleFactor *= puWeight_->at (events->at (0).numTruePV);
952 <    if(applyLeptonSF_){
953 <      if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
954 <      if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
948 >    //applying all appropriate scale factors
949 >    double scaleFactor = masterScaleFactor;
950 >    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
951 >
952 >    if(applyLeptonSF_ && datasetType_ != "data"){
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).second) continue;
966 >          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
967 >        }
968 >      }
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).second) continue;
982 >          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
983 >        }
984 >      }
985      }
986 <  }
987 <
988 <  stopCTauScaleFactor_ = 1.0;
989 <  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
990 <    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
991 <  scaleFactor *= stopCTauScaleFactor_;
992 <
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 >    scaleFactor *= bTagScaleFactor_;
1010      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1011  
1012 <    if(!eventPassedAllCuts)continue;
1012 >    if (printEventInfo_ && eventPassedAllCuts) {
1013 >      // Write information about event to screen, for testing purposes.
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  
739    if (printEventInfo_) {
740      // Write information about event to screen, for testing purposes.  
741      cout << "Event passed all cuts in channel " <<  currentChannel.name
742           << ": run="  << events->at(0).run
743           << "  lumi=" << events->at(0).lumi
744           << "  event=" << events->at(0).evt
745           << endl;  
1025      }
1026  
748    //filling histograms
749    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
750      histogram currentHistogram = histograms.at(histogramIndex);
1027  
1028 <      if(currentHistogram.inputVariables.size() == 1){
1029 <        TH1D* histo;
1030 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
1031 <
1032 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
1033 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
758 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
759 <        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
760 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
761 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
762 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
763 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
764 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
765 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
766 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
767 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
768 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
769 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
770 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
771 <                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
772 <                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
773 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
774 <                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
775 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
776 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
777 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
778 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
779 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
780 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
781 <                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
782 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
783 <                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
784 <                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
785 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
786 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
787 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
788 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
789 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
790 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
791 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
792 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
793 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
794 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
795 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
796 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
797 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
798 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
799 <                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
800 <
801 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
802 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
803 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
804 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
805 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
806 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
807 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
808 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
809 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
810 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
811 <
812 <        if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
813 <      }
814 <      else if(currentHistogram.inputVariables.size() == 2){
815 <        TH2D* histo;
816 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
817 <
818 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
819 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
820 <        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
821 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
822 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
823 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
824 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
825 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
826 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
827 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
828 <        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
829 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
830 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
831 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
832 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
833 <                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \
834 <                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
835 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
836 <                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
837 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
838 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
839 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
840 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
841 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
842 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
843 <                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
844 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
845 <                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
846 <                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
847 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
848 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
849 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
850 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
851 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
852 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
853 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
854 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
855 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
856 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
857 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
858 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
859 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
860 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
861 <                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
862 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
863 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
864 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
865 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
866 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
867 <                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
868 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
869 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
870 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
871 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
872 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
873 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
874 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
875 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
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 false, set currentDir point to the last cut.
1032 >      else{
1033 >        currentDir = currentCut;
1034        }
877    }
1035  
1036  
1037 +      if(eventPassedPreviousCuts.at(currentDir)){
1038  
1039 <    //fills histograms with the sizes of collections
1040 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1041 <
1042 <      string currentObject = objectsToPlot.at(currentObjectIndex);
1043 <
1044 <      string objectToPlot = "";  
1045 <
1046 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
1047 <      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1048 <      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1049 <      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1050 <      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1051 <      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1052 <      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
1053 <      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1054 <      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";    
1055 <      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";      
1056 <      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1057 <      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1058 <      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";  
1059 <      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";  
1060 <      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";  
1061 <      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";  
1062 <      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";  
1063 <      else objectToPlot = currentObject;
1064 <
1065 <      string tempCurrentObject = objectToPlot;
1066 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
1067 <      string histoName = "num" + tempCurrentObject;
1068 <
1069 <      //set position of primary vertex in event, in order to calculate quantities relative to it
1070 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1071 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
1072 <        int numToPlot = 0;
1073 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1074 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1075 <        }
1076 <        if(objectToPlot == "primaryvertexs"){
1077 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1078 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1079 <        }
1080 <        else {
1081 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
1082 <        }
1083 <      }
1084 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
1085 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1086 <      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1087 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1088 <      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1089 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1090 <      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1091 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1092 <      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1093 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1094 <      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1095 <      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1096 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1097 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1098 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1099 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
1100 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
1101 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
1102 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1103 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1104 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1105 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1106 <      else if(objectToPlot == "primaryvertexs"){
1107 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1108 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1109 <      }
1110 <      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
1039 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1040 >          histogram currentHistogram = histograms.at(histogramIndex);
1041 >
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  
954    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1315  
1316 <  } //end loop over channel
1316 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1317 >    } // end loop over cuts
1318  
1319 <  masterCutFlow_->fillCutFlow(scaleFactor);
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 < } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1356 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1357 >
1358 >  event.put (channelDecisions, "channelDecisions");
1359 >
1360 >  isFirstEvent_ = false;  
1361 >
1362 > } // end void OSUAnalysis::produce (const edm::Event &event, const edm::EventSetup &setup)
1363  
1364  
1365  
# Line 972 | 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 {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1377 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1378 >
1379 > }
1380 >
1381 > bool
1382 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1383 >
1384 >
1385 >  if(comparison == ">")       return testValue >  cutValue;
1386 >  else if(comparison == ">=") return testValue >= cutValue;
1387 >  else if(comparison == "<")  return testValue <  cutValue;
1388 >  else if(comparison == "<=") return testValue <= cutValue;
1389 >  else if(comparison == "==") return testValue == cutValue;
1390 >  else if(comparison == "=") return testValue == cutValue;
1391 >  else if(comparison == "!=") return testValue != cutValue;
1392 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1393  
1394   }
1395  
1396   bool
1397 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1397 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1398  
1399 +  //initialize to false until a chosen trigger is passed
1400    bool triggerDecision = false;
1401  
1402 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1403 <    {
1404 <      if(trigger->pass != 1) continue;
1405 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1406 <        {
1407 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
1408 <            triggerDecision = true;
1409 <          }
1410 <        }
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 >
1411 >    //if the event passes one of the veto triggers, exit and return false
1412 >    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1413 >      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1414      }
1415 <  return triggerDecision;
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 >    }
1419 >  }
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
1427 +  else return true;
1428   }
1429  
1430 < std::vector<std::string>
1430 >
1431 > vector<string>
1432   OSUAnalysis::splitString (string inputString){
1433  
1434 <  std::stringstream stringStream(inputString);
1435 <  std::istream_iterator<std::string> begin(stringStream);
1436 <  std::istream_iterator<std::string> end;
1437 <  std::vector<std::string> stringVector(begin, end);
1434 >  stringstream stringStream(inputString);
1435 >  istream_iterator<string> begin(stringStream);
1436 >  istream_iterator<string> end;
1437 >  vector<string> stringVector(begin, end);
1438    return stringVector;
1439  
1440   }
1441  
1442  
1443   void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1444 <  // Set two object strings from the tempInputCollection string,
1445 <  // For example, if tempInputCollection is "electron-muon pairs",
1446 <  // then obj1 = "electrons" and obj2 = "muons".  
1447 <  // Note that the objects have an "s" appended.  
1444 >  // Set two object strings from the tempInputCollection string,
1445 >  // For example, if tempInputCollection is "electron-muon pairs",
1446 >  // then obj1 = "electrons" and obj2 = "muons".
1447 >  // Note that the objects have an "s" appended.
1448  
1449    int dashIndex = tempInputCollection.find("-");
1450    int spaceIndex = tempInputCollection.find_last_of(" ");
1451    int secondWordLength = spaceIndex - dashIndex;
1452 <  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1452 >  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1453    obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1454 <  
1455 < }
1454 >
1455 > }
1456  
1457  
1458   string OSUAnalysis::getObjToGet(string obj) {
1459    // Return the string corresponding to the object to get for the given obj string.
1460 <  // Right now this only handles the case in which obj contains "secondary",
1461 <  // e.g, "secondary muons".  
1462 <  // Note that "s" is NOT appended.  
1463 <  
1464 <  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
1465 <  int firstSpaceIndex = obj.find_first_of(" ");  
1460 >  // Right now this only handles the case in which obj contains "secondary",
1461 >  // e.g, "secondary muons".
1462 >  // Note that "s" is NOT appended.
1463 >
1464 >  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1465 >  int firstSpaceIndex = obj.find_first_of(" ");
1466    return obj.substr(firstSpaceIndex+1,obj.length()-1);
1467  
1468 < }  
1468 > }
1469  
1470  
1471   //!jet valueLookup
1472   double
1473 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1473 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1474  
1475    double value = 0.0;
1476    if(variable == "energy") value = object->energy;
# Line 1156 | 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 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 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
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
1625   double
1626 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1626 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1627  
1628    double value = 0.0;
1629    if(variable == "energy") value = object->energy;
# Line 1259 | 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 1266 | 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 1322 | 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 <    const BNmet *met = chosenMET ();
1332 <    if (met)
1802 >    if (const BNmet *met = chosenMET ())
1803        {
1804 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1805 <          p2 (met->px, met->py, 0.0, met->pt);
1336 <
1337 <        value = (p1 + p2).Mt ();
1804 >        double dPhi = deltaPhi (object->phi, met->phi);
1805 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1806        }
1807      else
1808        value = -999;
# Line 1452 | Line 1920 | OSUAnalysis::valueLookup (const BNmuon*
1920      value = object->isGlobalMuon > 0                \
1921        && object->isPFMuon > 0                        \
1922        && object->normalizedChi2 < 10                \
1923 <                                  && object->numberOfValidMuonHits > 0        \
1923 >      && object->numberOfValidMuonHits > 0        \
1924        && object->numberOfMatchedStations > 1        \
1925        && fabs(object->correctedD0Vertex) < 0.2        \
1926        && fabs(object->correctedDZ) < 0.5        \
# Line 1461 | Line 1929 | OSUAnalysis::valueLookup (const BNmuon*
1929    }
1930    else if(variable == "tightIDdisplaced"){
1931      value = object->isGlobalMuon > 0                \
1932 +      && object->isPFMuon > 0                        \
1933        && object->normalizedChi2 < 10                \
1934 <                                  && object->numberOfValidMuonHits > 0        \
1934 >      && object->numberOfValidMuonHits > 0        \
1935        && object->numberOfMatchedStations > 1        \
1936        && object->numberOfValidPixelHits > 0        \
1937        && object->numberOfLayersWithMeasurement > 5;
1938    }
1939  
1940 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1940 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1941  
1942    else if(variable == "genMatchedPdgId"){
1943      int index = getGenMatchedParticleIndex(object);
# Line 1488 | Line 1957 | OSUAnalysis::valueLookup (const BNmuon*
1957    }
1958    else if(variable == "genMatchedMotherIdReverse"){
1959      int index = getGenMatchedParticleIndex(object);
1960 <    if(index == -1) value = 23;
1961 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1960 >    if(index == -1) value = 24;
1961 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1962    }
1963    else if(variable == "genMatchedGrandmotherId"){
1964      int index = getGenMatchedParticleIndex(object);
# Line 1503 | Line 1972 | OSUAnalysis::valueLookup (const BNmuon*
1972    }
1973    else if(variable == "genMatchedGrandmotherIdReverse"){
1974      int index = getGenMatchedParticleIndex(object);
1975 <    if(index == -1) value = 23;
1975 >    if(index == -1) value = 24;
1976      else if(fabs(mcparticles->at(index).motherId) == 15){
1977        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1978 <      if(motherIndex == -1) value = 23;
1979 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1978 >      if(motherIndex == -1) value = 24;
1979 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1980      }
1981 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1981 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1982 >  }
1983 >  else if(variable == "pfMuonsFromVertex"){
1984 >    double d0Error, dzError;
1985 >
1986 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1987 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1988 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1989 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1990 >      || fabs (object->correctedDZ / dzError) > 99.0;
1991 >    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1992    }
1993  
1994  
1995  
1996 <  else{std::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
2006 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
2006 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
2007  
2008    double value = 0.0;
2009    if(variable == "energy") value = object->energy;
# Line 1688 | 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 <    const BNmet *met = chosenMET ();
1693 <    if (met)
2174 >    if (const BNmet *met = chosenMET ())
2175        {
2176 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
2177 <          p2 (met->px, met->py, 0.0, met->pt);
1697 <
1698 <        value = (p1 + p2).Mt ();
2176 >        double dPhi = deltaPhi (object->phi, met->phi);
2177 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
2178        }
2179      else
2180        value = -999;
# Line 1762 | 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 1787 | 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 1860 | Line 2368 | OSUAnalysis::valueLookup (const BNelectr
2368    }
2369  
2370  
2371 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2371 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2372  
2373    else if(variable == "genMatchedPdgId"){
2374      int index = getGenMatchedParticleIndex(object);
# Line 1881 | Line 2389 | OSUAnalysis::valueLookup (const BNelectr
2389    }
2390    else if(variable == "genMatchedMotherIdReverse"){
2391      int index = getGenMatchedParticleIndex(object);
2392 <    if(index == -1) value = 23;
2393 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2392 >    if(index == -1) value = 24;
2393 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2394    }
2395    else if(variable == "genMatchedGrandmotherId"){
2396      int index = getGenMatchedParticleIndex(object);
# Line 1896 | Line 2404 | OSUAnalysis::valueLookup (const BNelectr
2404    }
2405    else if(variable == "genMatchedGrandmotherIdReverse"){
2406      int index = getGenMatchedParticleIndex(object);
2407 <    if(index == -1) value = 23;
2407 >    if(index == -1) value = 24;
2408      else if(fabs(mcparticles->at(index).motherId) == 15){
2409        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2410 <      if(motherIndex == -1) value = 23;
2411 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2410 >      if(motherIndex == -1) value = 24;
2411 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2412      }
2413 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2413 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2414 >  }
2415 >  else if(variable == "pfElectronsFromVertex"){
2416 >    double d0Error, dzError;
2417 >
2418 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2419 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2420 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2421 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2422 >      || fabs (object->correctedDZ / dzError) > 99.0;
2423 >    value = !value;
2424    }
2425  
2426  
2427  
2428 <  else{std::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
2438 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
2438 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2439  
2440    double value = 0.0;
2441  
# Line 1924 | 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 1985 | Line 2505 | OSUAnalysis::valueLookup (const BNevent*
2505    else if(variable == "id2") value = object->id2;
2506    else if(variable == "evt") value = object->evt;
2507    else if(variable == "puScaleFactor"){
2508 <    if(datasetType_ != "data")
2508 >    if(doPileupReweighting_ && datasetType_ != "data")
2509        value = puWeight_->at (events->at (0).numTruePV);
2510      else
2511        value = 1.0;
2512    }
2513 <  else if(variable == "muonScaleFactor"){
2514 <    if(datasetType_ != "data")
2515 <      value = muonSFWeight_->at (chosenMuon ()->eta);
2516 <    else
2517 <      value = 1.0;
2518 <  }
2519 <  else if(variable == "electronScaleFactor"){
2520 <    if(datasetType_ != "data")
2521 <      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
2522 <    else
2523 <      value = 1.0;
2513 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2514 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2515 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
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 if(variable == "stopCTauScaleFactor")
2006 <    value = stopCTauScaleFactor_;
2007 <
2008 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
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
2554 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2554 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2555  
2556    double value = 0.0;
2557  
# Line 2058 | 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 +  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 <
2063 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2607 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2608  
2609    else if(variable == "genMatchedPdgId"){
2610      int index = getGenMatchedParticleIndex(object);
# Line 2080 | Line 2624 | OSUAnalysis::valueLookup (const BNtau* o
2624    }
2625    else if(variable == "genMatchedMotherIdReverse"){
2626      int index = getGenMatchedParticleIndex(object);
2627 <    if(index == -1) value = 23;
2628 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2627 >    if(index == -1) value = 24;
2628 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2629    }
2630    else if(variable == "genMatchedGrandmotherId"){
2631      int index = getGenMatchedParticleIndex(object);
# Line 2095 | Line 2639 | OSUAnalysis::valueLookup (const BNtau* o
2639    }
2640    else if(variable == "genMatchedGrandmotherIdReverse"){
2641      int index = getGenMatchedParticleIndex(object);
2642 <    if(index == -1) value = 23;
2642 >    if(index == -1) value = 24;
2643      else if(fabs(mcparticles->at(index).motherId) == 15){
2644        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2645 <      if(motherIndex == -1) value = 23;
2646 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2645 >      if(motherIndex == -1) value = 24;
2646 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2647      }
2648 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2648 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2649    }
2650  
2651  
2652 <  else{std::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
2662 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2662 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2663  
2664    double value = 0.0;
2665  
# Line 2178 | 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{std::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
2736 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2736 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2737  
2738    double value = 0.0;
2739    double pMag = sqrt(object->pt * object->pt +
2740 <                     object->pz * object->pz);
2741 <  
2740 >                     object->pz * object->pz);
2741 >
2742    if(variable == "pt") value = object->pt;
2743    else if(variable == "px") value = object->px;
2744    else if(variable == "py") value = object->py;
# Line 2211 | Line 2757 | OSUAnalysis::valueLookup (const BNtrack*
2757    else if(variable == "numValidHits") value = object->numValidHits;
2758    else if(variable == "isHighPurity") value = object->isHighPurity;
2759  
2214
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 == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2768 <  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 <  
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"){
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);  
2821 <  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2820 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2821 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2822    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2823    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2824    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2825    else if(variable == "ptError")                    value = object->ptError;
2826    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2827 <  else if (variable == "d0wrtPV"){      
2828 <    double vx = object->vx - chosenVertex ()->x,        
2829 <      vy = object->vy - chosenVertex ()->y,      
2830 <      px = object->px,  
2831 <      py = object->py,  
2832 <      pt = object->pt;  
2833 <    value = (-vx * py + vy * px) / pt;  
2834 <  }      
2835 <  else if (variable == "dZwrtPV"){      
2836 <    double vx = object->vx - chosenVertex ()->x,        
2837 <      vy = object->vy - chosenVertex ()->y,      
2838 <      vz = object->vz - chosenVertex ()->z,      
2839 <      px = object->px,  
2840 <      py = object->py,  
2841 <      pz = object->pz,  
2842 <      pt = object->pt;  
2843 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2844 <  }    
2845 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2827 >  else if (variable == "d0wrtPV"){
2828 >    double vx = object->vx - chosenVertex ()->x,
2829 >      vy = object->vy - chosenVertex ()->y,
2830 >      px = object->px,
2831 >      py = object->py,
2832 >      pt = object->pt;
2833 >    value = (-vx * py + vy * px) / pt;
2834 >  }
2835 >  else if (variable == "dZwrtPV"){
2836 >    double vx = object->vx - chosenVertex ()->x,
2837 >      vy = object->vy - chosenVertex ()->y,
2838 >      vz = object->vz - chosenVertex ()->z,
2839 >      px = object->px,
2840 >      py = object->py,
2841 >      pz = object->pz,
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"){
2850      int index = getGenMatchedParticleIndex(object);
# Line 2275 | Line 2865 | OSUAnalysis::valueLookup (const BNtrack*
2865    }
2866    else if(variable == "genMatchedMotherIdReverse"){
2867      int index = getGenMatchedParticleIndex(object);
2868 <    if(index == -1) value = 23;
2869 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2868 >    if(index == -1) value = 24;
2869 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2870    }
2871    else if(variable == "genMatchedGrandmotherId"){
2872      int index = getGenMatchedParticleIndex(object);
# Line 2290 | Line 2880 | OSUAnalysis::valueLookup (const BNtrack*
2880    }
2881    else if(variable == "genMatchedGrandmotherIdReverse"){
2882      int index = getGenMatchedParticleIndex(object);
2883 <    if(index == -1) value = 23;
2883 >    if(index == -1) value = 24;
2884      else if(fabs(mcparticles->at(index).motherId) == 15){
2885        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2886 <      if(motherIndex == -1) value = 23;
2887 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2886 >      if(motherIndex == -1) value = 24;
2887 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2888      }
2889 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2889 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2890    }
2891  
2892  
2893  
2894 <  else{std::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
2904 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2904 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2905  
2906    double value = 0.0;
2907  
# Line 2330 | Line 2921 | OSUAnalysis::valueLookup (const BNgenjet
2921    else if(variable == "charge") value = object->charge;
2922  
2923  
2924 <  else{std::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 2339 | Line 2930 | OSUAnalysis::valueLookup (const BNgenjet
2930  
2931   //!mcparticle valueLookup
2932   double
2933 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2933 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2934  
2935    double value = 0.0;
2936  
# Line 2464 | Line 3055 | OSUAnalysis::valueLookup (const BNmcpart
3055    }
3056  
3057  
3058 <  else{std::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
3068 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
3068 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
3069  
3070    double value = 0.0;
3071  
# Line 2492 | Line 3084 | OSUAnalysis::valueLookup (const BNprimar
3084    else if(variable == "isGood") value = object->isGood;
3085  
3086  
3087 <  else{std::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 2501 | Line 3093 | OSUAnalysis::valueLookup (const BNprimar
3093  
3094   //!bxlumi valueLookup
3095   double
3096 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
3096 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
3097  
3098    double value = 0.0;
3099  
# Line 2510 | Line 3102 | OSUAnalysis::valueLookup (const BNbxlumi
3102    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3103  
3104  
3105 <  else{std::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 2519 | Line 3111 | OSUAnalysis::valueLookup (const BNbxlumi
3111  
3112   //!photon valueLookup
3113   double
3114 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
3114 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
3115  
3116    double value = 0.0;
3117  
# Line 2594 | Line 3186 | OSUAnalysis::valueLookup (const BNphoton
3186    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
3187  
3188  
2597
3189  
3190 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
3190 >
3191 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
3192  
3193    else if(variable == "genMatchedPdgId"){
3194      int index = getGenMatchedParticleIndex(object);
# Line 2618 | Line 3210 | OSUAnalysis::valueLookup (const BNphoton
3210    }
3211    else if(variable == "genMatchedMotherIdReverse"){
3212      int index = getGenMatchedParticleIndex(object);
3213 <    if(index == -1) value = 23;
3214 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
3213 >    if(index == -1) value = 24;
3214 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
3215    }
3216    else if(variable == "genMatchedGrandmotherId"){
3217      int index = getGenMatchedParticleIndex(object);
# Line 2633 | Line 3225 | OSUAnalysis::valueLookup (const BNphoton
3225    }
3226    else if(variable == "genMatchedGrandmotherIdReverse"){
3227      int index = getGenMatchedParticleIndex(object);
3228 <    if(index == -1) value = 23;
3228 >    if(index == -1) value = 24;
3229      else if(fabs(mcparticles->at(index).motherId) == 15){
3230        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
3231 <      if(motherIndex == -1) value = 23;
3232 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3231 >      if(motherIndex == -1) value = 24;
3232 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3233      }
3234 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3234 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3235    }
3236  
3237  
3238 <  else{std::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
3248 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
3248 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
3249  
3250    double value = 0.0;
3251  
# Line 2666 | Line 3259 | OSUAnalysis::valueLookup (const BNsuperc
3259    else if(variable == "theta") value = object->theta;
3260  
3261  
3262 <  else{std::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 >
3266 >  return value;
3267 > }
3268 >
3269 > //!trigobj valueLookup
3270 > double
3271 > OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
3272 >
3273 >  double value = 0.0;
3274 >
3275 >  if(variable == "pt") value = object->pt;
3276 >  else if(variable == "eta") value = object->eta;
3277 >  else if(variable == "phi") value = object->phi;
3278 >  else if(variable == "px") value = object->px;
3279 >  else if(variable == "py") value = object->py;
3280 >  else if(variable == "pz") value = object->pz;
3281 >  else if(variable == "et") value = object->et;
3282 >  else if(variable == "energy") value = object->energy;
3283 >  else if(variable == "etTotal") value = object->etTotal;
3284 >  else if(variable == "id") value = object->id;
3285 >  else if(variable == "charge") value = object->charge;
3286 >  else if(variable == "isIsolated") value = object->isIsolated;
3287 >  else if(variable == "isMip") value = object->isMip;
3288 >  else if(variable == "isForward") value = object->isForward;
3289 >  else if(variable == "isRPC") value = object->isRPC;
3290 >  else if(variable == "bx") value = object->bx;
3291 >  else if(variable == "filter") {
3292 >    if ((stringValue = object->filter) == "")
3293 >      stringValue = "none";  // stringValue should only be empty if value is filled
3294 >  }
3295 >
3296 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3297  
3298    value = applyFunction(function, value);
3299  
# Line 2675 | Line 3302 | OSUAnalysis::valueLookup (const BNsuperc
3302  
3303   //!muon-muon pair valueLookup
3304   double
3305 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
3305 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3306  
3307    double value = 0.0;
3308  
# Line 2737 | Line 3364 | OSUAnalysis::valueLookup (const BNmuon*
3364        value = object2->correctedD0;
3365      }
3366  
3367 <  else{std::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 2746 | Line 3466 | OSUAnalysis::valueLookup (const BNmuon*
3466  
3467   //!electron-electron pair valueLookup
3468   double
3469 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
3469 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
3470  
3471    double value = 0.0;
3472  
# Line 2793 | Line 3513 | OSUAnalysis::valueLookup (const BNelectr
3513      value = object2->correctedD0;
3514    }
3515  
3516 <  else{std::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){
3525 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3526  
3527    double value = 0.0;
3528  
# Line 2859 | 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 <
2863 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2864 <
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
3592 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function){
3592 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3593  
3594    double value = 0.0;
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 2896 | Line 3620 | OSUAnalysis::valueLookup (const BNelectr
3620      value = object1->charge*object2->charge;
3621    }
3622  
3623 <  else{std::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){
3702 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3703  
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 2932 | Line 3734 | OSUAnalysis::valueLookup (const BNmuon*
3734      value = object1->charge*object2->charge;
3735    }
3736  
3737 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2936 <
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){
3762 > OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3763  
3764    double value = 0.0;
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 == "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 2967 | Line 3786 | OSUAnalysis::valueLookup (const BNjet* o
3786    else if(variable == "chargeProduct"){
3787      value = object1->charge*object2->charge;
3788    }
2970  
2971  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3789  
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){  
3799 <  double electronMass = 0.000511;        
3800 <  double value = 0.0;    
3801 <  TLorentzVector fourVector1(0, 0, 0, 0);        
3802 <  TLorentzVector fourVector2(0, 0, 0, 0);        
3803 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
3797 > double
3798 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3799 >  double electronMass = 0.000511;
3800 >  double value = 0.0;
3801 >  TLorentzVector fourVector1(0, 0, 0, 0);
3802 >  TLorentzVector fourVector2(0, 0, 0, 0);
3803 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3804    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3805 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3806 <  else if(variable == "invMass"){        
3807 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3808 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3809 <        
3810 <    value = (fourVector1 + fourVector2).M();    
3811 <  }
3812 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3813 <  value = applyFunction(function, value);        
3814 <  return value;  
3805 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3806 >  else if(variable == "invMass"){
3807 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3808 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3809 >
3810 >    value = (fourVector1 + fourVector2).M();
3811 >  }
3812 >  else if(variable == "chargeProduct"){
3813 >    value = object1->charge*object2->charge;
3814 >  }
3815 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3816 >  value = applyFunction(function, value);
3817 >  return value;
3818 >
3819   }
3820  
3821  
3822   //!muon-track pair valueLookup
3823   double
3824 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3824 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3825    double pionMass = 0.140;
3826    double muonMass = 0.106;
3827    double value = 0.0;
# Line 3013 | Line 3836 | OSUAnalysis::valueLookup (const BNmuon*
3836  
3837      value = (fourVector1 + fourVector2).M();
3838    }
3839 +  else if(variable == "chargeProduct"){
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   }
3847  
3848   //!tau-tau pair valueLookup
3849   double
3850 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3850 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3851    double value = 0.0;
3852    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3853    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 3032 | Line 3858 | OSUAnalysis::valueLookup (const BNtau* o
3858      value = (fourVector1 + fourVector2).M();
3859    }
3860  
3861 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3861 >  else if(variable == "chargeProduct"){
3862 >    value = object1->charge*object2->charge;
3863 >  }
3864 >
3865 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3866    value = applyFunction(function, value);
3867    return value;
3868   }
3869  
3870   //!muon-tau pair valueLookup
3871   double
3872 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3872 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3873    double value = 0.0;
3874    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3875    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 3050 | Line 3880 | OSUAnalysis::valueLookup (const BNmuon*
3880      value = (fourVector1 + fourVector2).M();
3881    }
3882  
3883 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3883 >  else if(variable == "chargeProduct"){
3884 >    value = object1->charge*object2->charge;
3885 >  }
3886 >
3887 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3888    value = applyFunction(function, value);
3889    return value;
3890   }
3891  
3892   //!tau-track pair valueLookup
3893   double
3894 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3894 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3895    double value = 0.0;
3896    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3897    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3898 +  else if(variable == "chargeProduct"){
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 3070 | Line 3907 | OSUAnalysis::valueLookup (const BNtau* o
3907  
3908   //!track-event pair valueLookup
3909   double
3910 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3910 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3911  
3912    double value = 0.0;
3913    double pMag = sqrt(object1->pt * object1->pt +
3914 <                     object1->pz * object1->pz);  
3914 >                     object1->pz * object1->pz);
3915  
3916    if      (variable == "numPV")                      value = object2->numPV;
3917    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3918    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3919 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3920 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3919 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3920 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3921  
3922 <  else { std::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 >
3926 >  return value;
3927 >
3928 > }
3929 >
3930 > //!electron-trigobj pair valueLookup
3931 > double
3932 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3933 >
3934 >  double value = 0.0;
3935 >
3936 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3937 >  else if (variable == "match"){
3938 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3939 >      stringValue = object2->filter;
3940 >    else
3941 >      stringValue = "none";
3942 >  }
3943 >
3944 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3945 >
3946 >  value = applyFunction(function, value);
3947 >
3948 >  return value;
3949 >
3950 > }
3951 >
3952 > //!muon-trigobj pair valueLookup
3953 > double
3954 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3955 >
3956 >  double value = 0.0;
3957 >
3958 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3959 >
3960 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3961  
3962    value = applyFunction(function, value);
3963  
# Line 3092 | Line 3967 | OSUAnalysis::valueLookup (const BNtrack*
3967  
3968   //!stop valueLookup
3969   double
3970 < OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
3970 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3971  
3972  
3973    double value = 0.0;
# Line 3123 | Line 3998 | OSUAnalysis::valueLookup (const BNstop*
3998      double minD0=999;
3999      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4000        double vx = object->vx - vertex->x,
4001 <        vy = object->vy - vertex->y,
4002 <        px = object->px,
4003 <        py = object->py,
4004 <        pt = object->pt;
4001 >        vy = object->vy - vertex->y,
4002 >        px = object->px,
4003 >        py = object->py,
4004 >        pt = object->pt;
4005        value = (-vx * py + vy * px) / pt;
4006        if(abs(value) < abs(minD0)) minD0 = value;
4007      }
# Line 3136 | Line 4011 | OSUAnalysis::valueLookup (const BNstop*
4011      double minDz=999;
4012      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4013        double vx = object->vx - vertex->x,
4014 <        vy = object->vy - vertex->y,
4015 <        vz = object->vz - vertex->z,
4016 <        px = object->px,
4017 <        py = object->py,
4018 <        pz = object->pz,
4019 <        pt = object->pt;
4014 >        vy = object->vy - vertex->y,
4015 >        vz = object->vz - vertex->z,
4016 >        px = object->px,
4017 >        py = object->py,
4018 >        pz = object->pz,
4019 >        pt = object->pt;
4020        value = vz - (vx * px + vy * py)/pt * (pz/pt);
4021        if(abs(value) < abs(minDz)) minDz = value;
4022      }
# Line 3149 | Line 4024 | OSUAnalysis::valueLookup (const BNstop*
4024    }
4025    else if(variable == "distToVertex"){
4026      value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
4027 <                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
4028 <                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
4027 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
4028 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
4029    }
4030    else if (variable == "minDistToVertex"){
4031      double minDistToVertex=999;
4032      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4033        value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4034 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
4035 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
4036 <      
4034 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
4035 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
4036 >
4037        if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
4038      }
4039      value = minDistToVertex;
# Line 3167 | Line 4042 | OSUAnalysis::valueLookup (const BNstop*
4042      double minDistToVertex=999;
4043      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
4044        value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
4045 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
4046 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
4047 <      
4045 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
4046 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
4047 >
4048        if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
4049      }
4050      double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
4051 <                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
4052 <                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
4051 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
4052 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
4053  
4054      value = distToChosenVertex - minDistToVertex;
4055    }
# Line 3185 | 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));
4065 <      
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;
4068 <        minDistToVertex = dist;
4067 >        value = vertex_rank;
4068 >        minDistToVertex = dist;
4069        }
4070      }
4071    }
4072  
4073 +  else if (variable == "decaysToTau"){
4074 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4075 +  }
4076  
4077  
4078  
4079 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4079 >
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 3222 | 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 3256 | Line 4145 | OSUAnalysis::getTrkPtTrue (const BNtrack
4145  
4146   double
4147   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
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;  
4152 <  //   return -99;  
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 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4152 >  //   return -99;
4153    // }
4154 <  double radDeltaRCone = 0.5;  
4155 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
4156 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
4157 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
4158 <  return caloTotRhoCorrCalo;  
4159 <
4154 >  double radDeltaRCone = 0.5;
4155 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
4156 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
4157 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
4158 >  return caloTotRhoCorrCalo;
4159 >
4160   }
4161  
4162  
# Line 3281 | 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 3296 | 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 3305 | Line 4194 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
4194    double deltaRLowest = 999;
4195    int value = 0;
4196    if (DeadEcalVec.size() == 0) WriteDeadEcal();
4197 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
4197 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
4198      double eta = ecal->etaEcal;
4199      double phi = ecal->phiEcal;
4200 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
4200 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
4201      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
4202    }
4203    if (deltaRLowest<0.05) {value = 1;}
# Line 3316 | Line 4205 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
4205    return value;
4206   }
4207  
4208 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
4208 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
4209   template <class InputObject>
4210   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
4211    double genDeltaRLowest = 999.;
# Line 3336 | Line 4225 | OSUAnalysis::applyFunction(string functi
4225    else if(function == "log") value = log10(value);
4226  
4227    else if(function == "") value = value;
4228 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
4228 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4229  
4230    return value;
4231  
# Line 3345 | Line 4234 | OSUAnalysis::applyFunction(string functi
4234  
4235   template <class InputCollection>
4236   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
4237 <
4238 <  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
4239 <    string obj1, obj2;
4237 >
4238 >  if (currentCut.inputCollection.find("pair")!=string::npos)  {
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.  
4246 <      // For example, if currentCut.inputCollection==electron-muon pairs,
4247 <      // then the flags should not be set here when inputType==muons or inputType==electrons.  
4248 <      return;
4249 <    }  
4250 <  }    
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.
4246 >      // For example, if currentCut.inputCollection==electron-muon pairs,
4247 >      // then the flags should not be set here when inputType==muons or inputType==electrons.
4248 >      return;
4249 >    }
4250 >  }
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  
4259        vector<bool> subcutDecisions;
4260        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4261 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
4262 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4261 >        string stringValue = "";
4262 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4263 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
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 3381 | 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(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4289 <      else{ previousCumulativeFlag = false; break;}
4288 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4289 >      else{ previousCumulativeCutFlag = false; break;}
4290      }
4291 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4291 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4292 >    bool previousCumulativePlotFlag = true;
4293 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4294 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4295 >      else{ previousCumulativePlotFlag = false; break;}
4296 >    }
4297 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4298 >
4299 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4300  
4301    }
4302  
# Line 3402 | 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;
4312    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4313  
4314 <  // Get the strings for the two objects that make up the pair.  
4315 <  string obj1Type, obj2Type;
4314 >  // Get the strings for the two objects that make up the pair.
4315 >  string obj1Type, obj2Type;
4316    getTwoObjs(inputType, obj1Type, obj2Type);
4317    bool isTwoTypesOfObject = true;
4318 <  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
4318 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
4319  
4320 <  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
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) {    
4320 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
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.  
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    }
4334 <  
4334 >
4335    int counter = 0;
4336  
4337    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
# Line 3437 | 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  
4348          vector<bool> subcutDecisions;
4349          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4350 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
4351 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4350 >          string stringValue = "";
4351 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4352 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
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 3456 | 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        }
3462      // if (decision) isPassObj1.at(object1) = true;
3463      // if (decision) isPassObj2.at(object2) = true;
3464      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3465      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3466        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3467        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3468      }  
4380  
4381 <      //set flags for objects that pass each cut AND all the previous cuts
4382 <      bool previousCumulativeFlag = true;
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(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4385 <        else{ previousCumulativeFlag = false; break;}
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 +      bool previousCumulativePlotFlag = true;
4390 +      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
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 3492 | Line 4427 | void OSUAnalysis::setObjectFlags(cut &cu
4427   }
4428  
4429  
4430 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
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;
4436 <    else {  
4437 <      previousCumulativeFlag = false; break;  
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 >    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      }
4443    }
4444 <  return previousCumulativeFlag;  
4445 < }  
4444 >  return previousCumulativeFlag;
4445 > }
4446 >
4447 >
4448 >
4449 >
4450 > template <class InputCollection>
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) 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).second) continue;
4458 >
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);
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 = "";
4479      string function = "";
4480 <    if(currentString.find("(")==std::string::npos){
4480 >    if(currentString.find("(")==string::npos){
4481        inputVariable = currentString;// variable to cut on
4482      }
4483      else{
# Line 3525 | Line 4486 | void OSUAnalysis::fill1DHistogram(TH1* h
4486        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4487      }
4488  
4489 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
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;  
4494 >      // Write information about event to screen, for testing purposes.
4495 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4496      }
4497 <    
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 3550 | 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 = "";
4521        string function = "";
4522 <      if(currentString.find("(")==std::string::npos){
4522 >      if(currentString.find("(")==string::npos){
4523          inputVariable = currentString;// variable to cut on
4524        }
4525        else{
# Line 3566 | Line 4528 | void OSUAnalysis::fill1DHistogram(TH1* h
4528          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4529        }
4530  
4531 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
4531 >      string stringValue = "";
4532 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4533        histo->Fill(value,scaleFactor);
4534  
4535      }
# Line 3576 | 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);
4550      string inputVariable = "";
4551      string function = "";
4552 <    if(currentString.find("(")==std::string::npos){
4552 >    if(currentString.find("(")==string::npos){
4553        inputVariable = currentString;// variable to cut on
4554      }
4555      else{
# Line 3593 | Line 4557 | void OSUAnalysis::fill2DHistogram(TH2* h
4557        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4558        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4559      }
4560 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
4560 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4561  
4562      currentString = parameters.inputVariables.at(1);
4563      inputVariable = "";
4564      function = "";
4565 <    if(currentString.find("(")==std::string::npos){
4565 >    if(currentString.find("(")==string::npos){
4566        inputVariable = currentString;// variable to cut on
4567      }
4568      else{
# Line 3607 | Line 4571 | void OSUAnalysis::fill2DHistogram(TH2* h
4571        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4572      }
4573  
4574 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
4574 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4575  
4576      histo->Fill(valueX,valueY,scaleFactor);
4577  
# Line 3616 | 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 3630 | 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);
4603        string inputVariable = "";
4604        string function = "";
4605 <      if(currentString.find("(")==std::string::npos){
4605 >      if(currentString.find("(")==string::npos){
4606          inputVariable = currentString;// variable to cut on
4607        }
4608        else{
# Line 3645 | Line 4610 | void OSUAnalysis::fill2DHistogram(TH2* h
4610          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4611          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4612        }
4613 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
4613 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4614  
4615        currentString = parameters.inputVariables.at(1);
4616        inputVariable = "";
4617        function = "";
4618 <      if(currentString.find("(")==std::string::npos){
4618 >      if(currentString.find("(")==string::npos){
4619          inputVariable = currentString;// variable to cut on
4620        }
4621        else{
# Line 3658 | Line 4623 | void OSUAnalysis::fill2DHistogram(TH2* h
4623          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4624          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4625        }
4626 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
4626 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4627  
4628  
4629        histo->Fill(valueX,valueY,scaleFactor);
# Line 3679 | 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 << std::setprecision(3) << std::setw(20)
4647 >    //     clog << setprecision(3) << setw(20)
4648      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4649 <    //          << std::setw(20)
4649 >    //          << setw(20)
4650      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
4651 <    //          << std::setw(20)
4651 >    //          << setw(20)
4652      //          << "\tdeltaR = " << currentDeltaR
4653 <    //          << std::setprecision(1)
4654 <    //          << std::setw(20)
4653 >    //          << setprecision(1)
4654 >    //          << setw(20)
4655      //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
4656 <    //          << std::setw(20)
4656 >    //          << setw(20)
4657      //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
4658 <    //          << std::setw(20)
4658 >    //          << setw(20)
4659      //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
4660      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
4661        bestMatchIndex = mcparticle - mcparticles->begin();
# Line 3698 | 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 3753 | Line 4718 | int OSUAnalysis::findTauMotherIndex(cons
4718   // 20        strange baryon
4719   // 21        charm baryon
4720   // 22        bottom baryon
4721 < // 23        other
4721 > // 23        QCD string
4722 > // 24        other
4723  
4724   int OSUAnalysis::getPdgIdBinValue(int pdgId){
4725  
# Line 3777 | Line 4743 | int OSUAnalysis::getPdgIdBinValue(int pd
4743    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
4744    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
4745    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
4746 +  else if(absPdgId == 92  ) binValue = 23;
4747  
4748 <  else binValue = 23;
4748 >  else binValue = 24;
4749  
4750    return binValue;
4751  
# Line 3788 | Line 4755 | const BNprimaryvertex *
4755   OSUAnalysis::chosenVertex ()
4756   {
4757    const BNprimaryvertex *chosenVertex = 0;
4758 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
4759 <    vector<bool> vertexFlags;
4758 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
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 3797 | 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      }
4771    }
4772 <  else {
4773 <    chosenVertex = &primaryvertexs->at(0);
3807 <  }
4772 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4773 >    chosenVertex = & primaryvertexs->at (0);
4774  
4775    return chosenVertex;
4776   }
# Line 3813 | Line 4779 | const BNmet *
4779   OSUAnalysis::chosenMET ()
4780   {
4781    const BNmet *chosenMET = 0;
4782 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4783 <    vector<bool> metFlags;
4782 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
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 3822 | 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      }
4795    }
4796 <  else {
4797 <    chosenMET = &mets->at(0);
3832 <  }
4796 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4797 >    chosenMET = & mets->at (0);
4798  
4799    return chosenMET;
4800   }
# Line 3838 | Line 4803 | const BNelectron *
4803   OSUAnalysis::chosenElectron ()
4804   {
4805    const BNelectron *chosenElectron = 0;
4806 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4807 <    vector<bool> electronFlags;
4806 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
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 3847 | 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      }
4819    }
4820 <  else {
4821 <    chosenElectron = &electrons->at(0);
3857 <  }
4820 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4821 >    chosenElectron = & electrons->at (0);
4822  
4823    return chosenElectron;
4824   }
4825  
4826 +
4827   const BNmuon *
4828   OSUAnalysis::chosenMuon ()
4829   {
4830    const BNmuon *chosenMuon = 0;
4831 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4832 <    vector<bool> muonFlags;
4831 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
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 3872 | 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      }
4844    }
4845 <  else {
4846 <    chosenMuon = &muons->at(0);
3882 <  }
4845 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4846 >    chosenMuon = & muons->at (0);
4847  
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