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.42 by wulsin, Wed Mar 27 22:38:08 2013 UTC vs.
Revision 1.61 by ahart, Fri May 10 15:03:48 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")),
20 >  trigobjs_ (cfg.getParameter<edm::InputTag> ("trigobjs")),
21 >  puFile_ (cfg.getParameter<string> ("puFile")),
22 >  deadEcalFile_ (cfg.getParameter<string> ("deadEcalFile")),
23 >  muonSFFile_ (cfg.getParameter<string> ("muonSFFile")),
24 >  dataPU_ (cfg.getParameter<string> ("dataPU")),
25 >  electronSFID_ (cfg.getParameter<string> ("electronSFID")),
26 >  muonSF_ (cfg.getParameter<string> ("muonSF")),
27 >  dataset_ (cfg.getParameter<string> ("dataset")),
28 >  datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
32    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
33 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
34 <  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr"))
33 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
34 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
36 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
37  
38   {
39  
# Line 38 | Line 42 | OSUAnalysis::OSUAnalysis (const edm::Par
42    //create pile-up reweighting object, if necessary
43    if(datasetType_ != "data") {
44      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
45 <    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
46 <    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 >    if (applyLeptonSF_){
46 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
47 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
48 >    }
49    }
50 +  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
51 +    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
52  
53  
54    // Construct Cutflow Objects. These store the results of cut decisions and
55    // handle filling cut flow histograms.
56    masterCutFlow_ = new CutFlow (fs_);
57 <  std::vector<TFileDirectory> directories;
57 >  vector<TFileDirectory> directories;
58  
59    //always get vertex collection so we can assign the primary vertex in the event
60    objectsToGet.push_back("primaryvertexs");
61  
62 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
62 >  //always make the plot of number of primary vertices (to check pile-up reweighting)
63    objectsToPlot.push_back("primaryvertexs");
64  
65    //always get the MC particles to do GEN-matching
# Line 65 | Line 73 | OSUAnalysis::OSUAnalysis (const edm::Par
73  
74      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
75      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
76 +    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
77 +    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
78      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
79 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
80 <      objectsToGet.push_back(tempInputCollection);
79 >    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
80 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
81 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
82 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
83 >    if(tempInputCollection.find("pairs")==string::npos){ //just a single object
84 >      if(tempInputCollection.find("secondary")!=string::npos){//secondary object
85 >        int spaceIndex = tempInputCollection.find(" ");
86 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
87 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
88 >      }
89 >      else{
90 >        objectsToGet.push_back(tempInputCollection);
91 >      }
92        objectsToPlot.push_back(tempInputCollection);
93        objectsToCut.push_back(tempInputCollection);
94      }
95 <    else{//pair of objects, need to add them both to the things to objectsToGet
96 <      int dashIndex = tempInputCollection.find("-");
97 <      int spaceIndex = tempInputCollection.find(" ");
98 <      int secondWordLength = spaceIndex - dashIndex;
99 <      objectsToGet.push_back(tempInputCollection);
79 <      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
80 <      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
81 <      objectsToPlot.push_back(tempInputCollection);
82 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
83 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
95 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
96 >      string obj1;
97 >      string obj2;
98 >      getTwoObjs(tempInputCollection, obj1, obj2);
99 >      string obj2ToGet = getObjToGet(obj2);
100        objectsToCut.push_back(tempInputCollection);
101 <      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
102 <      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
101 >      objectsToCut.push_back(obj1);
102 >      objectsToCut.push_back(obj2);
103 >      objectsToPlot.push_back(tempInputCollection);
104 >      objectsToPlot.push_back(obj1);
105 >      objectsToPlot.push_back(obj2);
106 >      objectsToGet.push_back(tempInputCollection);
107 >      objectsToGet.push_back(obj1);
108 >      objectsToGet.push_back(obj2ToGet);
109  
110 <      }
110 >    }
111  
112      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
113  
114      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
115  
116 +      vector<double> defaultValue;
117 +      defaultValue.push_back (-1.0);
118 +
119        histogram tempHistogram;
120        tempHistogram.inputCollection = tempInputCollection;
121        tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
122        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
123 <      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
123 >      tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
124 >      tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
125 >      tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
126        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
127  
128        histograms.push_back(tempHistogram);
# Line 112 | Line 139 | OSUAnalysis::OSUAnalysis (const edm::Par
139    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
140  
141      string currentObject = objectsToPlot.at(currentObjectIndex);
142 <    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
142 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
143  
144      histogram tempIdHisto;
145      histogram tempMomIdHisto;
146      histogram tempGmaIdHisto;
147      histogram tempIdVsMomIdHisto;
148 +    histogram tempIdVsGmaIdHisto;
149  
150      tempIdHisto.inputCollection = currentObject;
151      tempMomIdHisto.inputCollection = currentObject;
152      tempGmaIdHisto.inputCollection = currentObject;
153      tempIdVsMomIdHisto.inputCollection = currentObject;
154 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
155 +
156 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
157 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
158  
159      currentObject = currentObject.substr(0, currentObject.size()-1);
160      tempIdHisto.name = currentObject+"GenMatchId";
161      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
162      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
163      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
164 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
165  
166      currentObject.at(0) = toupper(currentObject.at(0));
167      tempIdHisto.title = currentObject+" Gen-matched Particle";
168      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
169      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
170      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
171 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
172 +
173  
174      int maxNum = 24;
175      vector<double> binVector;
# Line 154 | Line 189 | OSUAnalysis::OSUAnalysis (const edm::Par
189      tempIdVsMomIdHisto.bins = binVector;
190      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
191      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
192 +    tempIdVsGmaIdHisto.bins = binVector;
193 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
194 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
195  
196      histograms.push_back(tempIdHisto);
197      histograms.push_back(tempMomIdHisto);
198      histograms.push_back(tempGmaIdHisto);
199      histograms.push_back(tempIdVsMomIdHisto);
200 +    histograms.push_back(tempIdVsGmaIdHisto);
201    }
202  
203  
# Line 192 | Line 231 | OSUAnalysis::OSUAnalysis (const edm::Par
231      TFileDirectory subDir = fs_->mkdir( channelName );
232      directories.push_back(subDir);
233  
234 <    std::map<std::string, TH1D*> oneDhistoMap;
234 >    map<string, TH1D*> oneDhistoMap;
235      oneDHists_.push_back(oneDhistoMap);
236 <    std::map<std::string, TH2D*> twoDhistoMap;
236 >    map<string, TH2D*> twoDhistoMap;
237      twoDHists_.push_back(twoDhistoMap);
238  
239  
# Line 204 | Line 243 | OSUAnalysis::OSUAnalysis (const edm::Par
243        histogram currentHistogram = histograms.at(currentHistogramIndex);
244        int numBinsElements = currentHistogram.bins.size();
245        int numInputVariables = currentHistogram.inputVariables.size();
246 +      int numBinEdgesX = currentHistogram.variableBinsX.size();
247 +      int numBinEdgesY = currentHistogram.variableBinsY.size();
248  
249 <      if(numBinsElements != 3 && numBinsElements !=6) {
250 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
249 >      if(numBinsElements == 1){
250 >        if(numBinEdgesX > 1){
251 >          if(numBinEdgesY > 1)
252 >            numBinsElements = 6;
253 >          else
254 >            numBinsElements = 3;
255 >        }
256 >      }
257 >      if(numBinsElements != 3 && numBinsElements !=6){
258 >        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
259          exit(0);
260        }
261        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
262 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
262 >        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
263          exit(0);
264        }
265        else if(numBinsElements == 3){
266 <        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));
266 >        if (currentHistogram.bins.size () == 3)
267 >          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));
268 >        else
269 >          {
270 >            oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
271 >          }
272        }
273        else if(numBinsElements == 6){
274 <        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));
275 <
274 >        if (currentHistogram.bins.size () == 6)
275 >          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));
276 >        else
277 >          twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
278        }
279  
280  
281 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
282 <
283 < // bin      particle type
284 < // ---      -------------
285 < //  0        unmatched
286 < //  1        u
287 < //  2        d
288 < //  3        s
289 < //  4        c
290 < //  5        b
291 < //  6        t
292 < //  7        e
293 < //  8        mu
294 < //  9        tau
295 < // 10        nu
296 < // 11        g
297 < // 12        gamma
298 < // 13        Z
299 < // 14        W
300 < // 15        light meson
301 < // 16        K meson
302 < // 17        D meson
303 < // 18        B meson
304 < // 19        light baryon
305 < // 20        strange baryon
306 < // 21        charm baryon
307 < // 22        bottom baryon
308 < // 23        other
281 >      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
282 >
283 >      // bin      particle type
284 >      // ---      -------------
285 >      //  0        unmatched
286 >      //  1        u
287 >      //  2        d
288 >      //  3        s
289 >      //  4        c
290 >      //  5        b
291 >      //  6        t
292 >      //  7        e
293 >      //  8        mu
294 >      //  9        tau
295 >      // 10        nu
296 >      // 11        g
297 >      // 12        gamma
298 >      // 13        Z
299 >      // 14        W
300 >      // 15        light meson
301 >      // 16        K meson
302 >      // 17        D meson
303 >      // 18        B meson
304 >      // 19        light baryon
305 >      // 20        strange baryon
306 >      // 21        charm baryon
307 >      // 22        bottom baryon
308 >      // 23        other
309  
310        vector<TString> labelArray;
311        labelArray.push_back("unmatched");
# Line 278 | Line 334 | OSUAnalysis::OSUAnalysis (const edm::Par
334        labelArray.push_back("other");
335  
336        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
337 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
338 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
339 <        }
340 <        else {
341 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
342 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
343 <        }
337 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
338 >          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
339 >        }
340 >        else {
341 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
342 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
343 >        }
344        }
345 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
346 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
347 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
345 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
346 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
347 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
348        }
349  
350      }
351  
352 <    // Book a histogram for the number of each object type to be plotted.  
353 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
352 >    // Book a histogram for the number of each object type to be plotted.
353 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
354      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
355        string currentObject = objectsToPlot.at(currentObjectIndex);
356        int maxNum = 10;
357        if(currentObject == "mcparticles") maxNum = 50;
358        else if(currentObject == "primaryvertexs") maxNum = 50;
359 <      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
360 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
361 <      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
362 <      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
359 >
360 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
361 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
362 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
363 >      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
364 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
365 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
366 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
367 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
368 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
369 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
370 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
371 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
372 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
373 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
374 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
375 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
376 >      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
377 >      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
378  
379        currentObject.at(0) = toupper(currentObject.at(0));
380        string histoName = "num" + currentObject;
# Line 329 | Line 400 | OSUAnalysis::OSUAnalysis (const edm::Par
400        cut tempCut;
401        //store input collection for cut
402        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
403 +      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
404 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
405 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
406 +      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
407 +      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
408 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
409 +      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
410 +      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
411        tempCut.inputCollection = tempInputCollection;
412 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
413 <        objectsToGet.push_back(tempInputCollection);
412 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
413 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
414 >          int spaceIndex = tempInputCollection.find(" ");
415 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
416 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
417 >        }
418 >        else{
419 >          objectsToGet.push_back(tempInputCollection);
420 >        }
421          objectsToCut.push_back(tempInputCollection);
422        }
423 <      else{//pair of objects, need to add them both to the things to objectsToGet
424 <        int dashIndex = tempInputCollection.find("-");
425 <        int spaceIndex = tempInputCollection.find(" ");
426 <        int secondWordLength = spaceIndex - dashIndex;
427 <        objectsToGet.push_back(tempInputCollection);
342 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
343 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
423 >      else{//pair of objects, need to add them both to objectsToGet
424 >        string obj1;
425 >        string obj2;
426 >        getTwoObjs(tempInputCollection, obj1, obj2);
427 >        string obj2ToGet = getObjToGet(obj2);
428          objectsToCut.push_back(tempInputCollection);
429 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
430 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
429 >        objectsToCut.push_back(obj1);
430 >        objectsToCut.push_back(obj2);
431 >        objectsToGet.push_back(tempInputCollection);
432 >        objectsToGet.push_back(obj1);
433 >        objectsToGet.push_back(obj2ToGet);
434  
435        }
436  
# Line 351 | Line 438 | OSUAnalysis::OSUAnalysis (const edm::Par
438  
439        //split cut string into parts and store them
440        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
441 <      std::vector<string> cutStringVector = splitString(cutString);
441 >      vector<string> cutStringVector = splitString(cutString);
442        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
443 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
443 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
444          exit(0);
445        }
446        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
447        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
448          int indexOffset = 4 * subcutIndex;
449          string currentVariableString = cutStringVector.at(indexOffset);
450 <        if(currentVariableString.find("(")==std::string::npos){
450 >        if(currentVariableString.find("(")==string::npos){
451            tempCut.functions.push_back("");//no function was specified
452            tempCut.variables.push_back(currentVariableString);// variable to cut on
453          }
# Line 371 | Line 458 | OSUAnalysis::OSUAnalysis (const edm::Par
458          }
459          tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
460          tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
461 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
462          if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
463        }
464  
465        //get number of objects required to pass cut for event to pass
466        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
467 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
467 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
468        if(numberRequiredVector.size()!=2){
469 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
469 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
470          exit(0);
471        }
472  
# Line 400 | Line 488 | OSUAnalysis::OSUAnalysis (const edm::Par
488        }
489        tempCut.name = tempCutName;
490  
403
491        tempChannel.cuts.push_back(tempCut);
492  
493  
407
494      }//end loop over cuts
495  
496      channels.push_back(tempChannel);
# Line 438 | Line 524 | OSUAnalysis::analyze (const edm::Event &
524  
525    // Retrieve necessary collections from the event.
526  
527 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
527 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
528      event.getByLabel (triggers_, triggers);
529  
530 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
530 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
531 >    event.getByLabel (trigobjs_, trigobjs);
532 >
533 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
534      event.getByLabel (jets_, jets);
535  
536 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
536 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
537      event.getByLabel (muons_, muons);
538  
539 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
539 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
540      event.getByLabel (electrons_, electrons);
541  
542 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
542 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
543      event.getByLabel (events_, events);
544  
545 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
545 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
546      event.getByLabel (taus_, taus);
547  
548 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
548 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
549      event.getByLabel (mets_, mets);
550  
551 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
551 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
552      event.getByLabel (tracks_, tracks);
553  
554 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
554 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
555      event.getByLabel (genjets_, genjets);
556  
557 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
557 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
558      event.getByLabel (mcparticles_, mcparticles);
559  
560 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
560 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
561      event.getByLabel (primaryvertexs_, primaryvertexs);
562  
563 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
563 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
564      event.getByLabel (bxlumis_, bxlumis);
565  
566 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
566 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
567      event.getByLabel (photons_, photons);
568  
569 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
569 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
570      event.getByLabel (superclusters_, superclusters);
571  
572 <  if (useTrackCaloRhoCorr_) {  
573 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
574 <    // This rho collection is not available in all BEANs.  
572 >  if (datasetType_ == "signalMC"){
573 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
574 >      event.getByLabel (stops_, stops);
575 >  }
576 >
577 >  if (useTrackCaloRhoCorr_) {
578 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
579 >    // This rho collection is not available in all BEANs.
580      // For description of rho values for different jet reconstruction algorithms, see
581 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
582 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
581 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
582 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
583    }
584  
585 +  double masterScaleFactor = 1.0;
586  
587    //get pile-up event weight
588 <  double scaleFactor = 1.00;
494 <  if(doPileupReweighting_ && datasetType_ != "data")
495 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
588 >  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
589  
590 +  stopCTauScaleFactor_ = 1.0;
591 +  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
592 +    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
593 +  masterScaleFactor *= stopCTauScaleFactor_;
594  
595    //loop over all channels
596  
# Line 512 | Line 609 | OSUAnalysis::analyze (const edm::Event &
609  
610      //loop over all cuts
611  
515
516
612      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
613        cut currentCut = currentChannel.cuts.at(currentCutIndex);
614  
# Line 532 | Line 627 | OSUAnalysis::analyze (const edm::Event &
627  
628  
629          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
630 +
631          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
632 +
633 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
634 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
635          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
636          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
637          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 544 | Line 643 | OSUAnalysis::analyze (const edm::Event &
643          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
644          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
645          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
646 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
647 +
648  
649  
650          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
651                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
652                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
653                                                                     "muon-muon pairs");
654 +
655 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
656 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
657 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
658 +                                                                   "muon-secondary muon pairs");
659 +
660 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
661 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
662 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
663 +                                                                   "electron-secondary electron pairs");
664 +
665          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
666                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
667                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 558 | Line 670 | OSUAnalysis::analyze (const edm::Event &
670                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
671                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
672                                                                         "electron-muon pairs");
673 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
674 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
675 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
676 <                                                                     "track-event pairs");
677 <        
673 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
674 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
675 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
676 >                                                                           "jet-jet pairs");
677 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
678 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
679 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
680 >                                                                       "electron-jet pairs");
681 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
682 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
683 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
684 >                                                                       "muon-jet pairs");
685 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
686 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
687 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
688 >                                                                     "track-event pairs");
689 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
690 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
691 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
692 >                                                                        "electron-track pairs");
693 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
694 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
695 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
696 >                                                                    "muon-track pairs");
697 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
698 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
699 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
700 >                                                                  "muon-tau pairs");
701 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
702 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
703 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
704 >                                                                 "tau-tau pairs");
705 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
706 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
707 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
708 >                                                                 "tau-track pairs");
709 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
710 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
711 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
712 >                                                                          "electron-trigobj pairs");
713 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
714 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
715 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
716 >                                                                      "muon-trigobj pairs");
717  
718 +        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
719        }
720  
721  
# Line 579 | Line 731 | OSUAnalysis::analyze (const edm::Event &
731      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
732  
733  
582
734      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
735  
736        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 587 | Line 738 | OSUAnalysis::analyze (const edm::Event &
738        int numberPassing = 0;
739  
740        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
741 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
741 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
742        }
592
743        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
744        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
595
745        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
746  
747      }
748  
749 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
749 >    double scaleFactor = masterScaleFactor;
750  
751 +    if(applyLeptonSF_ && datasetType_ != "data"){
752 +      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
753 +        vector<bool> muonFlags;
754 +        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
755 +          if (cumulativeFlags.at("muons").at(i).size()){
756 +            muonFlags = cumulativeFlags.at("muons").at(i);
757 +            break;
758 +          }
759 +        }
760 +        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
761 +          if(!muonFlags.at(muonIndex)) continue;
762 +          scaleFactor *= muonSFWeight_->at (muons->at(muonIndex).eta);
763 +        }
764 +      }
765 +      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
766 +        vector<bool> electronFlags;
767 +        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
768 +          if (cumulativeFlags.at("electrons").at(i).size()){
769 +            electronFlags = cumulativeFlags.at("electrons").at(i);
770 +            break;
771 +          }
772 +        }
773 +        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
774 +          if(!electronFlags.at(electronIndex)) continue;
775 +          scaleFactor *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
776 +        }
777 +      }
778 +    }
779  
780 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
781  
782      if(!eventPassedAllCuts)continue;
783  
784      if (printEventInfo_) {
785 <      // Write information about event to screen, for testing purposes.  
786 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
787 <           << ": run="  << events->at(0).run
788 <           << "  lumi=" << events->at(0).lumi
789 <           << "  event=" << events->at(0).evt
790 <           << endl;  
785 >      // Write information about event to screen, for testing purposes.
786 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
787 >           << ": run="  << events->at(0).run
788 >           << "  lumi=" << events->at(0).lumi
789 >           << "  event=" << events->at(0).evt
790 >           << endl;
791      }
792  
615
616 //     if(datasetType_ != "data") {
617 //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
618 //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
619 //     }
620
793      //filling histograms
794      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
795        histogram currentHistogram = histograms.at(histogramIndex);
# Line 626 | Line 798 | OSUAnalysis::analyze (const edm::Event &
798          TH1D* histo;
799          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
800  
629
630
801          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
802 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
802 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
803 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
804 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
805          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
806                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
807                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
808 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
809 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
810 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
811          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
812          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
813                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
814                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
815 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
816 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
817 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
818 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
819 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
820 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
821          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
822 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
823 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
822 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
823 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
824 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
825 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
826 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
827 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
828 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
829 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
830 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
831 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
832 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
833 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
834 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
835 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
836 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
837 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
838 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
839 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
840 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
841 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
842 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
843 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
844 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
845 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
846 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
847 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
848 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
849 >                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
850 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
851 >
852          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
853          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
854          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 650 | Line 859 | OSUAnalysis::analyze (const edm::Event &
859          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
860          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
861          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
862 +        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
863 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
864        }
865        else if(currentHistogram.inputVariables.size() == 2){
866          TH2D* histo;
867          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
868  
658
659
869          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
870          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
871 +        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
872          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
873                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
874                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
875 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
876 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
877 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
878          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
879 +        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
880          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
881                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
882                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
883 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
884 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \
885 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
886 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
887 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
888 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
889          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
890 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
891 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
890 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
891 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
892 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
893 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
894 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
895 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
896 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
897 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
898 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
899 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
900 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
901 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
902 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
903 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
904 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
905 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
906 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
907 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
908 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
909 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
910 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
911 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
912 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
913 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
914 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
915 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
916 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
917 >                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
918 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
919          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
920          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
921          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
922          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
923 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
924 <                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
925 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
923 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
924 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
925 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);
926          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
927          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
928          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
929          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
930          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
931          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
932 +        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
933 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
934        }
935      }
936  
937 +
938 +
939      //fills histograms with the sizes of collections
940      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
941  
942        string currentObject = objectsToPlot.at(currentObjectIndex);
943  
944 <      string objectToPlot = "";  
944 >      string objectToPlot = "";
945  
946 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
947 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
948 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
949 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
950 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
946 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
947 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
948 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
949 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
950 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
951 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
952 >      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
953 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
954 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
955 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
956 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
957 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
958 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
959 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
960 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
961 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
962 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
963 >      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
964 >      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
965        else objectToPlot = currentObject;
966 +
967        string tempCurrentObject = objectToPlot;
968 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  // Capitalize the first letter.  
968 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
969        string histoName = "num" + tempCurrentObject;
970  
705
971        //set position of primary vertex in event, in order to calculate quantities relative to it
972 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
972 >      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
973          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
974          int numToPlot = 0;
975          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
# Line 716 | Line 981 | OSUAnalysis::analyze (const edm::Event &
981          }
982          else {
983            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
984 <        }
984 >        }
985        }
986        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
987        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
988 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
989        else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
990 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
991        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
992 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
993        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
994 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
995        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
996 +      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
997 +      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
998 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
999 +      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1000 +      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1001        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1002        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1003        else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
# Line 733 | Line 1007 | OSUAnalysis::analyze (const edm::Event &
1007        else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1008        else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1009        else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1010 +      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1011        else if(objectToPlot == "primaryvertexs"){
1012          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1013          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1014 <      }
1014 >      }
1015 >      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
1016  
1017 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1017 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1018  
1019    } //end loop over channel
1020  
1021 <  masterCutFlow_->fillCutFlow(scaleFactor);
1021 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1022  
1023   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1024  
# Line 759 | Line 1035 | OSUAnalysis::evaluateComparison (double
1035    else if(comparison == "==") return testValue == cutValue;
1036    else if(comparison == "=") return testValue == cutValue;
1037    else if(comparison == "!=") return testValue != cutValue;
1038 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1038 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1039 >
1040 > }
1041 >
1042 > bool
1043 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1044 >
1045 >
1046 >  if(comparison == ">")       return testValue >  cutValue;
1047 >  else if(comparison == ">=") return testValue >= cutValue;
1048 >  else if(comparison == "<")  return testValue <  cutValue;
1049 >  else if(comparison == "<=") return testValue <= cutValue;
1050 >  else if(comparison == "==") return testValue == cutValue;
1051 >  else if(comparison == "=") return testValue == cutValue;
1052 >  else if(comparison == "!=") return testValue != cutValue;
1053 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1054  
1055   }
1056  
# Line 773 | Line 1064 | OSUAnalysis::evaluateTriggers (vector<st
1064        if(trigger->pass != 1) continue;
1065        for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1066          {
1067 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
1067 >          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1068              triggerDecision = true;
1069            }
1070          }
# Line 782 | Line 1073 | OSUAnalysis::evaluateTriggers (vector<st
1073  
1074   }
1075  
1076 < std::vector<std::string>
1076 > vector<string>
1077   OSUAnalysis::splitString (string inputString){
1078  
1079 <  std::stringstream stringStream(inputString);
1080 <  std::istream_iterator<std::string> begin(stringStream);
1081 <  std::istream_iterator<std::string> end;
1082 <  std::vector<std::string> stringVector(begin, end);
1079 >  stringstream stringStream(inputString);
1080 >  istream_iterator<string> begin(stringStream);
1081 >  istream_iterator<string> end;
1082 >  vector<string> stringVector(begin, end);
1083    return stringVector;
1084  
1085   }
1086  
1087 +
1088 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1089 +  // Set two object strings from the tempInputCollection string,
1090 +  // For example, if tempInputCollection is "electron-muon pairs",
1091 +  // then obj1 = "electrons" and obj2 = "muons".
1092 +  // Note that the objects have an "s" appended.
1093 +
1094 +  int dashIndex = tempInputCollection.find("-");
1095 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1096 +  int secondWordLength = spaceIndex - dashIndex;
1097 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1098 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1099 +
1100 + }
1101 +
1102 +
1103 + string OSUAnalysis::getObjToGet(string obj) {
1104 +  // Return the string corresponding to the object to get for the given obj string.
1105 +  // Right now this only handles the case in which obj contains "secondary",
1106 +  // e.g, "secondary muons".
1107 +  // Note that "s" is NOT appended.
1108 +
1109 +  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1110 +  int firstSpaceIndex = obj.find_first_of(" ");
1111 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1112 +
1113 + }
1114 +
1115 +
1116 + //!jet valueLookup
1117   double
1118 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1118 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1119  
1120    double value = 0.0;
1121    if(variable == "energy") value = object->energy;
# Line 914 | Line 1235 | OSUAnalysis::valueLookup (const BNjet* o
1235    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1236  
1237  
1238 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1238 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1239  
1240    value = applyFunction(function, value);
1241  
# Line 922 | Line 1243 | OSUAnalysis::valueLookup (const BNjet* o
1243   }
1244  
1245  
1246 <
1246 > //!muon valueLookup
1247   double
1248 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1248 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1249  
1250    double value = 0.0;
1251    if(variable == "energy") value = object->energy;
# Line 1088 | Line 1409 | OSUAnalysis::valueLookup (const BNmuon*
1409      const BNmet *met = chosenMET ();
1410      if (met)
1411        {
1412 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1413 <                       p2 (met->px, met->py, 0.0, met->pt);
1093 <
1094 <        value = (p1 + p2).Mt ();
1412 >        double dPhi = deltaPhi (object->phi, met->phi);
1413 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1414        }
1415      else
1416        value = -999;
# Line 1209 | Line 1528 | OSUAnalysis::valueLookup (const BNmuon*
1528      value = object->isGlobalMuon > 0                \
1529        && object->isPFMuon > 0                        \
1530        && object->normalizedChi2 < 10                \
1531 <      && object->numberOfValidMuonHits > 0        \
1531 >                                  && object->numberOfValidMuonHits > 0        \
1532        && object->numberOfMatchedStations > 1        \
1533        && fabs(object->correctedD0Vertex) < 0.2        \
1534        && fabs(object->correctedDZ) < 0.5        \
# Line 1219 | Line 1538 | OSUAnalysis::valueLookup (const BNmuon*
1538    else if(variable == "tightIDdisplaced"){
1539      value = object->isGlobalMuon > 0                \
1540        && object->normalizedChi2 < 10                \
1541 <      && object->numberOfValidMuonHits > 0        \
1541 >                                  && object->numberOfValidMuonHits > 0        \
1542        && object->numberOfMatchedStations > 1        \
1543        && object->numberOfValidPixelHits > 0        \
1544        && object->numberOfLayersWithMeasurement > 5;
1545    }
1546  
1547 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1547 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1548  
1549    else if(variable == "genMatchedPdgId"){
1550      int index = getGenMatchedParticleIndex(object);
# Line 1246 | Line 1565 | OSUAnalysis::valueLookup (const BNmuon*
1565    else if(variable == "genMatchedMotherIdReverse"){
1566      int index = getGenMatchedParticleIndex(object);
1567      if(index == -1) value = 23;
1568 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1568 >    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1569    }
1570    else if(variable == "genMatchedGrandmotherId"){
1571      int index = getGenMatchedParticleIndex(object);
# Line 1258 | Line 1577 | OSUAnalysis::valueLookup (const BNmuon*
1577      }
1578      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1579    }
1580 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1581 +    int index = getGenMatchedParticleIndex(object);
1582 +    if(index == -1) value = 23;
1583 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1584 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1585 +      if(motherIndex == -1) value = 23;
1586 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1587 +    }
1588 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1589 +  }
1590  
1591  
1592  
1593 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1593 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1594  
1595    value = applyFunction(function, value);
1596  
1597    return value;
1598   }
1599  
1600 <
1600 > //!electron valueLookup
1601   double
1602 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1602 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1603  
1604    double value = 0.0;
1605    if(variable == "energy") value = object->energy;
# Line 1439 | Line 1768 | OSUAnalysis::valueLookup (const BNelectr
1768      const BNmet *met = chosenMET ();
1769      if (met)
1770        {
1771 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1772 <                       p2 (met->px, met->py, 0.0, met->pt);
1444 <
1445 <        value = (p1 + p2).Mt ();
1771 >        double dPhi = deltaPhi (object->phi, met->phi);
1772 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1773        }
1774      else
1775        value = -999;
# Line 1607 | Line 1934 | OSUAnalysis::valueLookup (const BNelectr
1934    }
1935  
1936  
1937 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1937 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1938  
1939    else if(variable == "genMatchedPdgId"){
1940      int index = getGenMatchedParticleIndex(object);
# Line 1641 | Line 1968 | OSUAnalysis::valueLookup (const BNelectr
1968      }
1969      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1970    }
1971 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1972 +    int index = getGenMatchedParticleIndex(object);
1973 +    if(index == -1) value = 23;
1974 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1975 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1976 +      if(motherIndex == -1) value = 23;
1977 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1978 +    }
1979 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1980 +  }
1981  
1982  
1983  
1984 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1984 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1985  
1986    value = applyFunction(function, value);
1987  
1988    return value;
1989   }
1990  
1991 <
1991 > //!event valueLookup
1992   double
1993 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1993 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
1994  
1995    double value = 0.0;
1996  
# Line 1728 | Line 2065 | OSUAnalysis::valueLookup (const BNevent*
2065        value = 1.0;
2066    }
2067    else if(variable == "muonScaleFactor"){
2068 <    if(datasetType_ != "data")
2069 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1733 <    value = 1.0;
2068 >    if(datasetType_ != "data" && applyLeptonSF_ && chosenMuon ())
2069 >      value = muonSFWeight_->at (chosenMuon ()->eta);
2070      else
2071        value = 1.0;
2072    }
2073    else if(variable == "electronScaleFactor"){
2074 <    if(datasetType_ != "data")
2075 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1740 <    value = 1.0;
2074 >    if(datasetType_ != "data" && applyLeptonSF_ && chosenElectron ())
2075 >      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
2076      else
2077        value = 1.0;
2078    }
2079 +  else if(variable == "stopCTauScaleFactor")
2080 +    value = stopCTauScaleFactor_;
2081  
2082 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2082 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2083  
2084    value = applyFunction(function, value);
2085  
2086    return value;
2087   }
2088  
2089 + //!tau valueLookup
2090   double
2091 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2091 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2092  
2093    double value = 0.0;
2094  
# Line 1796 | Line 2134 | OSUAnalysis::valueLookup (const BNtau* o
2134  
2135  
2136  
2137 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2137 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2138  
2139    else if(variable == "genMatchedPdgId"){
2140      int index = getGenMatchedParticleIndex(object);
# Line 1829 | Line 2167 | OSUAnalysis::valueLookup (const BNtau* o
2167      }
2168      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2169    }
2170 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2171 +    int index = getGenMatchedParticleIndex(object);
2172 +    if(index == -1) value = 23;
2173 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2174 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2175 +      if(motherIndex == -1) value = 23;
2176 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2177 +    }
2178 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2179 +  }
2180  
2181  
2182 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2182 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2183  
2184    value = applyFunction(function, value);
2185  
2186    return value;
2187   }
2188  
2189 + //!met valueLookup
2190   double
2191 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2191 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2192  
2193    double value = 0.0;
2194  
# Line 1903 | Line 2252 | OSUAnalysis::valueLookup (const BNmet* o
2252    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2253    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2254  
2255 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2255 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2256  
2257    value = applyFunction(function, value);
2258  
2259    return value;
2260   }
2261  
2262 + //!track valueLookup
2263   double
2264 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2264 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2265  
2266    double value = 0.0;
2267    double pMag = sqrt(object->pt * object->pt +
2268 <                     object->pz * object->pz);
2269 <  
2268 >                     object->pz * object->pz);
2269 >
2270    if(variable == "pt") value = object->pt;
2271    else if(variable == "px") value = object->px;
2272    else if(variable == "py") value = object->py;
# Line 1937 | Line 2287 | OSUAnalysis::valueLookup (const BNtrack*
2287  
2288  
2289    //additional BNs info for disappTrks
1940  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2290    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2291    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2292    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2293    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2294    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2295    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2296 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2297    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2298    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2299    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2300 <  
2300 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2301  
2302    //user defined variables
2303    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;
2304    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2305 +  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2306    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2307    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2308 <  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2309 <  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2308 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2309 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2310    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2311    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2312    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2313    else if(variable == "ptError")                    value = object->ptError;
2314    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2315 <
2316 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2315 >  else if (variable == "d0wrtPV"){
2316 >    double vx = object->vx - chosenVertex ()->x,
2317 >      vy = object->vy - chosenVertex ()->y,
2318 >      px = object->px,
2319 >      py = object->py,
2320 >      pt = object->pt;
2321 >    value = (-vx * py + vy * px) / pt;
2322 >  }
2323 >  else if (variable == "dZwrtPV"){
2324 >    double vx = object->vx - chosenVertex ()->x,
2325 >      vy = object->vy - chosenVertex ()->y,
2326 >      vz = object->vz - chosenVertex ()->z,
2327 >      px = object->px,
2328 >      py = object->py,
2329 >      pz = object->pz,
2330 >      pt = object->pt;
2331 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2332 >  }
2333 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2334  
2335    else if(variable == "genMatchedPdgId"){
2336      int index = getGenMatchedParticleIndex(object);
# Line 1996 | Line 2364 | OSUAnalysis::valueLookup (const BNtrack*
2364      }
2365      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2366    }
2367 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2368 +    int index = getGenMatchedParticleIndex(object);
2369 +    if(index == -1) value = 23;
2370 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2371 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2372 +      if(motherIndex == -1) value = 23;
2373 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2374 +    }
2375 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2376 +  }
2377  
2378  
2379  
2380 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2380 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2381  
2382    value = applyFunction(function, value);
2383  
2384    return value;
2385   }
2386  
2387 + //!genjet valueLookup
2388   double
2389 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2389 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2390  
2391    double value = 0.0;
2392  
# Line 2027 | Line 2406 | OSUAnalysis::valueLookup (const BNgenjet
2406    else if(variable == "charge") value = object->charge;
2407  
2408  
2409 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2409 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2410  
2411    value = applyFunction(function, value);
2412  
2413    return value;
2414   }
2415  
2416 + //!mcparticle valueLookup
2417   double
2418 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2418 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2419  
2420    double value = 0.0;
2421  
# Line 2160 | Line 2540 | OSUAnalysis::valueLookup (const BNmcpart
2540    }
2541  
2542  
2543 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2543 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2544  
2545    value = applyFunction(function, value);
2546  
2547    return value;
2548   }
2549  
2550 + //!primaryvertex valueLookup
2551   double
2552 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2552 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2553  
2554    double value = 0.0;
2555  
# Line 2187 | Line 2568 | OSUAnalysis::valueLookup (const BNprimar
2568    else if(variable == "isGood") value = object->isGood;
2569  
2570  
2571 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2571 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2572  
2573    value = applyFunction(function, value);
2574  
2575    return value;
2576   }
2577  
2578 + //!bxlumi valueLookup
2579   double
2580 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2580 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2581  
2582    double value = 0.0;
2583  
# Line 2204 | Line 2586 | OSUAnalysis::valueLookup (const BNbxlumi
2586    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2587  
2588  
2589 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2589 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2590  
2591    value = applyFunction(function, value);
2592  
2593    return value;
2594   }
2595  
2596 + //!photon valueLookup
2597   double
2598 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2598 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2599  
2600    double value = 0.0;
2601  
# Line 2287 | Line 2670 | OSUAnalysis::valueLookup (const BNphoton
2670    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2671  
2672  
2290
2673  
2674 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2674 >
2675 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2676  
2677    else if(variable == "genMatchedPdgId"){
2678      int index = getGenMatchedParticleIndex(object);
# Line 2324 | Line 2707 | OSUAnalysis::valueLookup (const BNphoton
2707      }
2708      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2709    }
2710 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2711 +    int index = getGenMatchedParticleIndex(object);
2712 +    if(index == -1) value = 23;
2713 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2714 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2715 +      if(motherIndex == -1) value = 23;
2716 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2717 +    }
2718 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2719 +  }
2720  
2721  
2722 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2722 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2723  
2724    value = applyFunction(function, value);
2725  
2726    return value;
2727   }
2728  
2729 + //!supercluster valueLookup
2730   double
2731 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2731 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2732  
2733    double value = 0.0;
2734  
# Line 2348 | Line 2742 | OSUAnalysis::valueLookup (const BNsuperc
2742    else if(variable == "theta") value = object->theta;
2743  
2744  
2745 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2745 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2746  
2747    value = applyFunction(function, value);
2748  
2749    return value;
2750   }
2751  
2752 + //!trigobj valueLookup
2753 + double
2754 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2755 +
2756 +  double value = 0.0;
2757 +
2758 +  if(variable == "pt") value = object->pt;
2759 +  else if(variable == "eta") value = object->eta;
2760 +  else if(variable == "phi") value = object->phi;
2761 +  else if(variable == "px") value = object->px;
2762 +  else if(variable == "py") value = object->py;
2763 +  else if(variable == "pz") value = object->pz;
2764 +  else if(variable == "et") value = object->et;
2765 +  else if(variable == "energy") value = object->energy;
2766 +  else if(variable == "etTotal") value = object->etTotal;
2767 +  else if(variable == "id") value = object->id;
2768 +  else if(variable == "charge") value = object->charge;
2769 +  else if(variable == "isIsolated") value = object->isIsolated;
2770 +  else if(variable == "isMip") value = object->isMip;
2771 +  else if(variable == "isForward") value = object->isForward;
2772 +  else if(variable == "isRPC") value = object->isRPC;
2773 +  else if(variable == "bx") value = object->bx;
2774 +  else if(variable == "filter") {
2775 +    if ((stringValue = object->filter) == "")
2776 +      stringValue = "none";  // stringValue should only be empty if value is filled
2777 +  }
2778 +
2779 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2780  
2781 +  value = applyFunction(function, value);
2782 +
2783 +  return value;
2784 + }
2785 +
2786 + //!muon-muon pair valueLookup
2787   double
2788 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2788 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2789  
2790    double value = 0.0;
2791  
2792    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2793 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2794    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2795    else if(variable == "invMass"){
2796      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2403 | Line 2832 | OSUAnalysis::valueLookup (const BNmuon*
2832    else if(variable == "muon2CorrectedD0Vertex"){
2833      value = object2->correctedD0Vertex;
2834    }
2835 < else if(variable == "muon1timeAtIpInOut"){
2835 >  else if(variable == "muon1timeAtIpInOut"){
2836      value = object1->timeAtIpInOut;
2837    }
2838 < else if(variable == "muon2timeAtIpInOut"){
2838 >  else if(variable == "muon2timeAtIpInOut"){
2839      value = object2->timeAtIpInOut;
2840    }
2841 < else if(variable == "muon1correctedD0")
2842 <   {
2843 <     value = object1->correctedD0;
2844 <   }
2845 < else if(variable == "muon2correctedD0")
2846 <   {
2847 <     value = object2->correctedD0;
2848 <   }
2841 >  else if(variable == "muon1correctedD0")
2842 >    {
2843 >      value = object1->correctedD0;
2844 >    }
2845 >  else if(variable == "muon2correctedD0")
2846 >    {
2847 >      value = object2->correctedD0;
2848 >    }
2849  
2850 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2850 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2851  
2852    value = applyFunction(function, value);
2853  
2854    return value;
2855   }
2856  
2857 + //!electron-electron pair valueLookup
2858   double
2859 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2859 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
2860  
2861    double value = 0.0;
2862  
2863    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2864 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2865    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2866    else if(variable == "invMass"){
2867      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2472 | Line 2903 | OSUAnalysis::valueLookup (const BNelectr
2903      value = object2->correctedD0;
2904    }
2905  
2906 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2906 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2907  
2908    value = applyFunction(function, value);
2909  
2910    return value;
2911   }
2912 <
2912 > //!electron-muon pair valueLookup
2913   double
2914 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2914 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2915  
2916    double value = 0.0;
2917  
2918    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2919 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2920    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2921    else if(variable == "invMass"){
2922      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2531 | Line 2963 | OSUAnalysis::valueLookup (const BNelectr
2963    else if(variable == "muonDetIso"){
2964      value = (object2->trackIsoDR03) / object2->pt;
2965    }
2966 +  else if(variable == "electronRelPFrhoIso"){
2967 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2968 +  }
2969 +  else if(variable == "muonRelPFdBetaIso"){
2970 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2971 +  }
2972 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2973 +  value = applyFunction(function, value);
2974 +
2975 +  return value;
2976 + }
2977 +
2978 + //!electron-jet pair valueLookup
2979 + double
2980 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
2981 +
2982 +  double value = 0.0;
2983 +
2984 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2985 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2986 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2987 +  else if(variable == "invMass"){
2988 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2989 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2990 +    value = (fourVector1 + fourVector2).M();
2991 +  }
2992 +  else if(variable == "pt"){
2993 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2994 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2995 +    value = (fourVector1 + fourVector2).Pt();
2996 +  }
2997 +  else if(variable == "threeDAngle")
2998 +    {
2999 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3000 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3001 +      value = (threeVector1.Angle(threeVector2));
3002 +    }
3003 +  else if(variable == "chargeProduct"){
3004 +    value = object1->charge*object2->charge;
3005 +  }
3006  
3007 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3008 +  value = applyFunction(function, value);
3009 +
3010 +  return value;
3011 + }
3012 +
3013 + //!muon-jet pair valueLookup
3014 + double
3015 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3016 +
3017 +  double value = 0.0;
3018 +
3019 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3020 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3021 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3022 +  else if(variable == "invMass"){
3023 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3024 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3025 +    value = (fourVector1 + fourVector2).M();
3026 +  }
3027 +  else if(variable == "pt"){
3028 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3029 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3030 +    value = (fourVector1 + fourVector2).Pt();
3031 +  }
3032 +  else if(variable == "threeDAngle")
3033 +    {
3034 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3035 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3036 +      value = (threeVector1.Angle(threeVector2));
3037 +    }
3038 +  else if(variable == "chargeProduct"){
3039 +    value = object1->charge*object2->charge;
3040 +  }
3041 +
3042 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3043 +  value = applyFunction(function, value);
3044 +
3045 +  return value;
3046 + }
3047 +
3048 + //!jet-jet pair valueLookup
3049 + double
3050 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3051 +
3052 +  double value = 0.0;
3053 +
3054 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3055 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3056 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3057 +  else if(variable == "invMass"){
3058 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3059 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3060 +    value = (fourVector1 + fourVector2).M();
3061 +  }
3062 +  else if(variable == "pt"){
3063 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3064 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3065 +    value = (fourVector1 + fourVector2).Pt();
3066 +  }
3067 +  else if(variable == "threeDAngle")
3068 +    {
3069 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3070 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3071 +      value = (threeVector1.Angle(threeVector2));
3072 +    }
3073 +  else if(variable == "chargeProduct"){
3074 +    value = object1->charge*object2->charge;
3075 +  }
3076 +
3077 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3078 +  value = applyFunction(function, value);
3079 +
3080 +  return value;
3081 + }
3082 + //!electron-track pair valueLookup
3083 + double
3084 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3085 +  double electronMass = 0.000511;
3086 +  double value = 0.0;
3087 +  TLorentzVector fourVector1(0, 0, 0, 0);
3088 +  TLorentzVector fourVector2(0, 0, 0, 0);
3089 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3090 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3091 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3092 +  else if(variable == "invMass"){        
3093 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3094 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3095 +        
3096 +    value = (fourVector1 + fourVector2).M();    
3097 +  }
3098 +  else if(variable == "chargeProduct"){
3099 +    value = object1->charge*object2->charge;
3100 +  }
3101 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3102 +  value = applyFunction(function, value);        
3103 +  return value;  
3104 +
3105 + }
3106 +
3107 +
3108 + //!muon-track pair valueLookup
3109 + double
3110 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3111 +  double pionMass = 0.140;
3112 +  double muonMass = 0.106;
3113 +  double value = 0.0;
3114 +  TLorentzVector fourVector1(0, 0, 0, 0);
3115 +  TLorentzVector fourVector2(0, 0, 0, 0);
3116 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3117 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3118 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3119 +  else if(variable == "invMass"){
3120 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
3121 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
3122 +
3123 +    value = (fourVector1 + fourVector2).M();
3124 +  }
3125 +  else if(variable == "chargeProduct"){
3126 +    value = object1->charge*object2->charge;
3127 +  }
3128  
3129    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3130 +  value = applyFunction(function, value);
3131 +  return value;
3132 + }
3133 +
3134 + //!tau-tau pair valueLookup
3135 + double
3136 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3137 +  double value = 0.0;
3138 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3139 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3140 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3141 +  else if(variable == "invMass"){
3142 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3143 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3144 +    value = (fourVector1 + fourVector2).M();
3145 +  }
3146  
3147 +  else if(variable == "chargeProduct"){
3148 +    value = object1->charge*object2->charge;
3149 +  }
3150 +
3151 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3152    value = applyFunction(function, value);
3153 +  return value;
3154 + }
3155 +
3156 + //!muon-tau pair valueLookup
3157 + double
3158 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3159 +  double value = 0.0;
3160 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3161 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3162 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3163 +  else if(variable == "invMass"){
3164 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3165 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3166 +    value = (fourVector1 + fourVector2).M();
3167 +  }
3168 +
3169 +  else if(variable == "chargeProduct"){
3170 +    value = object1->charge*object2->charge;
3171 +  }
3172  
3173 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3174 +  value = applyFunction(function, value);
3175    return value;
3176   }
3177  
3178 + //!tau-track pair valueLookup
3179 + double
3180 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3181 +  double value = 0.0;
3182 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3183 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3184 +  else if(variable == "chargeProduct"){
3185 +    value = object1->charge*object2->charge;
3186 +  }
3187  
3188 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3189 +  value = applyFunction(function, value);
3190 +  return value;
3191 + }
3192  
3193  
3194 + //!track-event pair valueLookup
3195   double
3196 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3196 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3197  
3198    double value = 0.0;
3199    double pMag = sqrt(object1->pt * object1->pt +
3200 <                     object1->pz * object1->pz);  
3200 >                     object1->pz * object1->pz);
3201  
3202    if      (variable == "numPV")                      value = object2->numPV;
3203    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3204    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3205 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3206 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3205 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3206 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3207  
3208 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3208 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3209  
3210    value = applyFunction(function, value);
3211  
3212    return value;
3213  
3214 < }  
3214 > }
3215 >
3216 > //!electron-trigobj pair valueLookup
3217 > double
3218 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3219 >
3220 >  double value = 0.0;
3221 >
3222 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3223 >  else if (variable == "match"){
3224 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3225 >      stringValue = object2->filter;
3226 >    else
3227 >      stringValue = "none";
3228 >  }
3229 >
3230 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3231 >
3232 >  value = applyFunction(function, value);
3233 >
3234 >  return value;
3235 >
3236 > }
3237 >
3238 > //!muon-trigobj pair valueLookup
3239 > double
3240 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3241 >
3242 >  double value = 0.0;
3243 >
3244 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3245 >
3246 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3247 >
3248 >  value = applyFunction(function, value);
3249 >
3250 >  return value;
3251 >
3252 > }
3253 >
3254 > //!stop valueLookup
3255 > double
3256 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3257 >
3258 >
3259 >  double value = 0.0;
3260 >
3261 >  if(variable == "ctau") value = object->ctau;
3262 >
3263 >  else if (variable == "d0"){
3264 >    double vx = object->vx - chosenVertex ()->x,
3265 >      vy = object->vy - chosenVertex ()->y,
3266 >      px = object->px,
3267 >      py = object->py,
3268 >      pt = object->pt;
3269 >    value = (-vx * py + vy * px) / pt;
3270 >  }
3271 >
3272 >  else if (variable == "dz"){
3273 >    double vx = object->vx - chosenVertex ()->x,
3274 >      vy = object->vy - chosenVertex ()->y,
3275 >      vz = object->vz - chosenVertex ()->z,
3276 >      px = object->px,
3277 >      py = object->py,
3278 >      pz = object->pz,
3279 >      pt = object->pt;
3280 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3281 >  }
3282 >
3283 >  else if (variable == "minD0"){
3284 >    double minD0=999;
3285 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3286 >      double vx = object->vx - vertex->x,
3287 >        vy = object->vy - vertex->y,
3288 >        px = object->px,
3289 >        py = object->py,
3290 >        pt = object->pt;
3291 >      value = (-vx * py + vy * px) / pt;
3292 >      if(abs(value) < abs(minD0)) minD0 = value;
3293 >    }
3294 >    value = minD0;
3295 >  }
3296 >  else if (variable == "minDz"){
3297 >    double minDz=999;
3298 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3299 >      double vx = object->vx - vertex->x,
3300 >        vy = object->vy - vertex->y,
3301 >        vz = object->vz - vertex->z,
3302 >        px = object->px,
3303 >        py = object->py,
3304 >        pz = object->pz,
3305 >        pt = object->pt;
3306 >      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3307 >      if(abs(value) < abs(minDz)) minDz = value;
3308 >    }
3309 >    value = minDz;
3310 >  }
3311 >  else if(variable == "distToVertex"){
3312 >    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3313 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3314 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3315 >  }
3316 >  else if (variable == "minDistToVertex"){
3317 >    double minDistToVertex=999;
3318 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3319 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3320 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3321 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3322 >
3323 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3324 >    }
3325 >    value = minDistToVertex;
3326 >  }
3327 >  else if (variable == "distToVertexDifference"){
3328 >    double minDistToVertex=999;
3329 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3330 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3331 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3332 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3333 >
3334 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3335 >    }
3336 >    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3337 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3338 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3339 >
3340 >    value = distToChosenVertex - minDistToVertex;
3341 >  }
3342 >
3343 >  else if (variable == "closestVertexRank"){
3344 >    double minDistToVertex=999;
3345 >    int vertex_rank = 0;
3346 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3347 >      vertex_rank++;
3348 >      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3349 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3350 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3351 >
3352 >      if(abs(dist) < abs(minDistToVertex)){
3353 >        value = vertex_rank;
3354 >        minDistToVertex = dist;
3355 >      }
3356 >    }
3357 >  }
3358 >
3359 >
3360 >
3361 >
3362 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3363 >
3364 >  value = applyFunction(function, value);
3365 >
3366 >  return value;
3367 >
3368 > }
3369 >
3370 >
3371 >
3372  
3373   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3374   // Return true iff no other tracks are found in this cone.
# Line 2611 | Line 3417 | OSUAnalysis::getTrkPtTrue (const BNtrack
3417  
3418   double
3419   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3420 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3421 <  if (!useTrackCaloRhoCorr_) return -99;  
3422 <  // if (!rhokt6CaloJetsHandle_) {
3423 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3424 <  //   return -99;  
3420 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3421 >  if (!useTrackCaloRhoCorr_) return -99;
3422 >  // if (!rhokt6CaloJetsHandle_) {
3423 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3424 >  //   return -99;
3425    // }
3426 <  double radDeltaRCone = 0.5;  
3427 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3428 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3429 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3430 <  return caloTotRhoCorrCalo;  
3431 <
3426 >  double radDeltaRCone = 0.5;
3427 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3428 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3429 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3430 >  return caloTotRhoCorrCalo;
3431 >
3432   }
3433  
3434  
# Line 2660 | Line 3466 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3466    double deltaRLowest = 999;
3467    int value = 0;
3468    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3469 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3469 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3470      double eta = ecal->etaEcal;
3471      double phi = ecal->phiEcal;
3472 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3472 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3473      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3474    }
3475    if (deltaRLowest<0.05) {value = 1;}
# Line 2671 | Line 3477 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3477    return value;
3478   }
3479  
3480 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3480 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3481   template <class InputObject>
3482   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3483    double genDeltaRLowest = 999.;
3484    for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3485      double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3486      if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3487 < }
3487 >  }
3488    return genDeltaRLowest;
3489   }
3490  
# Line 2691 | Line 3497 | OSUAnalysis::applyFunction(string functi
3497    else if(function == "log") value = log10(value);
3498  
3499    else if(function == "") value = value;
3500 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3500 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3501  
3502    return value;
3503  
# Line 2701 | Line 3507 | OSUAnalysis::applyFunction(string functi
3507   template <class InputCollection>
3508   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3509  
3510 +  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3511 +    string obj1, obj2;
3512 +    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3513 +    if (inputType==obj1 ||
3514 +          inputType==obj2) {
3515 +      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3516 +      // and the inputType is a member of the pair.
3517 +      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3518 +      // For example, if currentCut.inputCollection==electron-muon pairs,
3519 +      // then the flags should not be set here when inputType==muons or inputType==electrons.
3520 +      return;
3521 +    }
3522 +  }
3523  
3524    for (uint object = 0; object != inputCollection->size(); object++){
3525  
2707
3526      bool decision = true;//object passes if this cut doesn't cut on that type of object
3527  
2710
3528      if(currentCut.inputCollection == inputType){
3529  
3530        vector<bool> subcutDecisions;
3531        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3532 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3533 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3532 >        string stringValue = "";
3533 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3534 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3535 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3536 >
3537        }
3538        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3539        else{
# Line 2727 | Line 3547 | void OSUAnalysis::setObjectFlags(cut &cu
3547          decision = tempDecision;
3548        }
3549      }
2730    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3550  
3551 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3552  
3553      //set flags for objects that pass each cut AND all the previous cuts
3554      bool previousCumulativeFlag = true;
# Line 2738 | Line 3558 | void OSUAnalysis::setObjectFlags(cut &cu
3558      }
3559      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3560  
2741
3561    }
3562  
3563   }
# Line 2752 | Line 3571 | void OSUAnalysis::setObjectFlags(cut &cu
3571    bool sameObjects = false;
3572    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3573  
3574 +  // Get the strings for the two objects that make up the pair.
3575 +  string obj1Type, obj2Type;
3576 +  getTwoObjs(inputType, obj1Type, obj2Type);
3577 +  bool isTwoTypesOfObject = true;
3578 +  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3579 +
3580 +  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3581 +  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3582 +  if (currentCut.inputCollection == inputType) {
3583 +    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3584 +      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3585 +      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3586 +    }
3587 +    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3588 +      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3589 +        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3590 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3591 +      }
3592 +    }
3593 +  }
3594  
3595    int counter = 0;
3596 +
3597    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3598      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3599  
# Line 2766 | Line 3606 | void OSUAnalysis::setObjectFlags(cut &cu
3606  
3607          vector<bool> subcutDecisions;
3608          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3609 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3610 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3609 >          string stringValue = "";
3610 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3611 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3612 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3613          }
3614  
3615          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 2782 | Line 3624 | void OSUAnalysis::setObjectFlags(cut &cu
3624            decision = tempDecision;
3625          }
3626        }
3627 +      // if (decision) isPassObj1.at(object1) = true;
3628 +      // if (decision) isPassObj2.at(object2) = true;
3629        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3630 +      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3631 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3632 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3633 +      }
3634  
3635        //set flags for objects that pass each cut AND all the previous cuts
3636        bool previousCumulativeFlag = true;
# Line 2797 | Line 3645 | void OSUAnalysis::setObjectFlags(cut &cu
3645        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3646        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3647        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3648 <
3648 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3649 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3650 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3651 >      }
3652        counter++;
2802    }
3653  
3654 <  }
3654 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3655 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3656 >
3657 > }
3658  
3659  
3660 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3661 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3662 +  // all cuts up to currentCutIndex
3663 +  bool previousCumulativeFlag = true;
3664 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3665 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3666 +    else {
3667 +      previousCumulativeFlag = false; break;
3668 +    }
3669 +  }
3670 +  return previousCumulativeFlag;
3671   }
3672  
3673  
# Line 2817 | Line 3681 | void OSUAnalysis::fill1DHistogram(TH1* h
3681      string currentString = parameters.inputVariables.at(0);
3682      string inputVariable = "";
3683      string function = "";
3684 <    if(currentString.find("(")==std::string::npos){
3684 >    if(currentString.find("(")==string::npos){
3685        inputVariable = currentString;// variable to cut on
3686      }
3687      else{
# Line 2826 | Line 3690 | void OSUAnalysis::fill1DHistogram(TH1* h
3690        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3691      }
3692  
3693 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3693 >    string stringValue = "";
3694 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3695      histo->Fill(value,scaleFactor);
3696  
3697      if (printEventInfo_) {
3698 <      // Write information about event to screen, for testing purposes.  
3699 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3698 >      // Write information about event to screen, for testing purposes.
3699 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3700      }
3701 <    
3701 >
3702    }
3703   }
3704  
# Line 2843 | Line 3708 | void OSUAnalysis::fill1DHistogram(TH1* h
3708    bool sameObjects = false;
3709    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3710  
3711 <  int pairCounter = 0;
3711 >  int pairCounter = -1;
3712    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3713      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3714  
3715        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3716  
3717 +      pairCounter++;
3718        //only take objects which have passed all cuts and pairs which have passed all cuts
3719        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3720        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2857 | Line 3723 | void OSUAnalysis::fill1DHistogram(TH1* h
3723        string currentString = parameters.inputVariables.at(0);
3724        string inputVariable = "";
3725        string function = "";
3726 <      if(currentString.find("(")==std::string::npos){
3726 >      if(currentString.find("(")==string::npos){
3727          inputVariable = currentString;// variable to cut on
3728        }
3729        else{
# Line 2866 | Line 3732 | void OSUAnalysis::fill1DHistogram(TH1* h
3732          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3733        }
3734  
3735 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3735 >      string stringValue = "";
3736 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3737        histo->Fill(value,scaleFactor);
3738  
2872      pairCounter++;
3739      }
3740    }
3741  
# Line 2883 | Line 3749 | void OSUAnalysis::fill2DHistogram(TH2* h
3749  
3750      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3751  
3752 +    string stringValue = "";
3753      string currentString = parameters.inputVariables.at(0);
3754      string inputVariable = "";
3755      string function = "";
3756 <    if(currentString.find("(")==std::string::npos){
3756 >    if(currentString.find("(")==string::npos){
3757        inputVariable = currentString;// variable to cut on
3758      }
3759      else{
# Line 2894 | Line 3761 | void OSUAnalysis::fill2DHistogram(TH2* h
3761        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3762        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3763      }
3764 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3764 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3765  
3766      currentString = parameters.inputVariables.at(1);
3767      inputVariable = "";
3768      function = "";
3769 <    if(currentString.find("(")==std::string::npos){
3769 >    if(currentString.find("(")==string::npos){
3770        inputVariable = currentString;// variable to cut on
3771      }
3772      else{
# Line 2908 | Line 3775 | void OSUAnalysis::fill2DHistogram(TH2* h
3775        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3776      }
3777  
3778 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3778 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3779  
3780      histo->Fill(valueX,valueY,scaleFactor);
3781  
# Line 2922 | Line 3789 | void OSUAnalysis::fill2DHistogram(TH2* h
3789    bool sameObjects = false;
3790    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3791  
3792 <  int pairCounter = 0;
3792 >  int pairCounter = -1;
3793    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3794      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3795  
3796        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3797  
3798 +      pairCounter++;
3799 +
3800        //only take objects which have passed all cuts and pairs which have passed all cuts
3801        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3802        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3803        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3804  
3805 +      string stringValue = "";
3806        string currentString = parameters.inputVariables.at(0);
3807        string inputVariable = "";
3808        string function = "";
3809 <      if(currentString.find("(")==std::string::npos){
3809 >      if(currentString.find("(")==string::npos){
3810          inputVariable = currentString;// variable to cut on
3811        }
3812        else{
# Line 2944 | Line 3814 | void OSUAnalysis::fill2DHistogram(TH2* h
3814          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3815          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3816        }
3817 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3817 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3818  
3819        currentString = parameters.inputVariables.at(1);
3820        inputVariable = "";
3821        function = "";
3822 <      if(currentString.find("(")==std::string::npos){
3822 >      if(currentString.find("(")==string::npos){
3823          inputVariable = currentString;// variable to cut on
3824        }
3825        else{
# Line 2957 | Line 3827 | void OSUAnalysis::fill2DHistogram(TH2* h
3827          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3828          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3829        }
3830 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3830 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3831  
3832  
3833        histo->Fill(valueX,valueY,scaleFactor);
3834  
2965      pairCounter++;
2966
3835      }
3836    }
3837  
# Line 2980 | Line 3848 | int OSUAnalysis::getGenMatchedParticleIn
3848  
3849      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3850      if(currentDeltaR > 0.05) continue;
3851 < //     cout << std::setprecision(3) << std::setw(20)
3852 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3853 < //          << std::setw(20)
3854 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3855 < //          << std::setw(20)
3856 < //          << "\tdeltaR = " << currentDeltaR
3857 < //          << std::setprecision(1)
3858 < //          << std::setw(20)
3859 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3860 < //          << std::setw(20)
3861 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3862 < //          << std::setw(20)
3863 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3851 >    //     cout << setprecision(3) << setw(20)
3852 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3853 >    //          << setw(20)
3854 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3855 >    //          << setw(20)
3856 >    //          << "\tdeltaR = " << currentDeltaR
3857 >    //          << setprecision(1)
3858 >    //          << setw(20)
3859 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3860 >    //          << setw(20)
3861 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3862 >    //          << setw(20)
3863 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3864      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3865        bestMatchIndex = mcparticle - mcparticles->begin();
3866        bestMatchDeltaR = currentDeltaR;
3867      }
3868  
3869    }
3870 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3871 < //   else cout << "no match found..." << endl;
3870 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3871 >  //   else cout << "no match found..." << endl;
3872    return bestMatchIndex;
3873  
3874   }
# Line 3089 | Line 3957 | const BNprimaryvertex *
3957   OSUAnalysis::chosenVertex ()
3958   {
3959    const BNprimaryvertex *chosenVertex = 0;
3960 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3961 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3962 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3960 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
3961 >    vector<bool> vertexFlags;
3962 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3963 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
3964 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
3965 >        break;
3966 >      }
3967 >    }
3968      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3969        if(!vertexFlags.at(vertexIndex)) continue;
3970        chosenVertex = & primaryvertexs->at(vertexIndex);
3971        break;
3972      }
3973    }
3101  else {
3102    chosenVertex = &primaryvertexs->at(0);
3103  }
3974  
3975    return chosenVertex;
3976   }
# Line 3109 | Line 3979 | const BNmet *
3979   OSUAnalysis::chosenMET ()
3980   {
3981    const BNmet *chosenMET = 0;
3982 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3983 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3984 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3982 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
3983 >    vector<bool> metFlags;
3984 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
3985 >      if (cumulativeFlags.at("mets").at(i).size()){
3986 >        metFlags = cumulativeFlags.at("mets").at(i);
3987 >        break;
3988 >      }
3989 >    }
3990      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3991        if(!metFlags.at(metIndex)) continue;
3992        chosenMET = & mets->at(metIndex);
3993        break;
3994      }
3995    }
3121  else {
3122    chosenMET = &mets->at(0);
3123  }
3996  
3997    return chosenMET;
3998   }
# Line 3129 | Line 4001 | const BNelectron *
4001   OSUAnalysis::chosenElectron ()
4002   {
4003    const BNelectron *chosenElectron = 0;
4004 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4005 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4006 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4004 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4005 >    vector<bool> electronFlags;
4006 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4007 >      if (cumulativeFlags.at("electrons").at(i).size()){
4008 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4009 >        break;
4010 >      }
4011 >    }
4012      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4013        if(!electronFlags.at(electronIndex)) continue;
4014        chosenElectron = & electrons->at(electronIndex);
4015        break;
4016      }
4017    }
3141  else {
3142    chosenElectron = &electrons->at(0);
3143  }
4018  
4019    return chosenElectron;
4020   }
# Line 3149 | Line 4023 | const BNmuon *
4023   OSUAnalysis::chosenMuon ()
4024   {
4025    const BNmuon *chosenMuon = 0;
4026 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4027 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4028 <                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4026 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4027 >    vector<bool> muonFlags;
4028 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4029 >      if (cumulativeFlags.at("muons").at(i).size()){
4030 >        muonFlags = cumulativeFlags.at("muons").at(i);
4031 >        break;
4032 >      }
4033 >    }
4034      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4035        if(!muonFlags.at(muonIndex)) continue;
4036        chosenMuon = & muons->at(muonIndex);
4037        break;
4038      }
4039    }
3161  else {
3162    chosenMuon = &muons->at(0);
3163  }
4040  
4041    return chosenMuon;
4042   }
4043  
3168
4044   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines