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.18 by lantonel, Fri Feb 22 10:38:08 2013 UTC vs.
Revision 1.52 by lantonel, Sat Apr 27 15:53:06 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
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")),
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 <  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents"))
30 >  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31 >  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
33 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
34 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
35  
36   {
37  
38    TH1::SetDefaultSumw2 ();
39  
40    //create pile-up reweighting object, if necessary
41 <  if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
41 >  if(datasetType_ != "data") {
42 >    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
43 >    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
44 >    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 >  }
46 > #ifdef DISPLACED_SUSY
47 >  if (datasetType_ == "signalMC")
48 >    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 > #endif
50 >
51  
52    // Construct Cutflow Objects. These store the results of cut decisions and
53    // handle filling cut flow histograms.
# Line 37 | Line 55 | OSUAnalysis::OSUAnalysis (const edm::Par
55    std::vector<TFileDirectory> directories;
56  
57    //always get vertex collection so we can assign the primary vertex in the event
58 <  allNecessaryObjects.push_back("primaryvertexs");
59 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
58 >  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  
63 +  //always get the MC particles to do GEN-matching
64 +  objectsToGet.push_back("mcparticles");
65 +
66    //always get the event collection to do pile-up reweighting
67 <  allNecessaryObjects.push_back("events");
67 >  objectsToGet.push_back("events");
68  
69    //parse the histogram definitions
70    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
71  
72      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
73      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
74 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
74 >    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
75 >    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
76 >    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
77 >    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
78 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
79 >    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
80 >      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
81 >        int spaceIndex = tempInputCollection.find(" ");
82 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
83 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
84 >      }
85 >      else{
86 >        objectsToGet.push_back(tempInputCollection);
87 >      }
88        objectsToPlot.push_back(tempInputCollection);
89 <      allNecessaryObjects.push_back(tempInputCollection);
89 >      objectsToCut.push_back(tempInputCollection);
90      }
91 <    else{//pair of objects, need to add them both to the things to allNecessaryObjects
92 <      int dashIndex = tempInputCollection.find("-");
93 <      int spaceIndex = tempInputCollection.find(" ");
94 <      int secondWordLength = spaceIndex - dashIndex;
95 <      allNecessaryObjects.push_back(tempInputCollection);
96 <      allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
97 <      allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
91 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
92 >      string obj1;
93 >      string obj2;
94 >      getTwoObjs(tempInputCollection, obj1, obj2);
95 >      string obj2ToGet = getObjToGet(obj2);  
96 >      objectsToCut.push_back(tempInputCollection);
97 >      objectsToCut.push_back(obj1);
98 >      objectsToCut.push_back(obj2);  
99        objectsToPlot.push_back(tempInputCollection);
100 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
101 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
102 <      }
100 >      objectsToPlot.push_back(obj1);
101 >      objectsToPlot.push_back(obj2);  
102 >      objectsToGet.push_back(tempInputCollection);
103 >      objectsToGet.push_back(obj1);
104 >      objectsToGet.push_back(obj2ToGet);
105 >
106 >    }
107  
108      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
109 <    
109 >
110      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
111  
112        histogram tempHistogram;
# Line 75 | Line 115 | OSUAnalysis::OSUAnalysis (const edm::Par
115        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
116        tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
117        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
118 <      
118 >
119        histograms.push_back(tempHistogram);
120  
121      }
122    }
123 <  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object
123 >  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
124    sort( objectsToPlot.begin(), objectsToPlot.end() );
125    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
126  
127  
128  
129 +  //add histograms with the gen-matched id, mother id, and grandmother id
130 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
131 +
132 +    string currentObject = objectsToPlot.at(currentObjectIndex);
133 +    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
134 +
135 +    histogram tempIdHisto;
136 +    histogram tempMomIdHisto;
137 +    histogram tempGmaIdHisto;
138 +    histogram tempIdVsMomIdHisto;
139 +    histogram tempIdVsGmaIdHisto;
140 +
141 +    tempIdHisto.inputCollection = currentObject;
142 +    tempMomIdHisto.inputCollection = currentObject;
143 +    tempGmaIdHisto.inputCollection = currentObject;
144 +    tempIdVsMomIdHisto.inputCollection = currentObject;
145 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
146 +
147 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
148 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
149 +
150 +    currentObject = currentObject.substr(0, currentObject.size()-1);
151 +    tempIdHisto.name = currentObject+"GenMatchId";
152 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
153 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
154 +    tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
155 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
156 +
157 +    currentObject.at(0) = toupper(currentObject.at(0));
158 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
159 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
160 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
161 +    tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
162 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
163 +
164 +
165 +    int maxNum = 24;
166 +    vector<double> binVector;
167 +    binVector.push_back(maxNum);
168 +    binVector.push_back(0);
169 +    binVector.push_back(maxNum);
170 +
171 +    tempIdHisto.bins = binVector;
172 +    tempIdHisto.inputVariables.push_back("genMatchedId");
173 +    tempMomIdHisto.bins = binVector;
174 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
175 +    tempGmaIdHisto.bins = binVector;
176 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
177 +    binVector.push_back(maxNum);
178 +    binVector.push_back(0);
179 +    binVector.push_back(maxNum);
180 +    tempIdVsMomIdHisto.bins = binVector;
181 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
182 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
183 +    tempIdVsGmaIdHisto.bins = binVector;
184 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
185 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
186 +
187 +    histograms.push_back(tempIdHisto);
188 +    histograms.push_back(tempMomIdHisto);
189 +    histograms.push_back(tempGmaIdHisto);
190 +    histograms.push_back(tempIdVsMomIdHisto);
191 +    histograms.push_back(tempIdVsGmaIdHisto);
192 +  }
193 +
194  
195    channel tempChannel;
196    //loop over all channels (event selections)
# Line 104 | Line 209 | OSUAnalysis::OSUAnalysis (const edm::Par
209        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
210        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
211          tempChannel.triggers.push_back(triggerNames.at(trigger));
212 <      allNecessaryObjects.push_back("triggers");
212 >      objectsToGet.push_back("triggers");
213      }
214  
215  
# Line 123 | Line 228 | OSUAnalysis::OSUAnalysis (const edm::Par
228      twoDHists_.push_back(twoDhistoMap);
229  
230  
231 +
232      //book all histograms included in the configuration
233      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
234        histogram currentHistogram = histograms.at(currentHistogramIndex);
# Line 130 | Line 236 | OSUAnalysis::OSUAnalysis (const edm::Par
236        int numInputVariables = currentHistogram.inputVariables.size();
237  
238        if(numBinsElements != 3 && numBinsElements !=6) {
239 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
240 <        exit(0);
239 >        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
240 >        exit(0);
241        }
242        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
243 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
244 <        exit(0);
243 >        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
244 >        exit(0);
245        }
246        else if(numBinsElements == 3){
247 <        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));
247 >        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));
248        }
249        else if(numBinsElements == 6){
250 <        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));
250 >        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));
251  
252        }
253  
254  
255 +      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
256 +
257 +      // bin      particle type
258 +      // ---      -------------
259 +      //  0        unmatched
260 +      //  1        u
261 +      //  2        d
262 +      //  3        s
263 +      //  4        c
264 +      //  5        b
265 +      //  6        t
266 +      //  7        e
267 +      //  8        mu
268 +      //  9        tau
269 +      // 10        nu
270 +      // 11        g
271 +      // 12        gamma
272 +      // 13        Z
273 +      // 14        W
274 +      // 15        light meson
275 +      // 16        K meson
276 +      // 17        D meson
277 +      // 18        B meson
278 +      // 19        light baryon
279 +      // 20        strange baryon
280 +      // 21        charm baryon
281 +      // 22        bottom baryon
282 +      // 23        other
283 +
284 +      vector<TString> labelArray;
285 +      labelArray.push_back("unmatched");
286 +      labelArray.push_back("u");
287 +      labelArray.push_back("d");
288 +      labelArray.push_back("s");
289 +      labelArray.push_back("c");
290 +      labelArray.push_back("b");
291 +      labelArray.push_back("t");
292 +      labelArray.push_back("e");
293 +      labelArray.push_back("#mu");
294 +      labelArray.push_back("#tau");
295 +      labelArray.push_back("#nu");
296 +      labelArray.push_back("g");
297 +      labelArray.push_back("#gamma");
298 +      labelArray.push_back("Z");
299 +      labelArray.push_back("W");
300 +      labelArray.push_back("light meson");
301 +      labelArray.push_back("K meson");
302 +      labelArray.push_back("D meson");
303 +      labelArray.push_back("B meson");
304 +      labelArray.push_back("light baryon");
305 +      labelArray.push_back("strange baryon");
306 +      labelArray.push_back("charm baryon");
307 +      labelArray.push_back("bottom baryon");
308 +      labelArray.push_back("other");
309 +
310 +      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
311 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
312 +          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
313 +        }
314 +        else {
315 +          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
316 +          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
317 +        }
318 +      }
319 +      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
320 +        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
321 +        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
322 +      }
323 +
324      }
325 <    //book a histogram for the number of each object type to be plotted
325 >
326 >    // Book a histogram for the number of each object type to be plotted.  
327 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
328      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
329        string currentObject = objectsToPlot.at(currentObjectIndex);
330        int maxNum = 10;
331        if(currentObject == "mcparticles") maxNum = 50;
332        else if(currentObject == "primaryvertexs") maxNum = 50;
156      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
157      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
158      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
333  
334 <      currentObject.at(0) = toupper(currentObject.at(0));
334 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
335 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
336 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
337 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
338 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
339 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
340 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
341 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
342 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
343 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
344 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
345 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
346 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
347 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
348 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
349 >
350 >      currentObject.at(0) = toupper(currentObject.at(0));  
351        string histoName = "num" + currentObject;
352  
353        if(histoName == "numPrimaryvertexs"){
354 <        string newHistoName = histoName + "BeforePileupCorrection";
355 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
356 <        newHistoName = histoName + "AfterPileupCorrection";
357 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
354 >        string newHistoName = histoName + "BeforePileupCorrection";
355 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
356 >        newHistoName = histoName + "AfterPileupCorrection";
357 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
358        }
359        else
360 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
360 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
361      }
362  
363  
364 +
365 +
366      //get list of cuts for this channel
367      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
368  
# Line 179 | Line 371 | OSUAnalysis::OSUAnalysis (const edm::Par
371        cut tempCut;
372        //store input collection for cut
373        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
374 +      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
375 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
376 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
377 +      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
378 +      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
379 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
380        tempCut.inputCollection = tempInputCollection;
381 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
382 <        allNecessaryObjects.push_back(tempInputCollection);
381 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
382 >        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
383 >          int spaceIndex = tempInputCollection.find(" ");
384 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
385 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
386 >        }
387 >        else{
388 >          objectsToGet.push_back(tempInputCollection);
389 >        }
390 >        objectsToCut.push_back(tempInputCollection);
391        }
392 <      else{//pair of objects, need to add them both to the things to allNecessaryObjects
393 <        int dashIndex = tempInputCollection.find("-");
394 <        int spaceIndex = tempInputCollection.find(" ");
395 <        int secondWordLength = spaceIndex - dashIndex;
396 <        allNecessaryObjects.push_back(tempInputCollection);
397 <        allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
398 <        allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
392 >      else{//pair of objects, need to add them both to objectsToGet
393 >        string obj1;
394 >        string obj2;
395 >        getTwoObjs(tempInputCollection, obj1, obj2);
396 >        string obj2ToGet = getObjToGet(obj2);  
397 >        objectsToCut.push_back(tempInputCollection);
398 >        objectsToCut.push_back(obj1);
399 >        objectsToCut.push_back(obj2);  
400 >        objectsToGet.push_back(tempInputCollection);
401 >        objectsToGet.push_back(obj1);
402 >        objectsToGet.push_back(obj2ToGet);
403  
404        }
405  
# Line 199 | Line 409 | OSUAnalysis::OSUAnalysis (const edm::Par
409        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
410        std::vector<string> cutStringVector = splitString(cutString);
411        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
412 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
413 <        exit(0);
412 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
413 >        exit(0);
414        }
415        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
416        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
417 <        int indexOffset = 4 * subcutIndex;
418 <        string currentVariableString = cutStringVector.at(indexOffset);
419 <        if(currentVariableString.find("(")==std::string::npos){
420 <          tempCut.functions.push_back("");//no function was specified
421 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
422 <        }
423 <        else{
424 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
425 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
426 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
427 <        }
428 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
429 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
430 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
417 >        int indexOffset = 4 * subcutIndex;
418 >        string currentVariableString = cutStringVector.at(indexOffset);
419 >        if(currentVariableString.find("(")==std::string::npos){
420 >          tempCut.functions.push_back("");//no function was specified
421 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
422 >        }
423 >        else{
424 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
425 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
426 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
427 >        }
428 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
429 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
430 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
431        }
432  
433        //get number of objects required to pass cut for event to pass
434        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
435        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
436        if(numberRequiredVector.size()!=2){
437 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
437 >        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
438          exit(0);
439        }
440  
# Line 246 | Line 456 | OSUAnalysis::OSUAnalysis (const edm::Par
456        }
457        tempCut.name = tempCutName;
458  
249
459        tempChannel.cuts.push_back(tempCut);
460  
461  
253
462      }//end loop over cuts
463  
464      channels.push_back(tempChannel);
# Line 259 | Line 467 | OSUAnalysis::OSUAnalysis (const edm::Par
467    }//end loop over channels
468  
469  
470 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
471 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
472 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
470 >  //make unique vector of objects we need to get from the event
471 >  sort( objectsToGet.begin(), objectsToGet.end() );
472 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
473 >  //make unique vector of objects we need to cut on
474 >  sort( objectsToCut.begin(), objectsToCut.end() );
475 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
476  
477  
478   }
# Line 279 | Line 490 | void
490   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
491   {
492  
282
493    // Retrieve necessary collections from the event.
494 <  edm::Handle<BNtriggerCollection> triggers;
495 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
494 >
495 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
496      event.getByLabel (triggers_, triggers);
497  
498 <  edm::Handle<BNjetCollection> jets;
289 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
498 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
499      event.getByLabel (jets_, jets);
500  
501 <  edm::Handle<BNmuonCollection> muons;
293 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
501 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
502      event.getByLabel (muons_, muons);
503  
504 <  edm::Handle<BNelectronCollection> electrons;
297 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
504 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
505      event.getByLabel (electrons_, electrons);
506  
507 <  edm::Handle<BNeventCollection> events;
301 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
507 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
508      event.getByLabel (events_, events);
509  
510 <  edm::Handle<BNtauCollection> taus;
305 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
510 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
511      event.getByLabel (taus_, taus);
512  
513 <  edm::Handle<BNmetCollection> mets;
309 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
513 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
514      event.getByLabel (mets_, mets);
515  
516 <  edm::Handle<BNtrackCollection> tracks;
313 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
516 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
517      event.getByLabel (tracks_, tracks);
518  
519 <  edm::Handle<BNgenjetCollection> genjets;
317 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
519 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
520      event.getByLabel (genjets_, genjets);
521  
522 <  edm::Handle<BNmcparticleCollection> mcparticles;
321 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
522 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
523      event.getByLabel (mcparticles_, mcparticles);
524  
525 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
325 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
525 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
526      event.getByLabel (primaryvertexs_, primaryvertexs);
527  
528 <  edm::Handle<BNbxlumiCollection> bxlumis;
329 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
528 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
529      event.getByLabel (bxlumis_, bxlumis);
530  
531 <  edm::Handle<BNphotonCollection> photons;
333 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
531 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
532      event.getByLabel (photons_, photons);
533  
534 <  edm::Handle<BNsuperclusterCollection> superclusters;
337 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
534 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
535      event.getByLabel (superclusters_, superclusters);
536  
537 + #ifdef DISPLACED_SUSY
538 +  if (datasetType_ == "signalMC"){
539 +    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
540 +      event.getByLabel (stops_, stops);
541 +  }
542 + #endif
543 +
544 +  if (useTrackCaloRhoCorr_) {  
545 +    // Used only for pile-up correction of by-hand calculation of isolation energy.  
546 +    // This rho collection is not available in all BEANs.  
547 +    // For description of rho values for different jet reconstruction algorithms, see
548 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
549 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
550 +  }
551  
341  //get pile-up event weight
342  double puScaleFactor = 0;
343  if(datasetType_ != "data")
344    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
345  else
346    puScaleFactor = 1.00;
552  
553 +  //get pile-up event weight
554 +  double scaleFactor = 1.00;
555 +  if(doPileupReweighting_ && datasetType_ != "data")
556 +    scaleFactor = puWeight_->at (events->at (0).numTruePV);
557 +
558 +  cTauScaleFactor_ = 1.0;
559 + #ifdef DISPLACED_SUSY
560 +  if (datasetType_ == "signalMC")
561 +    cTauScaleFactor_ = cTauWeight_->at (event);
562 + #endif
563 +  scaleFactor *= cTauScaleFactor_;
564  
565    //loop over all channels
566  
# Line 352 | Line 568 | OSUAnalysis::analyze (const edm::Event &
568      channel currentChannel = channels.at(currentChannelIndex);
569  
570      flagMap individualFlags;
355    flagMap cumulativeFlags;
571      counterMap passingCounter;
572 +    cumulativeFlags.clear ();
573  
574      bool triggerDecision = true;
575      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 362 | Line 578 | OSUAnalysis::analyze (const edm::Event &
578      }
579  
580      //loop over all cuts
581 +
582 +
583 +
584      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
585        cut currentCut = currentChannel.cuts.at(currentCutIndex);
586  
587 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
588 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
587 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
588 >        string currentObject = objectsToCut.at(currentObjectIndex);
589  
590 +        //initialize maps to get ready to set cuts
591          individualFlags[currentObject].push_back (vector<bool> ());
592          cumulativeFlags[currentObject].push_back (vector<bool> ());
593  
594 +      }
595 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
596 +        string currentObject = objectsToCut.at(currentObjectIndex);
597 +
598 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
599 +
600  
601          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
602 +
603          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
604 +
605 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
606 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
607          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
608          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
609          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 386 | Line 616 | OSUAnalysis::analyze (const edm::Event &
616          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
617          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
618  
389        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs");
390        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs");
391        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs");
619  
620 +
621 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
622 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
623 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
624 +                                                                   "muon-muon pairs");
625 +
626 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
627 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
628 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
629 +                                                                   "muon-secondary muon pairs");
630 +
631 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
632 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
633 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
634 +                                                                   "electron-secondary electron pairs");
635 +
636 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
637 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
638 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
639 +                                                                           "electron-electron pairs");
640 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
641 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
642 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
643 +                                                                       "electron-muon pairs");
644 +        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
645 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
646 +                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
647 +                                                                       "electron-jet pairs");
648 +        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
649 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
650 +                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
651 +                                                                       "muon-jet pairs");
652 +        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
653 +                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
654 +                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
655 +                                                                     "track-event pairs");
656 +        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
657 +                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
658 +                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
659 +                                                                        "electron-track pairs");
660 +        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
661 +                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
662 +                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
663 +                                                                    "muon-track pairs");
664 +        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
665 +                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
666 +                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
667 +                                                                  "muon-tau pairs");
668 +        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
669 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
670 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
671 +                                                                 "tau-tau pairs");
672 +        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
673 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
674 +                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
675 +                                                                 "tau-track pairs");
676 +
677 + #ifdef DISPLACED_SUSY
678 +        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
679 + #endif
680        }
681  
682  
# Line 397 | Line 684 | OSUAnalysis::analyze (const edm::Event &
684      }//end loop over all cuts
685  
686  
400
687      //use cumulative flags to apply cuts at event level
688  
689      bool eventPassedAllCuts = true;
# Line 413 | Line 699 | OSUAnalysis::analyze (const edm::Event &
699        int numberPassing = 0;
700  
701        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
702 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
702 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
703        }
418
704        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
705        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
421
706        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
707  
708      }
709  
710 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
711 <
710 >    //     if(datasetType_ != "data") {
711 >    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
712 >    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
713 >    //     }
714  
715 <
430 <    if(!eventPassedAllCuts)continue;
715 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
716  
717  
718  
719 +    if(!eventPassedAllCuts)continue;
720  
721 <    //set position of primary vertex in event, in order to calculate quantities relative to it
722 <    primaryVertex_ = 0;
723 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
724 <    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
725 <      if(!vertexFlags.at(vertexIndex)) continue;
726 <      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
727 <      break;
721 >    if (printEventInfo_) {
722 >      // Write information about event to screen, for testing purposes.  
723 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
724 >           << ": run="  << events->at(0).run
725 >           << "  lumi=" << events->at(0).lumi
726 >           << "  event=" << events->at(0).evt
727 >           << endl;  
728      }
729  
730  
445
731      //filling histograms
732      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
733        histogram currentHistogram = histograms.at(histogramIndex);
734  
735        if(currentHistogram.inputVariables.size() == 1){
736 <        TH1D* histo;
737 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
738 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
739 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
740 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
741 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
742 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
743 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
744 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
745 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
746 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
747 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
748 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
749 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
750 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
751 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
752 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
753 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
754 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
755 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
756 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
757 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
758 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
759 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
736 >        TH1D* histo;
737 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
738 >
739 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
740 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
741 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
742 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
743 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
744 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
745 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
746 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
747 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
748 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
749 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
750 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
751 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
752 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
753 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
754 >                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
755 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
756 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
757 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
758 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
759 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
760 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
761 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
762 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
763 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
764 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
765 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
766 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
767 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
768 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
769 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
770 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
771 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
772 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
773 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
774 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
775 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
776 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
777 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
778 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
779 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
780 >
781 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
782 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
783 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
784 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
785 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
786 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
787 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
788 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
789 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
790 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
791 >
792 > #ifdef DISPLACED_SUSY
793 >        if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
794 > #endif
795        }
796        else if(currentHistogram.inputVariables.size() == 2){
797 <        TH2D* histo;
798 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
799 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
800 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
801 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
802 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
803 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
804 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
805 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
806 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
807 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
808 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
809 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
810 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
811 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
812 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
813 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
814 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
815 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
816 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
817 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
818 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
819 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
820 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
821 <      }
797 >        TH2D* histo;
798 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
799 >
800 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
801 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
802 >        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
803 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
804 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
805 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
806 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
807 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
808 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
809 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
810 >        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
811 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
812 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
813 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
814 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
815 >                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
816 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
817 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
818 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
819 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
820 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
821 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
822 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
823 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
824 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
825 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
826 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
827 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
828 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
829 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
830 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
831 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
832 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
833 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
834 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
835 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
836 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
837 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
838 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
839 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
840 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
841 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
842 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
843 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
844 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
845 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
846 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
847 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
848 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
849 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
850 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
851 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
852 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
853 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
854 > #ifdef DISPLACED_SUSY
855 >        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
856 > #endif
857 >      }
858      }
859  
860  
861 +
862      //fills histograms with the sizes of collections
863      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
864 +
865        string currentObject = objectsToPlot.at(currentObjectIndex);
866  
867 <      if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
868 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
869 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
870 <      string tempCurrentObject = currentObject;
871 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
867 >      string objectToPlot = "";  
868 >
869 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
870 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
871 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
872 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
873 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
874 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
875 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
876 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";    
877 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";      
878 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
879 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
880 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";  
881 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";  
882 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";  
883 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";  
884 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";  
885 >      else objectToPlot = currentObject;
886 >
887 >      string tempCurrentObject = objectToPlot;
888 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
889        string histoName = "num" + tempCurrentObject;
890  
891 +      //set position of primary vertex in event, in order to calculate quantities relative to it
892 +      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
893 +        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
894 +        int numToPlot = 0;
895 +        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
896 +          if(lastCutFlags.at(currentFlag)) numToPlot++;
897 +        }
898 +        if(objectToPlot == "primaryvertexs"){
899 +          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
900 +          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
901 +        }
902 +        else {
903 +          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
904 +        }
905 +      }
906 +      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
907 +      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
908 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
909 +      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
910 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
911 +      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
912 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
913 +      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
914 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
915 +      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
916 +      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
917 +      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
918 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
919 +      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
920 +      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
921 +      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
922 +      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
923 +      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
924 +      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
925 +      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
926 +      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
927 +      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
928 +      else if(objectToPlot == "primaryvertexs"){
929 +        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
930 +        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
931 +      }
932 + #ifdef DISPLACED_SUSY
933 +      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
934 + #endif
935  
936 <      if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
518 <      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
519 <      else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
520 <      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
521 <      else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
522 <      else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
523 <      else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
524 <      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
525 <      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
526 <      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
527 <      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
528 <      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
529 <      else if(currentObject == "primaryvertexs"){
530 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
531 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
532 <      }
533 <      else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
534 <      else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
535 <      else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
936 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
937  
537    }
938    } //end loop over channel
939  
940 <  masterCutFlow_->fillCutFlow(puScaleFactor);
940 >  masterCutFlow_->fillCutFlow(scaleFactor);
941  
942 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
943  
944  
544 }
545
945  
946   bool
947   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 589 | Line 988 | OSUAnalysis::splitString (string inputSt
988  
989   }
990  
991 +
992 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
993 +  // Set two object strings from the tempInputCollection string,
994 +  // For example, if tempInputCollection is "electron-muon pairs",
995 +  // then obj1 = "electrons" and obj2 = "muons".  
996 +  // Note that the objects have an "s" appended.  
997 +
998 +  int dashIndex = tempInputCollection.find("-");
999 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1000 +  int secondWordLength = spaceIndex - dashIndex;
1001 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1002 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1003 +  
1004 + }
1005 +
1006 +
1007 + string OSUAnalysis::getObjToGet(string obj) {
1008 +  // Return the string corresponding to the object to get for the given obj string.
1009 +  // Right now this only handles the case in which obj contains "secondary",
1010 +  // e.g, "secondary muons".  
1011 +  // Note that "s" is NOT appended.  
1012 +  
1013 +  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
1014 +  int firstSpaceIndex = obj.find_first_of(" ");  
1015 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1016 +
1017 + }  
1018 +
1019 +
1020 + //!jet valueLookup
1021   double
1022   OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1023  
# Line 718 | Line 1147 | OSUAnalysis::valueLookup (const BNjet* o
1147   }
1148  
1149  
1150 <
1150 > //!muon valueLookup
1151   double
1152   OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1153  
# Line 736 | Line 1165 | OSUAnalysis::valueLookup (const BNmuon*
1165    else if(variable == "ecalIso") value = object->ecalIso;
1166    else if(variable == "hcalIso") value = object->hcalIso;
1167    else if(variable == "caloIso") value = object->caloIso;
1168 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
1168 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
1169    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1170    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1171    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 875 | Line 1304 | OSUAnalysis::valueLookup (const BNmuon*
1304    else if(variable == "time_ndof") value = object->time_ndof;
1305  
1306    //user-defined variables
1307 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1308 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1309 <  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1310 <  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1307 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1308 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1309 >  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1310 >  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1311    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1312 +  else if(variable == "metMT") {
1313 +    const BNmet *met = chosenMET ();
1314 +    if (met)
1315 +      {
1316 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1317 +          p2 (met->px, met->py, 0.0, met->pt);
1318 +
1319 +        value = (p1 + p2).Mt ();
1320 +      }
1321 +    else
1322 +      value = -999;
1323 +  }
1324 +
1325 +
1326 +
1327 +  else if(variable == "correctedD0VertexInEBPlus"){
1328 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1329 +    else value = -999;
1330 +  }
1331 +  else if(variable == "correctedD0VertexOutEBPlus"){
1332 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1333 +    else value = -999;
1334 +  }
1335 +  else if(variable == "correctedD0VertexEEPlus"){
1336 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1337 +    else value = -999;
1338 +  }
1339 +
1340 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1341 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1342 +    else value = -999;
1343 +  }
1344 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1345 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1346 +    else value = -999;
1347 +  }
1348 +  else if(variable == "correctedD0BeamspotEEPlus"){
1349 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1350 +    else value = -999;
1351 +  }
1352 +
1353 +  else if(variable == "correctedD0VertexInEBMinus"){
1354 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1355 +    else value = -999;
1356 +  }
1357 +  else if(variable == "correctedD0VertexOutEBMinus"){
1358 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1359 +    else value = -999;
1360 +  }
1361 +  else if(variable == "correctedD0VertexEEMinus"){
1362 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1363 +    else value = -999;
1364 +  }
1365 +
1366 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1367 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1368 +    else value = -999;
1369 +  }
1370 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1371 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1372 +    else value = -999;
1373 +  }
1374 +  else if(variable == "correctedD0BeamspotEEMinus"){
1375 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1376 +    else value = -999;
1377 +  }
1378 +
1379 +
1380 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1381 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1382 +    else value = -999;
1383 +  }
1384 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1385 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1386 +    else value = -999;
1387 +  }
1388 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1389 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1390 +    else value = -999;
1391 +  }
1392 +
1393 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1394 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1395 +    else value = -999;
1396 +  }
1397 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1398 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1399 +    else value = -999;
1400 +  }
1401 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1402 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1403 +    else value = -999;
1404 +  }
1405 +
1406 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1407 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1408 +    else value = -999;
1409 +  }
1410 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1411 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1412 +    else value = -999;
1413 +  }
1414 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1415 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1416 +    else value = -999;
1417 +  }
1418 +
1419 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1420 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1421 +    else value = -999;
1422 +  }
1423 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1424 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1425 +    else value = -999;
1426 +  }
1427 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1428 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1429 +    else value = -999;
1430 +  }
1431 +
1432 +
1433    else if(variable == "tightID") {
1434 <    value = object->isGlobalMuon > 0            \
1435 <      && object->isPFMuon > 0                   \
1436 <      && object->normalizedChi2 < 10            \
1437 <      && object->numberOfValidMuonHits > 0      \
1438 <      && object->numberOfMatchedStations > 1    \
1439 <      && fabs(object->correctedD0Vertex) < 0.2  \
1440 <      && fabs(object->correctedDZ) < 0.5        \
1441 <      && object->numberOfValidPixelHits > 0     \
1434 >    value = object->isGlobalMuon > 0                \
1435 >      && object->isPFMuon > 0                        \
1436 >      && object->normalizedChi2 < 10                \
1437 >                                  && object->numberOfValidMuonHits > 0        \
1438 >      && object->numberOfMatchedStations > 1        \
1439 >      && fabs(object->correctedD0Vertex) < 0.2        \
1440 >      && fabs(object->correctedDZ) < 0.5        \
1441 >      && object->numberOfValidPixelHits > 0                \
1442        && object->numberOfLayersWithMeasurement > 5;
893    
894
1443    }
1444    else if(variable == "tightIDdisplaced"){
1445 <    value = object->isGlobalMuon > 0            \
1446 <      && object->isPFMuon > 0                   \
1447 <      && object->normalizedChi2 < 10            \
1448 <      && object->numberOfValidMuonHits > 0      \
1449 <      && object->numberOfMatchedStations > 1    \
902 <      && object->numberOfValidPixelHits > 0     \
1445 >    value = object->isGlobalMuon > 0                \
1446 >      && object->normalizedChi2 < 10                \
1447 >                                  && object->numberOfValidMuonHits > 0        \
1448 >      && object->numberOfMatchedStations > 1        \
1449 >      && object->numberOfValidPixelHits > 0        \
1450        && object->numberOfLayersWithMeasurement > 5;
1451    }
1452  
1453 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1454 +
1455 +  else if(variable == "genMatchedPdgId"){
1456 +    int index = getGenMatchedParticleIndex(object);
1457 +    if(index == -1) value = 0;
1458 +    else value = mcparticles->at(index).id;
1459 +  }
1460 +
1461 +  else if(variable == "genMatchedId"){
1462 +    int index = getGenMatchedParticleIndex(object);
1463 +    if(index == -1) value = 0;
1464 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1465 +  }
1466 +  else if(variable == "genMatchedMotherId"){
1467 +    int index = getGenMatchedParticleIndex(object);
1468 +    if(index == -1) value = 0;
1469 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1470 +  }
1471 +  else if(variable == "genMatchedMotherIdReverse"){
1472 +    int index = getGenMatchedParticleIndex(object);
1473 +    if(index == -1) value = 23;
1474 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1475 +  }
1476 +  else if(variable == "genMatchedGrandmotherId"){
1477 +    int index = getGenMatchedParticleIndex(object);
1478 +    if(index == -1) value = 0;
1479 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1480 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1481 +      if(motherIndex == -1) value = 0;
1482 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1483 +    }
1484 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1485 +  }
1486 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1487 +    int index = getGenMatchedParticleIndex(object);
1488 +    if(index == -1) value = 23;
1489 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1490 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1491 +      if(motherIndex == -1) value = 23;
1492 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1493 +    }
1494 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1495 +  }
1496 +
1497 +
1498 +
1499    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1500  
1501    value = applyFunction(function, value);
# Line 910 | Line 1503 | OSUAnalysis::valueLookup (const BNmuon*
1503    return value;
1504   }
1505  
1506 <
1506 > //!electron valueLookup
1507   double
1508   OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1509  
# Line 1073 | Line 1666 | OSUAnalysis::valueLookup (const BNelectr
1666    else if(variable == "passConvVeto") value = object->passConvVeto;
1667  
1668    //user-defined variables
1669 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1670 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1669 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1670 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1671    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1672    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1673 +  else if(variable == "metMT") {
1674 +    const BNmet *met = chosenMET ();
1675 +    if (met)
1676 +      {
1677 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1678 +          p2 (met->px, met->py, 0.0, met->pt);
1679 +
1680 +        value = (p1 + p2).Mt ();
1681 +      }
1682 +    else
1683 +      value = -999;
1684 +  }
1685 +
1686 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1687 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1688 +    else value = -999;
1689 +  }
1690 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1691 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1692 +    else value = -999;
1693 +  }
1694 +
1695 +  else if(variable == "correctedD0VertexInEBPlus"){
1696 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1697 +    else value = -999;
1698 +  }
1699 +  else if(variable == "correctedD0VertexOutEBPlus"){
1700 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1701 +    else value = -999;
1702 +  }
1703 +  else if(variable == "correctedD0VertexEEPlus"){
1704 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1705 +    else value = -999;
1706 +  }
1707 +
1708 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1709 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1710 +    else value = -999;
1711 +  }
1712 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1713 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1714 +    else value = -999;
1715 +  }
1716 +  else if(variable == "correctedD0BeamspotEEPlus"){
1717 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1718 +    else value = -999;
1719 +  }
1720 +
1721 +  else if(variable == "correctedD0VertexInEBMinus"){
1722 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1723 +    else value = -999;
1724 +  }
1725 +  else if(variable == "correctedD0VertexOutEBMinus"){
1726 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1727 +    else value = -999;
1728 +  }
1729 +  else if(variable == "correctedD0VertexEEMinus"){
1730 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1731 +    else value = -999;
1732 +  }
1733 +
1734 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1735 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1736 +    else value = -999;
1737 +  }
1738 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1739 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1740 +    else value = -999;
1741 +  }
1742 +  else if(variable == "correctedD0BeamspotEEMinus"){
1743 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1744 +    else value = -999;
1745 +  }
1746 +
1747 +  else if(variable == "tightID"){
1748 +    if (object->isEB)
1749 +      {
1750 +        value = fabs(object->delEtaIn) < 0.004 \
1751 +          && fabs (object->delPhiIn) < 0.03 \
1752 +          && object->scSigmaIEtaIEta < 0.01 \
1753 +          && object->hadOverEm < 0.12 \
1754 +          && fabs (object->correctedD0Vertex) < 0.02 \
1755 +          && fabs (object->correctedDZ) < 0.1 \
1756 +          && object->absInvEMinusInvPin < 0.05 \
1757 +          && object->passConvVeto;
1758 +      }
1759 +    else
1760 +      {
1761 +        value = fabs(object->delEtaIn) < 0.005 \
1762 +          && fabs (object->delPhiIn) < 0.02 \
1763 +          && object->scSigmaIEtaIEta < 0.03 \
1764 +          && object->hadOverEm < 0.10 \
1765 +          && fabs (object->correctedD0Vertex) < 0.02 \
1766 +          && fabs (object->correctedDZ) < 0.1 \
1767 +          && object->absInvEMinusInvPin < 0.05 \
1768 +          && object->passConvVeto;
1769 +      }
1770 +  }
1771 +
1772 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1773 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1774 +    else value = -999;
1775 +  }
1776 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1777 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1778 +    else value = -999;
1779 +  }
1780 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1781 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1782 +    else value = -999;
1783 +  }
1784 +
1785 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1786 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1787 +    else value = -999;
1788 +  }
1789 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1790 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1791 +    else value = -999;
1792 +  }
1793 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1794 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1795 +    else value = -999;
1796 +  }
1797 +
1798 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1799 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1800 +    else value = -999;
1801 +  }
1802 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1803 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1804 +    else value = -999;
1805 +  }
1806 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1807 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1808 +    else value = -999;
1809 +  }
1810 +
1811 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1812 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1813 +    else value = -999;
1814 +  }
1815 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1816 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1817 +    else value = -999;
1818 +  }
1819 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1820 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1821 +    else value = -999;
1822 +  }
1823 +
1824 +
1825 +  else if(variable == "tightIDdisplaced"){
1826 +    if (object->isEB)
1827 +      {
1828 +        value = fabs(object->delEtaIn) < 0.004 \
1829 +          && fabs (object->delPhiIn) < 0.03 \
1830 +          && object->scSigmaIEtaIEta < 0.01 \
1831 +          && object->hadOverEm < 0.12 \
1832 +          && object->absInvEMinusInvPin < 0.05;
1833 +      }
1834 +    else
1835 +      {
1836 +        value = fabs (object->delEtaIn) < 0.005 \
1837 +          && fabs (object->delPhiIn) < 0.02 \
1838 +          && object->scSigmaIEtaIEta < 0.03 \
1839 +          && object->hadOverEm < 0.10 \
1840 +          && object->absInvEMinusInvPin < 0.05;
1841 +      }
1842 +  }
1843 +
1844 +
1845 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1846 +
1847 +  else if(variable == "genMatchedPdgId"){
1848 +    int index = getGenMatchedParticleIndex(object);
1849 +    if(index == -1) value = 0;
1850 +    else value = mcparticles->at(index).id;
1851 +  }
1852 +
1853 +
1854 +  else if(variable == "genMatchedId"){
1855 +    int index = getGenMatchedParticleIndex(object);
1856 +    if(index == -1) value = 0;
1857 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1858 +  }
1859 +  else if(variable == "genMatchedMotherId"){
1860 +    int index = getGenMatchedParticleIndex(object);
1861 +    if(index == -1) value = 0;
1862 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1863 +  }
1864 +  else if(variable == "genMatchedMotherIdReverse"){
1865 +    int index = getGenMatchedParticleIndex(object);
1866 +    if(index == -1) value = 23;
1867 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1868 +  }
1869 +  else if(variable == "genMatchedGrandmotherId"){
1870 +    int index = getGenMatchedParticleIndex(object);
1871 +    if(index == -1) value = 0;
1872 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1873 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1874 +      if(motherIndex == -1) value = 0;
1875 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1876 +    }
1877 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1878 +  }
1879 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1880 +    int index = getGenMatchedParticleIndex(object);
1881 +    if(index == -1) value = 23;
1882 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1883 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1884 +      if(motherIndex == -1) value = 23;
1885 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1886 +    }
1887 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1888 +  }
1889 +
1890  
1891  
1892    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1086 | Line 1896 | OSUAnalysis::valueLookup (const BNelectr
1896    return value;
1897   }
1898  
1899 <
1899 > //!event valueLookup
1900   double
1901   OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1902  
# Line 1156 | Line 1966 | OSUAnalysis::valueLookup (const BNevent*
1966    else if(variable == "id1") value = object->id1;
1967    else if(variable == "id2") value = object->id2;
1968    else if(variable == "evt") value = object->evt;
1969 +  else if(variable == "puScaleFactor"){
1970 +    if(datasetType_ != "data")
1971 +      value = puWeight_->at (events->at (0).numTruePV);
1972 +    else
1973 +      value = 1.0;
1974 +  }
1975 +  else if(variable == "muonScaleFactor"){
1976 +    if(datasetType_ != "data")
1977 +      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1978 +      value = 1.0;
1979 +    else
1980 +      value = 1.0;
1981 +  }
1982 +  else if(variable == "electronScaleFactor"){
1983 +    if(datasetType_ != "data")
1984 +      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1985 +      value = 1.0;
1986 +    else
1987 +      value = 1.0;
1988 +  }
1989 +  else if(variable == "cTauScaleFactor")
1990 +    value = cTauScaleFactor_;
1991  
1992    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1993  
# Line 1164 | Line 1996 | OSUAnalysis::valueLookup (const BNevent*
1996    return value;
1997   }
1998  
1999 + //!tau valueLookup
2000   double
2001   OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2002  
# Line 1210 | Line 2043 | OSUAnalysis::valueLookup (const BNtau* o
2043    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2044  
2045  
2046 +
2047 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2048 +
2049 +  else if(variable == "genMatchedPdgId"){
2050 +    int index = getGenMatchedParticleIndex(object);
2051 +    if(index == -1) value = 0;
2052 +    else value = mcparticles->at(index).id;
2053 +  }
2054 +
2055 +  else if(variable == "genMatchedId"){
2056 +    int index = getGenMatchedParticleIndex(object);
2057 +    if(index == -1) value = 0;
2058 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2059 +  }
2060 +  else if(variable == "genMatchedMotherId"){
2061 +    int index = getGenMatchedParticleIndex(object);
2062 +    if(index == -1) value = 0;
2063 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2064 +  }
2065 +  else if(variable == "genMatchedMotherIdReverse"){
2066 +    int index = getGenMatchedParticleIndex(object);
2067 +    if(index == -1) value = 23;
2068 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2069 +  }
2070 +  else if(variable == "genMatchedGrandmotherId"){
2071 +    int index = getGenMatchedParticleIndex(object);
2072 +    if(index == -1) value = 0;
2073 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2074 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2075 +      if(motherIndex == -1) value = 0;
2076 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2077 +    }
2078 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2079 +  }
2080 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2081 +    int index = getGenMatchedParticleIndex(object);
2082 +    if(index == -1) value = 23;
2083 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2084 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2085 +      if(motherIndex == -1) value = 23;
2086 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2087 +    }
2088 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2089 +  }
2090 +
2091 +
2092    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2093  
2094    value = applyFunction(function, value);
# Line 1217 | Line 2096 | OSUAnalysis::valueLookup (const BNtau* o
2096    return value;
2097   }
2098  
2099 + //!met valueLookup
2100   double
2101   OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2102  
# Line 1289 | Line 2169 | OSUAnalysis::valueLookup (const BNmet* o
2169    return value;
2170   }
2171  
2172 + //!track valueLookup
2173   double
2174   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2175  
2176    double value = 0.0;
2177 <
2177 >  double pMag = sqrt(object->pt * object->pt +
2178 >                     object->pz * object->pz);
2179 >  
2180    if(variable == "pt") value = object->pt;
2181    else if(variable == "px") value = object->px;
2182    else if(variable == "py") value = object->py;
# Line 1313 | Line 2196 | OSUAnalysis::valueLookup (const BNtrack*
2196    else if(variable == "isHighPurity") value = object->isHighPurity;
2197  
2198  
2199 +  //additional BNs info for disappTrks
2200 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2201 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2202 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2203 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2204 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2205 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2206 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2207 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2208 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2209 +  
2210 +
2211 +  //user defined variables
2212 +  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;
2213 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2214 +  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2215 +  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2216 +  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2217 +  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2218 +  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2219 +  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2220 +  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2221 +  else if(variable == "ptError")                    value = object->ptError;
2222 +  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2223 +  else if (variable == "d0wrtPV"){      
2224 +    double vx = object->vx - chosenVertex ()->x,        
2225 +      vy = object->vy - chosenVertex ()->y,      
2226 +      px = object->px,  
2227 +      py = object->py,  
2228 +      pt = object->pt;  
2229 +    value = (-vx * py + vy * px) / pt;  
2230 +  }      
2231 +  else if (variable == "dZwrtPV"){      
2232 +    double vx = object->vx - chosenVertex ()->x,        
2233 +      vy = object->vy - chosenVertex ()->y,      
2234 +      vz = object->vz - chosenVertex ()->z,      
2235 +      px = object->px,  
2236 +      py = object->py,  
2237 +      pz = object->pz,  
2238 +      pt = object->pt;  
2239 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2240 +  }    
2241 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2242 +
2243 +  else if(variable == "genMatchedPdgId"){
2244 +    int index = getGenMatchedParticleIndex(object);
2245 +    if(index == -1) value = 0;
2246 +    else value = mcparticles->at(index).id;
2247 +  }
2248 +
2249 +
2250 +  else if(variable == "genMatchedId"){
2251 +    int index = getGenMatchedParticleIndex(object);
2252 +    if(index == -1) value = 0;
2253 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2254 +  }
2255 +  else if(variable == "genMatchedMotherId"){
2256 +    int index = getGenMatchedParticleIndex(object);
2257 +    if(index == -1) value = 0;
2258 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2259 +  }
2260 +  else if(variable == "genMatchedMotherIdReverse"){
2261 +    int index = getGenMatchedParticleIndex(object);
2262 +    if(index == -1) value = 23;
2263 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2264 +  }
2265 +  else if(variable == "genMatchedGrandmotherId"){
2266 +    int index = getGenMatchedParticleIndex(object);
2267 +    if(index == -1) value = 0;
2268 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2269 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2270 +      if(motherIndex == -1) value = 0;
2271 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2272 +    }
2273 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2274 +  }
2275 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2276 +    int index = getGenMatchedParticleIndex(object);
2277 +    if(index == -1) value = 23;
2278 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2279 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2280 +      if(motherIndex == -1) value = 23;
2281 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2282 +    }
2283 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2284 +  }
2285 +
2286 +
2287 +
2288    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2289  
2290    value = applyFunction(function, value);
# Line 1320 | Line 2292 | OSUAnalysis::valueLookup (const BNtrack*
2292    return value;
2293   }
2294  
2295 + //!genjet valueLookup
2296   double
2297   OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2298  
# Line 1348 | Line 2321 | OSUAnalysis::valueLookup (const BNgenjet
2321    return value;
2322   }
2323  
2324 + //!mcparticle valueLookup
2325   double
2326   OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2327  
# Line 1440 | Line 2414 | OSUAnalysis::valueLookup (const BNmcpart
2414  
2415    //user-defined variables
2416    else if (variable == "d0"){
2417 <    double vx = object->vx - primaryVertex_->x,
2418 <      vy = object->vy - primaryVertex_->y,
2417 >    double vx = object->vx - chosenVertex ()->x,
2418 >      vy = object->vy - chosenVertex ()->y,
2419        px = object->px,
2420        py = object->py,
2421        pt = object->pt;
2422      value = (-vx * py + vy * px) / pt;
2423    }
2424    else if (variable == "dz"){
2425 <    double vx = object->vx - primaryVertex_->x,
2426 <      vy = object->vy - primaryVertex_->y,
2427 <      vz = object->vz - primaryVertex_->z,
2425 >    double vx = object->vx - chosenVertex ()->x,
2426 >      vy = object->vy - chosenVertex ()->y,
2427 >      vz = object->vz - chosenVertex ()->z,
2428        px = object->px,
2429        py = object->py,
2430        pz = object->pz,
2431        pt = object->pt;
2432      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2433    }
2434 <
2434 >  else if(variable == "v0"){
2435 >    value = sqrt(object->vx*object->vx + object->vy*object->vy);
2436 >  }
2437 >  else if(variable == "deltaV0"){
2438 >    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2439 >  }
2440 >  else if (variable == "deltaVx"){
2441 >    value = object->vx - chosenVertex ()->x;
2442 >  }
2443 >  else if (variable == "deltaVy"){
2444 >    value = object->vy - chosenVertex ()->y;
2445 >  }
2446 >  else if (variable == "deltaVz"){
2447 >    value = object->vz - chosenVertex ()->z;
2448 >  }
2449  
2450  
2451    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1467 | Line 2455 | OSUAnalysis::valueLookup (const BNmcpart
2455    return value;
2456   }
2457  
2458 + //!primaryvertex valueLookup
2459   double
2460   OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2461  
# Line 1494 | Line 2483 | OSUAnalysis::valueLookup (const BNprimar
2483    return value;
2484   }
2485  
2486 + //!bxlumi valueLookup
2487   double
2488   OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2489  
# Line 1511 | Line 2501 | OSUAnalysis::valueLookup (const BNbxlumi
2501    return value;
2502   }
2503  
2504 + //!photon valueLookup
2505   double
2506   OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2507  
# Line 1587 | Line 2578 | OSUAnalysis::valueLookup (const BNphoton
2578    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2579  
2580  
2581 +
2582 +
2583 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2584 +
2585 +  else if(variable == "genMatchedPdgId"){
2586 +    int index = getGenMatchedParticleIndex(object);
2587 +    if(index == -1) value = 0;
2588 +    else value = mcparticles->at(index).id;
2589 +  }
2590 +
2591 +
2592 +
2593 +  else if(variable == "genMatchedId"){
2594 +    int index = getGenMatchedParticleIndex(object);
2595 +    if(index == -1) value = 0;
2596 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2597 +  }
2598 +  else if(variable == "genMatchedMotherId"){
2599 +    int index = getGenMatchedParticleIndex(object);
2600 +    if(index == -1) value = 0;
2601 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2602 +  }
2603 +  else if(variable == "genMatchedMotherIdReverse"){
2604 +    int index = getGenMatchedParticleIndex(object);
2605 +    if(index == -1) value = 23;
2606 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2607 +  }
2608 +  else if(variable == "genMatchedGrandmotherId"){
2609 +    int index = getGenMatchedParticleIndex(object);
2610 +    if(index == -1) value = 0;
2611 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2612 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2613 +      if(motherIndex == -1) value = 0;
2614 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2615 +    }
2616 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2617 +  }
2618 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2619 +    int index = getGenMatchedParticleIndex(object);
2620 +    if(index == -1) value = 23;
2621 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2622 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2623 +      if(motherIndex == -1) value = 23;
2624 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2625 +    }
2626 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2627 +  }
2628 +
2629 +
2630    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2631  
2632    value = applyFunction(function, value);
# Line 1594 | Line 2634 | OSUAnalysis::valueLookup (const BNphoton
2634    return value;
2635   }
2636  
2637 + //!supercluster valueLookup
2638   double
2639   OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2640  
# Line 1616 | Line 2657 | OSUAnalysis::valueLookup (const BNsuperc
2657    return value;
2658   }
2659  
2660 <
2660 > //!muon-muon pair valueLookup
2661   double
2662   OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2663  
2664    double value = 0.0;
2665  
2666 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2666 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2667 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2668 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2669    else if(variable == "invMass"){
2670      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2671      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2672      value = (fourVector1 + fourVector2).M();
2673    }
2674 +  else if(variable == "pt"){
2675 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2676 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2677 +    value = (fourVector1 + fourVector2).Pt();
2678 +  }
2679 +  else if(variable == "threeDAngle")
2680 +    {
2681 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2682 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2683 +      value = (threeVector1.Angle(threeVector2));
2684 +    }
2685 +  else if(variable == "alpha")
2686 +    {
2687 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2688 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2689 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2690 +      value = (pi-threeVector1.Angle(threeVector2));
2691 +    }
2692    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2693    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2694 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2694 >  else if(variable == "d0Sign"){
2695 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2696 >    if(d0Sign < 0) value = -0.5;
2697 >    else if (d0Sign > 0) value = 0.5;
2698 >    else value = -999;
2699 >  }
2700 >  else if(variable == "chargeProduct"){
2701 >    value = object1->charge*object2->charge;
2702 >  }
2703 >  else if(variable == "muon1CorrectedD0Vertex"){
2704 >    value = object1->correctedD0Vertex;
2705 >  }
2706 >  else if(variable == "muon2CorrectedD0Vertex"){
2707 >    value = object2->correctedD0Vertex;
2708 >  }
2709 >  else if(variable == "muon1timeAtIpInOut"){
2710 >    value = object1->timeAtIpInOut;
2711 >  }
2712 >  else if(variable == "muon2timeAtIpInOut"){
2713 >    value = object2->timeAtIpInOut;
2714 >  }
2715 >  else if(variable == "muon1correctedD0")
2716 >    {
2717 >      value = object1->correctedD0;
2718 >    }
2719 >  else if(variable == "muon2correctedD0")
2720 >    {
2721 >      value = object2->correctedD0;
2722 >    }
2723  
2724    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2725  
# Line 1639 | Line 2728 | OSUAnalysis::valueLookup (const BNmuon*
2728    return value;
2729   }
2730  
2731 + //!electron-electron pair valueLookup
2732   double
2733   OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2734  
2735    double value = 0.0;
2736  
2737 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2737 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2738 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2739 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2740    else if(variable == "invMass"){
2741      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2742      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2743      value = (fourVector1 + fourVector2).M();
2744    }
2745 +  else if(variable == "pt"){
2746 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2747 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2748 +    value = (fourVector1 + fourVector2).Pt();
2749 +  }
2750 +  else if(variable == "threeDAngle")
2751 +    {
2752 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2753 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2754 +      value = (threeVector1.Angle(threeVector2));
2755 +    }
2756    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2757    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2758 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2758 >  else if(variable == "d0Sign"){
2759 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2760 >    if(d0Sign < 0) value = -0.5;
2761 >    else if (d0Sign > 0) value = 0.5;
2762 >    else value = -999;
2763 >  }
2764 >  else if(variable == "chargeProduct"){
2765 >    value = object1->charge*object2->charge;
2766 >  }
2767 >  else if(variable == "electron1CorrectedD0Vertex"){
2768 >    value = object1->correctedD0Vertex;
2769 >  }
2770 >  else if(variable == "electron2CorrectedD0Vertex"){
2771 >    value = object2->correctedD0Vertex;
2772 >  }
2773 >  else if(variable == "electron1CorrectedD0"){
2774 >    value = object1->correctedD0;
2775 >  }
2776 >  else if(variable == "electron2CorrectedD0"){
2777 >    value = object2->correctedD0;
2778 >  }
2779  
2780    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2781  
# Line 1661 | Line 2784 | OSUAnalysis::valueLookup (const BNelectr
2784    return value;
2785   }
2786  
2787 + //!electron-muon pair valueLookup
2788   double
2789   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2790  
2791    double value = 0.0;
2792  
2793 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2793 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2794 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2795 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2796    else if(variable == "invMass"){
2797      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2798      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2799      value = (fourVector1 + fourVector2).M();
2800    }
2801 +  else if(variable == "pt"){
2802 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2803 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2804 +    value = (fourVector1 + fourVector2).Pt();
2805 +  }
2806 +  else if(variable == "threeDAngle")
2807 +    {
2808 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2809 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2810 +      value = (threeVector1.Angle(threeVector2));
2811 +    }
2812    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2813    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2814 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2814 >  else if(variable == "d0Sign"){
2815 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2816 >    if(d0Sign < 0) value = -0.5;
2817 >    else if (d0Sign > 0) value = 0.5;
2818 >    else value = -999;
2819 >  }
2820 >  else if(variable == "chargeProduct"){
2821 >    value = object1->charge*object2->charge;
2822 >  }
2823 >  else if(variable == "electronCorrectedD0Vertex"){
2824 >    value = object1->correctedD0Vertex;
2825 >  }
2826 >  else if(variable == "muonCorrectedD0Vertex"){
2827 >    value = object2->correctedD0Vertex;
2828 >  }
2829 >  else if(variable == "electronCorrectedD0"){
2830 >    value = object1->correctedD0;
2831 >  }
2832 >  else if(variable == "muonCorrectedD0"){
2833 >    value = object2->correctedD0;
2834 >  }
2835 >  else if(variable == "electronDetIso"){
2836 >    value = (object1->trackIso) / object1->pt;
2837 >  }
2838 >  else if(variable == "muonDetIso"){
2839 >    value = (object2->trackIsoDR03) / object2->pt;
2840 >  }
2841 >  else if(variable == "electronRelPFrhoIso"){
2842 >    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2843 >  }
2844 >  else if(variable == "muonRelPFdBetaIso"){
2845 >    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2846 >  }
2847 >
2848 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2849 >
2850 >  value = applyFunction(function, value);
2851 >
2852 >  return value;
2853 > }
2854 >
2855 > //!electron-jet pair valueLookup
2856 > double
2857 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function){
2858 >
2859 >  double value = 0.0;
2860 >
2861 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2862 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2863 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2864 >  else if(variable == "invMass"){
2865 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2866 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2867 >    value = (fourVector1 + fourVector2).M();
2868 >  }
2869 >  else if(variable == "pt"){
2870 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2871 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2872 >    value = (fourVector1 + fourVector2).Pt();
2873 >  }
2874 >  else if(variable == "threeDAngle")
2875 >    {
2876 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2877 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2878 >      value = (threeVector1.Angle(threeVector2));
2879 >    }
2880 >  else if(variable == "chargeProduct"){
2881 >    value = object1->charge*object2->charge;
2882 >  }
2883 >
2884 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2885 >
2886 >  value = applyFunction(function, value);
2887 >
2888 >  return value;
2889 > }
2890 >
2891 > //!muon-jet pair valueLookup
2892 > double
2893 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function){
2894 >
2895 >  double value = 0.0;
2896 >
2897 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2898 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2899 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2900 >  else if(variable == "invMass"){
2901 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2902 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2903 >    value = (fourVector1 + fourVector2).M();
2904 >  }
2905 >  else if(variable == "pt"){
2906 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2907 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2908 >    value = (fourVector1 + fourVector2).Pt();
2909 >  }
2910 >  else if(variable == "threeDAngle")
2911 >    {
2912 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2913 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2914 >      value = (threeVector1.Angle(threeVector2));
2915 >    }
2916 >  else if(variable == "chargeProduct"){
2917 >    value = object1->charge*object2->charge;
2918 >  }
2919 >
2920 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2921 >
2922 >  value = applyFunction(function, value);
2923 >
2924 >  return value;
2925 > }
2926 >
2927 > //!electron-track pair valueLookup
2928 > double  
2929 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2930 >  double electronMass = 0.000511;        
2931 >  double value = 0.0;    
2932 >  TLorentzVector fourVector1(0, 0, 0, 0);        
2933 >  TLorentzVector fourVector2(0, 0, 0, 0);        
2934 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2935 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2936 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2937 >  else if(variable == "invMass"){        
2938 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2939 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2940 >        
2941 >    value = (fourVector1 + fourVector2).M();    
2942 >  }
2943 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2944 >  value = applyFunction(function, value);        
2945 >  return value;  
2946 > }
2947 >
2948 >
2949 > //!muon-track pair valueLookup
2950 > double
2951 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2952 >  double pionMass = 0.140;
2953 >  double muonMass = 0.106;
2954 >  double value = 0.0;
2955 >  TLorentzVector fourVector1(0, 0, 0, 0);
2956 >  TLorentzVector fourVector2(0, 0, 0, 0);
2957 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2958 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2959 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2960 >  else if(variable == "invMass"){
2961 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2962 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2963 >
2964 >    value = (fourVector1 + fourVector2).M();
2965 >  }
2966 >
2967 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2968 >  value = applyFunction(function, value);
2969 >  return value;
2970 > }
2971 >
2972 > //!tau-tau pair valueLookup
2973 > double
2974 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2975 >  double value = 0.0;
2976 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2977 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2978 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2979 >  else if(variable == "invMass"){
2980 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2981 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2982 >    value = (fourVector1 + fourVector2).M();
2983 >  }
2984  
2985    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2986 +  value = applyFunction(function, value);
2987 +  return value;
2988 + }
2989 +
2990 + //!muon-tau pair valueLookup
2991 + double
2992 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2993 +  double value = 0.0;
2994 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2995 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2996 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2997 +  else if(variable == "invMass"){
2998 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2999 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3000 +    value = (fourVector1 + fourVector2).M();
3001 +  }
3002  
3003 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3004    value = applyFunction(function, value);
3005 +  return value;
3006 + }
3007 +
3008 + //!tau-track pair valueLookup
3009 + double
3010 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3011 +  double value = 0.0;
3012 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3013 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3014  
3015 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3016 +  value = applyFunction(function, value);
3017    return value;
3018   }
3019  
3020  
3021 + //!track-event pair valueLookup
3022 + double
3023 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3024 +
3025 +  double value = 0.0;
3026 +  double pMag = sqrt(object1->pt * object1->pt +
3027 +                     object1->pz * object1->pz);  
3028 +
3029 +  if      (variable == "numPV")                      value = object2->numPV;
3030 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3031 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3032 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3033 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3034 +
3035 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3036 +
3037 +  value = applyFunction(function, value);
3038 +
3039 +  return value;
3040 +
3041 + }
3042 +
3043 + //!stop valueLookup
3044 + double
3045 + OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
3046 +
3047 +
3048 +  double value = 0.0;
3049 +
3050 +  if(variable == "ctau") value = object->ctau;
3051 +
3052 +  else if (variable == "d0"){
3053 +    double vx = object->vx - chosenVertex ()->x,
3054 +      vy = object->vy - chosenVertex ()->y,
3055 +      px = object->px,
3056 +      py = object->py,
3057 +      pt = object->pt;
3058 +    value = (-vx * py + vy * px) / pt;
3059 +  }
3060 +
3061 +  else if (variable == "dz"){
3062 +    double vx = object->vx - chosenVertex ()->x,
3063 +      vy = object->vy - chosenVertex ()->y,
3064 +      vz = object->vz - chosenVertex ()->z,
3065 +      px = object->px,
3066 +      py = object->py,
3067 +      pz = object->pz,
3068 +      pt = object->pt;
3069 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3070 +  }
3071 +
3072 +  else if (variable == "minD0"){
3073 +    double minD0=999;
3074 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3075 +      double vx = object->vx - vertex->x,
3076 +        vy = object->vy - vertex->y,
3077 +        px = object->px,
3078 +        py = object->py,
3079 +        pt = object->pt;
3080 +      value = (-vx * py + vy * px) / pt;
3081 +      if(abs(value) < abs(minD0)) minD0 = value;
3082 +    }
3083 +    value = minD0;
3084 +  }
3085 +  else if (variable == "minDz"){
3086 +    double minDz=999;
3087 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3088 +      double vx = object->vx - vertex->x,
3089 +        vy = object->vy - vertex->y,
3090 +        vz = object->vz - vertex->z,
3091 +        px = object->px,
3092 +        py = object->py,
3093 +        pz = object->pz,
3094 +        pt = object->pt;
3095 +      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3096 +      if(abs(value) < abs(minDz)) minDz = value;
3097 +    }
3098 +    value = minDz;
3099 +  }
3100 +  else if(variable == "distToVertex"){
3101 +    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3102 +                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3103 +                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3104 +  }
3105 +  else if (variable == "minDistToVertex"){
3106 +    double minDistToVertex=999;
3107 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3108 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3109 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3110 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3111 +      
3112 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3113 +    }
3114 +    value = minDistToVertex;
3115 +  }
3116 +  else if (variable == "distToVertexDifference"){
3117 +    double minDistToVertex=999;
3118 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3119 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3120 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3121 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3122 +      
3123 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3124 +    }
3125 +    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3126 +                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3127 +                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3128 +
3129 +    value = distToChosenVertex - minDistToVertex;
3130 +  }
3131 +
3132 +  else if (variable == "closestVertexRank"){
3133 +    double minDistToVertex=999;
3134 +    int vertex_rank = 0;
3135 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3136 +      vertex_rank++;
3137 +      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3138 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3139 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3140 +      
3141 +      if(abs(dist) < abs(minDistToVertex)){
3142 +        value = vertex_rank;
3143 +        minDistToVertex = dist;
3144 +      }
3145 +    }
3146 +  }
3147 +
3148 +
3149 +
3150 +
3151 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3152 +
3153 +  value = applyFunction(function, value);
3154 +
3155 +  return value;
3156 +
3157 + }  
3158 +
3159 +
3160 +
3161 +
3162 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3163 + // Return true iff no other tracks are found in this cone.
3164 + int
3165 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
3166 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
3167 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
3168 +    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
3169 +    if(deltaRtrk < 0.5) return 0;
3170 +  }
3171 +  return 1;
3172 +
3173 + }
3174 +
3175 +
3176 + double
3177 + OSUAnalysis::getTrkPtRes (const BNtrack* track1){
3178 +
3179 +  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
3180 +  double PtRes = (track1->pt - ptTrue) / ptTrue;
3181 +
3182 +  return PtRes;
3183 +
3184 + }
3185 +
3186 +
3187 + double
3188 + OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
3189 +  double value = -99;
3190 +  double genDeltaRLowest = 999;
3191 +
3192 +  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
3193 +    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
3194 +    if (genDeltaRtemp < genDeltaRLowest) {
3195 +      genDeltaRLowest = genDeltaRtemp;
3196 +      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
3197 +        double ptTrue = genPart->pt;
3198 +        value = ptTrue;
3199 +      }
3200 +    }
3201 +  }
3202 +
3203 +  return value;
3204 +
3205 + }
3206 +
3207 + double
3208 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3209 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3210 +  if (!useTrackCaloRhoCorr_) return -99;  
3211 +  // if (!rhokt6CaloJetsHandle_) {
3212 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3213 +  //   return -99;  
3214 +  // }
3215 +  double radDeltaRCone = 0.5;  
3216 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3217 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3218 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3219 +  return caloTotRhoCorrCalo;  
3220 +
3221 + }
3222 +
3223 +
3224 +
3225 +
3226 + //creates a map of the dead Ecal channels in the barrel and endcap
3227 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
3228 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
3229 + void
3230 + OSUAnalysis::WriteDeadEcal (){
3231 +  double etaEcal, phiEcal;
3232 +  ifstream DeadEcalFile(deadEcalFile_);
3233 +  if(!DeadEcalFile) {
3234 +    cout << "Error: DeadEcalFile has not been found." << endl;
3235 +    return;
3236 +  }
3237 +  if(DeadEcalVec.size()!= 0){
3238 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
3239 +    return;
3240 +  }
3241 +  while(!DeadEcalFile.eof())
3242 +    {
3243 +      DeadEcalFile >> etaEcal >> phiEcal;
3244 +      DeadEcal newChan;
3245 +      newChan.etaEcal = etaEcal;
3246 +      newChan.phiEcal = phiEcal;
3247 +      DeadEcalVec.push_back(newChan);
3248 +    }
3249 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
3250 + }
3251 +
3252 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
3253 + int
3254 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
3255 +  double deltaRLowest = 999;
3256 +  int value = 0;
3257 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
3258 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3259 +    double eta = ecal->etaEcal;
3260 +    double phi = ecal->phiEcal;
3261 +    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3262 +    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3263 +  }
3264 +  if (deltaRLowest<0.05) {value = 1;}
3265 +  else {value = 0;}
3266 +  return value;
3267 + }
3268 +
3269 + // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3270 + template <class InputObject>
3271 + double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3272 +  double genDeltaRLowest = 999.;
3273 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3274 +    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3275 +    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3276 +  }
3277 +  return genDeltaRLowest;
3278 + }
3279 +
3280   double
3281   OSUAnalysis::applyFunction(string function, double value){
3282  
3283    if(function == "abs") value = fabs(value);
3284 +  else if(function == "fabs") value = fabs(value);
3285 +  else if(function == "log10") value = log10(value);
3286 +  else if(function == "log") value = log10(value);
3287  
3288 +  else if(function == "") value = value;
3289 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3290  
3291    return value;
3292  
# Line 1697 | Line 3295 | OSUAnalysis::applyFunction(string functi
3295  
3296   template <class InputCollection>
3297   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3298 +
3299 +  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3300 +    string obj1, obj2;
3301 +    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3302 +    if (inputType==obj1 ||
3303 +        inputType==obj2) {
3304 +      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3305 +      // and the inputType is a member of the pair.  
3306 +      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3307 +      // For example, if currentCut.inputCollection==electron-muon pairs,
3308 +      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3309 +      return;
3310 +    }  
3311 +  }    
3312  
3313    for (uint object = 0; object != inputCollection->size(); object++){
3314  
# Line 1706 | Line 3318 | void OSUAnalysis::setObjectFlags(cut &cu
3318  
3319        vector<bool> subcutDecisions;
3320        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3321 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3322 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3321 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3322 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3323 >
3324        }
3325        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3326        else{
3327 <        bool tempDecision = true;
3328 <        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
3329 <          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
3330 <            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
3331 <          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
3327 >        bool tempDecision = true;
3328 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
3329 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
3330 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
3331 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
3332              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
3333 <        }
3334 <        decision = tempDecision;
3333 >        }
3334 >        decision = tempDecision;
3335        }
3336      }
3337 +
3338      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3339  
3340      //set flags for objects that pass each cut AND all the previous cuts
# Line 1738 | Line 3352 | void OSUAnalysis::setObjectFlags(cut &cu
3352  
3353   template <class InputCollection1, class InputCollection2>
3354   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
3355 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
3355 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
3356  
3357  
3358    bool sameObjects = false;
3359    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3360  
3361 <  int counter = 0;  
3361 >  // Get the strings for the two objects that make up the pair.  
3362 >  string obj1Type, obj2Type;
3363 >  getTwoObjs(inputType, obj1Type, obj2Type);
3364 >  bool isTwoTypesOfObject = true;
3365 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3366 >
3367 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3368 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3369 >  if (currentCut.inputCollection == inputType) {    
3370 >    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3371 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3372 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3373 >    }
3374 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3375 >      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3376 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3377 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3378 >      }
3379 >    }
3380 >  }
3381 >  
3382 >  int counter = 0;
3383 >
3384    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3385      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3386 <      
3386 >
3387        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3388  
3389  
# Line 1755 | Line 3391 | void OSUAnalysis::setObjectFlags(cut &cu
3391  
3392        if(currentCut.inputCollection == inputType){
3393  
3394 <        vector<bool> subcutDecisions;
3395 <        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3396 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3397 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3398 <        }
3394 >        vector<bool> subcutDecisions;
3395 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3396 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3397 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3398 >        }
3399  
3400 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3401 <        else{
3402 <          bool tempDecision = true;
3403 <          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
3404 <            if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
3405 <              tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
3406 <            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
3407 <              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
3408 <          }
3409 <          decision = tempDecision;
3410 <        }
3400 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3401 >        else{
3402 >          bool tempDecision = subcutDecisions.at(0);
3403 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
3404 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
3405 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
3406 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
3407 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
3408 >          }
3409 >          decision = tempDecision;
3410 >        }
3411        }
3412 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3413 <      
3412 >      // if (decision) isPassObj1.at(object1) = true;
3413 >      // if (decision) isPassObj2.at(object2) = true;
3414 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3415 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3416 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3417 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3418 >      }  
3419 >
3420        //set flags for objects that pass each cut AND all the previous cuts
3421        bool previousCumulativeFlag = true;
3422        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3423 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
3424 <        else{ previousCumulativeFlag = false; break;}
3423 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
3424 >        else{ previousCumulativeFlag = false; break;}
3425        }
3426 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3426 >      //apply flags for the components of the composite object as well
3427 >      bool currentCumulativeFlag = true;
3428 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
3429 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
3430 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3431 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3432 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3433 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3434 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3435 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3436 >      }
3437 >      counter++;
3438 >
3439 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3440 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3441  
3442 <      counter++;      
1787 <    }
1788 <    
1789 <  }
3442 > }
3443  
3444  
3445 < }
3445 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3446 >  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3447 >  // all cuts up to currentCutIndex  
3448 >  bool previousCumulativeFlag = true;  
3449 >  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3450 >    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3451 >    else {  
3452 >      previousCumulativeFlag = false; break;  
3453 >    }
3454 >  }
3455 >  return previousCumulativeFlag;  
3456 > }  
3457  
3458  
3459   template <class InputCollection>
3460 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
3460 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3461  
3462    for (uint object = 0; object != inputCollection->size(); object++){
3463  
# Line 1803 | Line 3467 | void OSUAnalysis::fill1DHistogram(TH1* h
3467      string inputVariable = "";
3468      string function = "";
3469      if(currentString.find("(")==std::string::npos){
3470 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3470 >      inputVariable = currentString;// variable to cut on
3471      }
3472      else{
3473 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3474 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3475 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3473 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3474 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3475 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3476      }
3477  
3478      double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3479 <    histo->Fill(value,puScaleFactor);
3479 >    histo->Fill(value,scaleFactor);
3480  
3481 +    if (printEventInfo_) {
3482 +      // Write information about event to screen, for testing purposes.  
3483 +      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3484 +    }
3485 +    
3486    }
1818
3487   }
3488  
3489   template <class InputCollection1, class InputCollection2>
3490 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
3490 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3491  
3492    bool sameObjects = false;
3493    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3494  
3495 <  int counter = 0;  
3495 >  int pairCounter = -1;
3496    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3497      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3498 <      
3498 >
3499        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3500  
3501 +      pairCounter++;
3502        //only take objects which have passed all cuts and pairs which have passed all cuts
3503        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3504        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3505 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
3505 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3506  
3507        string currentString = parameters.inputVariables.at(0);
3508        string inputVariable = "";
3509        string function = "";
3510        if(currentString.find("(")==std::string::npos){
3511 <        inputVariable = currentString;// variable to cut on                                                                                                          
3511 >        inputVariable = currentString;// variable to cut on
3512        }
3513        else{
3514 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3515 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3516 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3514 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3515 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3516 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3517        }
3518 <      
3518 >
3519        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3520 <      histo->Fill(value,puScaleFactor);
3520 >      histo->Fill(value,scaleFactor);
3521  
1853      counter++;      
3522      }
3523    }
3524  
# Line 1858 | Line 3526 | void OSUAnalysis::fill1DHistogram(TH1* h
3526  
3527  
3528   template <class InputCollection>
3529 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
3529 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3530  
3531    for (uint object = 0; object != inputCollection->size(); object++){
3532  
# Line 1868 | Line 3536 | void OSUAnalysis::fill2DHistogram(TH2* h
3536      string inputVariable = "";
3537      string function = "";
3538      if(currentString.find("(")==std::string::npos){
3539 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3539 >      inputVariable = currentString;// variable to cut on
3540      }
3541      else{
3542 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3543 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3544 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3542 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3543 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3544 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3545      }
3546      double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3547  
# Line 1881 | Line 3549 | void OSUAnalysis::fill2DHistogram(TH2* h
3549      inputVariable = "";
3550      function = "";
3551      if(currentString.find("(")==std::string::npos){
3552 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3552 >      inputVariable = currentString;// variable to cut on
3553      }
3554      else{
3555 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3556 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3557 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3555 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3556 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3557 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3558      }
3559  
3560      double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3561  
3562 <    histo->Fill(valueX,valueY,puScaleFactor);
3562 >    histo->Fill(valueX,valueY,scaleFactor);
3563  
3564    }
3565  
3566   }
3567  
3568   template <class InputCollection1, class InputCollection2>
3569 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
3569 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3570  
3571    bool sameObjects = false;
3572    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3573  
3574 <  int counter = 0;  
3574 >  int pairCounter = -1;
3575    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3576      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3577 <      
3577 >
3578        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3579  
3580 +      pairCounter++;
3581 +
3582        //only take objects which have passed all cuts and pairs which have passed all cuts
3583        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3584        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3585 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
3585 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3586  
3587        string currentString = parameters.inputVariables.at(0);
3588        string inputVariable = "";
3589        string function = "";
3590        if(currentString.find("(")==std::string::npos){
3591 <        inputVariable = currentString;// variable to cut on                                                                                                          
3591 >        inputVariable = currentString;// variable to cut on
3592        }
3593        else{
3594 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3595 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3596 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3594 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3595 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3596 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3597        }
3598        double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3599  
# Line 1931 | Line 3601 | void OSUAnalysis::fill2DHistogram(TH2* h
3601        inputVariable = "";
3602        function = "";
3603        if(currentString.find("(")==std::string::npos){
3604 <        inputVariable = currentString;// variable to cut on                                                                                                          
3604 >        inputVariable = currentString;// variable to cut on
3605        }
3606        else{
3607 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3608 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3609 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3607 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3608 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3609 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3610        }
3611        double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3612  
3613  
3614 <      histo->Fill(valueX,valueY,puScaleFactor);
3614 >      histo->Fill(valueX,valueY,scaleFactor);
3615  
1946      counter++;      
3616      }
3617    }
3618  
3619   }
3620  
3621  
3622 + template <class InputObject>
3623 + int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
3624  
3625 < DEFINE_FWK_MODULE(OSUAnalysis);
3625 >  int bestMatchIndex = -1;
3626 >  double bestMatchDeltaR = 999;
3627 >
3628 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3629 >
3630 >    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3631 >    if(currentDeltaR > 0.05) continue;
3632 >    //     cout << std::setprecision(3) << std::setw(20)
3633 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3634 >    //          << std::setw(20)
3635 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3636 >    //          << std::setw(20)
3637 >    //          << "\tdeltaR = " << currentDeltaR
3638 >    //          << std::setprecision(1)
3639 >    //          << std::setw(20)
3640 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3641 >    //          << std::setw(20)
3642 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3643 >    //          << std::setw(20)
3644 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3645 >    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3646 >      bestMatchIndex = mcparticle - mcparticles->begin();
3647 >      bestMatchDeltaR = currentDeltaR;
3648 >    }
3649 >
3650 >  }
3651 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3652 >  //   else cout << "no match found..." << endl;
3653 >  return bestMatchIndex;
3654 >
3655 > }
3656 >
3657 >
3658 > int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
3659 >
3660 >  int bestMatchIndex = -1;
3661 >  double bestMatchDeltaR = 999;
3662 >
3663 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3664 >
3665 >    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
3666 >
3667 >    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
3668 >    if(currentDeltaR > 0.05) continue;
3669 >
3670 >    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3671 >      bestMatchIndex = mcparticle - mcparticles->begin();
3672 >      bestMatchDeltaR = currentDeltaR;
3673 >    }
3674 >
3675 >  }
3676 >
3677 >  return bestMatchIndex;
3678 > }
3679 >
3680 >
3681 > // bin      particle type
3682 > // ---      -------------
3683 > //  0        unmatched
3684 > //  1        u
3685 > //  2        d
3686 > //  3        s
3687 > //  4        c
3688 > //  5        b
3689 > //  6        t
3690 > //  7        e
3691 > //  8        mu
3692 > //  9        tau
3693 > // 10        nu
3694 > // 11        g
3695 > // 12        gamma
3696 > // 13        Z
3697 > // 14        W
3698 > // 15        light meson
3699 > // 16        K meson
3700 > // 17        D meson
3701 > // 18        B meson
3702 > // 19        light baryon
3703 > // 20        strange baryon
3704 > // 21        charm baryon
3705 > // 22        bottom baryon
3706 > // 23        other
3707 >
3708 > int OSUAnalysis::getPdgIdBinValue(int pdgId){
3709 >
3710 >  int binValue = -999;
3711 >  int absPdgId = fabs(pdgId);
3712 >  if(pdgId == -1) binValue = 0;
3713 >  else if(absPdgId <= 6 ) binValue = absPdgId;
3714 >  else if(absPdgId == 11 ) binValue = 7;
3715 >  else if(absPdgId == 13 ) binValue = 8;
3716 >  else if(absPdgId == 15 ) binValue = 9;
3717 >  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
3718 >  else if(absPdgId == 21 ) binValue = 11;
3719 >  else if(absPdgId == 22 ) binValue = 12;
3720 >  else if(absPdgId == 23 ) binValue = 13;
3721 >  else if(absPdgId == 24 ) binValue = 14;
3722 >  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
3723 >  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
3724 >  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
3725 >  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
3726 >  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
3727 >  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3728 >  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3729 >  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3730 >
3731 >  else binValue = 23;
3732 >
3733 >  return binValue;
3734  
3735 + }
3736 +
3737 + const BNprimaryvertex *
3738 + OSUAnalysis::chosenVertex ()
3739 + {
3740 +  const BNprimaryvertex *chosenVertex = 0;
3741 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3742 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3743 +      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3744 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3745 +      if(!vertexFlags.at(vertexIndex)) continue;
3746 +      chosenVertex = & primaryvertexs->at(vertexIndex);
3747 +      break;
3748 +    }
3749 +  }
3750 +  else {
3751 +    chosenVertex = &primaryvertexs->at(0);
3752 +  }
3753 +
3754 +  return chosenVertex;
3755 + }
3756 +
3757 + const BNmet *
3758 + OSUAnalysis::chosenMET ()
3759 + {
3760 +  const BNmet *chosenMET = 0;
3761 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3762 +    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3763 +      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3764 +    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3765 +      if(!metFlags.at(metIndex)) continue;
3766 +      chosenMET = & mets->at(metIndex);
3767 +      break;
3768 +    }
3769 +  }
3770 +  else {
3771 +    chosenMET = &mets->at(0);
3772 +  }
3773 +
3774 +  return chosenMET;
3775 + }
3776  
3777 + const BNelectron *
3778 + OSUAnalysis::chosenElectron ()
3779 + {
3780 +  const BNelectron *chosenElectron = 0;
3781 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3782 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3783 +      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3784 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3785 +      if(!electronFlags.at(electronIndex)) continue;
3786 +      chosenElectron = & electrons->at(electronIndex);
3787 +      break;
3788 +    }
3789 +  }
3790 +  else {
3791 +    chosenElectron = &electrons->at(0);
3792 +  }
3793 +
3794 +  return chosenElectron;
3795 + }
3796 +
3797 + const BNmuon *
3798 + OSUAnalysis::chosenMuon ()
3799 + {
3800 +  const BNmuon *chosenMuon = 0;
3801 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3802 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3803 +      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3804 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3805 +      if(!muonFlags.at(muonIndex)) continue;
3806 +      chosenMuon = & muons->at(muonIndex);
3807 +      break;
3808 +    }
3809 +  }
3810 +  else {
3811 +    chosenMuon = &muons->at(0);
3812 +  }
3813 +
3814 +  return chosenMuon;
3815 + }
3816 +
3817 +
3818 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines