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.75 by wulsin, Fri May 31 09:15:04 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 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
32    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
33    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
34 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
34 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
36    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
37 <  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
38 <
37 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
38 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
39   {
40  
41    TH1::SetDefaultSumw2 ();
# Line 40 | Line 43 | OSUAnalysis::OSUAnalysis (const edm::Par
43    //create pile-up reweighting object, if necessary
44    if(datasetType_ != "data") {
45      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
46 <    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
47 <    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
46 >    if (applyLeptonSF_){
47 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
48 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
49 >    }
50    }
51 < #ifdef DISPLACED_SUSY
52 <  if (datasetType_ == "signalMC")
48 <    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 < #endif
51 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
52 >    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
53  
54  
55    // Construct Cutflow Objects. These store the results of cut decisions and
56    // handle filling cut flow histograms.
57    masterCutFlow_ = new CutFlow (fs_);
55  std::vector<TFileDirectory> directories;
58  
59    //always get vertex collection so we can assign the primary vertex in the event
60    objectsToGet.push_back("primaryvertexs");
59
60  //always make the plot of number of primary vertices (to check pile-up reweighting)
61    objectsToPlot.push_back("primaryvertexs");
62 +  objectsToCut.push_back("primaryvertexs");
63 +
64  
65    //always get the MC particles to do GEN-matching
66    objectsToGet.push_back("mcparticles");
# Line 66 | Line 68 | OSUAnalysis::OSUAnalysis (const edm::Par
68    //always get the event collection to do pile-up reweighting
69    objectsToGet.push_back("events");
70  
71 +
72 +  // Parse the tree variable definitions.    
73 +  for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
74 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
75 +    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; }  
76 +    objectsToGet.push_back(tempInputCollection);
77 +    objectsToCut.push_back(tempInputCollection);
78 +
79 +    //    vector<edm::ParameterSet> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<edm::ParameterSet> >("histograms"));
80 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
81 +
82 +    for(uint iBranch = 0; iBranch<branchList.size(); iBranch++){
83 +
84 +      vector<double> defaultValue;
85 +      defaultValue.push_back (-1.0);
86 +
87 +      BranchSpecs br;
88 +      br.inputCollection = tempInputCollection;
89 +      br.inputVariable = branchList.at(iBranch);  
90 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);  
91 +      br.name = string(newName.Data());  
92 +
93 +      treeBranches_.push_back(br);
94 +
95 +    }  
96 +
97 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
98 +
99 +
100    //parse the histogram definitions
101    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
102  
103      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
104      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
105 +    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
106 +    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
107      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
108      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
109 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
110 <      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
111 <        int spaceIndex = tempInputCollection.find(" ");
112 <        int secondWordLength = tempInputCollection.size() - spaceIndex;
113 <        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
109 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
110 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
111 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
112 >    if(tempInputCollection.find("pairs")==string::npos){ //just a single object
113 >      if(tempInputCollection.find("secondary")!=string::npos){//secondary object
114 >        int spaceIndex = tempInputCollection.find(" ");
115 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
116 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
117        }
118        else{
119 <        objectsToGet.push_back(tempInputCollection);
119 >        objectsToGet.push_back(tempInputCollection);
120        }
121        objectsToPlot.push_back(tempInputCollection);
122        objectsToCut.push_back(tempInputCollection);
123 <    }
124 <    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;
123 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
124 >      string obj1;
125        string obj2;
126        getTwoObjs(tempInputCollection, obj1, obj2);
127 <      string obj2ToGet = getObjToGet(obj2);  
127 >      string obj2ToGet = getObjToGet(obj2);
128        objectsToCut.push_back(tempInputCollection);
129        objectsToCut.push_back(obj1);
130 <      objectsToCut.push_back(obj2);  
130 >      objectsToCut.push_back(obj2);
131        objectsToPlot.push_back(tempInputCollection);
132        objectsToPlot.push_back(obj1);
133 <      objectsToPlot.push_back(obj2);  
133 >      objectsToPlot.push_back(obj2);
134        objectsToGet.push_back(tempInputCollection);
135        objectsToGet.push_back(obj1);
136        objectsToGet.push_back(obj2ToGet);
137 +    } // end else
138 +
139  
103    }
140  
141      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
142  
143      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
144  
145 +      vector<double> defaultValue;
146 +      defaultValue.push_back (-1.0);
147 +
148        histogram tempHistogram;
149        tempHistogram.inputCollection = tempInputCollection;
150        tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
151        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
152 <      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
152 >      tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
153 >      tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
154 >      tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
155        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
156  
157        histograms.push_back(tempHistogram);
158  
159      }
160 <  }
160 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
161 >
162    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
163    sort( objectsToPlot.begin(), objectsToPlot.end() );
164    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 127 | Line 169 | OSUAnalysis::OSUAnalysis (const edm::Par
169    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
170  
171      string currentObject = objectsToPlot.at(currentObjectIndex);
172 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
172 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
173  
174      histogram tempIdHisto;
175      histogram tempMomIdHisto;
176      histogram tempGmaIdHisto;
177      histogram tempIdVsMomIdHisto;
178 +    histogram tempIdVsGmaIdHisto;
179  
180      tempIdHisto.inputCollection = currentObject;
181      tempMomIdHisto.inputCollection = currentObject;
182      tempGmaIdHisto.inputCollection = currentObject;
183      tempIdVsMomIdHisto.inputCollection = currentObject;
184 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
185  
186      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
187 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
188  
189      currentObject = currentObject.substr(0, currentObject.size()-1);
190      tempIdHisto.name = currentObject+"GenMatchId";
191      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
192      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
193      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
194 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
195  
196      currentObject.at(0) = toupper(currentObject.at(0));
197      tempIdHisto.title = currentObject+" Gen-matched Particle";
198      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
199      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
200      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
201 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
202  
203 <    int maxNum = 24;
203 >
204 >    int maxNum = 25;
205      vector<double> binVector;
206      binVector.push_back(maxNum);
207      binVector.push_back(0);
# Line 171 | Line 219 | OSUAnalysis::OSUAnalysis (const edm::Par
219      tempIdVsMomIdHisto.bins = binVector;
220      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
221      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
222 +    tempIdVsGmaIdHisto.bins = binVector;
223 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
224 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
225  
226      histograms.push_back(tempIdHisto);
227      histograms.push_back(tempMomIdHisto);
228      histograms.push_back(tempGmaIdHisto);
229      histograms.push_back(tempIdVsMomIdHisto);
230 +    histograms.push_back(tempIdVsGmaIdHisto);
231    }
232  
233  
# Line 191 | Line 243 | OSUAnalysis::OSUAnalysis (const edm::Par
243      //set triggers for this channel
244      vector<string> triggerNames;
245      triggerNames.clear();
246 +    vector<string> triggerToVetoNames;
247 +    triggerToVetoNames.clear();
248 +
249      tempChannel.triggers.clear();
250 +    tempChannel.triggersToVeto.clear();
251      if(channels_.at(currentChannel).exists("triggers")){
252        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
253        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
254          tempChannel.triggers.push_back(triggerNames.at(trigger));
255        objectsToGet.push_back("triggers");
256      }
257 <
257 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
258 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
259 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
260 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
261 >      objectsToGet.push_back("triggers");
262 >    }
263  
264  
265  
266      //create cutFlow for this channel
267      cutFlows_.push_back (new CutFlow (fs_, channelName));
268 <
269 <    //book a directory in the output file with the name of the channel
209 <    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 <
268 >    vector<TFileDirectory> directories; //vector of directories in the output file.
269 >    vector<string> subSubDirNames;//subdirectories in each channel.
270      //get list of cuts for this channel
271      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
272  
273 +
274      //loop over and parse all cuts
275      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
276        cut tempCut;
277        //store input collection for cut
278        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
279        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
280 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
281 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
282        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
283        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
284 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
285 +      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
286 +      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
287        tempCut.inputCollection = tempInputCollection;
288 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
289 <        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
290 <          int spaceIndex = tempInputCollection.find(" ");
291 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
292 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
293 <        }
294 <        else{
295 <          objectsToGet.push_back(tempInputCollection);
296 <        }
297 <        objectsToCut.push_back(tempInputCollection);
288 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
289 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
290 >          int spaceIndex = tempInputCollection.find(" ");
291 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
292 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
293 >        }
294 >        else{
295 >          objectsToGet.push_back(tempInputCollection);
296 >        }
297 >        objectsToCut.push_back(tempInputCollection);
298        }
299        else{//pair of objects, need to add them both to objectsToGet
300 <        string obj1;
301 <        string obj2;
302 <        getTwoObjs(tempInputCollection, obj1, obj2);
303 <        string obj2ToGet = getObjToGet(obj2);  
300 >        string obj1;
301 >        string obj2;
302 >        getTwoObjs(tempInputCollection, obj1, obj2);
303 >        string obj2ToGet = getObjToGet(obj2);
304          objectsToCut.push_back(tempInputCollection);
305          objectsToCut.push_back(obj1);
306 <        objectsToCut.push_back(obj2);  
306 >        objectsToCut.push_back(obj2);
307          objectsToGet.push_back(tempInputCollection);
308          objectsToGet.push_back(obj1);
309          objectsToGet.push_back(obj2ToGet);
# Line 387 | Line 314 | OSUAnalysis::OSUAnalysis (const edm::Par
314  
315        //split cut string into parts and store them
316        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
317 <      std::vector<string> cutStringVector = splitString(cutString);
317 >      vector<string> cutStringVector = splitString(cutString);
318        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
319 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
319 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
320          exit(0);
321        }
322        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
323        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
324          int indexOffset = 4 * subcutIndex;
325          string currentVariableString = cutStringVector.at(indexOffset);
326 <        if(currentVariableString.find("(")==std::string::npos){
326 >        if(currentVariableString.find("(")==string::npos){
327            tempCut.functions.push_back("");//no function was specified
328            tempCut.variables.push_back(currentVariableString);// variable to cut on
329          }
# Line 407 | Line 334 | OSUAnalysis::OSUAnalysis (const edm::Par
334          }
335          tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
336          tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
337 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
338          if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
339        }
340  
341        //get number of objects required to pass cut for event to pass
342        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
343 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
343 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
344        if(numberRequiredVector.size()!=2){
345 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
345 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
346          exit(0);
347        }
348  
# Line 422 | Line 350 | OSUAnalysis::OSUAnalysis (const edm::Par
350        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
351        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
352  
353 <
353 >      //Set up vectors to store the directories and subDIrectories for each channel.
354 >      string subSubDirName;
355        string tempCutName;
356        if(cuts_.at(currentCut).exists("alias")){
357          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
358 +        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
359        }
360        else{
361          //construct string for cutflow table
# Line 433 | Line 363 | OSUAnalysis::OSUAnalysis (const edm::Par
363          string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
364          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
365          tempCutName = cutName;
366 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
367        }
368 +
369 +      subSubDirNames.push_back(subSubDirName);
370        tempCut.name = tempCutName;
371  
372        tempChannel.cuts.push_back(tempCut);
# Line 441 | Line 374 | OSUAnalysis::OSUAnalysis (const edm::Par
374  
375      }//end loop over cuts
376  
377 +    vector<map<string, TH1D*>> oneDHistsTmp;
378 +    vector<map<string, TH2D*>> twoDHistsTmp;
379 +    //book a directory in the output file with the name of the channel
380 +    TFileDirectory subDir = fs_->mkdir( channelName );
381 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
382 +    if(GetPlotsAfterEachCut_){
383 +      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
384 +        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
385 +        directories.push_back(subSubDir);
386 +        map<string, TH1D*> oneDhistoMap;
387 +        oneDHistsTmp.push_back(oneDhistoMap);
388 +        map<string, TH2D*> twoDhistoMap;
389 +        twoDHistsTmp.push_back(twoDhistoMap);
390 +      }
391 +      oneDHists_.push_back(oneDHistsTmp);
392 +      twoDHists_.push_back(twoDHistsTmp);
393 +    }
394 +    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
395 +    else{
396 +      map<string, TH1D*> oneDhistoMap;
397 +      oneDHistsTmp.push_back(oneDhistoMap);
398 +      map<string, TH2D*> twoDhistoMap;
399 +      twoDHistsTmp.push_back(twoDhistoMap);
400 +      oneDHists_.push_back(oneDHistsTmp);
401 +      twoDHists_.push_back(twoDHistsTmp);
402 +      directories.push_back(subDir);
403 +
404 +    }
405 +
406 +
407 +    //book all histograms included in the configuration
408 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
409 +
410 +      TTree* newTree = directories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));  
411 +      BNTrees_.push_back(newTree);  
412 +      
413 +      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
414 +        BranchSpecs currentVar = treeBranches_.at(iBranch);
415 +        vector<float> newVec;  
416 +        BNTreeBranchVals_[currentVar.name] = newVec;  
417 +        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
418 +
419 +      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
420 +
421 +
422 +      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
423 +
424 +        histogram currentHistogram = histograms.at(currentHistogramIndex);
425 +        int numBinsElements = currentHistogram.bins.size();
426 +        int numInputVariables = currentHistogram.inputVariables.size();
427 +        int numBinEdgesX = currentHistogram.variableBinsX.size();
428 +        int numBinEdgesY = currentHistogram.variableBinsY.size();
429 +        
430 +        if(numBinsElements == 1){
431 +          if(numBinEdgesX > 1){
432 +            if(numBinEdgesY > 1)
433 +              numBinsElements = 6;
434 +            else
435 +              numBinsElements = 3;
436 +          }
437 +        }
438 +        if(numBinsElements != 3 && numBinsElements !=6){
439 +          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
440 +          exit(0);
441 +        }
442 +        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
443 +          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
444 +          exit(0);
445 +        }
446 +        else if(numBinsElements == 3){
447 +          if (currentHistogram.bins.size () == 3)
448 +            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));
449 +          else
450 +            {
451 +              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
452 +            }
453 +        }
454 +        else if(numBinsElements == 6){
455 +          if (currentHistogram.bins.size () == 6)
456 +            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));
457 +          else
458 +            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 ());
459 +        }
460 +
461 +
462 +        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
463 +
464 +        // bin      particle type
465 +        // ---      -------------
466 +        //  0        unmatched
467 +        //  1        u
468 +        //  2        d
469 +        //  3        s
470 +        //  4        c
471 +        //  5        b
472 +        //  6        t
473 +        //  7        e
474 +        //  8        mu
475 +        //  9        tau
476 +        // 10        nu
477 +        // 11        g
478 +        // 12        gamma
479 +        // 13        Z
480 +        // 14        W
481 +        // 15        light meson
482 +        // 16        K meson
483 +        // 17        D meson
484 +        // 18        B meson
485 +        // 19        light baryon
486 +        // 20        strange baryon
487 +        // 21        charm baryon
488 +        // 22        bottom baryon
489 +        // 23        QCD string
490 +        // 24        other
491 +
492 +        vector<TString> labelArray;
493 +        labelArray.push_back("unmatched");
494 +        labelArray.push_back("u");
495 +        labelArray.push_back("d");
496 +        labelArray.push_back("s");
497 +        labelArray.push_back("c");
498 +        labelArray.push_back("b");
499 +        labelArray.push_back("t");
500 +        labelArray.push_back("e");
501 +        labelArray.push_back("#mu");
502 +        labelArray.push_back("#tau");
503 +        labelArray.push_back("#nu");
504 +        labelArray.push_back("g");
505 +        labelArray.push_back("#gamma");
506 +        labelArray.push_back("Z");
507 +        labelArray.push_back("W");
508 +        labelArray.push_back("light meson");
509 +        labelArray.push_back("K meson");
510 +        labelArray.push_back("D meson");
511 +        labelArray.push_back("B meson");
512 +        labelArray.push_back("light baryon");
513 +        labelArray.push_back("strange baryon");
514 +        labelArray.push_back("charm baryon");
515 +        labelArray.push_back("bottom baryon");
516 +        labelArray.push_back("QCD string");
517 +        labelArray.push_back("other");
518 +
519 +        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
520 +          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
521 +            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
522 +          }
523 +          else {
524 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
525 +            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
526 +          }
527 +        }
528 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
529 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
530 +          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
531 +        }
532 +
533 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
534 +
535 +
536 +      // Book a histogram for the number of each object type to be plotted.
537 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
538 +      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
539 +        string currentObject = objectsToPlot.at(currentObjectIndex);
540 +        int maxNum = 10;
541 +        if(currentObject == "mcparticles") maxNum = 50;
542 +        else if(currentObject == "primaryvertexs") maxNum = 50;
543 +
544 +        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
545 +        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
546 +        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
547 +        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
548 +        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
549 +        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
550 +        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
551 +        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
552 +        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
553 +        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
554 +        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
555 +        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
556 +        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
557 +        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
558 +        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
559 +        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
560 +        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
561 +        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
562 +        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
563 +
564 +        currentObject.at(0) = toupper(currentObject.at(0));
565 +        string histoName = "num" + currentObject;
566 +
567 +        if(histoName == "numPrimaryvertexs"){
568 +          string newHistoName = histoName + "BeforePileupCorrection";
569 +          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);
570 +          newHistoName = histoName + "AfterPileupCorrection";
571 +          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);
572 +        }
573 +        else
574 +          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
575 +      }
576 +    }//end of loop over directories
577      channels.push_back(tempChannel);
578      tempChannel.cuts.clear();
446
579    }//end loop over channels
580  
581  
# Line 472 | Line 604 | OSUAnalysis::analyze (const edm::Event &
604  
605    // Retrieve necessary collections from the event.
606  
607 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
607 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
608      event.getByLabel (triggers_, triggers);
609  
610 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
610 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
611 >    event.getByLabel (trigobjs_, trigobjs);
612 >
613 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
614      event.getByLabel (jets_, jets);
615  
616 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
616 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
617      event.getByLabel (muons_, muons);
618  
619 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
619 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
620      event.getByLabel (electrons_, electrons);
621  
622 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
622 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
623      event.getByLabel (events_, events);
624  
625 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
625 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
626      event.getByLabel (taus_, taus);
627  
628 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
628 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
629      event.getByLabel (mets_, mets);
630  
631 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
631 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
632      event.getByLabel (tracks_, tracks);
633  
634 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
634 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
635      event.getByLabel (genjets_, genjets);
636  
637 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
637 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
638      event.getByLabel (mcparticles_, mcparticles);
639  
640 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
640 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
641      event.getByLabel (primaryvertexs_, primaryvertexs);
642  
643 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
643 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
644      event.getByLabel (bxlumis_, bxlumis);
645  
646 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
646 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
647      event.getByLabel (photons_, photons);
648  
649 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
649 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
650      event.getByLabel (superclusters_, superclusters);
651  
652 <  if (useTrackCaloRhoCorr_) {  
653 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
654 <    // This rho collection is not available in all BEANs.  
652 >  if (datasetType_ == "signalMC"){
653 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
654 >      event.getByLabel (stops_, stops);
655 >  }
656 >
657 >  if (useTrackCaloRhoCorr_) {
658 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
659 >    // This rho collection is not available in all BEANs.
660      // For description of rho values for different jet reconstruction algorithms, see
661 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
662 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
661 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
662 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
663    }
664  
665 +  double masterScaleFactor = 1.0;
666  
667    //get pile-up event weight
668 <  double scaleFactor = 1.00;
669 <  if(doPileupReweighting_ && datasetType_ != "data")
670 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
671 <
672 <  cTauScaleFactor_ = 1.0;
673 < #ifdef DISPLACED_SUSY
674 <  if (datasetType_ == "signalMC")
675 <    cTauScaleFactor_ = cTauWeight_->at (event);
676 < #endif
677 <  scaleFactor *= cTauScaleFactor_;
668 >  if (doPileupReweighting_ && datasetType_ != "data") {
669 >    //for "data" datasets, the numTruePV is always set to -1
670 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
671 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
672 >  }
673 >
674 >  stopCTauScaleFactor_ = 1.0;
675 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
676 >    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
677 >  masterScaleFactor *= stopCTauScaleFactor_;
678  
679    //loop over all channels
680  
# Line 544 | Line 685 | OSUAnalysis::analyze (const edm::Event &
685      counterMap passingCounter;
686      cumulativeFlags.clear ();
687  
688 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
689 +         iter != BNTreeBranchVals_.end(); iter++) {
690 +      iter->second.clear();  // clear array
691 +    }
692 +
693 +
694      bool triggerDecision = true;
695 <    if(currentChannel.triggers.size() != 0){  //triggers specified
696 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
695 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
696 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
697        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
698      }
699  
700      //loop over all cuts
554
555
556
701      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
702        cut currentCut = currentChannel.cuts.at(currentCutIndex);
559
703        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
704          string currentObject = objectsToCut.at(currentObjectIndex);
705  
# Line 571 | Line 714 | OSUAnalysis::analyze (const edm::Event &
714          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
715  
716  
717 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
718 <
719 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
577 <
717 >        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
718 >        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
719 >        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
720          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
721 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
722          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
723          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
724          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 587 | Line 730 | OSUAnalysis::analyze (const edm::Event &
730          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
731          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
732          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
733 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
734 +
735  
736  
737          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
# Line 595 | Line 740 | OSUAnalysis::analyze (const edm::Event &
740                                                                     "muon-muon pairs");
741  
742          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
743 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
744 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
745 <                                                                   "muon-secondary muon pairs");
743 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
744 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
745 >                                                                             "muon-secondary muon pairs");
746 >
747 >        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
748 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
749 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
750 >                                                                                     "electron-secondary electron pairs");
751  
752          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
753                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 607 | Line 757 | OSUAnalysis::analyze (const edm::Event &
757                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
758                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
759                                                                         "electron-muon pairs");
760 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
761 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
762 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
763 <                                                                     "track-event pairs");
764 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
765 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
766 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
767 <                                                                        "electron-track pairs");
768 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
769 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
770 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
771 <                                                                    "muon-track pairs");
772 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
773 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
774 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
775 <                                                                  "muon-tau pairs");
776 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
777 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
778 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
779 <                                                                 "tau-tau pairs");
780 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
760 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
761 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
762 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
763 >                                                                 "jet-jet pairs");
764 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
765 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
766 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
767 >                                                                      "electron-jet pairs");
768 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
769 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
770 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
771 >                                                                  "muon-jet pairs");
772 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
773 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
774 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
775 >                                                                     "track-event pairs");
776 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
777 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
778 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
779 >                                                                        "electron-track pairs");
780 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
781 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
782 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
783 >                                                                    "muon-track pairs");
784 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
785 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
786 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
787 >                                                                  "muon-tau pairs");
788 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
789                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
790 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
791 <                                                                 "tau-track pairs");
792 <        
793 <        
790 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
791 >                                                                 "tau-tau pairs");
792 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
793 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
794 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
795 >                                                                   "tau-track pairs");
796 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
797 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
798 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
799 >                                                                          "electron-trigobj pairs");
800 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
801 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
802 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
803 >                                                                      "muon-trigobj pairs");
804 >
805 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
806        }
807  
808  
809  
810      }//end loop over all cuts
641
642
811      //use cumulative flags to apply cuts at event level
812  
813      bool eventPassedAllCuts = true;
814 <
814 >    //a vector to store cumulative cut descisions after each cut.
815 >    vector<bool> eventPassedPreviousCuts;
816      //apply trigger (true if none were specified)
817      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
818  
650
819      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
820  
821        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 655 | Line 823 | OSUAnalysis::analyze (const edm::Event &
823        int numberPassing = 0;
824  
825        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
826 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
826 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
827        }
828        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
829        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
830        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
831 <
831 >      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
832      }
833 +    double scaleFactor = masterScaleFactor;
834  
835 <    //     if(datasetType_ != "data") {
836 <    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
837 <    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
838 <    //     }
835 >    muonScaleFactor_ = electronScaleFactor_ = 1.0;
836 >    if(applyLeptonSF_ && datasetType_ != "data"){
837 >      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
838 >        vector<bool> muonFlags;
839 >        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
840 >          if (cumulativeFlags.at("muons").at(i).size()){
841 >            muonFlags = cumulativeFlags.at("muons").at(i);
842 >            break;
843 >          }
844 >        }
845 >        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
846 >          if(!muonFlags.at(muonIndex)) continue;
847 >          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
848 >        }
849 >      }
850 >      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
851 >        vector<bool> electronFlags;
852 >        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
853 >          if (cumulativeFlags.at("electrons").at(i).size()){
854 >            electronFlags = cumulativeFlags.at("electrons").at(i);
855 >            break;
856 >          }
857 >        }
858 >        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
859 >          if(!electronFlags.at(electronIndex)) continue;
860 >          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
861 >        }
862 >      }
863 >    }
864 >    scaleFactor *= muonScaleFactor_;
865 >    scaleFactor *= electronScaleFactor_;
866  
867      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
868  
673
674
675    if(!eventPassedAllCuts)continue;
676
869      if (printEventInfo_) {
870 <      // Write information about event to screen, for testing purposes.  
871 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
872 <           << ": run="  << events->at(0).run
873 <           << "  lumi=" << events->at(0).lumi
874 <           << "  event=" << events->at(0).evt
875 <           << endl;  
870 >      // Write information about event to screen, for testing purposes.
871 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
872 >           << ": run="  << events->at(0).run
873 >           << "  lumi=" << events->at(0).lumi
874 >           << "  event=" << events->at(0).evt
875 >           << endl;
876      }
877  
878  
879      //filling histograms
880 <    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
881 <      histogram currentHistogram = histograms.at(histogramIndex);
882 <
883 <      if(currentHistogram.inputVariables.size() == 1){
884 <        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);
880 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
881 >      uint currentDir;
882 >      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
883 >      else{
884 >        currentDir = currentCut;
885        }
886 <    }
886 >      if(eventPassedPreviousCuts.at(currentDir)){
887 >
888 >        // Assign BNTree variables
889 >        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
890 >          BranchSpecs brSpecs = treeBranches_.at(iBranch);  
891 >          string coll = brSpecs.inputCollection;  
892 >          if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
893 >
894 >          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));            
895 >          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));
896 >          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));        
897 >          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));
898 >          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
899 >          else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
900 >          else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).at(currentDir));
901 >          else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).at(currentDir));
902 >          else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).at(currentDir));
903 >          else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).at(currentDir));
904 >          else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).at(currentDir));
905 >          else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).at(currentDir));
906 >          else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).at(currentDir));
907 >          else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).at(currentDir));
908 >          else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).at(currentDir));
909 >          else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).at(currentDir));
910 >          else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).at(currentDir));
911 >          else if(coll == "stops"
912 >                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).at(currentDir));
913 >        } // end loop over histograms  
914 >                                                                                          
915 >
916 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
917 >          histogram currentHistogram = histograms.at(histogramIndex);
918 >
919 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
920 >
921 >          if(currentHistogram.inputVariables.size() == 1){
922 >            TH1D* histo;  
923 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
924 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
925 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
926 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
927 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
928 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
929 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
930 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
931 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
932 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
933 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
934 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
935 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
936 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
937 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
938 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
939 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
940 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
941 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
942 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
943 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
944 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
945 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
946 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
947 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
948 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
949 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
950 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
951 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
952 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
953 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
954 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
955 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
956 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
957 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
958 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
959 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
960 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
961 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
962 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
963 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
964 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
965 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
966 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
967 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
968 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
969 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
970 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
971 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
972 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
973 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
974 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
975 >
976 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
977 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
978 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
979 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
980 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
981 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
982 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
983 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
984 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
985 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
986 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
987 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
988 >          }
989 >          else if(currentHistogram.inputVariables.size() == 2){
990 >            TH2D* histo;
991 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
992 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
993 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
994 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
995 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
996 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
997 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
998 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
999 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1000 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1001 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1002 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1003 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1004 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1005 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1006 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1007 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1008 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1009 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1010 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1011 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1012 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1013 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1014 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1015 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1016 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1017 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1018 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1019 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1020 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1021 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1022 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1023 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1024 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1025 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1026 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1027 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1028 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1029 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1030 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1031 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1032 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1033 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1034 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1035 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1036 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1037 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1038 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1039 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1040 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1041 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1042 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1043 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1044 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1045 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1046 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1047 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1048 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1049 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1050 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1051 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1052 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1053 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1054 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1055 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1056 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1057 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1058 >          }
1059 >          
1060 >        }
1061  
1062  
1063 +        //fills histograms with the sizes of collections
1064 +        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1065  
1066 <    //fills histograms with the sizes of collections
1067 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1068 <
1069 <      string currentObject = objectsToPlot.at(currentObjectIndex);
1070 <
1071 <      string objectToPlot = "";  
1072 <
1073 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
1074 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
1075 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
1076 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
1077 <      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
1078 <      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
1079 <      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
1080 <      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
1081 <      else if(currentObject == "tau-track pairs")         objectToPlot = "tauTrackPairs";
1082 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
1083 <      else if(currentObject == "muon-secondary muon pairs")       objectToPlot = "muonSecondaryMuonPairs";  
1084 <      else if(currentObject == "secondary muons")         objectToPlot = "secondaryMuons";  
1085 <      else objectToPlot = currentObject;
1086 <
1087 <      string tempCurrentObject = objectToPlot;
1088 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
1089 <      string histoName = "num" + tempCurrentObject;
1090 <
1091 <      //set position of primary vertex in event, in order to calculate quantities relative to it
1092 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1093 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
1094 <        int numToPlot = 0;
1095 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1096 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1097 <        }
1098 <        if(objectToPlot == "primaryvertexs"){
1099 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1100 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1101 <        }
1102 <        else {
1103 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
1104 <        }
1066 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1067 >          string objectToPlot = "";
1068 >
1069 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1070 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1071 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1072 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1073 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1074 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1075 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1076 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1077 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1078 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1079 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1080 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1081 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1082 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1083 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1084 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1085 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1086 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1087 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1088 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1089 >          else objectToPlot = currentObject;
1090 >
1091 >          string tempCurrentObject = objectToPlot;
1092 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1093 >          string histoName = "num" + tempCurrentObject;
1094 >
1095 >          //set position of primary vertex in event, in order to calculate quantities relative to it
1096 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1097 >            vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1098 >            int numToPlot = 0;
1099 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1100 >              if(lastCutFlags.at(currentFlag)) numToPlot++;
1101 >            }
1102 >            if(objectToPlot == "primaryvertexs"){
1103 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1104 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1105 >            }
1106 >            else {
1107 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1108 >            }
1109 >          }
1110 >          else if(objectToPlot == "jets")           oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1111 >          else if(objectToPlot == "secondaryJets")  oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1112 >          else if(objectToPlot == "muons")          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1113 >          else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1114 >          else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1115 >          else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1116 >          else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1117 >          else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1118 >          else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1119 >          else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1120 >          else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1121 >          else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1122 >          else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1123 >          else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1124 >          else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1125 >          else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1126 >          else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1127 >          else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1128 >          else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1129 >          else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1130 >          else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1131 >          else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1132 >          else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1133 >          else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1134 >          else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1135 >          else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1136 >          else if(objectToPlot == "primaryvertexs"){
1137 >            oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1138 >            oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1139 >          }
1140 >          if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
1141 >
1142 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1143        }
1144 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
832 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
833 <      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
834 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
835 <      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
836 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
837 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
838 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
839 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
840 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
841 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
842 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
843 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
844 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
845 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
846 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
847 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
848 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
849 <      else if(objectToPlot == "primaryvertexs"){
850 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
851 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
852 <      }
1144 >    }
1145  
1146 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1146 >    BNTrees_.at(currentChannelIndex)->Fill();  
1147  
1148    } //end loop over channel
1149  
1150 <  masterCutFlow_->fillCutFlow(scaleFactor);
1150 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1151 >
1152  
1153   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1154  
# Line 872 | Line 1165 | OSUAnalysis::evaluateComparison (double
1165    else if(comparison == "==") return testValue == cutValue;
1166    else if(comparison == "=") return testValue == cutValue;
1167    else if(comparison == "!=") return testValue != cutValue;
1168 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1168 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1169 >
1170 > }
1171 >
1172 > bool
1173 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1174 >
1175 >
1176 >  if(comparison == ">")       return testValue >  cutValue;
1177 >  else if(comparison == ">=") return testValue >= cutValue;
1178 >  else if(comparison == "<")  return testValue <  cutValue;
1179 >  else if(comparison == "<=") return testValue <= cutValue;
1180 >  else if(comparison == "==") return testValue == cutValue;
1181 >  else if(comparison == "=") return testValue == cutValue;
1182 >  else if(comparison == "!=") return testValue != cutValue;
1183 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1184  
1185   }
1186  
1187   bool
1188 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1188 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1189  
1190 +  //initialize to false until a chosen trigger is passed
1191    bool triggerDecision = false;
1192  
1193 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1194 <    {
1195 <      if(trigger->pass != 1) continue;
1196 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1197 <        {
889 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
890 <            triggerDecision = true;
891 <          }
892 <        }
893 <    }
894 <  return triggerDecision;
1193 >  //loop over all triggers defined in the event
1194 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1195 >
1196 >    //we're only interested in triggers that actually passed
1197 >    if(trigger->pass != 1) continue;
1198  
1199 +    //if the event passes one of the veto triggers, exit and return false
1200 +    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1201 +      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1202 +    }
1203 +    //if the event passes one of the chosen triggers, set triggerDecision to true
1204 +    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1205 +      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1206 +    }  
1207 +  }
1208 +  //if none of the veto triggers fired:
1209 +  //return the OR of all the chosen triggers
1210 +  if (triggersToTest.size() != 0) return triggerDecision;
1211 +  //or if no triggers were defined return true
1212 +  else return true;
1213   }
1214  
1215 < std::vector<std::string>
1215 >
1216 > vector<string>
1217   OSUAnalysis::splitString (string inputString){
1218  
1219 <  std::stringstream stringStream(inputString);
1220 <  std::istream_iterator<std::string> begin(stringStream);
1221 <  std::istream_iterator<std::string> end;
1222 <  std::vector<std::string> stringVector(begin, end);
1219 >  stringstream stringStream(inputString);
1220 >  istream_iterator<string> begin(stringStream);
1221 >  istream_iterator<string> end;
1222 >  vector<string> stringVector(begin, end);
1223    return stringVector;
1224  
1225   }
1226  
1227  
1228   void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1229 <  // Set two object strings from the tempInputCollection string,
1230 <  // For example, if tempInputCollection is "electron-muon pairs",
1231 <  // then obj1 = "electrons" and obj2 = "muons".  
1232 <  // Note that the objects have an "s" appended.  
1229 >  // Set two object strings from the tempInputCollection string,
1230 >  // For example, if tempInputCollection is "electron-muon pairs",
1231 >  // then obj1 = "electrons" and obj2 = "muons".
1232 >  // Note that the objects have an "s" appended.
1233  
1234    int dashIndex = tempInputCollection.find("-");
1235    int spaceIndex = tempInputCollection.find_last_of(" ");
1236    int secondWordLength = spaceIndex - dashIndex;
1237 <  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1237 >  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1238    obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1239 <  
1240 < }
1239 >
1240 > }
1241  
1242  
1243   string OSUAnalysis::getObjToGet(string obj) {
1244    // Return the string corresponding to the object to get for the given obj string.
1245 <  // Right now this only handles the case in which obj contains "secondary",
1246 <  // e.g, "secondary muons".  
1247 <  // 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);
1245 >  // Right now this only handles the case in which obj contains "secondary",
1246 >  // e.g, "secondary muons".
1247 >  // Note that "s" is NOT appended.
1248  
1249 < }  
1249 >  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1250 >  int firstSpaceIndex = obj.find_first_of(" ");
1251 >  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1252  
1253 + }
1254  
1255  
1256 + //!jet valueLookup
1257   double
1258 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1258 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1259  
1260    double value = 0.0;
1261    if(variable == "energy") value = object->energy;
# Line 1057 | Line 1375 | OSUAnalysis::valueLookup (const BNjet* o
1375    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1376  
1377  
1378 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1378 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1379  
1380    value = applyFunction(function, value);
1381  
# Line 1065 | Line 1383 | OSUAnalysis::valueLookup (const BNjet* o
1383   }
1384  
1385  
1386 <
1386 > //!muon valueLookup
1387   double
1388 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1388 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1389  
1390    double value = 0.0;
1391    if(variable == "energy") value = object->energy;
# Line 1228 | Line 1546 | OSUAnalysis::valueLookup (const BNmuon*
1546    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1547    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1548    else if(variable == "metMT") {
1549 <    const BNmet *met = chosenMET ();
1232 <    if (met)
1549 >    if (const BNmet *met = chosenMET ())
1550        {
1551 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1552 <          p2 (met->px, met->py, 0.0, met->pt);
1236 <
1237 <        value = (p1 + p2).Mt ();
1551 >        double dPhi = deltaPhi (object->phi, met->phi);
1552 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1553        }
1554      else
1555        value = -999;
# Line 1352 | Line 1667 | OSUAnalysis::valueLookup (const BNmuon*
1667      value = object->isGlobalMuon > 0                \
1668        && object->isPFMuon > 0                        \
1669        && object->normalizedChi2 < 10                \
1670 <                                  && object->numberOfValidMuonHits > 0        \
1670 >      && object->numberOfValidMuonHits > 0        \
1671        && object->numberOfMatchedStations > 1        \
1672        && fabs(object->correctedD0Vertex) < 0.2        \
1673        && fabs(object->correctedDZ) < 0.5        \
# Line 1361 | Line 1676 | OSUAnalysis::valueLookup (const BNmuon*
1676    }
1677    else if(variable == "tightIDdisplaced"){
1678      value = object->isGlobalMuon > 0                \
1679 +      && object->isPFMuon > 0                        \
1680        && object->normalizedChi2 < 10                \
1681 <                                  && object->numberOfValidMuonHits > 0        \
1681 >      && object->numberOfValidMuonHits > 0        \
1682        && object->numberOfMatchedStations > 1        \
1683        && object->numberOfValidPixelHits > 0        \
1684        && object->numberOfLayersWithMeasurement > 5;
1685    }
1686  
1687 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1687 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1688  
1689    else if(variable == "genMatchedPdgId"){
1690      int index = getGenMatchedParticleIndex(object);
# Line 1388 | Line 1704 | OSUAnalysis::valueLookup (const BNmuon*
1704    }
1705    else if(variable == "genMatchedMotherIdReverse"){
1706      int index = getGenMatchedParticleIndex(object);
1707 <    if(index == -1) value = 23;
1708 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1707 >    if(index == -1) value = 24;
1708 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1709    }
1710    else if(variable == "genMatchedGrandmotherId"){
1711      int index = getGenMatchedParticleIndex(object);
# Line 1401 | Line 1717 | OSUAnalysis::valueLookup (const BNmuon*
1717      }
1718      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1719    }
1720 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1721 +    int index = getGenMatchedParticleIndex(object);
1722 +    if(index == -1) value = 24;
1723 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1724 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1725 +      if(motherIndex == -1) value = 24;
1726 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1727 +    }
1728 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1729 +  }
1730 +  else if(variable == "pfMuonsFromVertex"){
1731 +    double d0Error, dzError;
1732 +
1733 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1734 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1735 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1736 +      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1737 +      || fabs (object->correctedDZ / dzError) > 99.0;
1738 +    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1739 +  }
1740  
1741  
1742  
1743 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1743 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1744  
1745    value = applyFunction(function, value);
1746  
1747    return value;
1748   }
1749  
1750 <
1750 > //!electron valueLookup
1751   double
1752 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1752 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1753  
1754    double value = 0.0;
1755    if(variable == "energy") value = object->energy;
# Line 1579 | Line 1915 | OSUAnalysis::valueLookup (const BNelectr
1915    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1916    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1917    else if(variable == "metMT") {
1918 <    const BNmet *met = chosenMET ();
1583 <    if (met)
1918 >    if (const BNmet *met = chosenMET ())
1919        {
1920 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1921 <          p2 (met->px, met->py, 0.0, met->pt);
1587 <
1588 <        value = (p1 + p2).Mt ();
1920 >        double dPhi = deltaPhi (object->phi, met->phi);
1921 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1922        }
1923      else
1924        value = -999;
# Line 1750 | Line 2083 | OSUAnalysis::valueLookup (const BNelectr
2083    }
2084  
2085  
2086 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2086 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2087  
2088    else if(variable == "genMatchedPdgId"){
2089      int index = getGenMatchedParticleIndex(object);
# Line 1771 | Line 2104 | OSUAnalysis::valueLookup (const BNelectr
2104    }
2105    else if(variable == "genMatchedMotherIdReverse"){
2106      int index = getGenMatchedParticleIndex(object);
2107 <    if(index == -1) value = 23;
2108 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2107 >    if(index == -1) value = 24;
2108 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2109    }
2110    else if(variable == "genMatchedGrandmotherId"){
2111      int index = getGenMatchedParticleIndex(object);
# Line 1784 | Line 2117 | OSUAnalysis::valueLookup (const BNelectr
2117      }
2118      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2119    }
2120 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2121 +    int index = getGenMatchedParticleIndex(object);
2122 +    if(index == -1) value = 24;
2123 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2124 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2125 +      if(motherIndex == -1) value = 24;
2126 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2127 +    }
2128 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2129 +  }
2130 +  else if(variable == "pfElectronsFromVertex"){
2131 +    double d0Error, dzError;
2132 +
2133 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2134 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2135 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2136 +      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2137 +      || fabs (object->correctedDZ / dzError) > 99.0;
2138 +    value = !value;
2139 +  }
2140  
2141  
2142  
2143 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2143 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2144  
2145    value = applyFunction(function, value);
2146  
2147    return value;
2148   }
2149  
2150 <
2150 > //!event valueLookup
2151   double
2152 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
2152 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2153  
2154    double value = 0.0;
2155  
# Line 1865 | Line 2218 | OSUAnalysis::valueLookup (const BNevent*
2218    else if(variable == "id2") value = object->id2;
2219    else if(variable == "evt") value = object->evt;
2220    else if(variable == "puScaleFactor"){
2221 <    if(datasetType_ != "data")
2221 >    if(doPileupReweighting_ && datasetType_ != "data")
2222        value = puWeight_->at (events->at (0).numTruePV);
2223      else
2224        value = 1.0;
2225    }
2226 <  else if(variable == "muonScaleFactor"){
2227 <    if(datasetType_ != "data")
2228 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1876 <      value = 1.0;
1877 <    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_;
2226 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2227 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2228 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2229  
2230 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2230 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2231  
2232    value = applyFunction(function, value);
2233  
2234    return value;
2235   }
2236  
2237 + //!tau valueLookup
2238   double
2239 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2239 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2240  
2241    double value = 0.0;
2242  
# Line 1941 | Line 2282 | OSUAnalysis::valueLookup (const BNtau* o
2282  
2283  
2284  
2285 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2285 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2286  
2287    else if(variable == "genMatchedPdgId"){
2288      int index = getGenMatchedParticleIndex(object);
# Line 1961 | Line 2302 | OSUAnalysis::valueLookup (const BNtau* o
2302    }
2303    else if(variable == "genMatchedMotherIdReverse"){
2304      int index = getGenMatchedParticleIndex(object);
2305 <    if(index == -1) value = 23;
2306 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2305 >    if(index == -1) value = 24;
2306 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2307    }
2308    else if(variable == "genMatchedGrandmotherId"){
2309      int index = getGenMatchedParticleIndex(object);
# Line 1974 | Line 2315 | OSUAnalysis::valueLookup (const BNtau* o
2315      }
2316      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2317    }
2318 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2319 +    int index = getGenMatchedParticleIndex(object);
2320 +    if(index == -1) value = 24;
2321 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2322 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2323 +      if(motherIndex == -1) value = 24;
2324 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2325 +    }
2326 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2327 +  }
2328  
2329  
2330 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2330 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2331  
2332    value = applyFunction(function, value);
2333  
2334    return value;
2335   }
2336  
2337 + //!met valueLookup
2338   double
2339 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2339 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2340  
2341    double value = 0.0;
2342  
# Line 2048 | Line 2400 | OSUAnalysis::valueLookup (const BNmet* o
2400    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2401    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2402  
2403 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2403 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2404  
2405    value = applyFunction(function, value);
2406  
2407    return value;
2408   }
2409  
2410 + //!track valueLookup
2411   double
2412 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2412 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2413  
2414    double value = 0.0;
2415    double pMag = sqrt(object->pt * object->pt +
2416 <                     object->pz * object->pz);
2417 <  
2416 >                     object->pz * object->pz);
2417 >
2418    if(variable == "pt") value = object->pt;
2419    else if(variable == "px") value = object->px;
2420    else if(variable == "py") value = object->py;
# Line 2082 | Line 2435 | OSUAnalysis::valueLookup (const BNtrack*
2435  
2436  
2437    //additional BNs info for disappTrks
2085  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2438    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2439    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2440    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2441    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2442    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2443    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2444 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2445    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2446    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2447    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2448 <  
2448 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2449  
2450    //user defined variables
2451    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;
2452    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2453 +  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2454    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2455    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2456 <  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2457 <  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2456 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2457 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2458    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2459    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2460    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2461    else if(variable == "ptError")                    value = object->ptError;
2462    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2463 <  else if (variable == "d0wrtPV"){      
2464 <    double vx = object->vx - chosenVertex ()->x,        
2465 <      vy = object->vy - chosenVertex ()->y,      
2466 <      px = object->px,  
2467 <      py = object->py,  
2468 <      pt = object->pt;  
2469 <    value = (-vx * py + vy * px) / pt;  
2470 <  }      
2471 <  else if (variable == "dZwrtPV"){      
2472 <    double vx = object->vx - chosenVertex ()->x,        
2473 <      vy = object->vy - chosenVertex ()->y,      
2474 <      vz = object->vz - chosenVertex ()->z,      
2475 <      px = object->px,  
2476 <      py = object->py,  
2477 <      pz = object->pz,  
2478 <      pt = object->pt;  
2479 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2480 <  }    
2481 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2463 >  else if (variable == "d0wrtPV"){
2464 >    double vx = object->vx - chosenVertex ()->x,
2465 >      vy = object->vy - chosenVertex ()->y,
2466 >      px = object->px,
2467 >      py = object->py,
2468 >      pt = object->pt;
2469 >    value = (-vx * py + vy * px) / pt;
2470 >  }
2471 >  else if (variable == "dZwrtPV"){
2472 >    double vx = object->vx - chosenVertex ()->x,
2473 >      vy = object->vy - chosenVertex ()->y,
2474 >      vz = object->vz - chosenVertex ()->z,
2475 >      px = object->px,
2476 >      py = object->py,
2477 >      pz = object->pz,
2478 >      pt = object->pt;
2479 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2480 >  }
2481 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2482  
2483    else if(variable == "genMatchedPdgId"){
2484      int index = getGenMatchedParticleIndex(object);
# Line 2145 | Line 2499 | OSUAnalysis::valueLookup (const BNtrack*
2499    }
2500    else if(variable == "genMatchedMotherIdReverse"){
2501      int index = getGenMatchedParticleIndex(object);
2502 <    if(index == -1) value = 23;
2503 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2502 >    if(index == -1) value = 24;
2503 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2504    }
2505    else if(variable == "genMatchedGrandmotherId"){
2506      int index = getGenMatchedParticleIndex(object);
# Line 2158 | Line 2512 | OSUAnalysis::valueLookup (const BNtrack*
2512      }
2513      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2514    }
2515 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2516 +    int index = getGenMatchedParticleIndex(object);
2517 +    if(index == -1) value = 24;
2518 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2519 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2520 +      if(motherIndex == -1) value = 24;
2521 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2522 +    }
2523 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2524 +  }
2525  
2526  
2527  
2528 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2528 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2529  
2530    value = applyFunction(function, value);
2531  
2532    return value;
2533   }
2534  
2535 + //!genjet valueLookup
2536   double
2537 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2537 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2538  
2539    double value = 0.0;
2540  
# Line 2189 | Line 2554 | OSUAnalysis::valueLookup (const BNgenjet
2554    else if(variable == "charge") value = object->charge;
2555  
2556  
2557 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2557 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2558  
2559    value = applyFunction(function, value);
2560  
2561    return value;
2562   }
2563  
2564 + //!mcparticle valueLookup
2565   double
2566 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2566 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2567  
2568    double value = 0.0;
2569  
# Line 2322 | Line 2688 | OSUAnalysis::valueLookup (const BNmcpart
2688    }
2689  
2690  
2691 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2691 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2692  
2693    value = applyFunction(function, value);
2694  
2695    return value;
2696   }
2697  
2698 + //!primaryvertex valueLookup
2699   double
2700 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2700 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2701  
2702    double value = 0.0;
2703  
# Line 2349 | Line 2716 | OSUAnalysis::valueLookup (const BNprimar
2716    else if(variable == "isGood") value = object->isGood;
2717  
2718  
2719 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2719 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2720  
2721    value = applyFunction(function, value);
2722  
2723    return value;
2724   }
2725  
2726 + //!bxlumi valueLookup
2727   double
2728 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2728 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2729  
2730    double value = 0.0;
2731  
# Line 2366 | Line 2734 | OSUAnalysis::valueLookup (const BNbxlumi
2734    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2735  
2736  
2737 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2737 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2738  
2739    value = applyFunction(function, value);
2740  
2741    return value;
2742   }
2743  
2744 + //!photon valueLookup
2745   double
2746 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2746 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2747  
2748    double value = 0.0;
2749  
# Line 2449 | Line 2818 | OSUAnalysis::valueLookup (const BNphoton
2818    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2819  
2820  
2452
2821  
2822 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2822 >
2823 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2824  
2825    else if(variable == "genMatchedPdgId"){
2826      int index = getGenMatchedParticleIndex(object);
# Line 2473 | Line 2842 | OSUAnalysis::valueLookup (const BNphoton
2842    }
2843    else if(variable == "genMatchedMotherIdReverse"){
2844      int index = getGenMatchedParticleIndex(object);
2845 <    if(index == -1) value = 23;
2846 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2845 >    if(index == -1) value = 24;
2846 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2847    }
2848    else if(variable == "genMatchedGrandmotherId"){
2849      int index = getGenMatchedParticleIndex(object);
# Line 2486 | Line 2855 | OSUAnalysis::valueLookup (const BNphoton
2855      }
2856      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2857    }
2858 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2859 +    int index = getGenMatchedParticleIndex(object);
2860 +    if(index == -1) value = 24;
2861 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2862 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2863 +      if(motherIndex == -1) value = 24;
2864 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2865 +    }
2866 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2867 +  }
2868  
2869  
2870 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2870 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2871  
2872    value = applyFunction(function, value);
2873  
2874    return value;
2875   }
2876  
2877 + //!supercluster valueLookup
2878   double
2879 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2879 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2880  
2881    double value = 0.0;
2882  
# Line 2510 | Line 2890 | OSUAnalysis::valueLookup (const BNsuperc
2890    else if(variable == "theta") value = object->theta;
2891  
2892  
2893 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2893 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2894  
2895    value = applyFunction(function, value);
2896  
2897    return value;
2898   }
2899  
2900 + //!trigobj valueLookup
2901 + double
2902 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2903 +
2904 +  double value = 0.0;
2905 +
2906 +  if(variable == "pt") value = object->pt;
2907 +  else if(variable == "eta") value = object->eta;
2908 +  else if(variable == "phi") value = object->phi;
2909 +  else if(variable == "px") value = object->px;
2910 +  else if(variable == "py") value = object->py;
2911 +  else if(variable == "pz") value = object->pz;
2912 +  else if(variable == "et") value = object->et;
2913 +  else if(variable == "energy") value = object->energy;
2914 +  else if(variable == "etTotal") value = object->etTotal;
2915 +  else if(variable == "id") value = object->id;
2916 +  else if(variable == "charge") value = object->charge;
2917 +  else if(variable == "isIsolated") value = object->isIsolated;
2918 +  else if(variable == "isMip") value = object->isMip;
2919 +  else if(variable == "isForward") value = object->isForward;
2920 +  else if(variable == "isRPC") value = object->isRPC;
2921 +  else if(variable == "bx") value = object->bx;
2922 +  else if(variable == "filter") {
2923 +    if ((stringValue = object->filter) == "")
2924 +      stringValue = "none";  // stringValue should only be empty if value is filled
2925 +  }
2926  
2927 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2928 +
2929 +  value = applyFunction(function, value);
2930 +
2931 +  return value;
2932 + }
2933 +
2934 + //!muon-muon pair valueLookup
2935   double
2936 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2936 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2937  
2938    double value = 0.0;
2939  
# Line 2581 | Line 2995 | OSUAnalysis::valueLookup (const BNmuon*
2995        value = object2->correctedD0;
2996      }
2997  
2998 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2998 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2999  
3000    value = applyFunction(function, value);
3001  
3002    return value;
3003   }
3004  
3005 + //!electron-electron pair valueLookup
3006   double
3007 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
3007 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
3008  
3009    double value = 0.0;
3010  
# Line 2636 | Line 3051 | OSUAnalysis::valueLookup (const BNelectr
3051      value = object2->correctedD0;
3052    }
3053  
3054 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3054 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3055  
3056    value = applyFunction(function, value);
3057  
3058    return value;
3059   }
3060 <
3060 > //!electron-muon pair valueLookup
3061   double
3062 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
3062 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3063  
3064    double value = 0.0;
3065  
# Line 2702 | Line 3117 | OSUAnalysis::valueLookup (const BNelectr
3117    else if(variable == "muonRelPFdBetaIso"){
3118      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3119    }
3120 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3121 +  value = applyFunction(function, value);
3122  
3123 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3123 >  return value;
3124 > }
3125 >
3126 > //!electron-jet pair valueLookup
3127 > double
3128 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3129 >
3130 >  double value = 0.0;
3131 >
3132 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3133 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3134 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3135 >  else if(variable == "invMass"){
3136 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3137 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3138 >    value = (fourVector1 + fourVector2).M();
3139 >  }
3140 >  else if(variable == "pt"){
3141 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3142 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3143 >    value = (fourVector1 + fourVector2).Pt();
3144 >  }
3145 >  else if(variable == "threeDAngle")
3146 >    {
3147 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3148 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3149 >      value = (threeVector1.Angle(threeVector2));
3150 >    }
3151 >  else if(variable == "chargeProduct"){
3152 >    value = object1->charge*object2->charge;
3153 >  }
3154  
3155 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3156    value = applyFunction(function, value);
3157  
3158    return value;
3159   }
3160  
3161 + //!muon-jet pair valueLookup
3162 + double
3163 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3164 +
3165 +  double value = 0.0;
3166  
3167 < double  
2715 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2716 <  double electronMass = 0.000511;        
2717 <  double value = 0.0;    
2718 <  TLorentzVector fourVector1(0, 0, 0, 0);        
2719 <  TLorentzVector fourVector2(0, 0, 0, 0);        
2720 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
3167 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3168    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3169 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3170 <  else if(variable == "invMass"){        
3171 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3172 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3173 <        
3174 <    value = (fourVector1 + fourVector2).M();    
3169 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3170 >  else if(variable == "invMass"){
3171 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3172 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3173 >    value = (fourVector1 + fourVector2).M();
3174 >  }
3175 >  else if(variable == "pt"){
3176 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3177 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3178 >    value = (fourVector1 + fourVector2).Pt();
3179 >  }
3180 >  else if(variable == "threeDAngle")
3181 >    {
3182 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3183 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3184 >      value = (threeVector1.Angle(threeVector2));
3185 >    }
3186 >  else if(variable == "chargeProduct"){
3187 >    value = object1->charge*object2->charge;
3188    }
3189 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3190 <  value = applyFunction(function, value);        
3191 <  return value;  
3189 >
3190 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3191 >  value = applyFunction(function, value);
3192 >
3193 >  return value;
3194   }
3195  
3196 + //!jet-jet pair valueLookup
3197 + double
3198 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3199 +
3200 +  double value = 0.0;
3201 +
3202 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3203 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3204 +  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3205 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3206 +  else if(variable == "invMass"){
3207 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3208 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3209 +    value = (fourVector1 + fourVector2).M();
3210 +  }
3211 +  else if(variable == "pt"){
3212 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3213 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3214 +    value = (fourVector1 + fourVector2).Pt();
3215 +  }
3216 +  else if(variable == "threeDAngle")
3217 +    {
3218 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3219 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3220 +      value = (threeVector1.Angle(threeVector2));
3221 +    }
3222 +  else if(variable == "chargeProduct"){
3223 +    value = object1->charge*object2->charge;
3224 +  }
3225  
3226 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3227 +  value = applyFunction(function, value);
3228  
3229 +  return value;
3230 + }
3231 + //!electron-track pair valueLookup
3232   double
3233 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3233 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3234 >  double electronMass = 0.000511;
3235 >  double value = 0.0;
3236 >  TLorentzVector fourVector1(0, 0, 0, 0);
3237 >  TLorentzVector fourVector2(0, 0, 0, 0);
3238 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3239 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3240 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3241 >  else if(variable == "invMass"){
3242 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3243 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3244 >
3245 >    value = (fourVector1 + fourVector2).M();
3246 >  }
3247 >  else if(variable == "chargeProduct"){
3248 >    value = object1->charge*object2->charge;
3249 >  }
3250 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3251 >  value = applyFunction(function, value);
3252 >  return value;
3253 >
3254 > }
3255 >
3256 >
3257 > //!muon-track pair valueLookup
3258 > double
3259 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3260    double pionMass = 0.140;
3261    double muonMass = 0.106;
3262    double value = 0.0;
# Line 2749 | Line 3271 | OSUAnalysis::valueLookup (const BNmuon*
3271  
3272      value = (fourVector1 + fourVector2).M();
3273    }
3274 +  else if(variable == "chargeProduct"){
3275 +    value = object1->charge*object2->charge;
3276 +  }
3277  
3278    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3279    value = applyFunction(function, value);
3280    return value;
3281   }
3282  
3283 <
3283 > //!tau-tau pair valueLookup
3284   double
3285 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3285 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3286    double value = 0.0;
3287    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3288    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2768 | Line 3293 | OSUAnalysis::valueLookup (const BNtau* o
3293      value = (fourVector1 + fourVector2).M();
3294    }
3295  
3296 +  else if(variable == "chargeProduct"){
3297 +    value = object1->charge*object2->charge;
3298 +  }
3299 +
3300    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3301    value = applyFunction(function, value);
3302    return value;
3303   }
3304  
3305 <
3305 > //!muon-tau pair valueLookup
3306   double
3307 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3307 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3308    double value = 0.0;
3309    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3310    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2786 | Line 3315 | OSUAnalysis::valueLookup (const BNmuon*
3315      value = (fourVector1 + fourVector2).M();
3316    }
3317  
3318 +  else if(variable == "chargeProduct"){
3319 +    value = object1->charge*object2->charge;
3320 +  }
3321 +
3322    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3323    value = applyFunction(function, value);
3324    return value;
3325   }
3326  
3327 + //!tau-track pair valueLookup
3328   double
3329 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3329 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3330    double value = 0.0;
3331    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3332    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3333 +  else if(variable == "chargeProduct"){
3334 +    value = object1->charge*object2->charge;
3335 +  }
3336  
3337    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3338    value = applyFunction(function, value);
# Line 2803 | Line 3340 | OSUAnalysis::valueLookup (const BNtau* o
3340   }
3341  
3342  
3343 <
3343 > //!track-event pair valueLookup
3344   double
3345 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3345 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3346  
3347    double value = 0.0;
3348    double pMag = sqrt(object1->pt * object1->pt +
3349 <                     object1->pz * object1->pz);  
3349 >                     object1->pz * object1->pz);
3350  
3351    if      (variable == "numPV")                      value = object2->numPV;
3352    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3353    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3354 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3355 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3354 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3355 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3356 >
3357 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3358 >
3359 >  value = applyFunction(function, value);
3360 >
3361 >  return value;
3362 >
3363 > }
3364 >
3365 > //!electron-trigobj pair valueLookup
3366 > double
3367 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3368 >
3369 >  double value = 0.0;
3370 >
3371 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3372 >  else if (variable == "match"){
3373 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3374 >      stringValue = object2->filter;
3375 >    else
3376 >      stringValue = "none";
3377 >  }
3378 >
3379 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3380 >
3381 >  value = applyFunction(function, value);
3382 >
3383 >  return value;
3384 >
3385 > }
3386 >
3387 > //!muon-trigobj pair valueLookup
3388 > double
3389 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3390 >
3391 >  double value = 0.0;
3392  
3393 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3393 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3394 >
3395 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3396  
3397    value = applyFunction(function, value);
3398  
3399    return value;
3400  
3401 < }  
3401 > }
3402 >
3403 > //!stop valueLookup
3404 > double
3405 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3406 >
3407 >
3408 >  double value = 0.0;
3409 >
3410 >  if(variable == "ctau") value = object->ctau;
3411 >
3412 >  else if (variable == "d0"){
3413 >    double vx = object->vx - chosenVertex ()->x,
3414 >      vy = object->vy - chosenVertex ()->y,
3415 >      px = object->px,
3416 >      py = object->py,
3417 >      pt = object->pt;
3418 >    value = (-vx * py + vy * px) / pt;
3419 >  }
3420 >
3421 >  else if (variable == "dz"){
3422 >    double vx = object->vx - chosenVertex ()->x,
3423 >      vy = object->vy - chosenVertex ()->y,
3424 >      vz = object->vz - chosenVertex ()->z,
3425 >      px = object->px,
3426 >      py = object->py,
3427 >      pz = object->pz,
3428 >      pt = object->pt;
3429 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3430 >  }
3431 >
3432 >  else if (variable == "minD0"){
3433 >    double minD0=999;
3434 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3435 >      double vx = object->vx - vertex->x,
3436 >        vy = object->vy - vertex->y,
3437 >        px = object->px,
3438 >        py = object->py,
3439 >        pt = object->pt;
3440 >      value = (-vx * py + vy * px) / pt;
3441 >      if(abs(value) < abs(minD0)) minD0 = value;
3442 >    }
3443 >    value = minD0;
3444 >  }
3445 >  else if (variable == "minDz"){
3446 >    double minDz=999;
3447 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3448 >      double vx = object->vx - vertex->x,
3449 >        vy = object->vy - vertex->y,
3450 >        vz = object->vz - vertex->z,
3451 >        px = object->px,
3452 >        py = object->py,
3453 >        pz = object->pz,
3454 >        pt = object->pt;
3455 >      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3456 >      if(abs(value) < abs(minDz)) minDz = value;
3457 >    }
3458 >    value = minDz;
3459 >  }
3460 >  else if(variable == "distToVertex"){
3461 >    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3462 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3463 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3464 >  }
3465 >  else if (variable == "minDistToVertex"){
3466 >    double minDistToVertex=999;
3467 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3468 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3469 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3470 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3471 >
3472 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3473 >    }
3474 >    value = minDistToVertex;
3475 >  }
3476 >  else if (variable == "distToVertexDifference"){
3477 >    double minDistToVertex=999;
3478 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3479 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3480 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3481 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3482 >
3483 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3484 >    }
3485 >    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3486 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3487 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3488 >
3489 >    value = distToChosenVertex - minDistToVertex;
3490 >  }
3491 >
3492 >  else if (variable == "closestVertexRank"){
3493 >    double minDistToVertex=999;
3494 >    int vertex_rank = 0;
3495 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3496 >      vertex_rank++;
3497 >      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3498 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3499 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3500 >
3501 >      if(abs(dist) < abs(minDistToVertex)){
3502 >        value = vertex_rank;
3503 >        minDistToVertex = dist;
3504 >      }
3505 >    }
3506 >  }
3507 >
3508 >
3509 >
3510 >
3511 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3512 >
3513 >  value = applyFunction(function, value);
3514 >
3515 >  return value;
3516 >
3517 > }
3518 >
3519 >
3520 >
3521  
3522   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3523   // Return true iff no other tracks are found in this cone.
# Line 2872 | Line 3566 | OSUAnalysis::getTrkPtTrue (const BNtrack
3566  
3567   double
3568   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3569 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3570 <  if (!useTrackCaloRhoCorr_) return -99;  
3571 <  // if (!rhokt6CaloJetsHandle_) {
3572 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3573 <  //   return -99;  
3569 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3570 >  if (!useTrackCaloRhoCorr_) return -99;
3571 >  // if (!rhokt6CaloJetsHandle_) {
3572 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3573 >  //   return -99;
3574    // }
3575 <  double radDeltaRCone = 0.5;  
3576 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3577 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3578 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3579 <  return caloTotRhoCorrCalo;  
3580 <
3575 >  double radDeltaRCone = 0.5;
3576 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3577 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3578 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3579 >  return caloTotRhoCorrCalo;
3580 >
3581   }
3582  
3583  
# Line 2921 | Line 3615 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3615    double deltaRLowest = 999;
3616    int value = 0;
3617    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3618 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3618 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3619      double eta = ecal->etaEcal;
3620      double phi = ecal->phiEcal;
3621 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3621 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3622      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3623    }
3624    if (deltaRLowest<0.05) {value = 1;}
# Line 2932 | Line 3626 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3626    return value;
3627   }
3628  
3629 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3629 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3630   template <class InputObject>
3631   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3632    double genDeltaRLowest = 999.;
# Line 2952 | Line 3646 | OSUAnalysis::applyFunction(string functi
3646    else if(function == "log") value = log10(value);
3647  
3648    else if(function == "") value = value;
3649 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3649 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3650  
3651    return value;
3652  
# Line 2961 | Line 3655 | OSUAnalysis::applyFunction(string functi
3655  
3656   template <class InputCollection>
3657   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3658 <
3659 <  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3660 <    string obj1, obj2;
3658 >
3659 >  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3660 >    string obj1, obj2;
3661      getTwoObjs(currentCut.inputCollection, obj1, obj2);
3662      if (inputType==obj1 ||
3663 <        inputType==obj2) {
3663 >        inputType==obj2) {
3664        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3665 <      // and the inputType is a member of the pair.  
3666 <      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3667 <      // For example, if currentCut.inputCollection==electron-muon pairs,
3668 <      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3669 <      return;
3670 <    }  
3671 <  }    
3665 >      // and the inputType is a member of the pair.
3666 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3667 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3668 >      // then the flags should not be set here when inputType==muons or inputType==electrons.
3669 >      return;
3670 >    }
3671 >  }
3672  
3673    for (uint object = 0; object != inputCollection->size(); object++){
3674  
# Line 2984 | Line 3678 | void OSUAnalysis::setObjectFlags(cut &cu
3678  
3679        vector<bool> subcutDecisions;
3680        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3681 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3682 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3681 >        string stringValue = "";
3682 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3683 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3684 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3685  
3686        }
3687        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 3024 | Line 3720 | void OSUAnalysis::setObjectFlags(cut &cu
3720    bool sameObjects = false;
3721    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3722  
3723 <  // Get the strings for the two objects that make up the pair.  
3724 <  string obj1Type, obj2Type;
3723 >  // Get the strings for the two objects that make up the pair.
3724 >  string obj1Type, obj2Type;
3725    getTwoObjs(inputType, obj1Type, obj2Type);
3726    bool isTwoTypesOfObject = true;
3727 <  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3727 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3728  
3729 <  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3730 <  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3731 <  if (currentCut.inputCollection == inputType) {    
3729 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3730 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3731 >  if (currentCut.inputCollection == inputType) {
3732      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3733 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3733 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3734        cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3735      }
3736 <    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3736 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3737        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3738 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3739 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3738 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3739 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3740        }
3741      }
3742    }
3743 <  
3743 >
3744    int counter = 0;
3745  
3746    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
# Line 3059 | Line 3755 | void OSUAnalysis::setObjectFlags(cut &cu
3755  
3756          vector<bool> subcutDecisions;
3757          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3758 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3759 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3758 >          string stringValue = "";
3759 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3760 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3761 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3762          }
3763  
3764          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 3075 | Line 3773 | void OSUAnalysis::setObjectFlags(cut &cu
3773            decision = tempDecision;
3774          }
3775        }
3776 <      // if (decision) isPassObj1.at(object1) = true;
3777 <      // if (decision) isPassObj2.at(object2) = true;
3778 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3779 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3780 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3781 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3782 <      }  
3776 >      // if (decision) isPassObj1.at(object1) = true;
3777 >      // if (decision) isPassObj2.at(object2) = true;
3778 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3779 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3780 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3781 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3782 >      }
3783  
3784        //set flags for objects that pass each cut AND all the previous cuts
3785        bool previousCumulativeFlag = true;
# Line 3096 | Line 3794 | void OSUAnalysis::setObjectFlags(cut &cu
3794        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3795        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3796        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3797 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3798 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3799 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3797 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3798 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3799 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3800        }
3801        counter++;
3802  
3803 <    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3804 <  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3803 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3804 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3805  
3806   }
3807  
3808  
3809   bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3810 <  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3811 <  // all cuts up to currentCutIndex  
3812 <  bool previousCumulativeFlag = true;  
3813 <  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3810 >  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3811 >  // all cuts up to currentCutIndex
3812 >  bool previousCumulativeFlag = true;
3813 >  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3814      if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3815 <    else {  
3816 <      previousCumulativeFlag = false; break;  
3815 >    else {
3816 >      previousCumulativeFlag = false; break;
3817      }
3818    }
3819 <  return previousCumulativeFlag;  
3820 < }  
3819 >  return previousCumulativeFlag;
3820 > }
3821 >
3822 >
3823 >
3824 > template <class InputCollection>
3825 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, vector<bool> flags){
3826 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree  
3827 >
3828 >  for (uint object = 0; object != inputCollection->size(); object++){
3829 >
3830 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3831 >
3832 >    string inputVariable = parameters.inputVariable;
3833 >    string function = "";
3834 >    string stringValue = "";  
3835 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
3836 >    BNTreeBranchVals_.at(parameters.name).push_back(value);  
3837 >
3838 >  }
3839 > }
3840  
3841  
3842   template <class InputCollection>
# Line 3132 | Line 3849 | void OSUAnalysis::fill1DHistogram(TH1* h
3849      string currentString = parameters.inputVariables.at(0);
3850      string inputVariable = "";
3851      string function = "";
3852 <    if(currentString.find("(")==std::string::npos){
3852 >    if(currentString.find("(")==string::npos){
3853        inputVariable = currentString;// variable to cut on
3854      }
3855      else{
3856        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3857        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3858        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3859 <    }
3859 >    }  
3860  
3861 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3862 <    histo->Fill(value,scaleFactor);
3861 >    string stringValue = "";  
3862 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
3863 >    histo->Fill(value,scaleFactor);  
3864  
3865      if (printEventInfo_) {
3866 <      // Write information about event to screen, for testing purposes.  
3867 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3866 >      // Write information about event to screen, for testing purposes.
3867 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3868      }
3869 <    
3869 >
3870    }
3871   }
3872  
# Line 3173 | Line 3891 | void OSUAnalysis::fill1DHistogram(TH1* h
3891        string currentString = parameters.inputVariables.at(0);
3892        string inputVariable = "";
3893        string function = "";
3894 <      if(currentString.find("(")==std::string::npos){
3894 >      if(currentString.find("(")==string::npos){
3895          inputVariable = currentString;// variable to cut on
3896        }
3897        else{
# Line 3182 | Line 3900 | void OSUAnalysis::fill1DHistogram(TH1* h
3900          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3901        }
3902  
3903 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3903 >      string stringValue = "";
3904 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3905        histo->Fill(value,scaleFactor);
3906  
3907      }
# Line 3198 | Line 3917 | void OSUAnalysis::fill2DHistogram(TH2* h
3917  
3918      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3919  
3920 +    string stringValue = "";
3921      string currentString = parameters.inputVariables.at(0);
3922      string inputVariable = "";
3923      string function = "";
3924 <    if(currentString.find("(")==std::string::npos){
3924 >    if(currentString.find("(")==string::npos){
3925        inputVariable = currentString;// variable to cut on
3926      }
3927      else{
# Line 3209 | Line 3929 | void OSUAnalysis::fill2DHistogram(TH2* h
3929        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3930        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3931      }
3932 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3932 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3933  
3934      currentString = parameters.inputVariables.at(1);
3935      inputVariable = "";
3936      function = "";
3937 <    if(currentString.find("(")==std::string::npos){
3937 >    if(currentString.find("(")==string::npos){
3938        inputVariable = currentString;// variable to cut on
3939      }
3940      else{
# Line 3223 | Line 3943 | void OSUAnalysis::fill2DHistogram(TH2* h
3943        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3944      }
3945  
3946 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3946 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3947  
3948      histo->Fill(valueX,valueY,scaleFactor);
3949  
# Line 3250 | Line 3970 | void OSUAnalysis::fill2DHistogram(TH2* h
3970        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3971        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3972  
3973 +      string stringValue = "";
3974        string currentString = parameters.inputVariables.at(0);
3975        string inputVariable = "";
3976        string function = "";
3977 <      if(currentString.find("(")==std::string::npos){
3977 >      if(currentString.find("(")==string::npos){
3978          inputVariable = currentString;// variable to cut on
3979        }
3980        else{
# Line 3261 | Line 3982 | void OSUAnalysis::fill2DHistogram(TH2* h
3982          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3983          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3984        }
3985 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3985 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3986  
3987        currentString = parameters.inputVariables.at(1);
3988        inputVariable = "";
3989        function = "";
3990 <      if(currentString.find("(")==std::string::npos){
3990 >      if(currentString.find("(")==string::npos){
3991          inputVariable = currentString;// variable to cut on
3992        }
3993        else{
# Line 3274 | Line 3995 | void OSUAnalysis::fill2DHistogram(TH2* h
3995          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3996          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3997        }
3998 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3998 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3999  
4000  
4001        histo->Fill(valueX,valueY,scaleFactor);
# Line 3295 | Line 4016 | int OSUAnalysis::getGenMatchedParticleIn
4016  
4017      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4018      if(currentDeltaR > 0.05) continue;
4019 <    //     cout << std::setprecision(3) << std::setw(20)
4019 >    //     cout << setprecision(3) << setw(20)
4020      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4021 <    //          << std::setw(20)
4021 >    //          << setw(20)
4022      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
4023 <    //          << std::setw(20)
4023 >    //          << setw(20)
4024      //          << "\tdeltaR = " << currentDeltaR
4025 <    //          << std::setprecision(1)
4026 <    //          << std::setw(20)
4025 >    //          << setprecision(1)
4026 >    //          << setw(20)
4027      //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
4028 <    //          << std::setw(20)
4028 >    //          << setw(20)
4029      //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
4030 <    //          << std::setw(20)
4030 >    //          << setw(20)
4031      //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
4032      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
4033        bestMatchIndex = mcparticle - mcparticles->begin();
# Line 3369 | Line 4090 | int OSUAnalysis::findTauMotherIndex(cons
4090   // 20        strange baryon
4091   // 21        charm baryon
4092   // 22        bottom baryon
4093 < // 23        other
4093 > // 23        QCD string
4094 > // 24        other
4095  
4096   int OSUAnalysis::getPdgIdBinValue(int pdgId){
4097  
# Line 3393 | Line 4115 | int OSUAnalysis::getPdgIdBinValue(int pd
4115    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
4116    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
4117    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
4118 +  else if(absPdgId == 92  ) binValue = 23;
4119  
4120 <  else binValue = 23;
4120 >  else binValue = 24;
4121  
4122    return binValue;
4123  
# Line 3404 | Line 4127 | const BNprimaryvertex *
4127   OSUAnalysis::chosenVertex ()
4128   {
4129    const BNprimaryvertex *chosenVertex = 0;
4130 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
4131 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
4132 <      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
4130 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4131 >    vector<bool> vertexFlags;
4132 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4133 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4134 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
4135 >        break;
4136 >      }
4137 >    }
4138      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4139        if(!vertexFlags.at(vertexIndex)) continue;
4140        chosenVertex = & primaryvertexs->at(vertexIndex);
4141        break;
4142      }
4143    }
4144 <  else {
4145 <    chosenVertex = &primaryvertexs->at(0);
3418 <  }
4144 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4145 >    chosenVertex = & primaryvertexs->at (0);
4146  
4147    return chosenVertex;
4148   }
# Line 3424 | Line 4151 | const BNmet *
4151   OSUAnalysis::chosenMET ()
4152   {
4153    const BNmet *chosenMET = 0;
4154 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4155 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
4156 <      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
4154 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4155 >    vector<bool> metFlags;
4156 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4157 >      if (cumulativeFlags.at("mets").at(i).size()){
4158 >        metFlags = cumulativeFlags.at("mets").at(i);
4159 >        break;
4160 >      }
4161 >    }
4162      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4163        if(!metFlags.at(metIndex)) continue;
4164        chosenMET = & mets->at(metIndex);
4165        break;
4166      }
4167    }
4168 <  else {
4169 <    chosenMET = &mets->at(0);
3438 <  }
4168 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4169 >    chosenMET = & mets->at (0);
4170  
4171    return chosenMET;
4172   }
# Line 3444 | Line 4175 | const BNelectron *
4175   OSUAnalysis::chosenElectron ()
4176   {
4177    const BNelectron *chosenElectron = 0;
4178 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4179 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4180 <      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4178 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4179 >    vector<bool> electronFlags;
4180 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4181 >      if (cumulativeFlags.at("electrons").at(i).size()){
4182 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4183 >        break;
4184 >      }
4185 >    }
4186      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4187        if(!electronFlags.at(electronIndex)) continue;
4188        chosenElectron = & electrons->at(electronIndex);
4189        break;
4190      }
4191    }
4192 <  else {
4193 <    chosenElectron = &electrons->at(0);
3458 <  }
4192 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4193 >    chosenElectron = & electrons->at (0);
4194  
4195    return chosenElectron;
4196   }
# Line 3464 | Line 4199 | const BNmuon *
4199   OSUAnalysis::chosenMuon ()
4200   {
4201    const BNmuon *chosenMuon = 0;
4202 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4203 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4204 <      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4202 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4203 >    vector<bool> muonFlags;
4204 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4205 >      if (cumulativeFlags.at("muons").at(i).size()){
4206 >        muonFlags = cumulativeFlags.at("muons").at(i);
4207 >        break;
4208 >      }
4209 >    }
4210      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4211        if(!muonFlags.at(muonIndex)) continue;
4212        chosenMuon = & muons->at(muonIndex);
4213        break;
4214      }
4215    }
4216 <  else {
4217 <    chosenMuon = &muons->at(0);
3478 <  }
4216 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4217 >    chosenMuon = & muons->at (0);
4218  
4219    return chosenMuon;
4220   }
4221  
3483
4222   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines