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.63 by ahart, Tue May 14 19:35:16 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 <    int maxNum = 24;
173 >
174 >    int maxNum = 25;
175      vector<double> binVector;
176      binVector.push_back(maxNum);
177      binVector.push_back(0);
# 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        QCD string
309 >      // 24        other
310  
311        vector<TString> labelArray;
312        labelArray.push_back("unmatched");
# Line 275 | Line 332 | OSUAnalysis::OSUAnalysis (const edm::Par
332        labelArray.push_back("strange baryon");
333        labelArray.push_back("charm baryon");
334        labelArray.push_back("bottom baryon");
335 +      labelArray.push_back("QCD string");
336        labelArray.push_back("other");
337  
338        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
339 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
340 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
341 <        }
342 <        else {
343 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
344 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
345 <        }
339 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
340 >          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
341 >        }
342 >        else {
343 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
344 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
345 >        }
346        }
347 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
348 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
349 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
347 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
348 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
349 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
350        }
351  
352      }
353  
354 <    // Book a histogram for the number of each object type to be plotted.  
355 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
354 >    // Book a histogram for the number of each object type to be plotted.
355 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
356      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
357        string currentObject = objectsToPlot.at(currentObjectIndex);
358        int maxNum = 10;
359        if(currentObject == "mcparticles") maxNum = 50;
360        else if(currentObject == "primaryvertexs") maxNum = 50;
361 <      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
362 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
363 <      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
364 <      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
361 >
362 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
363 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
364 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
365 >      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
366 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
367 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
368 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
369 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
370 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
371 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
372 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
373 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
374 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
375 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
376 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
377 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
378 >      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
379 >      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
380  
381        currentObject.at(0) = toupper(currentObject.at(0));
382        string histoName = "num" + currentObject;
# Line 329 | Line 402 | OSUAnalysis::OSUAnalysis (const edm::Par
402        cut tempCut;
403        //store input collection for cut
404        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
405 +      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
406 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
407 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
408 +      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
409 +      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
410 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
411 +      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
412 +      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
413        tempCut.inputCollection = tempInputCollection;
414 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
415 <        objectsToGet.push_back(tempInputCollection);
414 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
415 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
416 >          int spaceIndex = tempInputCollection.find(" ");
417 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
418 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
419 >        }
420 >        else{
421 >          objectsToGet.push_back(tempInputCollection);
422 >        }
423          objectsToCut.push_back(tempInputCollection);
424        }
425 <      else{//pair of objects, need to add them both to the things to objectsToGet
426 <        int dashIndex = tempInputCollection.find("-");
427 <        int spaceIndex = tempInputCollection.find(" ");
428 <        int secondWordLength = spaceIndex - dashIndex;
429 <        objectsToGet.push_back(tempInputCollection);
342 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
343 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
425 >      else{//pair of objects, need to add them both to objectsToGet
426 >        string obj1;
427 >        string obj2;
428 >        getTwoObjs(tempInputCollection, obj1, obj2);
429 >        string obj2ToGet = getObjToGet(obj2);
430          objectsToCut.push_back(tempInputCollection);
431 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
432 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
431 >        objectsToCut.push_back(obj1);
432 >        objectsToCut.push_back(obj2);
433 >        objectsToGet.push_back(tempInputCollection);
434 >        objectsToGet.push_back(obj1);
435 >        objectsToGet.push_back(obj2ToGet);
436  
437        }
438  
# Line 351 | Line 440 | OSUAnalysis::OSUAnalysis (const edm::Par
440  
441        //split cut string into parts and store them
442        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
443 <      std::vector<string> cutStringVector = splitString(cutString);
443 >      vector<string> cutStringVector = splitString(cutString);
444        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
445 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
445 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
446          exit(0);
447        }
448        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
449        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
450          int indexOffset = 4 * subcutIndex;
451          string currentVariableString = cutStringVector.at(indexOffset);
452 <        if(currentVariableString.find("(")==std::string::npos){
452 >        if(currentVariableString.find("(")==string::npos){
453            tempCut.functions.push_back("");//no function was specified
454            tempCut.variables.push_back(currentVariableString);// variable to cut on
455          }
# Line 371 | Line 460 | OSUAnalysis::OSUAnalysis (const edm::Par
460          }
461          tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
462          tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
463 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
464          if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
465        }
466  
467        //get number of objects required to pass cut for event to pass
468        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
469 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
469 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
470        if(numberRequiredVector.size()!=2){
471 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
471 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
472          exit(0);
473        }
474  
# Line 400 | Line 490 | OSUAnalysis::OSUAnalysis (const edm::Par
490        }
491        tempCut.name = tempCutName;
492  
403
493        tempChannel.cuts.push_back(tempCut);
494  
495  
407
496      }//end loop over cuts
497  
498      channels.push_back(tempChannel);
# Line 438 | Line 526 | OSUAnalysis::analyze (const edm::Event &
526  
527    // Retrieve necessary collections from the event.
528  
529 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
529 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
530      event.getByLabel (triggers_, triggers);
531  
532 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
532 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
533 >    event.getByLabel (trigobjs_, trigobjs);
534 >
535 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
536      event.getByLabel (jets_, jets);
537  
538 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
538 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
539      event.getByLabel (muons_, muons);
540  
541 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
541 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
542      event.getByLabel (electrons_, electrons);
543  
544 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
544 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
545      event.getByLabel (events_, events);
546  
547 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
547 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
548      event.getByLabel (taus_, taus);
549  
550 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
550 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
551      event.getByLabel (mets_, mets);
552  
553 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
553 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
554      event.getByLabel (tracks_, tracks);
555  
556 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
556 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
557      event.getByLabel (genjets_, genjets);
558  
559 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
559 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
560      event.getByLabel (mcparticles_, mcparticles);
561  
562 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
562 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
563      event.getByLabel (primaryvertexs_, primaryvertexs);
564  
565 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
565 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
566      event.getByLabel (bxlumis_, bxlumis);
567  
568 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
568 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
569      event.getByLabel (photons_, photons);
570  
571 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
571 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
572      event.getByLabel (superclusters_, superclusters);
573  
574 <  if (useTrackCaloRhoCorr_) {  
575 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
576 <    // This rho collection is not available in all BEANs.  
574 >  if (datasetType_ == "signalMC"){
575 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
576 >      event.getByLabel (stops_, stops);
577 >  }
578 >
579 >  if (useTrackCaloRhoCorr_) {
580 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
581 >    // This rho collection is not available in all BEANs.
582      // For description of rho values for different jet reconstruction algorithms, see
583 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
584 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
583 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
584 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
585    }
586  
587 +  double masterScaleFactor = 1.0;
588  
589    //get pile-up event weight
590 <  double scaleFactor = 1.00;
494 <  if(doPileupReweighting_ && datasetType_ != "data")
495 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
590 >  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
591  
592 +  stopCTauScaleFactor_ = 1.0;
593 +  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
594 +    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
595 +  masterScaleFactor *= stopCTauScaleFactor_;
596  
597    //loop over all channels
598  
# Line 512 | Line 611 | OSUAnalysis::analyze (const edm::Event &
611  
612      //loop over all cuts
613  
515
516
614      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
615        cut currentCut = currentChannel.cuts.at(currentCutIndex);
616  
# Line 532 | Line 629 | OSUAnalysis::analyze (const edm::Event &
629  
630  
631          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
632 +
633          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
634 +
635 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
636 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
637          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
638          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
639          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 544 | Line 645 | OSUAnalysis::analyze (const edm::Event &
645          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
646          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
647          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
648 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
649 +
650  
651  
652          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
653                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
654                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
655                                                                     "muon-muon pairs");
656 +
657 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
658 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
659 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
660 +                                                                   "muon-secondary muon pairs");
661 +
662 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
663 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
664 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
665 +                                                                   "electron-secondary electron pairs");
666 +
667          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
668                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
669                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 558 | Line 672 | OSUAnalysis::analyze (const edm::Event &
672                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
673                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
674                                                                         "electron-muon pairs");
675 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
676 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
677 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
678 <                                                                     "track-event pairs");
679 <        
675 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
676 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
677 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
678 >                                                                           "jet-jet pairs");
679 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
680 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
681 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
682 >                                                                       "electron-jet pairs");
683 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
684 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
685 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
686 >                                                                       "muon-jet pairs");
687 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
688 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
689 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
690 >                                                                     "track-event pairs");
691 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
692 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
693 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
694 >                                                                        "electron-track pairs");
695 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
696 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
697 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
698 >                                                                    "muon-track pairs");
699 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
700 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
701 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
702 >                                                                  "muon-tau pairs");
703 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
704 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
705 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
706 >                                                                 "tau-tau pairs");
707 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
708 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
709 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
710 >                                                                 "tau-track pairs");
711 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
712 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
713 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
714 >                                                                          "electron-trigobj pairs");
715 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
716 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
717 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
718 >                                                                      "muon-trigobj pairs");
719  
720 +        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
721        }
722  
723  
# Line 579 | Line 733 | OSUAnalysis::analyze (const edm::Event &
733      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
734  
735  
582
736      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
737  
738        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 587 | Line 740 | OSUAnalysis::analyze (const edm::Event &
740        int numberPassing = 0;
741  
742        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
743 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
743 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
744        }
592
745        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
746        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
595
747        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
748  
749      }
750  
751 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
751 >    double scaleFactor = masterScaleFactor;
752  
753 +    muonScaleFactor_ = electronScaleFactor_ = 1.0;
754 +    if(applyLeptonSF_ && datasetType_ != "data"){
755 +      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
756 +        vector<bool> muonFlags;
757 +        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
758 +          if (cumulativeFlags.at("muons").at(i).size()){
759 +            muonFlags = cumulativeFlags.at("muons").at(i);
760 +            break;
761 +          }
762 +        }
763 +        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
764 +          if(!muonFlags.at(muonIndex)) continue;
765 +          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
766 +        }
767 +      }
768 +      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
769 +        vector<bool> electronFlags;
770 +        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
771 +          if (cumulativeFlags.at("electrons").at(i).size()){
772 +            electronFlags = cumulativeFlags.at("electrons").at(i);
773 +            break;
774 +          }
775 +        }
776 +        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
777 +          if(!electronFlags.at(electronIndex)) continue;
778 +          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
779 +        }
780 +      }
781 +    }
782 +    scaleFactor *= muonScaleFactor_;
783 +    scaleFactor *= electronScaleFactor_;
784  
785 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
786  
787      if(!eventPassedAllCuts)continue;
788  
789      if (printEventInfo_) {
790 <      // Write information about event to screen, for testing purposes.  
791 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
792 <           << ": run="  << events->at(0).run
793 <           << "  lumi=" << events->at(0).lumi
794 <           << "  event=" << events->at(0).evt
795 <           << endl;  
790 >      // Write information about event to screen, for testing purposes.
791 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
792 >           << ": run="  << events->at(0).run
793 >           << "  lumi=" << events->at(0).lumi
794 >           << "  event=" << events->at(0).evt
795 >           << endl;
796      }
797  
615
616 //     if(datasetType_ != "data") {
617 //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
618 //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
619 //     }
620
798      //filling histograms
799      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
800        histogram currentHistogram = histograms.at(histogramIndex);
# Line 626 | Line 803 | OSUAnalysis::analyze (const edm::Event &
803          TH1D* histo;
804          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
805  
629
630
806          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
807 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
807 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
808 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
809 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
810          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
811                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
812                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
813 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
814 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
815 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
816          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
817          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
818                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
819                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
820 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
821 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
822 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
823 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
824 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
825 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
826          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
827 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
828 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
827 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
828 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
829 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
830 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
831 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
832 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
833 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
834 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
835 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
836 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
837 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
838 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
839 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
840 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
841 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
842 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
843 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
844 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
845 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
846 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
847 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
848 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
849 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
850 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
851 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
852 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
853 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
854 >                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
855 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
856 >
857          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
858          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
859          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 650 | Line 864 | OSUAnalysis::analyze (const edm::Event &
864          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
865          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
866          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
867 +        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
868 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
869        }
870        else if(currentHistogram.inputVariables.size() == 2){
871          TH2D* histo;
872          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
873  
658
659
874          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
875          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
876 +        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
877          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
878                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
879                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
880 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
881 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
882 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
883          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
884 +        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
885          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
886                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
887                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
888 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
889 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \
890 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
891 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
892 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
893 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
894          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
895 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
896 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
895 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
896 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
897 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
898 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
899 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
900 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
901 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
902 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
903 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
904 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
905 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
906 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
907 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
908 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
909 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
910 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
911 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
912 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
913 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
914 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
915 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
916 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
917 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
918 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
919 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
920 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
921 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
922 >                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
923 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
924          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
925          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
926          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
927          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
928 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
929 <                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
930 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
928 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
929 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
930 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);
931          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
932          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
933          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
934          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
935          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
936          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
937 +        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
938 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
939        }
940      }
941  
942 +
943 +
944      //fills histograms with the sizes of collections
945      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
946  
947        string currentObject = objectsToPlot.at(currentObjectIndex);
948  
949 <      string objectToPlot = "";  
949 >      string objectToPlot = "";
950  
951 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
952 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
953 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
954 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
955 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
951 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
952 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
953 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
954 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
955 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
956 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
957 >      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
958 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
959 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
960 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
961 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
962 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
963 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
964 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
965 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
966 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
967 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
968 >      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
969 >      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
970        else objectToPlot = currentObject;
971 +
972        string tempCurrentObject = objectToPlot;
973 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  // Capitalize the first letter.  
973 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
974        string histoName = "num" + tempCurrentObject;
975  
705
976        //set position of primary vertex in event, in order to calculate quantities relative to it
977 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
977 >      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
978          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
979          int numToPlot = 0;
980          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
# Line 716 | Line 986 | OSUAnalysis::analyze (const edm::Event &
986          }
987          else {
988            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
989 <        }
989 >        }
990        }
991        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
992        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
993 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
994        else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
995 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
996        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
997 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
998        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
999 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1000        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1001 +      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1002 +      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1003 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1004 +      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1005 +      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1006        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1007        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1008        else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
# Line 733 | Line 1012 | OSUAnalysis::analyze (const edm::Event &
1012        else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1013        else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1014        else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1015 +      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1016        else if(objectToPlot == "primaryvertexs"){
1017          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1018          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1019 <      }
1019 >      }
1020 >      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
1021  
1022 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1022 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1023  
1024    } //end loop over channel
1025  
1026 <  masterCutFlow_->fillCutFlow(scaleFactor);
1026 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1027  
1028   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1029  
# Line 759 | Line 1040 | OSUAnalysis::evaluateComparison (double
1040    else if(comparison == "==") return testValue == cutValue;
1041    else if(comparison == "=") return testValue == cutValue;
1042    else if(comparison == "!=") return testValue != cutValue;
1043 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1043 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1044 >
1045 > }
1046 >
1047 > bool
1048 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1049 >
1050 >
1051 >  if(comparison == ">")       return testValue >  cutValue;
1052 >  else if(comparison == ">=") return testValue >= cutValue;
1053 >  else if(comparison == "<")  return testValue <  cutValue;
1054 >  else if(comparison == "<=") return testValue <= cutValue;
1055 >  else if(comparison == "==") return testValue == cutValue;
1056 >  else if(comparison == "=") return testValue == cutValue;
1057 >  else if(comparison == "!=") return testValue != cutValue;
1058 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1059  
1060   }
1061  
# Line 773 | Line 1069 | OSUAnalysis::evaluateTriggers (vector<st
1069        if(trigger->pass != 1) continue;
1070        for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1071          {
1072 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
1072 >          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1073              triggerDecision = true;
1074            }
1075          }
# Line 782 | Line 1078 | OSUAnalysis::evaluateTriggers (vector<st
1078  
1079   }
1080  
1081 < std::vector<std::string>
1081 > vector<string>
1082   OSUAnalysis::splitString (string inputString){
1083  
1084 <  std::stringstream stringStream(inputString);
1085 <  std::istream_iterator<std::string> begin(stringStream);
1086 <  std::istream_iterator<std::string> end;
1087 <  std::vector<std::string> stringVector(begin, end);
1084 >  stringstream stringStream(inputString);
1085 >  istream_iterator<string> begin(stringStream);
1086 >  istream_iterator<string> end;
1087 >  vector<string> stringVector(begin, end);
1088    return stringVector;
1089  
1090   }
1091  
1092 +
1093 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1094 +  // Set two object strings from the tempInputCollection string,
1095 +  // For example, if tempInputCollection is "electron-muon pairs",
1096 +  // then obj1 = "electrons" and obj2 = "muons".
1097 +  // Note that the objects have an "s" appended.
1098 +
1099 +  int dashIndex = tempInputCollection.find("-");
1100 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1101 +  int secondWordLength = spaceIndex - dashIndex;
1102 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1103 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1104 +
1105 + }
1106 +
1107 +
1108 + string OSUAnalysis::getObjToGet(string obj) {
1109 +  // Return the string corresponding to the object to get for the given obj string.
1110 +  // Right now this only handles the case in which obj contains "secondary",
1111 +  // e.g, "secondary muons".
1112 +  // Note that "s" is NOT appended.
1113 +
1114 +  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1115 +  int firstSpaceIndex = obj.find_first_of(" ");
1116 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1117 +
1118 + }
1119 +
1120 +
1121 + //!jet valueLookup
1122   double
1123 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1123 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1124  
1125    double value = 0.0;
1126    if(variable == "energy") value = object->energy;
# Line 914 | Line 1240 | OSUAnalysis::valueLookup (const BNjet* o
1240    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1241  
1242  
1243 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1243 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1244  
1245    value = applyFunction(function, value);
1246  
# Line 922 | Line 1248 | OSUAnalysis::valueLookup (const BNjet* o
1248   }
1249  
1250  
1251 <
1251 > //!muon valueLookup
1252   double
1253 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1253 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1254  
1255    double value = 0.0;
1256    if(variable == "energy") value = object->energy;
# Line 1085 | Line 1411 | OSUAnalysis::valueLookup (const BNmuon*
1411    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1412    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1413    else if(variable == "metMT") {
1414 <    const BNmet *met = chosenMET ();
1089 <    if (met)
1414 >    if (const BNmet *met = chosenMET ())
1415        {
1416 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1417 <                       p2 (met->px, met->py, 0.0, met->pt);
1093 <
1094 <        value = (p1 + p2).Mt ();
1416 >        double dPhi = deltaPhi (object->phi, met->phi);
1417 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1418        }
1419      else
1420        value = -999;
# Line 1209 | Line 1532 | OSUAnalysis::valueLookup (const BNmuon*
1532      value = object->isGlobalMuon > 0                \
1533        && object->isPFMuon > 0                        \
1534        && object->normalizedChi2 < 10                \
1535 <      && object->numberOfValidMuonHits > 0        \
1535 >                                  && object->numberOfValidMuonHits > 0        \
1536        && object->numberOfMatchedStations > 1        \
1537        && fabs(object->correctedD0Vertex) < 0.2        \
1538        && fabs(object->correctedDZ) < 0.5        \
# Line 1219 | Line 1542 | OSUAnalysis::valueLookup (const BNmuon*
1542    else if(variable == "tightIDdisplaced"){
1543      value = object->isGlobalMuon > 0                \
1544        && object->normalizedChi2 < 10                \
1545 <      && object->numberOfValidMuonHits > 0        \
1545 >                                  && object->numberOfValidMuonHits > 0        \
1546        && object->numberOfMatchedStations > 1        \
1547        && object->numberOfValidPixelHits > 0        \
1548        && object->numberOfLayersWithMeasurement > 5;
1549    }
1550  
1551 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1551 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1552  
1553    else if(variable == "genMatchedPdgId"){
1554      int index = getGenMatchedParticleIndex(object);
# Line 1245 | Line 1568 | OSUAnalysis::valueLookup (const BNmuon*
1568    }
1569    else if(variable == "genMatchedMotherIdReverse"){
1570      int index = getGenMatchedParticleIndex(object);
1571 <    if(index == -1) value = 23;
1572 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1571 >    if(index == -1) value = 24;
1572 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1573    }
1574    else if(variable == "genMatchedGrandmotherId"){
1575      int index = getGenMatchedParticleIndex(object);
# Line 1258 | Line 1581 | OSUAnalysis::valueLookup (const BNmuon*
1581      }
1582      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1583    }
1584 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1585 +    int index = getGenMatchedParticleIndex(object);
1586 +    if(index == -1) value = 24;
1587 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1588 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1589 +      if(motherIndex == -1) value = 24;
1590 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1591 +    }
1592 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1593 +  }
1594  
1595  
1596  
1597 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1597 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1598  
1599    value = applyFunction(function, value);
1600  
1601    return value;
1602   }
1603  
1604 <
1604 > //!electron valueLookup
1605   double
1606 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1606 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1607  
1608    double value = 0.0;
1609    if(variable == "energy") value = object->energy;
# Line 1436 | Line 1769 | OSUAnalysis::valueLookup (const BNelectr
1769    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1770    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1771    else if(variable == "metMT") {
1772 <    const BNmet *met = chosenMET ();
1440 <    if (met)
1772 >    if (const BNmet *met = chosenMET ())
1773        {
1774 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1775 <                       p2 (met->px, met->py, 0.0, met->pt);
1444 <
1445 <        value = (p1 + p2).Mt ();
1774 >        double dPhi = deltaPhi (object->phi, met->phi);
1775 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1776        }
1777      else
1778        value = -999;
# Line 1607 | Line 1937 | OSUAnalysis::valueLookup (const BNelectr
1937    }
1938  
1939  
1940 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1940 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1941  
1942    else if(variable == "genMatchedPdgId"){
1943      int index = getGenMatchedParticleIndex(object);
# Line 1628 | Line 1958 | OSUAnalysis::valueLookup (const BNelectr
1958    }
1959    else if(variable == "genMatchedMotherIdReverse"){
1960      int index = getGenMatchedParticleIndex(object);
1961 <    if(index == -1) value = 23;
1962 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1961 >    if(index == -1) value = 24;
1962 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
1963    }
1964    else if(variable == "genMatchedGrandmotherId"){
1965      int index = getGenMatchedParticleIndex(object);
# Line 1641 | Line 1971 | OSUAnalysis::valueLookup (const BNelectr
1971      }
1972      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1973    }
1974 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1975 +    int index = getGenMatchedParticleIndex(object);
1976 +    if(index == -1) value = 24;
1977 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1978 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1979 +      if(motherIndex == -1) value = 24;
1980 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1981 +    }
1982 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1983 +  }
1984  
1985  
1986  
1987 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1987 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1988  
1989    value = applyFunction(function, value);
1990  
1991    return value;
1992   }
1993  
1994 <
1994 > //!event valueLookup
1995   double
1996 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1996 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
1997  
1998    double value = 0.0;
1999  
# Line 1727 | Line 2067 | OSUAnalysis::valueLookup (const BNevent*
2067      else
2068        value = 1.0;
2069    }
2070 <  else if(variable == "muonScaleFactor"){
2071 <    if(datasetType_ != "data")
2072 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1733 <    value = 1.0;
1734 <    else
1735 <      value = 1.0;
1736 <  }
1737 <  else if(variable == "electronScaleFactor"){
1738 <    if(datasetType_ != "data")
1739 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1740 <    value = 1.0;
1741 <    else
1742 <      value = 1.0;
1743 <  }
2070 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2071 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2072 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2073  
2074 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2074 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2075  
2076    value = applyFunction(function, value);
2077  
2078    return value;
2079   }
2080  
2081 + //!tau valueLookup
2082   double
2083 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2083 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2084  
2085    double value = 0.0;
2086  
# Line 1796 | Line 2126 | OSUAnalysis::valueLookup (const BNtau* o
2126  
2127  
2128  
2129 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2129 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2130  
2131    else if(variable == "genMatchedPdgId"){
2132      int index = getGenMatchedParticleIndex(object);
# Line 1816 | Line 2146 | OSUAnalysis::valueLookup (const BNtau* o
2146    }
2147    else if(variable == "genMatchedMotherIdReverse"){
2148      int index = getGenMatchedParticleIndex(object);
2149 <    if(index == -1) value = 23;
2150 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2149 >    if(index == -1) value = 24;
2150 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2151    }
2152    else if(variable == "genMatchedGrandmotherId"){
2153      int index = getGenMatchedParticleIndex(object);
# Line 1829 | Line 2159 | OSUAnalysis::valueLookup (const BNtau* o
2159      }
2160      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2161    }
2162 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2163 +    int index = getGenMatchedParticleIndex(object);
2164 +    if(index == -1) value = 24;
2165 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2166 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2167 +      if(motherIndex == -1) value = 24;
2168 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2169 +    }
2170 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2171 +  }
2172  
2173  
2174 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2174 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2175  
2176    value = applyFunction(function, value);
2177  
2178    return value;
2179   }
2180  
2181 + //!met valueLookup
2182   double
2183 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2183 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2184  
2185    double value = 0.0;
2186  
# Line 1903 | Line 2244 | OSUAnalysis::valueLookup (const BNmet* o
2244    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2245    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2246  
2247 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2247 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2248  
2249    value = applyFunction(function, value);
2250  
2251    return value;
2252   }
2253  
2254 + //!track valueLookup
2255   double
2256 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2256 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2257  
2258    double value = 0.0;
2259    double pMag = sqrt(object->pt * object->pt +
2260 <                     object->pz * object->pz);
2261 <  
2260 >                     object->pz * object->pz);
2261 >
2262    if(variable == "pt") value = object->pt;
2263    else if(variable == "px") value = object->px;
2264    else if(variable == "py") value = object->py;
# Line 1937 | Line 2279 | OSUAnalysis::valueLookup (const BNtrack*
2279  
2280  
2281    //additional BNs info for disappTrks
1940  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2282    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2283    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2284    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2285    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2286    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2287    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2288 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2289    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2290    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2291    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2292 <  
2292 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2293  
2294    //user defined variables
2295    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;
2296    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2297 +  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2298    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2299    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2300 <  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2301 <  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2300 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2301 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2302    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2303    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2304    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2305    else if(variable == "ptError")                    value = object->ptError;
2306    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2307 <
2308 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2307 >  else if (variable == "d0wrtPV"){
2308 >    double vx = object->vx - chosenVertex ()->x,
2309 >      vy = object->vy - chosenVertex ()->y,
2310 >      px = object->px,
2311 >      py = object->py,
2312 >      pt = object->pt;
2313 >    value = (-vx * py + vy * px) / pt;
2314 >  }
2315 >  else if (variable == "dZwrtPV"){
2316 >    double vx = object->vx - chosenVertex ()->x,
2317 >      vy = object->vy - chosenVertex ()->y,
2318 >      vz = object->vz - chosenVertex ()->z,
2319 >      px = object->px,
2320 >      py = object->py,
2321 >      pz = object->pz,
2322 >      pt = object->pt;
2323 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2324 >  }
2325 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2326  
2327    else if(variable == "genMatchedPdgId"){
2328      int index = getGenMatchedParticleIndex(object);
# Line 1983 | Line 2343 | OSUAnalysis::valueLookup (const BNtrack*
2343    }
2344    else if(variable == "genMatchedMotherIdReverse"){
2345      int index = getGenMatchedParticleIndex(object);
2346 <    if(index == -1) value = 23;
2347 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2346 >    if(index == -1) value = 24;
2347 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2348    }
2349    else if(variable == "genMatchedGrandmotherId"){
2350      int index = getGenMatchedParticleIndex(object);
# Line 1996 | Line 2356 | OSUAnalysis::valueLookup (const BNtrack*
2356      }
2357      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2358    }
2359 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2360 +    int index = getGenMatchedParticleIndex(object);
2361 +    if(index == -1) value = 24;
2362 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2363 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2364 +      if(motherIndex == -1) value = 24;
2365 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2366 +    }
2367 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2368 +  }
2369  
2370  
2371  
2372 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2372 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2373  
2374    value = applyFunction(function, value);
2375  
2376    return value;
2377   }
2378  
2379 + //!genjet valueLookup
2380   double
2381 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2381 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2382  
2383    double value = 0.0;
2384  
# Line 2027 | Line 2398 | OSUAnalysis::valueLookup (const BNgenjet
2398    else if(variable == "charge") value = object->charge;
2399  
2400  
2401 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2401 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2402  
2403    value = applyFunction(function, value);
2404  
2405    return value;
2406   }
2407  
2408 + //!mcparticle valueLookup
2409   double
2410 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2410 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2411  
2412    double value = 0.0;
2413  
# Line 2160 | Line 2532 | OSUAnalysis::valueLookup (const BNmcpart
2532    }
2533  
2534  
2535 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2535 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2536  
2537    value = applyFunction(function, value);
2538  
2539    return value;
2540   }
2541  
2542 + //!primaryvertex valueLookup
2543   double
2544 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2544 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2545  
2546    double value = 0.0;
2547  
# Line 2187 | Line 2560 | OSUAnalysis::valueLookup (const BNprimar
2560    else if(variable == "isGood") value = object->isGood;
2561  
2562  
2563 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2563 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2564  
2565    value = applyFunction(function, value);
2566  
2567    return value;
2568   }
2569  
2570 + //!bxlumi valueLookup
2571   double
2572 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2572 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2573  
2574    double value = 0.0;
2575  
# Line 2204 | Line 2578 | OSUAnalysis::valueLookup (const BNbxlumi
2578    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2579  
2580  
2581 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2581 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2582  
2583    value = applyFunction(function, value);
2584  
2585    return value;
2586   }
2587  
2588 + //!photon valueLookup
2589   double
2590 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2590 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2591  
2592    double value = 0.0;
2593  
# Line 2287 | Line 2662 | OSUAnalysis::valueLookup (const BNphoton
2662    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2663  
2664  
2290
2665  
2666 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2666 >
2667 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2668  
2669    else if(variable == "genMatchedPdgId"){
2670      int index = getGenMatchedParticleIndex(object);
# Line 2311 | Line 2686 | OSUAnalysis::valueLookup (const BNphoton
2686    }
2687    else if(variable == "genMatchedMotherIdReverse"){
2688      int index = getGenMatchedParticleIndex(object);
2689 <    if(index == -1) value = 23;
2690 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2689 >    if(index == -1) value = 24;
2690 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2691    }
2692    else if(variable == "genMatchedGrandmotherId"){
2693      int index = getGenMatchedParticleIndex(object);
# Line 2324 | Line 2699 | OSUAnalysis::valueLookup (const BNphoton
2699      }
2700      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2701    }
2702 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2703 +    int index = getGenMatchedParticleIndex(object);
2704 +    if(index == -1) value = 24;
2705 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2706 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2707 +      if(motherIndex == -1) value = 24;
2708 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2709 +    }
2710 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2711 +  }
2712  
2713  
2714 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2714 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2715  
2716    value = applyFunction(function, value);
2717  
2718    return value;
2719   }
2720  
2721 + //!supercluster valueLookup
2722   double
2723 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2723 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2724  
2725    double value = 0.0;
2726  
# Line 2348 | Line 2734 | OSUAnalysis::valueLookup (const BNsuperc
2734    else if(variable == "theta") value = object->theta;
2735  
2736  
2737 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2737 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2738  
2739    value = applyFunction(function, value);
2740  
2741    return value;
2742   }
2743  
2744 + //!trigobj valueLookup
2745 + double
2746 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2747 +
2748 +  double value = 0.0;
2749 +
2750 +  if(variable == "pt") value = object->pt;
2751 +  else if(variable == "eta") value = object->eta;
2752 +  else if(variable == "phi") value = object->phi;
2753 +  else if(variable == "px") value = object->px;
2754 +  else if(variable == "py") value = object->py;
2755 +  else if(variable == "pz") value = object->pz;
2756 +  else if(variable == "et") value = object->et;
2757 +  else if(variable == "energy") value = object->energy;
2758 +  else if(variable == "etTotal") value = object->etTotal;
2759 +  else if(variable == "id") value = object->id;
2760 +  else if(variable == "charge") value = object->charge;
2761 +  else if(variable == "isIsolated") value = object->isIsolated;
2762 +  else if(variable == "isMip") value = object->isMip;
2763 +  else if(variable == "isForward") value = object->isForward;
2764 +  else if(variable == "isRPC") value = object->isRPC;
2765 +  else if(variable == "bx") value = object->bx;
2766 +  else if(variable == "filter") {
2767 +    if ((stringValue = object->filter) == "")
2768 +      stringValue = "none";  // stringValue should only be empty if value is filled
2769 +  }
2770 +
2771 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2772  
2773 +  value = applyFunction(function, value);
2774 +
2775 +  return value;
2776 + }
2777 +
2778 + //!muon-muon pair valueLookup
2779   double
2780 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2780 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2781  
2782    double value = 0.0;
2783  
2784    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2785 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2786    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2787    else if(variable == "invMass"){
2788      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2403 | Line 2824 | OSUAnalysis::valueLookup (const BNmuon*
2824    else if(variable == "muon2CorrectedD0Vertex"){
2825      value = object2->correctedD0Vertex;
2826    }
2827 < else if(variable == "muon1timeAtIpInOut"){
2827 >  else if(variable == "muon1timeAtIpInOut"){
2828      value = object1->timeAtIpInOut;
2829    }
2830 < else if(variable == "muon2timeAtIpInOut"){
2830 >  else if(variable == "muon2timeAtIpInOut"){
2831      value = object2->timeAtIpInOut;
2832    }
2833 < else if(variable == "muon1correctedD0")
2834 <   {
2835 <     value = object1->correctedD0;
2836 <   }
2837 < else if(variable == "muon2correctedD0")
2838 <   {
2839 <     value = object2->correctedD0;
2840 <   }
2833 >  else if(variable == "muon1correctedD0")
2834 >    {
2835 >      value = object1->correctedD0;
2836 >    }
2837 >  else if(variable == "muon2correctedD0")
2838 >    {
2839 >      value = object2->correctedD0;
2840 >    }
2841  
2842 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2842 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2843  
2844    value = applyFunction(function, value);
2845  
2846    return value;
2847   }
2848  
2849 + //!electron-electron pair valueLookup
2850   double
2851 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2851 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
2852  
2853    double value = 0.0;
2854  
2855    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2856 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2857    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2858    else if(variable == "invMass"){
2859      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2472 | Line 2895 | OSUAnalysis::valueLookup (const BNelectr
2895      value = object2->correctedD0;
2896    }
2897  
2898 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2898 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2899  
2900    value = applyFunction(function, value);
2901  
2902    return value;
2903   }
2904 <
2904 > //!electron-muon pair valueLookup
2905   double
2906 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2906 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2907  
2908    double value = 0.0;
2909  
2910    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2911 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2912    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2913    else if(variable == "invMass"){
2914      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2531 | Line 2955 | OSUAnalysis::valueLookup (const BNelectr
2955    else if(variable == "muonDetIso"){
2956      value = (object2->trackIsoDR03) / object2->pt;
2957    }
2958 +  else if(variable == "electronRelPFrhoIso"){
2959 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2960 +  }
2961 +  else if(variable == "muonRelPFdBetaIso"){
2962 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2963 +  }
2964 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2965 +  value = applyFunction(function, value);
2966 +
2967 +  return value;
2968 + }
2969 +
2970 + //!electron-jet pair valueLookup
2971 + double
2972 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
2973 +
2974 +  double value = 0.0;
2975 +
2976 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2977 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2978 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2979 +  else if(variable == "invMass"){
2980 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2981 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2982 +    value = (fourVector1 + fourVector2).M();
2983 +  }
2984 +  else if(variable == "pt"){
2985 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2986 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2987 +    value = (fourVector1 + fourVector2).Pt();
2988 +  }
2989 +  else if(variable == "threeDAngle")
2990 +    {
2991 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2992 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2993 +      value = (threeVector1.Angle(threeVector2));
2994 +    }
2995 +  else if(variable == "chargeProduct"){
2996 +    value = object1->charge*object2->charge;
2997 +  }
2998 +
2999 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3000 +  value = applyFunction(function, value);
3001 +
3002 +  return value;
3003 + }
3004 +
3005 + //!muon-jet pair valueLookup
3006 + double
3007 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3008 +
3009 +  double value = 0.0;
3010 +
3011 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3012 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3013 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3014 +  else if(variable == "invMass"){
3015 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3016 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3017 +    value = (fourVector1 + fourVector2).M();
3018 +  }
3019 +  else if(variable == "pt"){
3020 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3021 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3022 +    value = (fourVector1 + fourVector2).Pt();
3023 +  }
3024 +  else if(variable == "threeDAngle")
3025 +    {
3026 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3027 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3028 +      value = (threeVector1.Angle(threeVector2));
3029 +    }
3030 +  else if(variable == "chargeProduct"){
3031 +    value = object1->charge*object2->charge;
3032 +  }
3033 +
3034 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3035 +  value = applyFunction(function, value);
3036  
3037 +  return value;
3038 + }
3039 +
3040 + //!jet-jet pair valueLookup
3041 + double
3042 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3043 +
3044 +  double value = 0.0;
3045 +
3046 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3047 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3048 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3049 +  else if(variable == "invMass"){
3050 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3051 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3052 +    value = (fourVector1 + fourVector2).M();
3053 +  }
3054 +  else if(variable == "pt"){
3055 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3056 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3057 +    value = (fourVector1 + fourVector2).Pt();
3058 +  }
3059 +  else if(variable == "threeDAngle")
3060 +    {
3061 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3062 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3063 +      value = (threeVector1.Angle(threeVector2));
3064 +    }
3065 +  else if(variable == "chargeProduct"){
3066 +    value = object1->charge*object2->charge;
3067 +  }
3068 +
3069 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3070 +  value = applyFunction(function, value);
3071 +
3072 +  return value;
3073 + }
3074 + //!electron-track pair valueLookup
3075 + double
3076 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3077 +  double electronMass = 0.000511;
3078 +  double value = 0.0;
3079 +  TLorentzVector fourVector1(0, 0, 0, 0);
3080 +  TLorentzVector fourVector2(0, 0, 0, 0);
3081 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3082 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3083 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3084 +  else if(variable == "invMass"){        
3085 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3086 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3087 +        
3088 +    value = (fourVector1 + fourVector2).M();    
3089 +  }
3090 +  else if(variable == "chargeProduct"){
3091 +    value = object1->charge*object2->charge;
3092 +  }
3093 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3094 +  value = applyFunction(function, value);        
3095 +  return value;  
3096 +
3097 + }
3098 +
3099 +
3100 + //!muon-track pair valueLookup
3101 + double
3102 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3103 +  double pionMass = 0.140;
3104 +  double muonMass = 0.106;
3105 +  double value = 0.0;
3106 +  TLorentzVector fourVector1(0, 0, 0, 0);
3107 +  TLorentzVector fourVector2(0, 0, 0, 0);
3108 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3109 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3110 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3111 +  else if(variable == "invMass"){
3112 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
3113 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
3114 +
3115 +    value = (fourVector1 + fourVector2).M();
3116 +  }
3117 +  else if(variable == "chargeProduct"){
3118 +    value = object1->charge*object2->charge;
3119 +  }
3120  
3121    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3122 +  value = applyFunction(function, value);
3123 +  return value;
3124 + }
3125 +
3126 + //!tau-tau pair valueLookup
3127 + double
3128 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3129 +  double value = 0.0;
3130 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3131 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3132 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3133 +  else if(variable == "invMass"){
3134 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3135 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3136 +    value = (fourVector1 + fourVector2).M();
3137 +  }
3138  
3139 +  else if(variable == "chargeProduct"){
3140 +    value = object1->charge*object2->charge;
3141 +  }
3142 +
3143 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3144    value = applyFunction(function, value);
3145 +  return value;
3146 + }
3147 +
3148 + //!muon-tau pair valueLookup
3149 + double
3150 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3151 +  double value = 0.0;
3152 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3153 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3154 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3155 +  else if(variable == "invMass"){
3156 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3157 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3158 +    value = (fourVector1 + fourVector2).M();
3159 +  }
3160 +
3161 +  else if(variable == "chargeProduct"){
3162 +    value = object1->charge*object2->charge;
3163 +  }
3164  
3165 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3166 +  value = applyFunction(function, value);
3167    return value;
3168   }
3169  
3170 + //!tau-track pair valueLookup
3171 + double
3172 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3173 +  double value = 0.0;
3174 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3175 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3176 +  else if(variable == "chargeProduct"){
3177 +    value = object1->charge*object2->charge;
3178 +  }
3179  
3180 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3181 +  value = applyFunction(function, value);
3182 +  return value;
3183 + }
3184  
3185  
3186 + //!track-event pair valueLookup
3187   double
3188 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3188 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3189  
3190    double value = 0.0;
3191    double pMag = sqrt(object1->pt * object1->pt +
3192 <                     object1->pz * object1->pz);  
3192 >                     object1->pz * object1->pz);
3193  
3194    if      (variable == "numPV")                      value = object2->numPV;
3195    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3196    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3197 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3198 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3197 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3198 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3199  
3200 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3200 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3201  
3202    value = applyFunction(function, value);
3203  
3204    return value;
3205  
3206 < }  
3206 > }
3207 >
3208 > //!electron-trigobj pair valueLookup
3209 > double
3210 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3211 >
3212 >  double value = 0.0;
3213 >
3214 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3215 >  else if (variable == "match"){
3216 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3217 >      stringValue = object2->filter;
3218 >    else
3219 >      stringValue = "none";
3220 >  }
3221 >
3222 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3223 >
3224 >  value = applyFunction(function, value);
3225 >
3226 >  return value;
3227 >
3228 > }
3229 >
3230 > //!muon-trigobj pair valueLookup
3231 > double
3232 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3233 >
3234 >  double value = 0.0;
3235 >
3236 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3237 >
3238 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3239 >
3240 >  value = applyFunction(function, value);
3241 >
3242 >  return value;
3243 >
3244 > }
3245 >
3246 > //!stop valueLookup
3247 > double
3248 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3249 >
3250 >
3251 >  double value = 0.0;
3252 >
3253 >  if(variable == "ctau") value = object->ctau;
3254 >
3255 >  else if (variable == "d0"){
3256 >    double vx = object->vx - chosenVertex ()->x,
3257 >      vy = object->vy - chosenVertex ()->y,
3258 >      px = object->px,
3259 >      py = object->py,
3260 >      pt = object->pt;
3261 >    value = (-vx * py + vy * px) / pt;
3262 >  }
3263 >
3264 >  else if (variable == "dz"){
3265 >    double vx = object->vx - chosenVertex ()->x,
3266 >      vy = object->vy - chosenVertex ()->y,
3267 >      vz = object->vz - chosenVertex ()->z,
3268 >      px = object->px,
3269 >      py = object->py,
3270 >      pz = object->pz,
3271 >      pt = object->pt;
3272 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3273 >  }
3274 >
3275 >  else if (variable == "minD0"){
3276 >    double minD0=999;
3277 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3278 >      double vx = object->vx - vertex->x,
3279 >        vy = object->vy - vertex->y,
3280 >        px = object->px,
3281 >        py = object->py,
3282 >        pt = object->pt;
3283 >      value = (-vx * py + vy * px) / pt;
3284 >      if(abs(value) < abs(minD0)) minD0 = value;
3285 >    }
3286 >    value = minD0;
3287 >  }
3288 >  else if (variable == "minDz"){
3289 >    double minDz=999;
3290 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3291 >      double vx = object->vx - vertex->x,
3292 >        vy = object->vy - vertex->y,
3293 >        vz = object->vz - vertex->z,
3294 >        px = object->px,
3295 >        py = object->py,
3296 >        pz = object->pz,
3297 >        pt = object->pt;
3298 >      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3299 >      if(abs(value) < abs(minDz)) minDz = value;
3300 >    }
3301 >    value = minDz;
3302 >  }
3303 >  else if(variable == "distToVertex"){
3304 >    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3305 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3306 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3307 >  }
3308 >  else if (variable == "minDistToVertex"){
3309 >    double minDistToVertex=999;
3310 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3311 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3312 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3313 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3314 >
3315 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3316 >    }
3317 >    value = minDistToVertex;
3318 >  }
3319 >  else if (variable == "distToVertexDifference"){
3320 >    double minDistToVertex=999;
3321 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3322 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3323 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3324 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3325 >
3326 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3327 >    }
3328 >    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3329 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3330 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3331 >
3332 >    value = distToChosenVertex - minDistToVertex;
3333 >  }
3334 >
3335 >  else if (variable == "closestVertexRank"){
3336 >    double minDistToVertex=999;
3337 >    int vertex_rank = 0;
3338 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3339 >      vertex_rank++;
3340 >      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3341 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3342 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3343 >
3344 >      if(abs(dist) < abs(minDistToVertex)){
3345 >        value = vertex_rank;
3346 >        minDistToVertex = dist;
3347 >      }
3348 >    }
3349 >  }
3350 >
3351 >
3352 >
3353 >
3354 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3355 >
3356 >  value = applyFunction(function, value);
3357 >
3358 >  return value;
3359 >
3360 > }
3361 >
3362 >
3363 >
3364  
3365   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3366   // Return true iff no other tracks are found in this cone.
# Line 2611 | Line 3409 | OSUAnalysis::getTrkPtTrue (const BNtrack
3409  
3410   double
3411   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3412 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3413 <  if (!useTrackCaloRhoCorr_) return -99;  
3414 <  // if (!rhokt6CaloJetsHandle_) {
3415 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3416 <  //   return -99;  
3412 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3413 >  if (!useTrackCaloRhoCorr_) return -99;
3414 >  // if (!rhokt6CaloJetsHandle_) {
3415 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3416 >  //   return -99;
3417    // }
3418 <  double radDeltaRCone = 0.5;  
3419 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3420 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3421 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3422 <  return caloTotRhoCorrCalo;  
3423 <
3418 >  double radDeltaRCone = 0.5;
3419 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3420 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3421 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3422 >  return caloTotRhoCorrCalo;
3423 >
3424   }
3425  
3426  
# Line 2660 | Line 3458 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3458    double deltaRLowest = 999;
3459    int value = 0;
3460    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3461 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3461 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3462      double eta = ecal->etaEcal;
3463      double phi = ecal->phiEcal;
3464 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3464 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3465      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3466    }
3467    if (deltaRLowest<0.05) {value = 1;}
# Line 2671 | Line 3469 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3469    return value;
3470   }
3471  
3472 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3472 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3473   template <class InputObject>
3474   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3475    double genDeltaRLowest = 999.;
3476    for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3477      double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3478      if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3479 < }
3479 >  }
3480    return genDeltaRLowest;
3481   }
3482  
# Line 2691 | Line 3489 | OSUAnalysis::applyFunction(string functi
3489    else if(function == "log") value = log10(value);
3490  
3491    else if(function == "") value = value;
3492 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3492 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3493  
3494    return value;
3495  
# Line 2701 | Line 3499 | OSUAnalysis::applyFunction(string functi
3499   template <class InputCollection>
3500   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3501  
3502 +  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3503 +    string obj1, obj2;
3504 +    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3505 +    if (inputType==obj1 ||
3506 +          inputType==obj2) {
3507 +      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3508 +      // and the inputType is a member of the pair.
3509 +      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3510 +      // For example, if currentCut.inputCollection==electron-muon pairs,
3511 +      // then the flags should not be set here when inputType==muons or inputType==electrons.
3512 +      return;
3513 +    }
3514 +  }
3515  
3516    for (uint object = 0; object != inputCollection->size(); object++){
3517  
2707
3518      bool decision = true;//object passes if this cut doesn't cut on that type of object
3519  
2710
3520      if(currentCut.inputCollection == inputType){
3521  
3522        vector<bool> subcutDecisions;
3523        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3524 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3525 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3524 >        string stringValue = "";
3525 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3526 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3527 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3528 >
3529        }
3530        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3531        else{
# Line 2727 | Line 3539 | void OSUAnalysis::setObjectFlags(cut &cu
3539          decision = tempDecision;
3540        }
3541      }
2730    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3542  
3543 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3544  
3545      //set flags for objects that pass each cut AND all the previous cuts
3546      bool previousCumulativeFlag = true;
# Line 2738 | Line 3550 | void OSUAnalysis::setObjectFlags(cut &cu
3550      }
3551      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3552  
2741
3553    }
3554  
3555   }
# Line 2752 | Line 3563 | void OSUAnalysis::setObjectFlags(cut &cu
3563    bool sameObjects = false;
3564    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3565  
3566 +  // Get the strings for the two objects that make up the pair.
3567 +  string obj1Type, obj2Type;
3568 +  getTwoObjs(inputType, obj1Type, obj2Type);
3569 +  bool isTwoTypesOfObject = true;
3570 +  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3571 +
3572 +  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3573 +  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3574 +  if (currentCut.inputCollection == inputType) {
3575 +    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3576 +      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3577 +      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3578 +    }
3579 +    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3580 +      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3581 +        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3582 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3583 +      }
3584 +    }
3585 +  }
3586  
3587    int counter = 0;
3588 +
3589    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3590      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3591  
# Line 2766 | Line 3598 | void OSUAnalysis::setObjectFlags(cut &cu
3598  
3599          vector<bool> subcutDecisions;
3600          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3601 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3602 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3601 >          string stringValue = "";
3602 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3603 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3604 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3605          }
3606  
3607          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 2782 | Line 3616 | void OSUAnalysis::setObjectFlags(cut &cu
3616            decision = tempDecision;
3617          }
3618        }
3619 +      // if (decision) isPassObj1.at(object1) = true;
3620 +      // if (decision) isPassObj2.at(object2) = true;
3621        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3622 +      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3623 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3624 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3625 +      }
3626  
3627        //set flags for objects that pass each cut AND all the previous cuts
3628        bool previousCumulativeFlag = true;
# Line 2797 | Line 3637 | void OSUAnalysis::setObjectFlags(cut &cu
3637        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3638        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3639        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3640 <
3640 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3641 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3642 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3643 >      }
3644        counter++;
2802    }
3645  
3646 <  }
3646 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3647 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3648 >
3649 > }
3650  
3651  
3652 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3653 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3654 +  // all cuts up to currentCutIndex
3655 +  bool previousCumulativeFlag = true;
3656 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3657 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3658 +    else {
3659 +      previousCumulativeFlag = false; break;
3660 +    }
3661 +  }
3662 +  return previousCumulativeFlag;
3663   }
3664  
3665  
# Line 2817 | Line 3673 | void OSUAnalysis::fill1DHistogram(TH1* h
3673      string currentString = parameters.inputVariables.at(0);
3674      string inputVariable = "";
3675      string function = "";
3676 <    if(currentString.find("(")==std::string::npos){
3676 >    if(currentString.find("(")==string::npos){
3677        inputVariable = currentString;// variable to cut on
3678      }
3679      else{
# Line 2826 | Line 3682 | void OSUAnalysis::fill1DHistogram(TH1* h
3682        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3683      }
3684  
3685 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3685 >    string stringValue = "";
3686 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3687      histo->Fill(value,scaleFactor);
3688  
3689      if (printEventInfo_) {
3690 <      // Write information about event to screen, for testing purposes.  
3691 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3690 >      // Write information about event to screen, for testing purposes.
3691 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3692      }
3693 <    
3693 >
3694    }
3695   }
3696  
# Line 2843 | Line 3700 | void OSUAnalysis::fill1DHistogram(TH1* h
3700    bool sameObjects = false;
3701    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3702  
3703 <  int pairCounter = 0;
3703 >  int pairCounter = -1;
3704    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3705      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3706  
3707        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3708  
3709 +      pairCounter++;
3710        //only take objects which have passed all cuts and pairs which have passed all cuts
3711        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3712        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2857 | Line 3715 | void OSUAnalysis::fill1DHistogram(TH1* h
3715        string currentString = parameters.inputVariables.at(0);
3716        string inputVariable = "";
3717        string function = "";
3718 <      if(currentString.find("(")==std::string::npos){
3718 >      if(currentString.find("(")==string::npos){
3719          inputVariable = currentString;// variable to cut on
3720        }
3721        else{
# Line 2866 | Line 3724 | void OSUAnalysis::fill1DHistogram(TH1* h
3724          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3725        }
3726  
3727 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3727 >      string stringValue = "";
3728 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3729        histo->Fill(value,scaleFactor);
3730  
2872      pairCounter++;
3731      }
3732    }
3733  
# Line 2883 | Line 3741 | void OSUAnalysis::fill2DHistogram(TH2* h
3741  
3742      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3743  
3744 +    string stringValue = "";
3745      string currentString = parameters.inputVariables.at(0);
3746      string inputVariable = "";
3747      string function = "";
3748 <    if(currentString.find("(")==std::string::npos){
3748 >    if(currentString.find("(")==string::npos){
3749        inputVariable = currentString;// variable to cut on
3750      }
3751      else{
# Line 2894 | Line 3753 | void OSUAnalysis::fill2DHistogram(TH2* h
3753        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3754        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3755      }
3756 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3756 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3757  
3758      currentString = parameters.inputVariables.at(1);
3759      inputVariable = "";
3760      function = "";
3761 <    if(currentString.find("(")==std::string::npos){
3761 >    if(currentString.find("(")==string::npos){
3762        inputVariable = currentString;// variable to cut on
3763      }
3764      else{
# Line 2908 | Line 3767 | void OSUAnalysis::fill2DHistogram(TH2* h
3767        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3768      }
3769  
3770 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3770 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3771  
3772      histo->Fill(valueX,valueY,scaleFactor);
3773  
# Line 2922 | Line 3781 | void OSUAnalysis::fill2DHistogram(TH2* h
3781    bool sameObjects = false;
3782    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3783  
3784 <  int pairCounter = 0;
3784 >  int pairCounter = -1;
3785    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3786      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3787  
3788        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3789  
3790 +      pairCounter++;
3791 +
3792        //only take objects which have passed all cuts and pairs which have passed all cuts
3793        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3794        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3795        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3796  
3797 +      string stringValue = "";
3798        string currentString = parameters.inputVariables.at(0);
3799        string inputVariable = "";
3800        string function = "";
3801 <      if(currentString.find("(")==std::string::npos){
3801 >      if(currentString.find("(")==string::npos){
3802          inputVariable = currentString;// variable to cut on
3803        }
3804        else{
# Line 2944 | Line 3806 | void OSUAnalysis::fill2DHistogram(TH2* h
3806          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3807          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3808        }
3809 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3809 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3810  
3811        currentString = parameters.inputVariables.at(1);
3812        inputVariable = "";
3813        function = "";
3814 <      if(currentString.find("(")==std::string::npos){
3814 >      if(currentString.find("(")==string::npos){
3815          inputVariable = currentString;// variable to cut on
3816        }
3817        else{
# Line 2957 | Line 3819 | void OSUAnalysis::fill2DHistogram(TH2* h
3819          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3820          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3821        }
3822 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3822 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3823  
3824  
3825        histo->Fill(valueX,valueY,scaleFactor);
3826  
2965      pairCounter++;
2966
3827      }
3828    }
3829  
# Line 2980 | Line 3840 | int OSUAnalysis::getGenMatchedParticleIn
3840  
3841      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3842      if(currentDeltaR > 0.05) continue;
3843 < //     cout << std::setprecision(3) << std::setw(20)
3844 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3845 < //          << std::setw(20)
3846 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3847 < //          << std::setw(20)
3848 < //          << "\tdeltaR = " << currentDeltaR
3849 < //          << std::setprecision(1)
3850 < //          << std::setw(20)
3851 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3852 < //          << std::setw(20)
3853 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3854 < //          << std::setw(20)
3855 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3843 >    //     cout << setprecision(3) << setw(20)
3844 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3845 >    //          << setw(20)
3846 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3847 >    //          << setw(20)
3848 >    //          << "\tdeltaR = " << currentDeltaR
3849 >    //          << setprecision(1)
3850 >    //          << setw(20)
3851 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3852 >    //          << setw(20)
3853 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3854 >    //          << setw(20)
3855 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3856      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3857        bestMatchIndex = mcparticle - mcparticles->begin();
3858        bestMatchDeltaR = currentDeltaR;
3859      }
3860  
3861    }
3862 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3863 < //   else cout << "no match found..." << endl;
3862 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3863 >  //   else cout << "no match found..." << endl;
3864    return bestMatchIndex;
3865  
3866   }
# Line 3054 | Line 3914 | int OSUAnalysis::findTauMotherIndex(cons
3914   // 20        strange baryon
3915   // 21        charm baryon
3916   // 22        bottom baryon
3917 < // 23        other
3917 > // 23        QCD string
3918 > // 24        other
3919  
3920   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3921  
# Line 3078 | Line 3939 | int OSUAnalysis::getPdgIdBinValue(int pd
3939    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3940    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3941    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3942 +  else if(absPdgId == 92  ) binValue = 23;
3943  
3944 <  else binValue = 23;
3944 >  else binValue = 24;
3945  
3946    return binValue;
3947  
# Line 3089 | Line 3951 | const BNprimaryvertex *
3951   OSUAnalysis::chosenVertex ()
3952   {
3953    const BNprimaryvertex *chosenVertex = 0;
3954 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3955 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3956 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3954 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
3955 >    vector<bool> vertexFlags;
3956 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3957 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
3958 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
3959 >        break;
3960 >      }
3961 >    }
3962      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3963        if(!vertexFlags.at(vertexIndex)) continue;
3964        chosenVertex = & primaryvertexs->at(vertexIndex);
3965        break;
3966      }
3967    }
3968 <  else {
3969 <    chosenVertex = &primaryvertexs->at(0);
3103 <  }
3968 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
3969 >    chosenVertex = & primaryvertexs->at (0);
3970  
3971    return chosenVertex;
3972   }
# Line 3109 | Line 3975 | const BNmet *
3975   OSUAnalysis::chosenMET ()
3976   {
3977    const BNmet *chosenMET = 0;
3978 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3979 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3980 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3978 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
3979 >    vector<bool> metFlags;
3980 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
3981 >      if (cumulativeFlags.at("mets").at(i).size()){
3982 >        metFlags = cumulativeFlags.at("mets").at(i);
3983 >        break;
3984 >      }
3985 >    }
3986      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3987        if(!metFlags.at(metIndex)) continue;
3988        chosenMET = & mets->at(metIndex);
3989        break;
3990      }
3991    }
3992 <  else {
3993 <    chosenMET = &mets->at(0);
3123 <  }
3992 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
3993 >    chosenMET = & mets->at (0);
3994  
3995    return chosenMET;
3996   }
# Line 3129 | Line 3999 | const BNelectron *
3999   OSUAnalysis::chosenElectron ()
4000   {
4001    const BNelectron *chosenElectron = 0;
4002 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4003 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4004 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4002 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4003 >    vector<bool> electronFlags;
4004 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4005 >      if (cumulativeFlags.at("electrons").at(i).size()){
4006 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4007 >        break;
4008 >      }
4009 >    }
4010      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4011        if(!electronFlags.at(electronIndex)) continue;
4012        chosenElectron = & electrons->at(electronIndex);
4013        break;
4014      }
4015    }
4016 <  else {
4017 <    chosenElectron = &electrons->at(0);
3143 <  }
4016 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4017 >    chosenElectron = & electrons->at (0);
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    }
4040 <  else {
4041 <    chosenMuon = &muons->at(0);
3163 <  }
4040 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4041 >    chosenMuon = & muons->at (0);
4042  
4043    return chosenMuon;
4044   }
4045  
3168
4046   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines