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.49 by wulsin, Wed Apr 17 15:39:43 2013 UTC vs.
Revision 1.96 by lantonel, Tue Jul 9 08:35:17 2013 UTC

# Line 17 | Line 17 | OSUAnalysis::OSUAnalysis (const edm::Par
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 <  puFile_ (cfg.getParameter<std::string> ("puFile")),
21 <  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 <  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23 <  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24 <  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25 <  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
26 <  dataset_ (cfg.getParameter<std::string> ("dataset")),
27 <  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
20 >  trigobjs_ (cfg.getParameter<edm::InputTag> ("trigobjs")),
21 >  puFile_ (cfg.getParameter<string> ("puFile")),
22 >  deadEcalFile_ (cfg.getParameter<string> ("deadEcalFile")),
23 >  muonSFFile_ (cfg.getParameter<string> ("muonSFFile")),
24 >  dataPU_ (cfg.getParameter<string> ("dataPU")),
25 >  electronSFID_ (cfg.getParameter<string> ("electronSFID")),
26 >  muonSF_ (cfg.getParameter<string> ("muonSF")),
27 >  dataset_ (cfg.getParameter<string> ("dataset")),
28 >  datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
32 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
33    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
34    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
35 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
38 >  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
39 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
40 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
41    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
42 <  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
43 <
44 < {
42 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
43 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
44 > {
45  
46    TH1::SetDefaultSumw2 ();
47  
48    //create pile-up reweighting object, if necessary
49    if(datasetType_ != "data") {
50      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
51 <    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
52 <    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
51 >    if (applyLeptonSF_){
52 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
53 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
54 >    }
55 >    if (applyBtagSF_){
56 >      bTagSFWeight_ = new BtagSFWeight;
57 >    }
58    }
59 < #ifdef DISPLACED_SUSY
60 <  if (datasetType_ == "signalMC")
48 <    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 < #endif
59 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
60 >    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
61  
62  
63    // Construct Cutflow Objects. These store the results of cut decisions and
64    // handle filling cut flow histograms.
65    masterCutFlow_ = new CutFlow (fs_);
55  std::vector<TFileDirectory> directories;
66  
67    //always get vertex collection so we can assign the primary vertex in the event
68    objectsToGet.push_back("primaryvertexs");
59
60  //always make the plot of number of primary vertices (to check pile-up reweighting)
69    objectsToPlot.push_back("primaryvertexs");
70 +  objectsToFlag.push_back("primaryvertexs");
71 +
72  
73    //always get the MC particles to do GEN-matching
74    objectsToGet.push_back("mcparticles");
# Line 66 | Line 76 | OSUAnalysis::OSUAnalysis (const edm::Par
76    //always get the event collection to do pile-up reweighting
77    objectsToGet.push_back("events");
78  
79 +
80 +  // Parse the tree variable definitions.
81 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
82 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
83 +    if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
84 +    objectsToGet.push_back(tempInputCollection);
85 +    objectsToFlag.push_back(tempInputCollection);
86 +
87 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
88 +
89 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
90 +      BranchSpecs br;
91 +      br.inputCollection = tempInputCollection;
92 +      br.inputVariable = branchList.at(iBranch);
93 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
94 +      br.name = string(newName.Data());
95 +      treeBranches_.push_back(br);
96 +    }
97 +
98 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
99 +
100 +
101    //parse the histogram definitions
102    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
103  
104      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
105      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
106 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
107 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
108 +    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
109 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
110 +    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
111 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
112 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
113      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
114      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
115 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
116 <      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
117 <        int spaceIndex = tempInputCollection.find(" ");
118 <        int secondWordLength = tempInputCollection.size() - spaceIndex;
119 <        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
115 >    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
116 >    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117 >    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118 >    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
119 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
120 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
121 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
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
89 <      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 +
149  
103    }
150  
151      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
152  
153      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
154  
155 +      vector<double> defaultValue;
156 +      defaultValue.push_back (-1.0);
157 +
158        histogram tempHistogram;
159        tempHistogram.inputCollection = tempInputCollection;
160        tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
161        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
162 <      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
162 >      tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
163 >      tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
164 >      tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
165        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
166  
167        histograms.push_back(tempHistogram);
168  
169      }
170 <  }
170 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
171 >
172    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
173    sort( objectsToPlot.begin(), objectsToPlot.end() );
174    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 127 | Line 179 | OSUAnalysis::OSUAnalysis (const edm::Par
179    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
180  
181      string currentObject = objectsToPlot.at(currentObjectIndex);
182 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
182 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
183  
184      histogram tempIdHisto;
185      histogram tempMomIdHisto;
186      histogram tempGmaIdHisto;
187      histogram tempIdVsMomIdHisto;
188 +    histogram tempIdVsGmaIdHisto;
189  
190      tempIdHisto.inputCollection = currentObject;
191      tempMomIdHisto.inputCollection = currentObject;
192      tempGmaIdHisto.inputCollection = currentObject;
193      tempIdVsMomIdHisto.inputCollection = currentObject;
194 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
195  
196      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
197 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
198  
199      currentObject = currentObject.substr(0, currentObject.size()-1);
200      tempIdHisto.name = currentObject+"GenMatchId";
201      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
202      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
203      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
204 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
205  
206      currentObject.at(0) = toupper(currentObject.at(0));
207      tempIdHisto.title = currentObject+" Gen-matched Particle";
208      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
209      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
210      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
211 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
212 +
213  
214 <    int maxNum = 24;
214 >    int maxNum = 25;
215      vector<double> binVector;
216      binVector.push_back(maxNum);
217      binVector.push_back(0);
# Line 171 | Line 229 | OSUAnalysis::OSUAnalysis (const edm::Par
229      tempIdVsMomIdHisto.bins = binVector;
230      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
231      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
232 +    tempIdVsGmaIdHisto.bins = binVector;
233 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
234 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
235  
236      histograms.push_back(tempIdHisto);
237      histograms.push_back(tempMomIdHisto);
238      histograms.push_back(tempGmaIdHisto);
239      histograms.push_back(tempIdVsMomIdHisto);
240 +    histograms.push_back(tempIdVsGmaIdHisto);
241    }
242  
243  
# Line 191 | Line 253 | OSUAnalysis::OSUAnalysis (const edm::Par
253      //set triggers for this channel
254      vector<string> triggerNames;
255      triggerNames.clear();
256 +    vector<string> triggerToVetoNames;
257 +    triggerToVetoNames.clear();
258 +
259      tempChannel.triggers.clear();
260 +    tempChannel.triggersToVeto.clear();
261      if(channels_.at(currentChannel).exists("triggers")){
262        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
263        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
264          tempChannel.triggers.push_back(triggerNames.at(trigger));
265        objectsToGet.push_back("triggers");
266      }
267 <
267 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
268 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
269 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
270 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
271 >      objectsToGet.push_back("triggers");
272 >    }
273  
274  
275  
276      //create cutFlow for this channel
277      cutFlows_.push_back (new CutFlow (fs_, channelName));
278 <
279 <    //book a directory in the output file with the name of the channel
280 <    TFileDirectory subDir = fs_->mkdir( channelName );
210 <    directories.push_back(subDir);
211 <
212 <    std::map<std::string, TH1D*> oneDhistoMap;
213 <    oneDHists_.push_back(oneDhistoMap);
214 <    std::map<std::string, TH2D*> twoDhistoMap;
215 <    twoDHists_.push_back(twoDhistoMap);
216 <
217 <
218 <
219 <    //book all histograms included in the configuration
220 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
221 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
222 <      int numBinsElements = currentHistogram.bins.size();
223 <      int numInputVariables = currentHistogram.inputVariables.size();
224 <
225 <      if(numBinsElements != 3 && numBinsElements !=6) {
226 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
227 <        exit(0);
228 <      }
229 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
230 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
231 <        exit(0);
232 <      }
233 <      else if(numBinsElements == 3){
234 <        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));
235 <      }
236 <      else if(numBinsElements == 6){
237 <        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));
238 <
239 <      }
240 <
241 <
242 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
243 <
244 <      // bin      particle type
245 <      // ---      -------------
246 <      //  0        unmatched
247 <      //  1        u
248 <      //  2        d
249 <      //  3        s
250 <      //  4        c
251 <      //  5        b
252 <      //  6        t
253 <      //  7        e
254 <      //  8        mu
255 <      //  9        tau
256 <      // 10        nu
257 <      // 11        g
258 <      // 12        gamma
259 <      // 13        Z
260 <      // 14        W
261 <      // 15        light meson
262 <      // 16        K meson
263 <      // 17        D meson
264 <      // 18        B meson
265 <      // 19        light baryon
266 <      // 20        strange baryon
267 <      // 21        charm baryon
268 <      // 22        bottom baryon
269 <      // 23        other
270 <
271 <      vector<TString> labelArray;
272 <      labelArray.push_back("unmatched");
273 <      labelArray.push_back("u");
274 <      labelArray.push_back("d");
275 <      labelArray.push_back("s");
276 <      labelArray.push_back("c");
277 <      labelArray.push_back("b");
278 <      labelArray.push_back("t");
279 <      labelArray.push_back("e");
280 <      labelArray.push_back("#mu");
281 <      labelArray.push_back("#tau");
282 <      labelArray.push_back("#nu");
283 <      labelArray.push_back("g");
284 <      labelArray.push_back("#gamma");
285 <      labelArray.push_back("Z");
286 <      labelArray.push_back("W");
287 <      labelArray.push_back("light meson");
288 <      labelArray.push_back("K meson");
289 <      labelArray.push_back("D meson");
290 <      labelArray.push_back("B meson");
291 <      labelArray.push_back("light baryon");
292 <      labelArray.push_back("strange baryon");
293 <      labelArray.push_back("charm baryon");
294 <      labelArray.push_back("bottom baryon");
295 <      labelArray.push_back("other");
296 <
297 <      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
298 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
299 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
300 <        }
301 <        else {
302 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
303 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
304 <        }
305 <      }
306 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
307 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
308 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
309 <      }
310 <
311 <    }
312 <
313 <    // Book a histogram for the number of each object type to be plotted.  
314 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
315 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
316 <      string currentObject = objectsToPlot.at(currentObjectIndex);
317 <      int maxNum = 10;
318 <      if(currentObject == "mcparticles") maxNum = 50;
319 <      else if(currentObject == "primaryvertexs") maxNum = 50;
320 <
321 <      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
322 <      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
323 <      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
324 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
325 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
326 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
327 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
328 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
329 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
330 <      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
331 <      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
332 <
333 <      currentObject.at(0) = toupper(currentObject.at(0));  
334 <      string histoName = "num" + currentObject;
335 <
336 <      if(histoName == "numPrimaryvertexs"){
337 <        string newHistoName = histoName + "BeforePileupCorrection";
338 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
339 <        newHistoName = histoName + "AfterPileupCorrection";
340 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
341 <      }
342 <      else
343 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
344 <    }
345 <
346 <
347 <
348 <
278 >    vector<TFileDirectory> directories; //vector of directories in the output file.
279 >    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
280 >    vector<string> subSubDirNames;//subdirectories in each channel.
281      //get list of cuts for this channel
282      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
283  
284 +
285      //loop over and parse all cuts
286      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
287        cut tempCut;
288        //store input collection for cut
289        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
290        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
291 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
292 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
293 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
294 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
295 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
296 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
297 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
298        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
299        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
300 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
301 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
302 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
303 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
304 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
305 +      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
306 +      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
307        tempCut.inputCollection = tempInputCollection;
308 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
309 <        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
310 <          int spaceIndex = tempInputCollection.find(" ");
311 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
312 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
313 <        }
314 <        else{
315 <          objectsToGet.push_back(tempInputCollection);
316 <        }
317 <        objectsToCut.push_back(tempInputCollection);
308 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
309 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
310 >          int spaceIndex = tempInputCollection.find(" ");
311 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
312 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
313 >        }
314 >        else{
315 >          objectsToGet.push_back(tempInputCollection);
316 >        }
317 >        objectsToCut.push_back(tempInputCollection);
318 >        objectsToFlag.push_back(tempInputCollection);
319        }
320        else{//pair of objects, need to add them both to objectsToGet
321 <        string obj1;
322 <        string obj2;
323 <        getTwoObjs(tempInputCollection, obj1, obj2);
324 <        string obj2ToGet = getObjToGet(obj2);  
321 >        string obj1;
322 >        string obj2;
323 >        getTwoObjs(tempInputCollection, obj1, obj2);
324 >        string obj2ToGet = getObjToGet(obj2);
325          objectsToCut.push_back(tempInputCollection);
326          objectsToCut.push_back(obj1);
327 <        objectsToCut.push_back(obj2);  
327 >        objectsToCut.push_back(obj2);
328 >        objectsToFlag.push_back(tempInputCollection);
329 >        objectsToFlag.push_back(obj1);
330 >        objectsToFlag.push_back(obj2);
331          objectsToGet.push_back(tempInputCollection);
332          objectsToGet.push_back(obj1);
333          objectsToGet.push_back(obj2ToGet);
# Line 387 | Line 338 | OSUAnalysis::OSUAnalysis (const edm::Par
338  
339        //split cut string into parts and store them
340        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
341 <      std::vector<string> cutStringVector = splitString(cutString);
341 >      vector<string> cutStringVector = splitString(cutString);
342        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
343 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
343 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
344          exit(0);
345        }
346        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
347        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
348          int indexOffset = 4 * subcutIndex;
349          string currentVariableString = cutStringVector.at(indexOffset);
350 <        if(currentVariableString.find("(")==std::string::npos){
350 >        if(currentVariableString.find("(")==string::npos){
351            tempCut.functions.push_back("");//no function was specified
352            tempCut.variables.push_back(currentVariableString);// variable to cut on
353          }
# Line 407 | Line 358 | OSUAnalysis::OSUAnalysis (const edm::Par
358          }
359          tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
360          tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
361 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
362          if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
363        }
364  
365        //get number of objects required to pass cut for event to pass
366        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
367 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
367 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
368        if(numberRequiredVector.size()!=2){
369 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
369 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
370          exit(0);
371        }
372  
# Line 422 | Line 374 | OSUAnalysis::OSUAnalysis (const edm::Par
374        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
375        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
376  
377 <
377 >      //Set up vectors to store the directories and subDirectories for each channel.
378 >      string subSubDirName;
379        string tempCutName;
380        if(cuts_.at(currentCut).exists("alias")){
381          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
382 +        subSubDirName = "After " + tempCutName + " Cut Applied";
383        }
384        else{
385          //construct string for cutflow table
# Line 433 | Line 387 | OSUAnalysis::OSUAnalysis (const edm::Par
387          string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
388          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
389          tempCutName = cutName;
390 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
391 +      }
392 +
393 +      tempCut.isVeto = false;
394 +      if(cuts_.at(currentCut).exists("isVeto")){
395 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
396 +        if (isVeto == true) tempCut.isVeto = true;
397        }
398 +      subSubDirNames.push_back(subSubDirName);
399        tempCut.name = tempCutName;
400  
401        tempChannel.cuts.push_back(tempCut);
# Line 441 | Line 403 | OSUAnalysis::OSUAnalysis (const edm::Par
403  
404      }//end loop over cuts
405  
406 +    vector<map<string, TH1D*>> oneDHistsTmp;
407 +    vector<map<string, TH2D*>> twoDHistsTmp;
408 +    //book a directory in the output file with the name of the channel
409 +    TFileDirectory subDir = fs_->mkdir( channelName );
410 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
411 +    if(GetPlotsAfterEachCut_){
412 +      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
413 +        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
414 +        directories.push_back(subSubDir);
415 +        map<string, TH1D*> oneDhistoMap;
416 +        oneDHistsTmp.push_back(oneDhistoMap);
417 +        map<string, TH2D*> twoDhistoMap;
418 +        twoDHistsTmp.push_back(twoDhistoMap);
419 +      }
420 +      treeDirectories.push_back(subDir);
421 +      oneDHists_.push_back(oneDHistsTmp);
422 +      twoDHists_.push_back(twoDHistsTmp);
423 +    }
424 +    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
425 +    else{
426 +      map<string, TH1D*> oneDhistoMap;
427 +      oneDHistsTmp.push_back(oneDhistoMap);
428 +      map<string, TH2D*> twoDhistoMap;
429 +      twoDHistsTmp.push_back(twoDhistoMap);
430 +      oneDHists_.push_back(oneDHistsTmp);
431 +      twoDHists_.push_back(twoDHistsTmp);
432 +      directories.push_back(subDir);
433 +      treeDirectories.push_back(subDir);
434 +
435 +    }
436 +
437 +    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
438 +      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
439 +      BNTrees_.push_back(newTree);
440 +      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
441 +        BranchSpecs currentVar = treeBranches_.at(iBranch);
442 +        vector<float> newVec;
443 +        BNTreeBranchVals_[currentVar.name] = newVec;
444 +        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
445 +      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
446 +    }
447 +
448 +    //book all histograms included in the configuration
449 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
450 +
451 +      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
452 +
453 +        histogram currentHistogram = histograms.at(currentHistogramIndex);
454 +        int numBinsElements = currentHistogram.bins.size();
455 +        int numInputVariables = currentHistogram.inputVariables.size();
456 +        int numBinEdgesX = currentHistogram.variableBinsX.size();
457 +        int numBinEdgesY = currentHistogram.variableBinsY.size();
458 +
459 +        if(numBinsElements == 1){
460 +          if(numBinEdgesX > 1){
461 +            if(numBinEdgesY > 1)
462 +              numBinsElements = 6;
463 +            else
464 +              numBinsElements = 3;
465 +          }
466 +        }
467 +        if(numBinsElements != 3 && numBinsElements !=6){
468 +          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
469 +          exit(0);
470 +        }
471 +        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
472 +          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
473 +          exit(0);
474 +        }
475 +        else if(numBinsElements == 3){
476 +          if (currentHistogram.bins.size () == 3)
477 +            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));
478 +          else
479 +            {
480 +              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
481 +            }
482 +        }
483 +        else if(numBinsElements == 6){
484 +          if (currentHistogram.bins.size () == 6)
485 +            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));
486 +          else
487 +            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 ());
488 +        }
489 +
490 +
491 +        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
492 +
493 +        // bin      particle type
494 +        // ---      -------------
495 +        //  0        unmatched
496 +        //  1        u
497 +        //  2        d
498 +        //  3        s
499 +        //  4        c
500 +        //  5        b
501 +        //  6        t
502 +        //  7        e
503 +        //  8        mu
504 +        //  9        tau
505 +        // 10        nu
506 +        // 11        g
507 +        // 12        gamma
508 +        // 13        Z
509 +        // 14        W
510 +        // 15        light meson
511 +        // 16        K meson
512 +        // 17        D meson
513 +        // 18        B meson
514 +        // 19        light baryon
515 +        // 20        strange baryon
516 +        // 21        charm baryon
517 +        // 22        bottom baryon
518 +        // 23        QCD string
519 +        // 24        other
520 +
521 +        vector<TString> labelArray;
522 +        labelArray.push_back("unmatched");
523 +        labelArray.push_back("u");
524 +        labelArray.push_back("d");
525 +        labelArray.push_back("s");
526 +        labelArray.push_back("c");
527 +        labelArray.push_back("b");
528 +        labelArray.push_back("t");
529 +        labelArray.push_back("e");
530 +        labelArray.push_back("#mu");
531 +        labelArray.push_back("#tau");
532 +        labelArray.push_back("#nu");
533 +        labelArray.push_back("g");
534 +        labelArray.push_back("#gamma");
535 +        labelArray.push_back("Z");
536 +        labelArray.push_back("W");
537 +        labelArray.push_back("light meson");
538 +        labelArray.push_back("K meson");
539 +        labelArray.push_back("D meson");
540 +        labelArray.push_back("B meson");
541 +        labelArray.push_back("light baryon");
542 +        labelArray.push_back("strange baryon");
543 +        labelArray.push_back("charm baryon");
544 +        labelArray.push_back("bottom baryon");
545 +        labelArray.push_back("QCD string");
546 +        labelArray.push_back("other");
547 +
548 +        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
549 +          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
550 +            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
551 +          }
552 +          else {
553 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
554 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
555 +          }
556 +        }
557 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
558 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
559 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
560 +        }
561 +
562 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
563 +
564 +
565 +      // Book a histogram for the number of each object type to be plotted.
566 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
567 +      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
568 +        string currentObject = objectsToPlot.at(currentObjectIndex);
569 +        int maxNum = 10;
570 +        if(currentObject == "mcparticles") maxNum = 50;
571 +        else if(currentObject == "primaryvertexs") maxNum = 50;
572 +
573 +        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
574 +        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
575 +        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
576 +        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
577 +        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
578 +        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
579 +        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
580 +        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
581 +        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
582 +        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
583 +        else if(currentObject == "photon-jet pairs")          currentObject = "photonJetPairs";
584 +        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
585 +        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
586 +        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
587 +        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
588 +        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
589 +        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
590 +        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
591 +        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
592 +        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
593 +        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
594 +        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
595 +        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
596 +        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
597 +        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
598 +        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
599 +        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
600 +        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
601 +
602 +        currentObject.at(0) = toupper(currentObject.at(0));
603 +        string histoName = "num" + currentObject;
604 +
605 +        if(histoName == "numPrimaryvertexs"){
606 +          string newHistoName = histoName + "BeforePileupCorrection";
607 +          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);
608 +          newHistoName = histoName + "AfterPileupCorrection";
609 +          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);
610 +        }
611 +        else
612 +          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
613 +      }
614 +    }//end of loop over directories
615      channels.push_back(tempChannel);
616      tempChannel.cuts.clear();
446
617    }//end loop over channels
618  
619  
# Line 453 | Line 623 | OSUAnalysis::OSUAnalysis (const edm::Par
623    //make unique vector of objects we need to cut on
624    sort( objectsToCut.begin(), objectsToCut.end() );
625    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
626 +  //make unique vector of objects we need to set flags for
627 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
628 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
629  
630 +  produces<map<string, bool> > ("channelDecisions");
631 +
632 + } // end constructor OSUAnalysis::OSUAnalysis()
633  
458 }
634  
635   OSUAnalysis::~OSUAnalysis ()
636   {
637 +
638    // Destroying the CutFlow objects causes the cut flow numbers and time
639    // information to be printed to standard output.
640    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
641      delete cutFlows_.at(currentChannel);
642    }
643 +
644 +  cout << "=============================================" << endl;  
645 +  cout << "Successfully completed OSUAnalysis." << endl;  
646 +  cout << "=============================================" << endl;  
647 +
648   }
649  
650   void
651 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
651 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
652   {
472
653    // Retrieve necessary collections from the event.
654  
655 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
655 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
656      event.getByLabel (triggers_, triggers);
657  
658 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
658 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
659 >    event.getByLabel (trigobjs_, trigobjs);
660 >
661 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
662      event.getByLabel (jets_, jets);
663  
664 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
664 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
665      event.getByLabel (muons_, muons);
666  
667 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
667 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
668      event.getByLabel (electrons_, electrons);
669  
670 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
670 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
671      event.getByLabel (events_, events);
672  
673 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
673 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
674      event.getByLabel (taus_, taus);
675  
676 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
676 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
677      event.getByLabel (mets_, mets);
678  
679 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
679 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
680      event.getByLabel (tracks_, tracks);
681  
682 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
682 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
683      event.getByLabel (genjets_, genjets);
684  
685 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
685 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
686      event.getByLabel (mcparticles_, mcparticles);
687  
688 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
688 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
689      event.getByLabel (primaryvertexs_, primaryvertexs);
690  
691 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
691 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
692      event.getByLabel (bxlumis_, bxlumis);
693  
694 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
694 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
695      event.getByLabel (photons_, photons);
696  
697 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
697 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
698      event.getByLabel (superclusters_, superclusters);
699  
700 <  if (useTrackCaloRhoCorr_) {  
701 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
702 <    // This rho collection is not available in all BEANs.  
700 >  if (datasetType_ == "signalMC"){
701 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
702 >      event.getByLabel (stops_, stops);
703 >  }
704 >
705 >  if (useTrackCaloRhoCorr_) {
706 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
707 >    // This rho collection is not available in all BEANs.
708      // For description of rho values for different jet reconstruction algorithms, see
709 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
710 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
709 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
710 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
711    }
712  
713 +  double masterScaleFactor = 1.0;
714  
715    //get pile-up event weight
716 <  double scaleFactor = 1.00;
717 <  if(doPileupReweighting_ && datasetType_ != "data")
718 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
719 <
720 <  cTauScaleFactor_ = 1.0;
721 < #ifdef DISPLACED_SUSY
722 <  if (datasetType_ == "signalMC")
723 <    cTauScaleFactor_ = cTauWeight_->at (event);
724 < #endif
725 <  scaleFactor *= cTauScaleFactor_;
716 >  if (doPileupReweighting_ && datasetType_ != "data") {
717 >    //for "data" datasets, the numTruePV is always set to -1
718 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
719 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
720 >  }
721 >
722 >  stopCTauScaleFactor_ = 1.0;
723 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
724 >    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
725 >  masterScaleFactor *= stopCTauScaleFactor_;
726  
727    //loop over all channels
728  
729 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
730    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
731      channel currentChannel = channels.at(currentChannelIndex);
732  
# Line 544 | Line 734 | OSUAnalysis::analyze (const edm::Event &
734      counterMap passingCounter;
735      cumulativeFlags.clear ();
736  
737 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
738 +         iter != BNTreeBranchVals_.end(); iter++) {
739 +      iter->second.clear();  // clear array
740 +    }
741 +
742      bool triggerDecision = true;
743 <    if(currentChannel.triggers.size() != 0){  //triggers specified
744 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
743 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
744 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
745        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
746      }
747  
748      //loop over all cuts
554
555
556
749      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
750        cut currentCut = currentChannel.cuts.at(currentCutIndex);
751  
752 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
753 <        string currentObject = objectsToCut.at(currentObjectIndex);
752 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
753 >        string currentObject = objectsToFlag.at(currentObjectIndex);
754  
755          //initialize maps to get ready to set cuts
756 <        individualFlags[currentObject].push_back (vector<bool> ());
757 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
756 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
757 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
758  
759        }
568      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
569        string currentObject = objectsToCut.at(currentObjectIndex);
570
571        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
760  
761 +      //set flags for all relevant objects
762 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
763 +        string currentObject = objectsToFlag.at(currentObjectIndex);
764  
765 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
765 >        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
766  
576        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
767  
768 +        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
769 +        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
770 +        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
771          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
772 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
773          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
774          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
775          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 587 | Line 781 | OSUAnalysis::analyze (const edm::Event &
781          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
782          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
783          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
784 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
785 +
786  
787  
788          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
# Line 595 | Line 791 | OSUAnalysis::analyze (const edm::Event &
791                                                                     "muon-muon pairs");
792  
793          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
794 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
795 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
796 <                                                                   "muon-secondary muon pairs");
794 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
795 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
796 >                                                                             "muon-secondary muon pairs");
797 >
798 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
799 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
800 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
801 >                                                                             "muon-secondary jet pairs");
802 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
803 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
804 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
805 >                                                                             "photon-secondary jet pairs");
806 >
807 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
808 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
809 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
810 >                                                                             "electron-secondary jet pairs");
811 >
812 >        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
813 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
814 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
815 >                                                                                     "electron-secondary electron pairs");
816  
817          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
818                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 607 | Line 822 | OSUAnalysis::analyze (const edm::Event &
822                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
823                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
824                                                                         "electron-muon pairs");
825 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
826 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
827 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
828 <                                                                     "track-event pairs");
829 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
830 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
831 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
832 <                                                                        "electron-track pairs");
833 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
834 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
835 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
836 <                                                                    "muon-track pairs");
837 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
838 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
839 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
840 <                                                                  "muon-tau pairs");
841 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
842 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
843 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
844 <                                                                 "tau-tau pairs");
845 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
825 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
826 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
827 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
828 >                                                                 "jet-jet pairs");
829 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
830 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
831 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
832 >                                                                 "jet-secondary jet pairs");
833 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
834 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
835 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
836 >                                                                      "electron-jet pairs");
837 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
838 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
839 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
840 >                                                                      "electron-photon pairs");
841 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
842 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
843 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
844 >                                                                      "photon-jet pairs");
845 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
846 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
847 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
848 >                                                                  "muon-jet pairs");
849 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
850 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
851 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
852 >                                                                  "met-jet pairs");
853 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
854 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
855 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
856 >                                                                 "track-jet pairs");
857 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
858 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
859 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
860 >                                                                  "muon-photon pairs");
861 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
862 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
863 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
864 >                                                                     "track-event pairs");
865 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
866 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
867 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
868 >                                                                        "electron-track pairs");
869 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
870 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
871 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
872 >                                                                    "muon-track pairs");
873 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
874 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
875 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
876 >                                                                  "muon-tau pairs");
877 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
878                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
879 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
880 <                                                                 "tau-track pairs");
881 <        
882 <        
879 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
880 >                                                                 "tau-tau pairs");
881 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
882 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
883 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
884 >                                                                   "tau-track pairs");
885 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
886 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
887 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
888 >                                                                          "electron-trigobj pairs");
889 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
890 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
891 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
892 >                                                                      "muon-trigobj pairs");
893 >
894 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
895        }
896  
897  
898  
899      }//end loop over all cuts
641
642
900      //use cumulative flags to apply cuts at event level
901  
902 +    //a vector to store cumulative cut descisions after each cut.
903 +    vector<bool> eventPassedPreviousCuts;
904      bool eventPassedAllCuts = true;
646
905      //apply trigger (true if none were specified)
906      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
907  
650
908      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
909  
910        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 655 | Line 912 | OSUAnalysis::analyze (const edm::Event &
912        int numberPassing = 0;
913  
914        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
915 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
915 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
916        }
917        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
918        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
919        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
920 +      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
921 +    }
922  
923 +    //applying all appropriate scale factors
924 +    double scaleFactor = masterScaleFactor;
925 +    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
926 +
927 +    if(applyLeptonSF_ && datasetType_ != "data"){
928 +      //only apply SFs if we've cut on this object
929 +      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
930 +        flagPair muonFlags;
931 +        //get the last valid flags in the flag map
932 +        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
933 +          if (cumulativeFlags.at("muons").at(i).size()){
934 +            muonFlags = cumulativeFlags.at("muons").at(i);
935 +            break;
936 +          }
937 +        }
938 +        //apply the weight for each of those objects
939 +        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
940 +          if(!muonFlags.at(muonIndex).second) continue;
941 +          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
942 +        }
943 +      }
944 +      //only apply SFs if we've cut on this object
945 +      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
946 +        flagPair electronFlags;
947 +        //get the last valid flags in the flag map
948 +        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
949 +          if (cumulativeFlags.at("electrons").at(i).size()){
950 +            electronFlags = cumulativeFlags.at("electrons").at(i);
951 +            break;
952 +          }
953 +        }
954 +        //apply the weight for each of those objects
955 +        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
956 +          if(!electronFlags.at(electronIndex).second) continue;
957 +          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
958 +        }
959 +      }
960      }
961 +    if(applyBtagSF_ && datasetType_ != "data"){
962 +      //only apply SFs if we've cut on this object
963 +      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
964 +        flagPair jetFlags;
965 +        vector<double> jetSFs;
966 +        //get the last valid flags in the flag map
967 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
968 +          if (cumulativeFlags.at("jets").at(i).size()){
969 +            jetFlags = cumulativeFlags.at("jets").at(i);
970 +            break;
971 +          }
972 +        }
973 +        //apply the weight for each of those objects
974 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
975 +          if(!jetFlags.at(jetIndex).second) continue;
976 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
977 +          jetSFs.push_back(jetSFTmp);
978 +        }
979 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
980 +      }
981 +    }
982 +    scaleFactor *= muonScaleFactor_;
983 +    scaleFactor *= electronScaleFactor_;
984 +    scaleFactor *= bTagScaleFactor_;
985 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
986  
987 <    //     if(datasetType_ != "data") {
988 <    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
989 <    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
990 <    //     }
987 >    if (printEventInfo_) {
988 >      // Write information about event to screen, for testing purposes.
989 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
990 >           << ": run="  << events->at(0).run
991 >           << "  lumi=" << events->at(0).lumi
992 >           << "  event=" << events->at(0).evt
993 >           << endl;
994 >    }
995  
671    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
996  
997 +    //filling histograms
998 +    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
999 +      uint currentDir;
1000 +      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1001 +      else{
1002 +        currentDir = currentCut;
1003 +      }
1004  
1005  
1006 <    if(!eventPassedAllCuts)continue;
1006 >      if(eventPassedPreviousCuts.at(currentDir)){
1007  
1008 <    if (printEventInfo_) {
1009 <      // Write information about event to screen, for testing purposes.  
679 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
680 <           << ": run="  << events->at(0).run
681 <           << "  lumi=" << events->at(0).lumi
682 <           << "  event=" << events->at(0).evt
683 <           << endl;  
684 <    }
1008 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1009 >          histogram currentHistogram = histograms.at(histogramIndex);
1010  
1011 +          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1012 +
1013 +          if(currentHistogram.inputVariables.size() == 1){
1014 +            TH1D* histo;
1015 +            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1016 +            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1017 +            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1018 +            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1019 +            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1020 +            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1021 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1022 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1023 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1024 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1025 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1026 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1027 +             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1028 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1029 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1030 +             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1031 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1032 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1033 +             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1034 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1035 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1036 +
1037 +            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1038 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1039 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1040 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1041 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1042 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1043 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1044 +             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1045 +                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1046 +                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1047 +
1048 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1049 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1050 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1051 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1052 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1053 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1054 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1055 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1056 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1057 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1058 +                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1059 +                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1060 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1061 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1062 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1063 +            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1064 +                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1065 +                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1066 +            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1067 +                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1068 +                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1069 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1070 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1071 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1072 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1073 +                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1074 +                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1075 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1076 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1077 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1078 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1079 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1080 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1081 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1082 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1083 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1084 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1085 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1086 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1087 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1088 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1089 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1090 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1091 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1092 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1093 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1094 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1095 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1096 +
1097 +            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1098 +            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1099 +            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1100 +            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1101 +            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1102 +            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1103 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1104 +            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1105 +            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1106 +            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1107 +            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1108 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1109 +          }
1110 +          else if(currentHistogram.inputVariables.size() == 2){
1111 +            TH2D* histo;
1112 +            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1113 +            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1114 +            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1115 +            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1116 +            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1117 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1118 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1119 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1120 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1121 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1122 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1123 +            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1124 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1125 +                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1126 +            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1127 +                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1128 +                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1129 +            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1130 +                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1131 +                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1132 +            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1133 +            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1134 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1135 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1136 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1137 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1138 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1139 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1140 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1141 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1142 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1143 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1144 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1145 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1146 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1147 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1148 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1149 +            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1150 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1151 +                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1152 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1153 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1154 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1155 +            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1156 +                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1157 +                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1158 +            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1159 +                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1160 +                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1161 +            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1162 +                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1163 +                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1164 +            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1165 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1166 +                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1167 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1168 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1169 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1170 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1171 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1172 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1173 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1174 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1175 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1176 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1177 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1178 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1179 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1180 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1181 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1182 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1183 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1184 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1185 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1186 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1187 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1188 +            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1189 +            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1190 +            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1191 +            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1192 +            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1193 +                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1194 +                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1195 +            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1196 +            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1197 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1198 +            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1199 +            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1200 +            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1201 +            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1202 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1203 +          }
1204  
1205 <    //filling histograms
688 <    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
689 <      histogram currentHistogram = histograms.at(histogramIndex);
1205 >        }
1206  
691      if(currentHistogram.inputVariables.size() == 1){
692        TH1D* histo;
693        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
694
695        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
696        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
697        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
698        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
699                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
700                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
701        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
702                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
703                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
704        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
705        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
706                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
707                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
708        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
709                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
710                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
711        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
712                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
713                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
714        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
715                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
716                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
717        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
718                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
719                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
720        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
721                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
722                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
723        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
724                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
725                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
726
727        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
728        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
729        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
730        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
731        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
732        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
733        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
734        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
735        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
736        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
737      }
738      else if(currentHistogram.inputVariables.size() == 2){
739        TH2D* histo;
740        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
741
742        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
743        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
744        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
745        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
746                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
747                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
748        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
749                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
750                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
751        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
752        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
753                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
754                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
755        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
756                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
757                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
758        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
759                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
760                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
761        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
762                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
763                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
764        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
765                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
766                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
767        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
768                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
769                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
770        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
771                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
772                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
773        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
774        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
775        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
776        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
777        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
778                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
779                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
780        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
781        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
782        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
783        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
784        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
785        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
786      }
787    }
1207  
1208 +        //fills histograms with the sizes of collections
1209 +        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1210  
1211 +          string currentObject = objectsToPlot.at(currentObjectIndex);
1212 +          string objectToPlot = "";
1213  
1214 <    //fills histograms with the sizes of collections
1215 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1216 <
1217 <      string currentObject = objectsToPlot.at(currentObjectIndex);
1218 <
1219 <      string objectToPlot = "";  
1220 <
1221 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
1222 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
1223 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
1224 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
1225 <      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
1226 <      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
1227 <      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
1228 <      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
1229 <      else if(currentObject == "tau-track pairs")         objectToPlot = "tauTrackPairs";
1230 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
1231 <      else if(currentObject == "muon-secondary muon pairs")       objectToPlot = "muonSecondaryMuonPairs";  
1232 <      else if(currentObject == "secondary muons")         objectToPlot = "secondaryMuons";  
1233 <      else objectToPlot = currentObject;
1234 <
1235 <      string tempCurrentObject = objectToPlot;
1236 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
1237 <      string histoName = "num" + tempCurrentObject;
1238 <
1239 <      //set position of primary vertex in event, in order to calculate quantities relative to it
1240 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1241 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
1242 <        int numToPlot = 0;
1243 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1244 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1245 <        }
1246 <        if(objectToPlot == "primaryvertexs"){
1247 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1248 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1249 <        }
1250 <        else {
1251 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
1252 <        }
1253 <      }
1254 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
1255 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1256 <      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1257 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1258 <      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1259 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1260 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1261 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1262 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1263 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1264 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1265 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
1266 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
1267 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
1268 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1269 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1270 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1271 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1272 <      else if(objectToPlot == "primaryvertexs"){
1273 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1274 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1275 <      }
1214 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1215 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1216 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1217 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1218 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1219 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1220 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1221 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1222 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1223 >          else if(currentObject == "muon-photon pairs")                  objectToPlot = "muonPhotonPairs";
1224 >          else if(currentObject == "photon-jet pairs")                   objectToPlot = "photonJetPairs";
1225 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1226 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1227 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1228 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1229 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1230 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1231 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1232 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1233 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1234 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1235 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1236 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1237 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1238 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1239 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1240 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1241 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1242 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1243 >          else objectToPlot = currentObject;
1244 >
1245 >          string tempCurrentObject = objectToPlot;
1246 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1247 >          string histoName = "num" + tempCurrentObject;
1248 >
1249 >
1250 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1251 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1252 >            int numToPlot = 0;
1253 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1254 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1255 >            }
1256 >
1257 >            if(objectToPlot == "primaryvertexs"){
1258 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1259 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1260 >            }
1261 >            else {
1262 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1263 >            }
1264 >          }
1265 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1266 >
1267 >
1268 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1269 >    } // end loop over cuts
1270 >
1271 >    if (!useEDMFormat_ && eventPassedAllCuts){
1272 >      // Assign BNTree variables
1273 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1274 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1275 >        string coll = brSpecs.inputCollection;
1276 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1277 >
1278 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1279 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1280 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1281 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1282 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1283 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1284 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1285 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1286 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1287 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1288 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1289 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1290 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1291 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1292 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1293 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1294 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1295 >        else if(coll == "stops"
1296 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1297 >      } // end loop over branches
1298 >
1299 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1300 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1301 >    }
1302 >
1303 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1304  
1305 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1305 >  } // end loop over channel
1306  
1307 <  } //end loop over channel
1307 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1308  
1309 <  masterCutFlow_->fillCutFlow(scaleFactor);
1309 >  event.put (channelDecisions, "channelDecisions");
1310  
1311   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1312  
# Line 872 | Line 1323 | OSUAnalysis::evaluateComparison (double
1323    else if(comparison == "==") return testValue == cutValue;
1324    else if(comparison == "=") return testValue == cutValue;
1325    else if(comparison == "!=") return testValue != cutValue;
1326 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1326 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1327  
1328   }
1329  
1330   bool
1331 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1331 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1332  
1333 +
1334 +  if(comparison == ">")       return testValue >  cutValue;
1335 +  else if(comparison == ">=") return testValue >= cutValue;
1336 +  else if(comparison == "<")  return testValue <  cutValue;
1337 +  else if(comparison == "<=") return testValue <= cutValue;
1338 +  else if(comparison == "==") return testValue == cutValue;
1339 +  else if(comparison == "=") return testValue == cutValue;
1340 +  else if(comparison == "!=") return testValue != cutValue;
1341 +  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1342 +
1343 + }
1344 +
1345 + bool
1346 + OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1347 +
1348 +  //initialize to false until a chosen trigger is passed
1349    bool triggerDecision = false;
1350  
1351 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1352 <    {
1353 <      if(trigger->pass != 1) continue;
1354 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1355 <        {
1356 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
1357 <            triggerDecision = true;
1358 <          }
1359 <        }
1351 >  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1352 >  //loop over all triggers defined in the event
1353 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1354 >
1355 >    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1356 >
1357 >    //we're only interested in triggers that actually passed
1358 >    if(trigger->pass != 1) continue;
1359 >
1360 >    //if the event passes one of the veto triggers, exit and return false
1361 >    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1362 >      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1363      }
1364 <  return triggerDecision;
1364 >    //if the event passes one of the chosen triggers, set triggerDecision to true
1365 >    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1366 >      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1367 >    }
1368 >  }
1369  
1370 +  printAllTriggers_ = false;  // only print triggers once, not every event
1371 +
1372 +  //if none of the veto triggers fired:
1373 +  //return the OR of all the chosen triggers
1374 +  if (triggersToTest.size() != 0) return triggerDecision;
1375 +  //or if no triggers were defined return true
1376 +  else return true;
1377   }
1378  
1379 < std::vector<std::string>
1379 >
1380 > vector<string>
1381   OSUAnalysis::splitString (string inputString){
1382  
1383 <  std::stringstream stringStream(inputString);
1384 <  std::istream_iterator<std::string> begin(stringStream);
1385 <  std::istream_iterator<std::string> end;
1386 <  std::vector<std::string> stringVector(begin, end);
1383 >  stringstream stringStream(inputString);
1384 >  istream_iterator<string> begin(stringStream);
1385 >  istream_iterator<string> end;
1386 >  vector<string> stringVector(begin, end);
1387    return stringVector;
1388  
1389   }
1390  
1391  
1392   void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1393 <  // Set two object strings from the tempInputCollection string,
1394 <  // For example, if tempInputCollection is "electron-muon pairs",
1395 <  // then obj1 = "electrons" and obj2 = "muons".  
1396 <  // Note that the objects have an "s" appended.  
1393 >  // Set two object strings from the tempInputCollection string,
1394 >  // For example, if tempInputCollection is "electron-muon pairs",
1395 >  // then obj1 = "electrons" and obj2 = "muons".
1396 >  // Note that the objects have an "s" appended.
1397  
1398    int dashIndex = tempInputCollection.find("-");
1399    int spaceIndex = tempInputCollection.find_last_of(" ");
1400    int secondWordLength = spaceIndex - dashIndex;
1401 <  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1401 >  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1402    obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1403 <  
1404 < }
1403 >
1404 > }
1405  
1406  
1407   string OSUAnalysis::getObjToGet(string obj) {
1408    // Return the string corresponding to the object to get for the given obj string.
1409 <  // Right now this only handles the case in which obj contains "secondary",
1410 <  // e.g, "secondary muons".  
1411 <  // Note that "s" is NOT appended.  
930 <  
931 <  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
932 <  int firstSpaceIndex = obj.find_first_of(" ");  
933 <  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1409 >  // Right now this only handles the case in which obj contains "secondary",
1410 >  // e.g, "secondary muons".
1411 >  // Note that "s" is NOT appended.
1412  
1413 < }  
1413 >  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1414 >  int firstSpaceIndex = obj.find_first_of(" ");
1415 >  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1416  
1417 + }
1418  
1419  
1420 + //!jet valueLookup
1421   double
1422 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1422 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1423  
1424    double value = 0.0;
1425    if(variable == "energy") value = object->energy;
# Line 1056 | Line 1538 | OSUAnalysis::valueLookup (const BNjet* o
1538    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1539    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1540  
1541 +  //user defined variable
1542 +  else if(variable == "disappTrkLeadingJetID") {
1543 +    value = object->pt > 110
1544 +      && fabs(object->eta) < 2.4
1545 +      && object->chargedHadronEnergyFraction > 0.2
1546 +      && object->neutralHadronEnergyFraction < 0.7
1547 +      && object->chargedEmEnergyFraction < 0.5
1548 +      && object->neutralEmEnergyFraction < 0.7;
1549 +  }
1550 +
1551 +  else if(variable == "disappTrkSubLeadingJetID") {
1552 +    value = object->pt > 30
1553 +      && fabs(object->eta) < 4.5
1554 +      && object->neutralHadronEnergyFraction < 0.7
1555 +      && object->chargedEmEnergyFraction < 0.5;
1556 +  }
1557 +
1558 +  else if(variable == "dPhiMet") {
1559 +    if (const BNmet *met = chosenMET ()) {
1560 +      value = deltaPhi (object->phi, met->phi);
1561 +    } else value = -999;
1562 +  }
1563  
1564 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1564 >
1565 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1566  
1567    value = applyFunction(function, value);
1568  
1569    return value;
1570 < }
1066 <
1570 > } // end jet valueLookup
1571  
1572  
1573 + //!muon valueLookup
1574   double
1575 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1575 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1576  
1577    double value = 0.0;
1578    if(variable == "energy") value = object->energy;
# Line 1222 | Line 1727 | OSUAnalysis::valueLookup (const BNmuon*
1727    else if(variable == "time_ndof") value = object->time_ndof;
1728  
1729    //user-defined variables
1730 +  else if(variable == "looseID") {
1731 +    value = object->pt > 10 &&
1732 +      (object->isGlobalMuon  > 0 ||
1733 +       object->isTrackerMuon > 0);
1734 +  }
1735    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1736    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1737    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1738    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1739    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1740    else if(variable == "metMT") {
1741 <    const BNmet *met = chosenMET ();
1232 <    if (met)
1741 >    if (const BNmet *met = chosenMET ())
1742        {
1743 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1744 <          p2 (met->px, met->py, 0.0, met->pt);
1236 <
1237 <        value = (p1 + p2).Mt ();
1743 >        double dPhi = deltaPhi (object->phi, met->phi);
1744 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1745        }
1746      else
1747        value = -999;
# Line 1352 | Line 1859 | OSUAnalysis::valueLookup (const BNmuon*
1859      value = object->isGlobalMuon > 0                \
1860        && object->isPFMuon > 0                        \
1861        && object->normalizedChi2 < 10                \
1862 <                                  && object->numberOfValidMuonHits > 0        \
1862 >      && object->numberOfValidMuonHits > 0        \
1863        && object->numberOfMatchedStations > 1        \
1864        && fabs(object->correctedD0Vertex) < 0.2        \
1865        && fabs(object->correctedDZ) < 0.5        \
# Line 1361 | Line 1868 | OSUAnalysis::valueLookup (const BNmuon*
1868    }
1869    else if(variable == "tightIDdisplaced"){
1870      value = object->isGlobalMuon > 0                \
1871 +      && object->isPFMuon > 0                        \
1872        && object->normalizedChi2 < 10                \
1873 <                                  && object->numberOfValidMuonHits > 0        \
1873 >      && object->numberOfValidMuonHits > 0        \
1874        && object->numberOfMatchedStations > 1        \
1875        && object->numberOfValidPixelHits > 0        \
1876        && object->numberOfLayersWithMeasurement > 5;
1877    }
1878  
1879 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1879 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1880  
1881    else if(variable == "genMatchedPdgId"){
1882      int index = getGenMatchedParticleIndex(object);
# Line 1388 | Line 1896 | OSUAnalysis::valueLookup (const BNmuon*
1896    }
1897    else if(variable == "genMatchedMotherIdReverse"){
1898      int index = getGenMatchedParticleIndex(object);
1899 <    if(index == -1) value = 23;
1900 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1899 >    if(index == -1) value = 24;
1900 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1901    }
1902    else if(variable == "genMatchedGrandmotherId"){
1903      int index = getGenMatchedParticleIndex(object);
# Line 1401 | Line 1909 | OSUAnalysis::valueLookup (const BNmuon*
1909      }
1910      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1911    }
1912 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1913 +    int index = getGenMatchedParticleIndex(object);
1914 +    if(index == -1) value = 24;
1915 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1916 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1917 +      if(motherIndex == -1) value = 24;
1918 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1919 +    }
1920 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1921 +  }
1922 +  else if(variable == "pfMuonsFromVertex"){
1923 +    double d0Error, dzError;
1924  
1925 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1926 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1927 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1928 +      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1929 +      || fabs (object->correctedDZ / dzError) > 99.0;
1930 +    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1931 +  }
1932  
1933  
1934 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1934 >
1935 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1936  
1937    value = applyFunction(function, value);
1938  
1939    return value;
1940 < }
1940 > } // end muon valueLookup
1941  
1942  
1943 + //!electron valueLookup
1944   double
1945 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1945 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1946  
1947    double value = 0.0;
1948    if(variable == "energy") value = object->energy;
# Line 1579 | Line 2108 | OSUAnalysis::valueLookup (const BNelectr
2108    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2109    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2110    else if(variable == "metMT") {
2111 <    const BNmet *met = chosenMET ();
1583 <    if (met)
2111 >    if (const BNmet *met = chosenMET ())
2112        {
2113 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
2114 <          p2 (met->px, met->py, 0.0, met->pt);
1587 <
1588 <        value = (p1 + p2).Mt ();
2113 >        double dPhi = deltaPhi (object->phi, met->phi);
2114 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
2115        }
2116      else
2117        value = -999;
# Line 1677 | Line 2203 | OSUAnalysis::valueLookup (const BNelectr
2203        }
2204    }
2205  
2206 +  else if(variable == "looseID"){
2207 +    value = object->pt > 10
2208 +      && object->mvaNonTrigV0 > 0;
2209 +      }
2210    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2211      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2212      else value = -999;
# Line 1750 | Line 2280 | OSUAnalysis::valueLookup (const BNelectr
2280    }
2281  
2282  
2283 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2283 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2284  
2285    else if(variable == "genMatchedPdgId"){
2286      int index = getGenMatchedParticleIndex(object);
# Line 1771 | Line 2301 | OSUAnalysis::valueLookup (const BNelectr
2301    }
2302    else if(variable == "genMatchedMotherIdReverse"){
2303      int index = getGenMatchedParticleIndex(object);
2304 <    if(index == -1) value = 23;
2305 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2304 >    if(index == -1) value = 24;
2305 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2306    }
2307    else if(variable == "genMatchedGrandmotherId"){
2308      int index = getGenMatchedParticleIndex(object);
# Line 1784 | Line 2314 | OSUAnalysis::valueLookup (const BNelectr
2314      }
2315      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2316    }
2317 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2318 +    int index = getGenMatchedParticleIndex(object);
2319 +    if(index == -1) value = 24;
2320 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2321 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2322 +      if(motherIndex == -1) value = 24;
2323 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2324 +    }
2325 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2326 +  }
2327 +  else if(variable == "pfElectronsFromVertex"){
2328 +    double d0Error, dzError;
2329  
2330 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2331 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2332 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2333 +      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2334 +      || fabs (object->correctedDZ / dzError) > 99.0;
2335 +    value = !value;
2336 +  }
2337  
2338  
2339 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2339 >
2340 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2341  
2342    value = applyFunction(function, value);
2343  
2344    return value;
2345 < }
2345 > } // end electron valueLookup
2346  
2347  
2348 + //!event valueLookup
2349   double
2350 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
2350 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2351  
2352    double value = 0.0;
2353  
# Line 1865 | Line 2416 | OSUAnalysis::valueLookup (const BNevent*
2416    else if(variable == "id2") value = object->id2;
2417    else if(variable == "evt") value = object->evt;
2418    else if(variable == "puScaleFactor"){
2419 <    if(datasetType_ != "data")
2419 >    if(doPileupReweighting_ && datasetType_ != "data")
2420        value = puWeight_->at (events->at (0).numTruePV);
2421      else
2422        value = 1.0;
2423    }
2424 <  else if(variable == "muonScaleFactor"){
2425 <    if(datasetType_ != "data")
2426 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
2427 <      value = 1.0;
2428 <    else
1878 <      value = 1.0;
1879 <  }
1880 <  else if(variable == "electronScaleFactor"){
1881 <    if(datasetType_ != "data")
1882 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1883 <      value = 1.0;
1884 <    else
1885 <      value = 1.0;
1886 <  }
1887 <  else if(variable == "cTauScaleFactor")
1888 <    value = cTauScaleFactor_;
1889 <
1890 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2424 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2425 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2426 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2427 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2428 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2429  
2430    value = applyFunction(function, value);
2431  
2432    return value;
2433 < }
2433 > } // end event valueLookup
2434 >
2435  
2436 + //!tau valueLookup
2437   double
2438 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2438 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2439  
2440    double value = 0.0;
2441  
# Line 1939 | Line 2479 | OSUAnalysis::valueLookup (const BNtau* o
2479    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2480    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2481  
2482 +  else if (variable == "looseHadronicID") {
2483 +    value = object->pt > 10
2484 +      && object->eta < 2.3
2485 +      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2486 +      && object->HPSdecayModeFinding > 0
2487 +      && object->HPSagainstElectronLoose > 0
2488 +      && object->HPSagainstMuonTight > 0;
2489 +  }
2490  
2491 <
1944 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2491 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2492  
2493    else if(variable == "genMatchedPdgId"){
2494      int index = getGenMatchedParticleIndex(object);
# Line 1961 | Line 2508 | OSUAnalysis::valueLookup (const BNtau* o
2508    }
2509    else if(variable == "genMatchedMotherIdReverse"){
2510      int index = getGenMatchedParticleIndex(object);
2511 <    if(index == -1) value = 23;
2512 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2511 >    if(index == -1) value = 24;
2512 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2513    }
2514    else if(variable == "genMatchedGrandmotherId"){
2515      int index = getGenMatchedParticleIndex(object);
# Line 1974 | Line 2521 | OSUAnalysis::valueLookup (const BNtau* o
2521      }
2522      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2523    }
2524 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2525 +    int index = getGenMatchedParticleIndex(object);
2526 +    if(index == -1) value = 24;
2527 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2528 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2529 +      if(motherIndex == -1) value = 24;
2530 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2531 +    }
2532 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2533 +  }
2534  
2535  
2536 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2536 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2537  
2538    value = applyFunction(function, value);
2539  
2540    return value;
2541 < }
2541 > } // end tau valueLookup
2542  
2543 +
2544 + //!met valueLookup
2545   double
2546 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2546 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2547  
2548    double value = 0.0;
2549  
# Line 2048 | Line 2607 | OSUAnalysis::valueLookup (const BNmet* o
2607    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2608    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2609  
2610 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2610 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2611  
2612    value = applyFunction(function, value);
2613  
2614    return value;
2615 < }
2615 > } // end met valueLookup
2616  
2617 +
2618 + //!track valueLookup
2619   double
2620 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2620 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2621  
2622    double value = 0.0;
2623    double pMag = sqrt(object->pt * object->pt +
2624 <                     object->pz * object->pz);
2625 <  
2624 >                     object->pz * object->pz);
2625 >
2626    if(variable == "pt") value = object->pt;
2627    else if(variable == "px") value = object->px;
2628    else if(variable == "py") value = object->py;
# Line 2080 | Line 2641 | OSUAnalysis::valueLookup (const BNtrack*
2641    else if(variable == "numValidHits") value = object->numValidHits;
2642    else if(variable == "isHighPurity") value = object->isHighPurity;
2643  
2083
2644    //additional BNs info for disappTrks
2645 <  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2646 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2647 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2648 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2649 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2650 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2651 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2652 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2093 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2645 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2646 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2647 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2648 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2649 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2650 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2651 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2652 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2653    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2654 <  
2654 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2655 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2656 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2657 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2658 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2659 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2660 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2661 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2662 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2663 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2664 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2665 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2666 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2667 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2668 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2669 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2670 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2671 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2672  
2673    //user defined variables
2674    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;
2675    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2676 +  else if(variable == "depTrkRp5MinusPt"){
2677 +    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2678 +           value = 0;
2679 +         }
2680 +         else value =  (object->depTrkRp5 - object->pt);
2681 +  }
2682 +  else if(variable == "depTrkRp3MinusPt"){
2683 +    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2684 +      value = 0;
2685 +    }
2686 +    else value =  (object->depTrkRp3 - object->pt);
2687 +  }
2688 +
2689 +  else if(variable == "dPhiMet") {
2690 +    if (const BNmet *met = chosenMET ()) {
2691 +      value = deltaPhi (object->phi, met->phi);
2692 +    } else value = -999;
2693 +  }
2694 +  
2695 +  
2696    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2697    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2698 <  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2699 <  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2698 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2699 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2700    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2701    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2702    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2703    else if(variable == "ptError")                    value = object->ptError;
2704    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2705 <  else if (variable == "d0wrtPV"){      
2706 <    double vx = object->vx - chosenVertex ()->x,        
2707 <      vy = object->vy - chosenVertex ()->y,      
2708 <      px = object->px,  
2709 <      py = object->py,  
2710 <      pt = object->pt;  
2711 <    value = (-vx * py + vy * px) / pt;  
2712 <  }      
2713 <  else if (variable == "dZwrtPV"){      
2714 <    double vx = object->vx - chosenVertex ()->x,        
2715 <      vy = object->vy - chosenVertex ()->y,      
2716 <      vz = object->vz - chosenVertex ()->z,      
2717 <      px = object->px,  
2718 <      py = object->py,  
2719 <      pz = object->pz,  
2720 <      pt = object->pt;  
2721 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2722 <  }    
2723 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2705 >  else if (variable == "d0wrtPV"){
2706 >    double vx = object->vx - chosenVertex ()->x,
2707 >      vy = object->vy - chosenVertex ()->y,
2708 >      px = object->px,
2709 >      py = object->py,
2710 >      pt = object->pt;
2711 >    value = (-vx * py + vy * px) / pt;
2712 >  }
2713 >  else if (variable == "dZwrtPV"){
2714 >    double vx = object->vx - chosenVertex ()->x,
2715 >      vy = object->vy - chosenVertex ()->y,
2716 >      vz = object->vz - chosenVertex ()->z,
2717 >      px = object->px,
2718 >      py = object->py,
2719 >      pz = object->pz,
2720 >      pt = object->pt;
2721 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2722 >  }
2723 >
2724 >
2725 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2726  
2727    else if(variable == "genMatchedPdgId"){
2728      int index = getGenMatchedParticleIndex(object);
# Line 2145 | Line 2743 | OSUAnalysis::valueLookup (const BNtrack*
2743    }
2744    else if(variable == "genMatchedMotherIdReverse"){
2745      int index = getGenMatchedParticleIndex(object);
2746 <    if(index == -1) value = 23;
2747 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2746 >    if(index == -1) value = 24;
2747 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2748    }
2749    else if(variable == "genMatchedGrandmotherId"){
2750      int index = getGenMatchedParticleIndex(object);
# Line 2158 | Line 2756 | OSUAnalysis::valueLookup (const BNtrack*
2756      }
2757      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2758    }
2759 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2760 +    int index = getGenMatchedParticleIndex(object);
2761 +    if(index == -1) value = 24;
2762 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2763 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2764 +      if(motherIndex == -1) value = 24;
2765 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2766 +    }
2767 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2768 +  }
2769  
2770  
2771  
2772 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2772 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2773  
2774    value = applyFunction(function, value);
2775  
2776    return value;
2777 < }
2777 > } // end track valueLookup
2778 >
2779  
2780 + //!genjet valueLookup
2781   double
2782 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2782 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2783  
2784    double value = 0.0;
2785  
# Line 2189 | Line 2799 | OSUAnalysis::valueLookup (const BNgenjet
2799    else if(variable == "charge") value = object->charge;
2800  
2801  
2802 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2802 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2803  
2804    value = applyFunction(function, value);
2805  
2806    return value;
2807   }
2808  
2809 + //!mcparticle valueLookup
2810   double
2811 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2811 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2812  
2813    double value = 0.0;
2814  
# Line 2322 | Line 2933 | OSUAnalysis::valueLookup (const BNmcpart
2933    }
2934  
2935  
2936 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2936 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2937  
2938    value = applyFunction(function, value);
2939  
2940    return value;
2941 < }
2941 > } // end mcparticle valueLookup
2942  
2943 +
2944 + //!primaryvertex valueLookup
2945   double
2946 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2946 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2947  
2948    double value = 0.0;
2949  
# Line 2349 | Line 2962 | OSUAnalysis::valueLookup (const BNprimar
2962    else if(variable == "isGood") value = object->isGood;
2963  
2964  
2965 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2965 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2966  
2967    value = applyFunction(function, value);
2968  
2969    return value;
2970   }
2971  
2972 + //!bxlumi valueLookup
2973   double
2974 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2974 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2975  
2976    double value = 0.0;
2977  
# Line 2366 | Line 2980 | OSUAnalysis::valueLookup (const BNbxlumi
2980    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2981  
2982  
2983 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2983 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2984  
2985    value = applyFunction(function, value);
2986  
2987    return value;
2988   }
2989  
2990 + //!photon valueLookup
2991   double
2992 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2992 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2993  
2994    double value = 0.0;
2995  
# Line 2449 | Line 3064 | OSUAnalysis::valueLookup (const BNphoton
3064    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
3065  
3066  
2452
3067  
3068 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
3068 >
3069 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
3070  
3071    else if(variable == "genMatchedPdgId"){
3072      int index = getGenMatchedParticleIndex(object);
# Line 2473 | Line 3088 | OSUAnalysis::valueLookup (const BNphoton
3088    }
3089    else if(variable == "genMatchedMotherIdReverse"){
3090      int index = getGenMatchedParticleIndex(object);
3091 <    if(index == -1) value = 23;
3092 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
3091 >    if(index == -1) value = 24;
3092 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
3093    }
3094    else if(variable == "genMatchedGrandmotherId"){
3095      int index = getGenMatchedParticleIndex(object);
# Line 2486 | Line 3101 | OSUAnalysis::valueLookup (const BNphoton
3101      }
3102      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3103    }
3104 +  else if(variable == "genMatchedGrandmotherIdReverse"){
3105 +    int index = getGenMatchedParticleIndex(object);
3106 +    if(index == -1) value = 24;
3107 +    else if(fabs(mcparticles->at(index).motherId) == 15){
3108 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
3109 +      if(motherIndex == -1) value = 24;
3110 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3111 +    }
3112 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3113 +  }
3114  
3115  
3116 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3116 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3117  
3118    value = applyFunction(function, value);
3119  
3120    return value;
3121 < }
3121 > } // end photon valueLookup
3122  
3123 +
3124 + //!supercluster valueLookup
3125   double
3126 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
3126 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
3127  
3128    double value = 0.0;
3129  
# Line 2510 | Line 3137 | OSUAnalysis::valueLookup (const BNsuperc
3137    else if(variable == "theta") value = object->theta;
3138  
3139  
3140 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3140 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3141  
3142    value = applyFunction(function, value);
3143  
3144    return value;
3145   }
3146  
3147 + //!trigobj valueLookup
3148 + double
3149 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
3150 +
3151 +  double value = 0.0;
3152 +
3153 +  if(variable == "pt") value = object->pt;
3154 +  else if(variable == "eta") value = object->eta;
3155 +  else if(variable == "phi") value = object->phi;
3156 +  else if(variable == "px") value = object->px;
3157 +  else if(variable == "py") value = object->py;
3158 +  else if(variable == "pz") value = object->pz;
3159 +  else if(variable == "et") value = object->et;
3160 +  else if(variable == "energy") value = object->energy;
3161 +  else if(variable == "etTotal") value = object->etTotal;
3162 +  else if(variable == "id") value = object->id;
3163 +  else if(variable == "charge") value = object->charge;
3164 +  else if(variable == "isIsolated") value = object->isIsolated;
3165 +  else if(variable == "isMip") value = object->isMip;
3166 +  else if(variable == "isForward") value = object->isForward;
3167 +  else if(variable == "isRPC") value = object->isRPC;
3168 +  else if(variable == "bx") value = object->bx;
3169 +  else if(variable == "filter") {
3170 +    if ((stringValue = object->filter) == "")
3171 +      stringValue = "none";  // stringValue should only be empty if value is filled
3172 +  }
3173 +
3174 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3175 +
3176 +  value = applyFunction(function, value);
3177  
3178 +  return value;
3179 + }
3180 +
3181 + //!muon-muon pair valueLookup
3182   double
3183 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
3183 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3184  
3185    double value = 0.0;
3186  
# Line 2581 | Line 3242 | OSUAnalysis::valueLookup (const BNmuon*
3242        value = object2->correctedD0;
3243      }
3244  
3245 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3245 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3246 >
3247 >  value = applyFunction(function, value);
3248 >
3249 >  return value;
3250 > } // end muon-muon pair valueLookup
3251 >
3252 >
3253 > //!muon-photon pair valueLookup
3254 > double
3255 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3256 >
3257 >  double value = 0.0;
3258 >
3259 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3260 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3261 >  else if(variable == "photonEta") value = object2->eta;
3262 >  else if(variable == "muonEta") value = object1->eta;
3263 >  else if(variable == "photonPhi") value = object2->phi;
3264 >  else if(variable == "muonPhi") value = object1->phi;
3265 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3266 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3267 >  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3268 >  else if(variable == "invMass"){
3269 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3270 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3271 >    value = (fourVector1 + fourVector2).M();
3272 >  }
3273 >  else if(variable == "pt"){
3274 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3275 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3276 >    value = (fourVector1 + fourVector2).Pt();
3277 >  }
3278 >  else if(variable == "threeDAngle")
3279 >    {
3280 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3281 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3282 >      value = (threeVector1.Angle(threeVector2));
3283 >    }
3284 >  else if(variable == "alpha")
3285 >    {
3286 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3287 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3288 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3289 >      value = (pi-threeVector1.Angle(threeVector2));
3290 >    }
3291 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3292 >
3293 >  value = applyFunction(function, value);
3294 >
3295 >  return value;
3296 > }
3297 >
3298 > //!electron-photon pair valueLookup
3299 > double
3300 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3301 >
3302 >  double value = 0.0;
3303 >
3304 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3305 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3306 >  else if(variable == "photonEta") value = object2->eta;
3307 >  else if(variable == "electronEta") value = object1->eta;
3308 >  else if(variable == "photonPhi") value = object2->phi;
3309 >  else if(variable == "electronPhi") value = object1->phi;
3310 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3311 >  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3312 >  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3313 >  else if(variable == "invMass"){
3314 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3315 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3316 >    value = (fourVector1 + fourVector2).M();
3317 >  }
3318 >  else if(variable == "pt"){
3319 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3320 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3321 >    value = (fourVector1 + fourVector2).Pt();
3322 >  }
3323 >  else if(variable == "threeDAngle")
3324 >    {
3325 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3326 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3327 >      value = (threeVector1.Angle(threeVector2));
3328 >    }
3329 >  else if(variable == "alpha")
3330 >    {
3331 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3332 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3333 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3334 >      value = (pi-threeVector1.Angle(threeVector2));
3335 >    }
3336 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3337  
3338    value = applyFunction(function, value);
3339  
3340    return value;
3341   }
3342  
3343 + //!electron-electron pair valueLookup
3344   double
3345 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
3345 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
3346  
3347    double value = 0.0;
3348  
# Line 2636 | Line 3389 | OSUAnalysis::valueLookup (const BNelectr
3389      value = object2->correctedD0;
3390    }
3391  
3392 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3392 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3393  
3394    value = applyFunction(function, value);
3395  
3396    return value;
3397   }
3398  
3399 + //!electron-muon pair valueLookup
3400   double
3401 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
3401 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3402  
3403    double value = 0.0;
3404  
# Line 2702 | Line 3456 | OSUAnalysis::valueLookup (const BNelectr
3456    else if(variable == "muonRelPFdBetaIso"){
3457      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3458    }
3459 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3460 +  value = applyFunction(function, value);
3461  
3462 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3462 >  return value;
3463 > } // end electron-muon pair valueLookup
3464 >
3465 >
3466 > //!electron-jet pair valueLookup
3467 > double
3468 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3469 >
3470 >  double value = 0.0;
3471 >
3472 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3473 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3474 >  else if(variable == "jetEta") value = object2->eta;
3475 >  else if(variable == "jetPhi") value = object2->phi;
3476 >  else if(variable == "electronEta") value = object1->eta;
3477 >  else if(variable == "electronPhi") value = object1->phi;
3478 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3479 >  else if(variable == "invMass"){
3480 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3481 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3482 >    value = (fourVector1 + fourVector2).M();
3483 >  }
3484 >  else if(variable == "pt"){
3485 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3486 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3487 >    value = (fourVector1 + fourVector2).Pt();
3488 >  }
3489 >  else if(variable == "threeDAngle")
3490 >    {
3491 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3492 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3493 >      value = (threeVector1.Angle(threeVector2));
3494 >    }
3495 >  else if(variable == "chargeProduct"){
3496 >    value = object1->charge*object2->charge;
3497 >  }
3498 >
3499 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3500 >  value = applyFunction(function, value);
3501 >
3502 >  return value;
3503 > }
3504 >
3505 > //!photon-jet pair valueLookup
3506 > double
3507 > OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3508 >
3509 >  double value = 0.0;
3510 >
3511 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3512 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3513 >  else if(variable == "jetEta") value = object2->eta;
3514 >  else if(variable == "jetPhi") value = object2->phi;
3515 >  else if(variable == "photonEta") value = object1->eta;
3516 >  else if(variable == "photonPhi") value = object1->phi;
3517 >  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3518 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3519 >  else if(variable == "invMass"){
3520 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3521 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3522 >    value = (fourVector1 + fourVector2).M();
3523 >  }
3524 >  else if(variable == "pt"){
3525 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3526 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3527 >    value = (fourVector1 + fourVector2).Pt();
3528 >  }
3529 >  else if(variable == "threeDAngle")
3530 >    {
3531 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3532 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3533 >      value = (threeVector1.Angle(threeVector2));
3534 >    }
3535 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3536 >  value = applyFunction(function, value);
3537 >
3538 >  return value;
3539 > }
3540 >
3541 > // track-jet pair valueLookup
3542 > double
3543 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3544  
3545 +  double value = 0.0;
3546 +
3547 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3548 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3549 +
3550 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3551    value = applyFunction(function, value);
3552  
3553    return value;
3554 +
3555   }
3556  
3557  
3558 < double  
3559 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
3560 <  double electronMass = 0.000511;        
3561 <  double value = 0.0;    
3562 <  TLorentzVector fourVector1(0, 0, 0, 0);        
3563 <  TLorentzVector fourVector2(0, 0, 0, 0);        
3564 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
3558 >
3559 > // met-jet pair valueLookup
3560 > double
3561 > OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3562 >
3563 >  double value = 0.0;
3564 >
3565 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3566 >
3567 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3568 >  value = applyFunction(function, value);
3569 >
3570 >  return value;
3571 >
3572 > }  
3573 >
3574 >
3575 >
3576 > //!muon-jet pair valueLookup
3577 > double
3578 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3579 >
3580 >  double value = 0.0;
3581 >
3582 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3583 >  else if(variable == "jetEta") value = object2->eta;
3584 >  else if(variable == "jetPhi") value = object2->phi;
3585 >  else if(variable == "muonEta") value = object1->eta;
3586 >  else if(variable == "muonPhi") value = object1->phi;
3587 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3588 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3589 >  else if(variable == "invMass"){
3590 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3591 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3592 >    value = (fourVector1 + fourVector2).M();
3593 >  }
3594 >  else if(variable == "pt"){
3595 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3596 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3597 >    value = (fourVector1 + fourVector2).Pt();
3598 >  }
3599 >  else if(variable == "threeDAngle")
3600 >    {
3601 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3602 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3603 >      value = (threeVector1.Angle(threeVector2));
3604 >    }
3605 >  else if(variable == "chargeProduct"){
3606 >    value = object1->charge*object2->charge;
3607 >  }
3608 >
3609 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3610 >  value = applyFunction(function, value);
3611 >
3612 >  return value;
3613 > }
3614 > //!jet-jet pair valueLookup
3615 > double
3616 > OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3617 >
3618 >  double value = 0.0;
3619 >
3620 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3621    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3622 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3623 <  else if(variable == "invMass"){        
3624 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3625 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3626 <        
3627 <    value = (fourVector1 + fourVector2).M();    
3622 >  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3623 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3624 >  else if(variable == "invMass"){
3625 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3626 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3627 >    value = (fourVector1 + fourVector2).M();
3628 >  }
3629 >  else if(variable == "pt"){
3630 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3631 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3632 >    value = (fourVector1 + fourVector2).Pt();
3633    }
3634 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3635 <  value = applyFunction(function, value);        
3636 <  return value;  
3634 >  else if(variable == "threeDAngle")
3635 >    {
3636 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3637 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3638 >      value = (threeVector1.Angle(threeVector2));
3639 >    }
3640 >  else if(variable == "chargeProduct"){
3641 >    value = object1->charge*object2->charge;
3642 >  }
3643 >
3644 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3645 >  value = applyFunction(function, value);
3646 >
3647 >  return value;
3648   }
3649  
3650 + //!electron-track pair valueLookup
3651 + double
3652 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3653 +  double electronMass = 0.000511;
3654 +  double value = 0.0;
3655 +  TLorentzVector fourVector1(0, 0, 0, 0);
3656 +  TLorentzVector fourVector2(0, 0, 0, 0);
3657 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3658 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3659 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3660 +  else if(variable == "invMass"){
3661 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3662 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3663 +
3664 +    value = (fourVector1 + fourVector2).M();
3665 +  }
3666 +  else if(variable == "chargeProduct"){
3667 +    value = object1->charge*object2->charge;
3668 +  }
3669 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3670 +  value = applyFunction(function, value);
3671 +  return value;
3672 +
3673 + }
3674  
3675  
3676 + //!muon-track pair valueLookup
3677   double
3678 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3678 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3679    double pionMass = 0.140;
3680    double muonMass = 0.106;
3681    double value = 0.0;
# Line 2749 | Line 3690 | OSUAnalysis::valueLookup (const BNmuon*
3690  
3691      value = (fourVector1 + fourVector2).M();
3692    }
3693 +  else if(variable == "chargeProduct"){
3694 +    value = object1->charge*object2->charge;
3695 +  }
3696  
3697    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3698    value = applyFunction(function, value);
3699    return value;
3700   }
3701  
3702 <
3702 > //!tau-tau pair valueLookup
3703   double
3704 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3704 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3705    double value = 0.0;
3706    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3707    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2768 | Line 3712 | OSUAnalysis::valueLookup (const BNtau* o
3712      value = (fourVector1 + fourVector2).M();
3713    }
3714  
3715 +  else if(variable == "chargeProduct"){
3716 +    value = object1->charge*object2->charge;
3717 +  }
3718 +
3719    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3720    value = applyFunction(function, value);
3721    return value;
3722   }
3723  
3724 <
3724 > //!muon-tau pair valueLookup
3725   double
3726 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3726 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3727    double value = 0.0;
3728    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3729    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2786 | Line 3734 | OSUAnalysis::valueLookup (const BNmuon*
3734      value = (fourVector1 + fourVector2).M();
3735    }
3736  
3737 +  else if(variable == "chargeProduct"){
3738 +    value = object1->charge*object2->charge;
3739 +  }
3740 +
3741    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3742    value = applyFunction(function, value);
3743    return value;
3744   }
3745  
3746 + //!tau-track pair valueLookup
3747   double
3748 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3748 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3749    double value = 0.0;
3750    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3751    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3752 +  else if(variable == "chargeProduct"){
3753 +    value = object1->charge*object2->charge;
3754 +  }
3755  
3756    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3757    value = applyFunction(function, value);
# Line 2803 | Line 3759 | OSUAnalysis::valueLookup (const BNtau* o
3759   }
3760  
3761  
3762 <
3762 > //!track-event pair valueLookup
3763   double
3764 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3764 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3765  
3766    double value = 0.0;
3767    double pMag = sqrt(object1->pt * object1->pt +
3768 <                     object1->pz * object1->pz);  
3768 >                     object1->pz * object1->pz);
3769  
3770    if      (variable == "numPV")                      value = object2->numPV;
3771    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3772    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3773 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3774 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3773 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3774 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3775  
3776 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3776 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3777  
3778    value = applyFunction(function, value);
3779  
3780    return value;
3781  
3782 < }  
3782 > }
3783 >
3784 > //!electron-trigobj pair valueLookup
3785 > double
3786 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3787 >
3788 >  double value = 0.0;
3789 >
3790 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3791 >  else if (variable == "match"){
3792 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3793 >      stringValue = object2->filter;
3794 >    else
3795 >      stringValue = "none";
3796 >  }
3797 >
3798 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3799 >
3800 >  value = applyFunction(function, value);
3801 >
3802 >  return value;
3803 >
3804 > }
3805 >
3806 > //!muon-trigobj pair valueLookup
3807 > double
3808 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3809 >
3810 >  double value = 0.0;
3811 >
3812 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3813 >
3814 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3815 >
3816 >  value = applyFunction(function, value);
3817 >
3818 >  return value;
3819 >
3820 > }
3821 >
3822 > //!stop valueLookup
3823 > double
3824 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3825 >
3826 >
3827 >  double value = 0.0;
3828 >
3829 >  if(variable == "ctau") value = object->ctau;
3830 >
3831 >  else if (variable == "d0"){
3832 >    double vx = object->vx - chosenVertex ()->x,
3833 >      vy = object->vy - chosenVertex ()->y,
3834 >      px = object->px,
3835 >      py = object->py,
3836 >      pt = object->pt;
3837 >    value = (-vx * py + vy * px) / pt;
3838 >  }
3839 >
3840 >  else if (variable == "dz"){
3841 >    double vx = object->vx - chosenVertex ()->x,
3842 >      vy = object->vy - chosenVertex ()->y,
3843 >      vz = object->vz - chosenVertex ()->z,
3844 >      px = object->px,
3845 >      py = object->py,
3846 >      pz = object->pz,
3847 >      pt = object->pt;
3848 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3849 >  }
3850 >
3851 >  else if (variable == "minD0"){
3852 >    double minD0=999;
3853 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3854 >      double vx = object->vx - vertex->x,
3855 >        vy = object->vy - vertex->y,
3856 >        px = object->px,
3857 >        py = object->py,
3858 >        pt = object->pt;
3859 >      value = (-vx * py + vy * px) / pt;
3860 >      if(abs(value) < abs(minD0)) minD0 = value;
3861 >    }
3862 >    value = minD0;
3863 >  }
3864 >  else if (variable == "minDz"){
3865 >    double minDz=999;
3866 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3867 >      double vx = object->vx - vertex->x,
3868 >        vy = object->vy - vertex->y,
3869 >        vz = object->vz - vertex->z,
3870 >        px = object->px,
3871 >        py = object->py,
3872 >        pz = object->pz,
3873 >        pt = object->pt;
3874 >      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3875 >      if(abs(value) < abs(minDz)) minDz = value;
3876 >    }
3877 >    value = minDz;
3878 >  }
3879 >  else if(variable == "distToVertex"){
3880 >    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3881 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3882 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3883 >  }
3884 >  else if (variable == "minDistToVertex"){
3885 >    double minDistToVertex=999;
3886 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3887 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3888 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3889 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3890 >
3891 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3892 >    }
3893 >    value = minDistToVertex;
3894 >  }
3895 >  else if (variable == "distToVertexDifference"){
3896 >    double minDistToVertex=999;
3897 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3898 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3899 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3900 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3901 >
3902 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3903 >    }
3904 >    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3905 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3906 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3907 >
3908 >    value = distToChosenVertex - minDistToVertex;
3909 >  }
3910 >
3911 >  else if (variable == "closestVertexRank"){
3912 >    double minDistToVertex=999;
3913 >    int vertex_rank = 0;
3914 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3915 >      vertex_rank++;
3916 >      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3917 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3918 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3919 >
3920 >      if(abs(dist) < abs(minDistToVertex)){
3921 >        value = vertex_rank;
3922 >        minDistToVertex = dist;
3923 >      }
3924 >    }
3925 >  }
3926 >
3927 >
3928 >
3929 >
3930 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3931 >
3932 >  value = applyFunction(function, value);
3933 >
3934 >  return value;
3935 >
3936 > } // end stop valueLookup
3937 >
3938 >
3939 >
3940 >
3941  
3942   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3943   // Return true iff no other tracks are found in this cone.
# Line 2872 | Line 3986 | OSUAnalysis::getTrkPtTrue (const BNtrack
3986  
3987   double
3988   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3989 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3990 <  if (!useTrackCaloRhoCorr_) return -99;  
3991 <  // if (!rhokt6CaloJetsHandle_) {
3992 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3993 <  //   return -99;  
3989 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3990 >  if (!useTrackCaloRhoCorr_) return -99;
3991 >  // if (!rhokt6CaloJetsHandle_) {
3992 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3993 >  //   return -99;
3994    // }
3995 <  double radDeltaRCone = 0.5;  
3996 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3997 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3998 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3999 <  return caloTotRhoCorrCalo;  
4000 <
3995 >  double radDeltaRCone = 0.5;
3996 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3997 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3998 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3999 >  return caloTotRhoCorrCalo;
4000 >
4001   }
4002  
4003  
# Line 2921 | Line 4035 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
4035    double deltaRLowest = 999;
4036    int value = 0;
4037    if (DeadEcalVec.size() == 0) WriteDeadEcal();
4038 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
4038 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
4039      double eta = ecal->etaEcal;
4040      double phi = ecal->phiEcal;
4041 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
4041 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
4042      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
4043    }
4044    if (deltaRLowest<0.05) {value = 1;}
# Line 2932 | Line 4046 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
4046    return value;
4047   }
4048  
4049 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
4049 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
4050   template <class InputObject>
4051   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
4052    double genDeltaRLowest = 999.;
# Line 2952 | Line 4066 | OSUAnalysis::applyFunction(string functi
4066    else if(function == "log") value = log10(value);
4067  
4068    else if(function == "") value = value;
4069 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
4069 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
4070  
4071    return value;
4072  
# Line 2961 | Line 4075 | OSUAnalysis::applyFunction(string functi
4075  
4076   template <class InputCollection>
4077   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
4078 <
4079 <  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
4080 <    string obj1, obj2;
4078 >
4079 >  if (currentCut.inputCollection.find("pair")!=string::npos)  {
4080 >    string obj1, obj2;
4081      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4082      if (inputType==obj1 ||
4083 <        inputType==obj2) {
4083 >        inputType==obj2) {
4084        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4085 <      // and the inputType is a member of the pair.  
4086 <      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
4087 <      // For example, if currentCut.inputCollection==electron-muon pairs,
4088 <      // then the flags should not be set here when inputType==muons or inputType==electrons.  
4089 <      return;
4090 <    }  
4091 <  }    
4085 >      // and the inputType is a member of the pair.
4086 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
4087 >      // For example, if currentCut.inputCollection==electron-muon pairs,
4088 >      // then the flags should not be set here when inputType==muons or inputType==electrons.
4089 >      return;
4090 >    }
4091 >  }
4092  
4093    for (uint object = 0; object != inputCollection->size(); object++){
4094  
4095 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4095 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4096 >    bool plotDecision = true;
4097  
4098      if(currentCut.inputCollection == inputType){
4099  
4100        vector<bool> subcutDecisions;
4101        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4102 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
4103 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4102 >        string stringValue = "";
4103 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4104 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4105 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4106  
4107        }
4108 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4108 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4109        else{
4110          bool tempDecision = true;
4111          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 2997 | Line 4114 | void OSUAnalysis::setObjectFlags(cut &cu
4114            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4115              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4116          }
4117 <        decision = tempDecision;
4117 >        cutDecision = tempDecision;
4118        }
4119 +      //invert the cut for plotting if this cut is a veto
4120 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4121 +      else plotDecision = cutDecision;
4122      }
4123  
4124 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4124 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4125  
4126 <    //set flags for objects that pass each cut AND all the previous cuts
4127 <    bool previousCumulativeFlag = true;
4126 >    //set flags for objects that pass this cut AND all the previous cuts
4127 >    bool previousCumulativeCutFlag = true;
4128      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4129 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4130 <      else{ previousCumulativeFlag = false; break;}
4129 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4130 >      else{ previousCumulativeCutFlag = false; break;}
4131      }
4132 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4132 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4133 >    bool previousCumulativePlotFlag = true;
4134 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4135 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4136 >      else{ previousCumulativePlotFlag = false; break;}
4137 >    }
4138 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4139 >
4140 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4141  
4142    }
4143  
# Line 3018 | Line 4146 | void OSUAnalysis::setObjectFlags(cut &cu
4146  
4147   template <class InputCollection1, class InputCollection2>
4148   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4149 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4149 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4150  
4151  
4152    bool sameObjects = false;
4153    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4154  
4155 <  // Get the strings for the two objects that make up the pair.  
4156 <  string obj1Type, obj2Type;
4155 >  // Get the strings for the two objects that make up the pair.
4156 >  string obj1Type, obj2Type;
4157    getTwoObjs(inputType, obj1Type, obj2Type);
4158    bool isTwoTypesOfObject = true;
4159 <  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
4159 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
4160  
4161 <  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
4162 <  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
4163 <  if (currentCut.inputCollection == inputType) {    
4161 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
4162 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4163 >  if (currentCut.inputCollection == inputType) {
4164      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4165 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4166 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4165 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4166 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4167      }
4168 <    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
4168 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4169        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4170 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4171 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4170 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4171 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4172        }
4173      }
4174    }
4175 <  
4175 >
4176    int counter = 0;
4177  
4178    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
# Line 3053 | Line 4181 | void OSUAnalysis::setObjectFlags(cut &cu
4181        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4182  
4183  
4184 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4184 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4185 >      bool plotDecision = true;
4186  
4187        if(currentCut.inputCollection == inputType){
4188  
4189          vector<bool> subcutDecisions;
4190          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4191 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
4192 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4191 >          string stringValue = "";
4192 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4193 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4194 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4195          }
4196  
4197 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4197 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4198          else{
4199            bool tempDecision = subcutDecisions.at(0);
4200            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3072 | Line 4203 | void OSUAnalysis::setObjectFlags(cut &cu
4203              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4204                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4205            }
4206 <          decision = tempDecision;
4206 >          cutDecision = tempDecision;
4207          }
4208 +        //invert the cut for plotting if this cut is a veto
4209 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4210 +        else plotDecision = cutDecision;
4211 +      }
4212 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4213 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4214 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4215 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4216 +      }
4217 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4218 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4219 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4220 +      }
4221 +
4222 +      //set flags for objects that pass this cut AND all the previous cuts
4223 +      bool previousCumulativeCutFlag = true;
4224 +      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4225 +        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4226 +        else{ previousCumulativeCutFlag = false; break;}
4227        }
4228 <      // if (decision) isPassObj1.at(object1) = true;
3079 <      // if (decision) isPassObj2.at(object2) = true;
3080 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3081 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3082 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3083 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3084 <      }  
4228 >      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4229  
4230 <      //set flags for objects that pass each cut AND all the previous cuts
3087 <      bool previousCumulativeFlag = true;
4230 >      bool previousCumulativePlotFlag = true;
4231        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4232 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4233 <        else{ previousCumulativeFlag = false; break;}
4232 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4233 >        else{ previousCumulativePlotFlag = false; break;}
4234        }
4235 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4236 +      
4237        //apply flags for the components of the composite object as well
4238 <      bool currentCumulativeFlag = true;
4239 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4240 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4241 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4242 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4243 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4244 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
4245 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
4246 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
4238 >      bool currentCumulativeCutFlag = true;
4239 >      bool currentCumulativePlotFlag = true;
4240 >
4241 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4242 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4243 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4244 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4245 >
4246 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4247 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4248 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4249 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4250 >
4251 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4252 >
4253 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4254 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4255 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4256 >      }
4257 >
4258 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4259 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4260 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4261        }
4262 +
4263        counter++;
4264  
4265 <    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
4266 <  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
4265 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
4266 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
4267  
4268   }
4269  
4270  
4271 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4272 <  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4273 <  // all cuts up to currentCutIndex  
4274 <  bool previousCumulativeFlag = true;  
4275 <  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
4276 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4277 <    else {  
4278 <      previousCumulativeFlag = false; break;  
4271 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4272 >  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4273 >  // all cuts up to currentCutIndex
4274 >  bool previousCumulativeFlag = true;
4275 >  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4276 >    bool tempFlag = false;
4277 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4278 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4279 >
4280 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4281 >    else {
4282 >      previousCumulativeFlag = false; break;
4283      }
4284    }
4285 <  return previousCumulativeFlag;  
4286 < }  
4285 >  return previousCumulativeFlag;
4286 > }
4287 >
4288 >
4289  
4290  
4291   template <class InputCollection>
4292 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4292 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4293 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4294 >
4295 >  if (BNTreeBranchVals_.count(parameters.name)==0) cout << "Error[assignTreeBranch]:  trying to assign value to " << parameters.name << " that does not have a branch set up.  Will likely seg fault." << endl;
4296 >  for (uint object = 0; object != inputCollection->size(); object++) {
4297 >
4298 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4299 >
4300 >    string inputVariable = parameters.inputVariable;
4301 >    string function = "";
4302 >    string stringValue = "";
4303 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4304 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4305 >
4306 >  }
4307 > }
4308 >
4309 >
4310 > template <class InputCollection>
4311 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4312 >
4313  
4314    for (uint object = 0; object != inputCollection->size(); object++){
4315  
4316 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4316 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4317  
4318      string currentString = parameters.inputVariables.at(0);
4319      string inputVariable = "";
4320      string function = "";
4321 <    if(currentString.find("(")==std::string::npos){
4321 >    if(currentString.find("(")==string::npos){
4322        inputVariable = currentString;// variable to cut on
4323      }
4324      else{
# Line 3141 | Line 4327 | void OSUAnalysis::fill1DHistogram(TH1* h
4327        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4328      }
4329  
4330 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
4330 >    string stringValue = "";
4331 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4332      histo->Fill(value,scaleFactor);
4333  
4334      if (printEventInfo_) {
4335 <      // Write information about event to screen, for testing purposes.  
4336 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
4335 >      // Write information about event to screen, for testing purposes.
4336 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4337      }
4338 <    
4338 >
4339    }
4340   }
4341  
4342   template <class InputCollection1, class InputCollection2>
4343 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4343 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4344  
4345    bool sameObjects = false;
4346    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3166 | Line 4353 | void OSUAnalysis::fill1DHistogram(TH1* h
4353  
4354        pairCounter++;
4355        //only take objects which have passed all cuts and pairs which have passed all cuts
4356 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4357 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4358 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4356 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4357 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4358 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4359  
4360        string currentString = parameters.inputVariables.at(0);
4361        string inputVariable = "";
4362        string function = "";
4363 <      if(currentString.find("(")==std::string::npos){
4363 >      if(currentString.find("(")==string::npos){
4364          inputVariable = currentString;// variable to cut on
4365        }
4366        else{
# Line 3182 | Line 4369 | void OSUAnalysis::fill1DHistogram(TH1* h
4369          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4370        }
4371  
4372 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
4372 >      string stringValue = "";
4373 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4374        histo->Fill(value,scaleFactor);
4375  
4376      }
# Line 3192 | Line 4380 | void OSUAnalysis::fill1DHistogram(TH1* h
4380  
4381  
4382   template <class InputCollection>
4383 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4383 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4384  
4385    for (uint object = 0; object != inputCollection->size(); object++){
4386  
4387 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4387 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4388  
4389 +    string stringValue = "";
4390      string currentString = parameters.inputVariables.at(0);
4391      string inputVariable = "";
4392      string function = "";
4393 <    if(currentString.find("(")==std::string::npos){
4393 >    if(currentString.find("(")==string::npos){
4394        inputVariable = currentString;// variable to cut on
4395      }
4396      else{
# Line 3209 | Line 4398 | void OSUAnalysis::fill2DHistogram(TH2* h
4398        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4399        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4400      }
4401 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
4401 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4402  
4403      currentString = parameters.inputVariables.at(1);
4404      inputVariable = "";
4405      function = "";
4406 <    if(currentString.find("(")==std::string::npos){
4406 >    if(currentString.find("(")==string::npos){
4407        inputVariable = currentString;// variable to cut on
4408      }
4409      else{
# Line 3223 | Line 4412 | void OSUAnalysis::fill2DHistogram(TH2* h
4412        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4413      }
4414  
4415 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
4415 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4416  
4417      histo->Fill(valueX,valueY,scaleFactor);
4418  
# Line 3232 | Line 4421 | void OSUAnalysis::fill2DHistogram(TH2* h
4421   }
4422  
4423   template <class InputCollection1, class InputCollection2>
4424 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4424 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4425  
4426    bool sameObjects = false;
4427    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3246 | Line 4435 | void OSUAnalysis::fill2DHistogram(TH2* h
4435        pairCounter++;
4436  
4437        //only take objects which have passed all cuts and pairs which have passed all cuts
4438 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4439 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4440 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4438 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4439 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4440 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4441  
4442 +      string stringValue = "";
4443        string currentString = parameters.inputVariables.at(0);
4444        string inputVariable = "";
4445        string function = "";
4446 <      if(currentString.find("(")==std::string::npos){
4446 >      if(currentString.find("(")==string::npos){
4447          inputVariable = currentString;// variable to cut on
4448        }
4449        else{
# Line 3261 | Line 4451 | void OSUAnalysis::fill2DHistogram(TH2* h
4451          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4452          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4453        }
4454 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
4454 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4455  
4456        currentString = parameters.inputVariables.at(1);
4457        inputVariable = "";
4458        function = "";
4459 <      if(currentString.find("(")==std::string::npos){
4459 >      if(currentString.find("(")==string::npos){
4460          inputVariable = currentString;// variable to cut on
4461        }
4462        else{
# Line 3274 | Line 4464 | void OSUAnalysis::fill2DHistogram(TH2* h
4464          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4465          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4466        }
4467 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
4467 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4468  
4469  
4470        histo->Fill(valueX,valueY,scaleFactor);
# Line 3295 | Line 4485 | int OSUAnalysis::getGenMatchedParticleIn
4485  
4486      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4487      if(currentDeltaR > 0.05) continue;
4488 <    //     cout << std::setprecision(3) << std::setw(20)
4488 >    //     cout << setprecision(3) << setw(20)
4489      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4490 <    //          << std::setw(20)
4490 >    //          << setw(20)
4491      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
4492 <    //          << std::setw(20)
4492 >    //          << setw(20)
4493      //          << "\tdeltaR = " << currentDeltaR
4494 <    //          << std::setprecision(1)
4495 <    //          << std::setw(20)
4494 >    //          << setprecision(1)
4495 >    //          << setw(20)
4496      //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
4497 <    //          << std::setw(20)
4497 >    //          << setw(20)
4498      //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
4499 <    //          << std::setw(20)
4499 >    //          << setw(20)
4500      //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
4501      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
4502        bestMatchIndex = mcparticle - mcparticles->begin();
# Line 3369 | Line 4559 | int OSUAnalysis::findTauMotherIndex(cons
4559   // 20        strange baryon
4560   // 21        charm baryon
4561   // 22        bottom baryon
4562 < // 23        other
4562 > // 23        QCD string
4563 > // 24        other
4564  
4565   int OSUAnalysis::getPdgIdBinValue(int pdgId){
4566  
# Line 3393 | Line 4584 | int OSUAnalysis::getPdgIdBinValue(int pd
4584    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
4585    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
4586    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
4587 +  else if(absPdgId == 92  ) binValue = 23;
4588  
4589 <  else binValue = 23;
4589 >  else binValue = 24;
4590  
4591    return binValue;
4592  
# Line 3404 | Line 4596 | const BNprimaryvertex *
4596   OSUAnalysis::chosenVertex ()
4597   {
4598    const BNprimaryvertex *chosenVertex = 0;
4599 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
4600 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
4601 <      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
4599 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4600 >    flagPair vertexFlags;
4601 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4602 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4603 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
4604 >        break;
4605 >      }
4606 >    }
4607      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4608 <      if(!vertexFlags.at(vertexIndex)) continue;
4608 >      if(!vertexFlags.at(vertexIndex).first) continue;
4609        chosenVertex = & primaryvertexs->at(vertexIndex);
4610        break;
4611      }
4612    }
4613 <  else {
4614 <    chosenVertex = &primaryvertexs->at(0);
3418 <  }
4613 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4614 >    chosenVertex = & primaryvertexs->at (0);
4615  
4616    return chosenVertex;
4617   }
# Line 3424 | Line 4620 | const BNmet *
4620   OSUAnalysis::chosenMET ()
4621   {
4622    const BNmet *chosenMET = 0;
4623 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4624 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
4625 <      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
4623 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4624 >    flagPair metFlags;
4625 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4626 >      if (cumulativeFlags.at("mets").at(i).size()){
4627 >        metFlags = cumulativeFlags.at("mets").at(i);
4628 >        break;
4629 >      }
4630 >    }
4631      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4632 <      if(!metFlags.at(metIndex)) continue;
4632 >      if(!metFlags.at(metIndex).first) continue;
4633        chosenMET = & mets->at(metIndex);
4634        break;
4635      }
4636    }
4637 <  else {
4638 <    chosenMET = &mets->at(0);
3438 <  }
4637 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4638 >    chosenMET = & mets->at (0);
4639  
4640    return chosenMET;
4641   }
# Line 3444 | Line 4644 | const BNelectron *
4644   OSUAnalysis::chosenElectron ()
4645   {
4646    const BNelectron *chosenElectron = 0;
4647 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4648 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4649 <      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4647 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4648 >    flagPair electronFlags;
4649 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4650 >      if (cumulativeFlags.at("electrons").at(i).size()){
4651 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4652 >        break;
4653 >      }
4654 >    }
4655      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4656 <      if(!electronFlags.at(electronIndex)) continue;
4656 >      if(!electronFlags.at(electronIndex).first) continue;
4657        chosenElectron = & electrons->at(electronIndex);
4658        break;
4659      }
4660    }
4661 <  else {
4662 <    chosenElectron = &electrons->at(0);
3458 <  }
4661 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4662 >    chosenElectron = & electrons->at (0);
4663  
4664    return chosenElectron;
4665   }
4666  
4667 +
4668   const BNmuon *
4669   OSUAnalysis::chosenMuon ()
4670   {
4671    const BNmuon *chosenMuon = 0;
4672 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4673 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4674 <      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4672 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4673 >    flagPair muonFlags;
4674 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4675 >      if (cumulativeFlags.at("muons").at(i).size()){
4676 >        muonFlags = cumulativeFlags.at("muons").at(i);
4677 >        break;
4678 >      }
4679 >    }
4680      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4681 <      if(!muonFlags.at(muonIndex)) continue;
4681 >      if(!muonFlags.at(muonIndex).first) continue;
4682        chosenMuon = & muons->at(muonIndex);
4683        break;
4684      }
4685    }
4686 <  else {
4687 <    chosenMuon = &muons->at(0);
3478 <  }
4686 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4687 >    chosenMuon = & muons->at (0);
4688  
4689    return chosenMuon;
4690   }
4691  
3483
4692   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines