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.31 by ahart, Mon Mar 18 10:21:44 2013 UTC vs.
Revision 1.54 by ahart, Wed May 1 19:49:01 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")),
# Line 27 | Line 28 | OSUAnalysis::OSUAnalysis (const edm::Par
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31 <  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting"))
31 >  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
33 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
34 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
35 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
36 >
37   {
38  
39    TH1::SetDefaultSumw2 ();
# Line 35 | Line 41 | OSUAnalysis::OSUAnalysis (const edm::Par
41    //create pile-up reweighting object, if necessary
42    if(datasetType_ != "data") {
43      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
44 <    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
45 <    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
44 >    if (applyLeptonSF_){
45 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
46 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
47 >    }
48    }
49 + #ifdef DISPLACED_SUSY
50 +  if (datasetType_ == "signalMC")
51 +    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
52 + #endif
53 +
54  
55    // Construct Cutflow Objects. These store the results of cut decisions and
56    // handle filling cut flow histograms.
# Line 47 | Line 60 | OSUAnalysis::OSUAnalysis (const edm::Par
60    //always get vertex collection so we can assign the primary vertex in the event
61    objectsToGet.push_back("primaryvertexs");
62  
63 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
63 >  //always make the plot of number of primary vertices (to check pile-up reweighting)
64    objectsToPlot.push_back("primaryvertexs");
65  
66    //always get the MC particles to do GEN-matching
# Line 61 | Line 74 | OSUAnalysis::OSUAnalysis (const edm::Par
74  
75      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
76      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
77 +    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
78 +    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
79 +    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
80 +    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
81 +    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
82      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
83 <      objectsToGet.push_back(tempInputCollection);
83 >      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
84 >        int spaceIndex = tempInputCollection.find(" ");
85 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
86 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
87 >      }
88 >      else{
89 >        objectsToGet.push_back(tempInputCollection);
90 >      }
91        objectsToPlot.push_back(tempInputCollection);
92        objectsToCut.push_back(tempInputCollection);
93      }
94 <    else{//pair of objects, need to add them both to the things to objectsToGet
95 <      int dashIndex = tempInputCollection.find("-");
96 <      int spaceIndex = tempInputCollection.find(" ");
97 <      int secondWordLength = spaceIndex - dashIndex;
98 <      objectsToGet.push_back(tempInputCollection);
74 <      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
75 <      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
76 <      objectsToPlot.push_back(tempInputCollection);
77 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
78 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
94 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
95 >      string obj1;
96 >      string obj2;
97 >      getTwoObjs(tempInputCollection, obj1, obj2);
98 >      string obj2ToGet = getObjToGet(obj2);  
99        objectsToCut.push_back(tempInputCollection);
100 <      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
101 <      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
100 >      objectsToCut.push_back(obj1);
101 >      objectsToCut.push_back(obj2);  
102 >      objectsToPlot.push_back(tempInputCollection);
103 >      objectsToPlot.push_back(obj1);
104 >      objectsToPlot.push_back(obj2);  
105 >      objectsToGet.push_back(tempInputCollection);
106 >      objectsToGet.push_back(obj1);
107 >      objectsToGet.push_back(obj2ToGet);
108  
109 <      }
109 >    }
110  
111      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
112  
# Line 107 | Line 133 | OSUAnalysis::OSUAnalysis (const edm::Par
133    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
134  
135      string currentObject = objectsToPlot.at(currentObjectIndex);
136 <    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
136 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
137  
138      histogram tempIdHisto;
139      histogram tempMomIdHisto;
140      histogram tempGmaIdHisto;
141 +    histogram tempIdVsMomIdHisto;
142 +    histogram tempIdVsGmaIdHisto;
143  
144      tempIdHisto.inputCollection = currentObject;
145      tempMomIdHisto.inputCollection = currentObject;
146      tempGmaIdHisto.inputCollection = currentObject;
147 +    tempIdVsMomIdHisto.inputCollection = currentObject;
148 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
149 +
150 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
151 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
152  
153      currentObject = currentObject.substr(0, currentObject.size()-1);
154      tempIdHisto.name = currentObject+"GenMatchId";
155      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
156      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
157 +    tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
158 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
159  
160      currentObject.at(0) = toupper(currentObject.at(0));
161      tempIdHisto.title = currentObject+" Gen-matched Particle";
162      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
163      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
164 +    tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
165 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
166 +
167  
168      int maxNum = 24;
169      vector<double> binVector;
# Line 139 | Line 177 | OSUAnalysis::OSUAnalysis (const edm::Par
177      tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
178      tempGmaIdHisto.bins = binVector;
179      tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
180 +    binVector.push_back(maxNum);
181 +    binVector.push_back(0);
182 +    binVector.push_back(maxNum);
183 +    tempIdVsMomIdHisto.bins = binVector;
184 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
185 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
186 +    tempIdVsGmaIdHisto.bins = binVector;
187 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
188 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
189  
190      histograms.push_back(tempIdHisto);
191      histograms.push_back(tempMomIdHisto);
192      histograms.push_back(tempGmaIdHisto);
193 <
193 >    histograms.push_back(tempIdVsMomIdHisto);
194 >    histograms.push_back(tempIdVsGmaIdHisto);
195    }
196  
197  
150
198    channel tempChannel;
199    //loop over all channels (event selections)
200    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
# Line 184 | Line 231 | OSUAnalysis::OSUAnalysis (const edm::Par
231      twoDHists_.push_back(twoDhistoMap);
232  
233  
234 +
235      //book all histograms included in the configuration
236      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
237        histogram currentHistogram = histograms.at(currentHistogramIndex);
# Line 209 | Line 257 | OSUAnalysis::OSUAnalysis (const edm::Par
257  
258        if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
259  
260 < // bin      particle type
261 < // ---      -------------
262 < //  0        unmatched
263 < //  1        u
264 < //  2        d
265 < //  3        s
266 < //  4        c
267 < //  5        b
268 < //  6        t
269 < //  7        e
270 < //  8        mu
271 < //  9        tau
272 < // 10        nu
273 < // 11        g
274 < // 12        gamma
275 < // 13        Z
276 < // 14        W
277 < // 15        light meson
278 < // 16        K meson
279 < // 17        D meson
280 < // 18        B meson
281 < // 19        light baryon
282 < // 20        strange baryon
283 < // 21        charm baryon
284 < // 22        bottom baryon
285 < // 23        other
260 >      // bin      particle type
261 >      // ---      -------------
262 >      //  0        unmatched
263 >      //  1        u
264 >      //  2        d
265 >      //  3        s
266 >      //  4        c
267 >      //  5        b
268 >      //  6        t
269 >      //  7        e
270 >      //  8        mu
271 >      //  9        tau
272 >      // 10        nu
273 >      // 11        g
274 >      // 12        gamma
275 >      // 13        Z
276 >      // 14        W
277 >      // 15        light meson
278 >      // 16        K meson
279 >      // 17        D meson
280 >      // 18        B meson
281 >      // 19        light baryon
282 >      // 20        strange baryon
283 >      // 21        charm baryon
284 >      // 22        bottom baryon
285 >      // 23        other
286  
287        vector<TString> labelArray;
288        labelArray.push_back("unmatched");
# Line 263 | Line 311 | OSUAnalysis::OSUAnalysis (const edm::Par
311        labelArray.push_back("other");
312  
313        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
314 <        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
314 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
315 >          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
316 >        }
317 >        else {
318 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
319 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
320 >        }
321 >      }
322 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
323 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
324 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
325        }
268    }
326  
327 <    //book a histogram for the number of each object type to be plotted
327 >    }
328  
329 +    // Book a histogram for the number of each object type to be plotted.  
330 +    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
331      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
332        string currentObject = objectsToPlot.at(currentObjectIndex);
333        int maxNum = 10;
334        if(currentObject == "mcparticles") maxNum = 50;
335        else if(currentObject == "primaryvertexs") maxNum = 50;
277      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
278      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
279      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
336  
337 <      currentObject.at(0) = toupper(currentObject.at(0));
337 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
338 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
339 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
340 >      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
341 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
342 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
343 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
344 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
345 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
346 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
347 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
348 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
349 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
350 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
351 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
352 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
353 >
354 >      currentObject.at(0) = toupper(currentObject.at(0));  
355        string histoName = "num" + currentObject;
356  
357        if(histoName == "numPrimaryvertexs"){
# Line 294 | Line 367 | OSUAnalysis::OSUAnalysis (const edm::Par
367  
368  
369  
297
370      //get list of cuts for this channel
371      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
372  
# Line 303 | Line 375 | OSUAnalysis::OSUAnalysis (const edm::Par
375        cut tempCut;
376        //store input collection for cut
377        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
378 +      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
379 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
380 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
381 +      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
382 +      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
383 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
384        tempCut.inputCollection = tempInputCollection;
385        if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
386 <        objectsToGet.push_back(tempInputCollection);
386 >        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
387 >          int spaceIndex = tempInputCollection.find(" ");
388 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
389 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
390 >        }
391 >        else{
392 >          objectsToGet.push_back(tempInputCollection);
393 >        }
394 >        objectsToCut.push_back(tempInputCollection);
395 >      }
396 >      else{//pair of objects, need to add them both to objectsToGet
397 >        string obj1;
398 >        string obj2;
399 >        getTwoObjs(tempInputCollection, obj1, obj2);
400 >        string obj2ToGet = getObjToGet(obj2);  
401          objectsToCut.push_back(tempInputCollection);
402 <      }
403 <      else{//pair of objects, need to add them both to the things to objectsToGet
312 <        int dashIndex = tempInputCollection.find("-");
313 <        int spaceIndex = tempInputCollection.find(" ");
314 <        int secondWordLength = spaceIndex - dashIndex;
402 >        objectsToCut.push_back(obj1);
403 >        objectsToCut.push_back(obj2);  
404          objectsToGet.push_back(tempInputCollection);
405 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
406 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
318 <        objectsToCut.push_back(tempInputCollection);
319 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
320 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
405 >        objectsToGet.push_back(obj1);
406 >        objectsToGet.push_back(obj2ToGet);
407  
408        }
409  
# Line 374 | Line 460 | OSUAnalysis::OSUAnalysis (const edm::Par
460        }
461        tempCut.name = tempCutName;
462  
377
463        tempChannel.cuts.push_back(tempCut);
464  
465  
381
466      }//end loop over cuts
467  
468      channels.push_back(tempChannel);
# Line 454 | Line 538 | OSUAnalysis::analyze (const edm::Event &
538    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
539      event.getByLabel (superclusters_, superclusters);
540  
541 <  //get pile-up event weight
542 <  double scaleFactor = 1.00;
543 <  if(doPileupReweighting_ && datasetType_ != "data")
544 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
541 > #ifdef DISPLACED_SUSY
542 >  if (datasetType_ == "signalMC"){
543 >    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
544 >      event.getByLabel (stops_, stops);
545 >  }
546 > #endif
547 >
548 >  if (useTrackCaloRhoCorr_) {  
549 >    // Used only for pile-up correction of by-hand calculation of isolation energy.  
550 >    // This rho collection is not available in all BEANs.  
551 >    // For description of rho values for different jet reconstruction algorithms, see
552 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
553 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
554 >  }
555  
556 +  double scaleFactor = 1.0;
557  
558    //loop over all channels
559  
# Line 477 | Line 572 | OSUAnalysis::analyze (const edm::Event &
572  
573      //loop over all cuts
574  
480
481
575      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
576        cut currentCut = currentChannel.cuts.at(currentCutIndex);
577  
# Line 497 | Line 590 | OSUAnalysis::analyze (const edm::Event &
590  
591  
592          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
593 +
594          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
595 +
596 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
597 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
598          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
599          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
600          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 511 | Line 608 | OSUAnalysis::analyze (const edm::Event &
608          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
609  
610  
611 +
612          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
613                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
614                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
615                                                                     "muon-muon pairs");
616 +
617 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
618 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
619 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
620 +                                                                   "muon-secondary muon pairs");
621 +
622 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
623 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
624 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
625 +                                                                   "electron-secondary electron pairs");
626 +
627          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
628                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
629                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 523 | Line 632 | OSUAnalysis::analyze (const edm::Event &
632                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
633                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
634                                                                         "electron-muon pairs");
635 <
636 <
635 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
636 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
637 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
638 >                                                                           "jet-jet pairs");
639 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
640 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
641 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
642 >                                                                       "electron-jet pairs");
643 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
644 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
645 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
646 >                                                                       "muon-jet pairs");
647 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
648 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
649 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
650 >                                                                     "track-event pairs");
651 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
652 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
653 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
654 >                                                                        "electron-track pairs");
655 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
656 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
657 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
658 >                                                                    "muon-track pairs");
659 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
660 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
661 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
662 >                                                                  "muon-tau pairs");
663 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
664 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
665 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
666 >                                                                 "tau-tau pairs");
667 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
668 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
669 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
670 >                                                                 "tau-track pairs");
671 >
672 > #ifdef DISPLACED_SUSY
673 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
674 > #endif
675        }
676  
677  
# Line 540 | Line 687 | OSUAnalysis::analyze (const edm::Event &
687      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
688  
689  
543
690      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
691  
692        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 548 | Line 694 | OSUAnalysis::analyze (const edm::Event &
694        int numberPassing = 0;
695  
696        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
697 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
697 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
698        }
553
699        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
700        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
556
701        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
702  
703      }
704  
705 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
705 >  //get pile-up event weight
706 >  if (datasetType_ != "data"){
707 >    if(doPileupReweighting_) scaleFactor *= puWeight_->at (events->at (0).numTruePV);
708 >    if(applyLeptonSF_){
709 >      if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
710 >      if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
711 >    }
712 >  }
713  
714 +  cTauScaleFactor_ = 1.0;
715 + #ifdef DISPLACED_SUSY
716 +  if (datasetType_ == "signalMC")
717 +    cTauScaleFactor_ = cTauWeight_->at (event);
718 + #endif
719 +  scaleFactor *= cTauScaleFactor_;
720  
721 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
722  
723      if(!eventPassedAllCuts)continue;
724  
725 <
726 <    //if(datasetType_ != "data") {
727 <    //  scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
728 <    //  scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
729 <    //}
725 >    if (printEventInfo_) {
726 >      // Write information about event to screen, for testing purposes.  
727 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
728 >           << ": run="  << events->at(0).run
729 >           << "  lumi=" << events->at(0).lumi
730 >           << "  event=" << events->at(0).evt
731 >           << endl;  
732 >    }
733  
734      //filling histograms
735      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
# Line 578 | Line 739 | OSUAnalysis::analyze (const edm::Event &
739          TH1D* histo;
740          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
741  
581
582
742          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
743 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
743 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
744 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
745 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
746          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
747                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
748                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
749 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
750 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
751 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
752          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
753          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
754                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
755                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
756 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
757 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
758 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
759 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
760 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
761 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
762          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
763 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
764 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
763 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
764 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
765 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
766 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
767 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
768 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
769 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
770 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
771 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
772 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
773 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
774 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
775 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
776 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
777 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
778 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
779 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
780 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
781 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
782 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
783 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
784 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
785 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
786 >
787          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
788          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
789          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 602 | Line 794 | OSUAnalysis::analyze (const edm::Event &
794          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
795          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
796          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
797 +
798 + #ifdef DISPLACED_SUSY
799 +        if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
800 + #endif
801        }
802        else if(currentHistogram.inputVariables.size() == 2){
803          TH2D* histo;
804          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
805  
610
611
806          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
807          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
808 +        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
809          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
810                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
811                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
812 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
813 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
814 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
815          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
816 +        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
817          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
827 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
828 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
829 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").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") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(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") fill2DHistogram(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 == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
851          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
852          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
853          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
854 +        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
855 +                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
856 +                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
857          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
858          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
859          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
860          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
861          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
862          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
863 + #ifdef DISPLACED_SUSY
864 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
865 + #endif
866        }
867      }
868  
869 +
870 +
871      //fills histograms with the sizes of collections
872      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
873 +
874        string currentObject = objectsToPlot.at(currentObjectIndex);
875  
876 <      string objectToPlot = "";
876 >      string objectToPlot = "";  
877  
878 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
879 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
880 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
878 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
879 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
880 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
881 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
882 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
883 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
884 >      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
885 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
886 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";    
887 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";      
888 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
889 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
890 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";  
891 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";  
892 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";  
893 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";  
894 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";  
895        else objectToPlot = currentObject;
896 +
897        string tempCurrentObject = objectToPlot;
898 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
898 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
899        string histoName = "num" + tempCurrentObject;
900  
651
652
653
901        //set position of primary vertex in event, in order to calculate quantities relative to it
902        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
903          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
904 <        int numToPlot = 0;
904 >        int numToPlot = 0;
905          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
906            if(lastCutFlags.at(currentFlag)) numToPlot++;
907          }
# Line 662 | Line 909 | OSUAnalysis::analyze (const edm::Event &
909            oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
910            oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
911          }
912 <        else
912 >        else {
913            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
914 +        }
915        }
916        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
917        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
918 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
919        else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
920 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
921        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
922 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
923        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
924 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
925        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
926 +      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
927 +      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
928 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
929        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
930        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
931        else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
# Line 683 | Line 938 | OSUAnalysis::analyze (const edm::Event &
938        else if(objectToPlot == "primaryvertexs"){
939          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
940          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
941 <      }
942 <
943 <    }
944 <
690 <
941 >      }
942 > #ifdef DISPLACED_SUSY
943 >      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
944 > #endif
945  
946 +    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
947  
948    } //end loop over channel
949  
950    masterCutFlow_->fillCutFlow(scaleFactor);
951  
952 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
953  
954  
699 }
700
955  
956   bool
957   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 744 | Line 998 | OSUAnalysis::splitString (string inputSt
998  
999   }
1000  
1001 +
1002 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1003 +  // Set two object strings from the tempInputCollection string,
1004 +  // For example, if tempInputCollection is "electron-muon pairs",
1005 +  // then obj1 = "electrons" and obj2 = "muons".  
1006 +  // Note that the objects have an "s" appended.  
1007 +
1008 +  int dashIndex = tempInputCollection.find("-");
1009 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1010 +  int secondWordLength = spaceIndex - dashIndex;
1011 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1012 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1013 +  
1014 + }
1015 +
1016 +
1017 + string OSUAnalysis::getObjToGet(string obj) {
1018 +  // Return the string corresponding to the object to get for the given obj string.
1019 +  // Right now this only handles the case in which obj contains "secondary",
1020 +  // e.g, "secondary muons".  
1021 +  // Note that "s" is NOT appended.  
1022 +  
1023 +  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
1024 +  int firstSpaceIndex = obj.find_first_of(" ");  
1025 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1026 +
1027 + }  
1028 +
1029 +
1030 + //!jet valueLookup
1031   double
1032   OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1033  
# Line 873 | Line 1157 | OSUAnalysis::valueLookup (const BNjet* o
1157   }
1158  
1159  
1160 <
1160 > //!muon valueLookup
1161   double
1162   OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1163  
# Line 1040 | Line 1324 | OSUAnalysis::valueLookup (const BNmuon*
1324      if (met)
1325        {
1326          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1327 <                       p2 (met->px, met->py, 0.0, met->pt);
1327 >          p2 (met->px, met->py, 0.0, met->pt);
1328  
1329          value = (p1 + p2).Mt ();
1330        }
# Line 1160 | Line 1444 | OSUAnalysis::valueLookup (const BNmuon*
1444      value = object->isGlobalMuon > 0                \
1445        && object->isPFMuon > 0                        \
1446        && object->normalizedChi2 < 10                \
1447 <      && object->numberOfValidMuonHits > 0        \
1447 >                                  && object->numberOfValidMuonHits > 0        \
1448        && object->numberOfMatchedStations > 1        \
1449        && fabs(object->correctedD0Vertex) < 0.2        \
1450        && fabs(object->correctedDZ) < 0.5        \
# Line 1170 | Line 1454 | OSUAnalysis::valueLookup (const BNmuon*
1454    else if(variable == "tightIDdisplaced"){
1455      value = object->isGlobalMuon > 0                \
1456        && object->normalizedChi2 < 10                \
1457 <      && object->numberOfValidMuonHits > 0        \
1457 >                                  && object->numberOfValidMuonHits > 0        \
1458        && object->numberOfMatchedStations > 1        \
1459        && object->numberOfValidPixelHits > 0        \
1460        && object->numberOfLayersWithMeasurement > 5;
1461    }
1462  
1463 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1464  
1465 +  else if(variable == "genMatchedPdgId"){
1466 +    int index = getGenMatchedParticleIndex(object);
1467 +    if(index == -1) value = 0;
1468 +    else value = mcparticles->at(index).id;
1469 +  }
1470  
1471    else if(variable == "genMatchedId"){
1472      int index = getGenMatchedParticleIndex(object);
# Line 1188 | Line 1478 | OSUAnalysis::valueLookup (const BNmuon*
1478      if(index == -1) value = 0;
1479      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1480    }
1481 +  else if(variable == "genMatchedMotherIdReverse"){
1482 +    int index = getGenMatchedParticleIndex(object);
1483 +    if(index == -1) value = 23;
1484 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1485 +  }
1486    else if(variable == "genMatchedGrandmotherId"){
1487      int index = getGenMatchedParticleIndex(object);
1488      if(index == -1) value = 0;
# Line 1198 | Line 1493 | OSUAnalysis::valueLookup (const BNmuon*
1493      }
1494      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1495    }
1496 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1497 +    int index = getGenMatchedParticleIndex(object);
1498 +    if(index == -1) value = 23;
1499 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1500 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1501 +      if(motherIndex == -1) value = 23;
1502 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1503 +    }
1504 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1505 +  }
1506  
1507  
1508  
# Line 1208 | Line 1513 | OSUAnalysis::valueLookup (const BNmuon*
1513    return value;
1514   }
1515  
1516 <
1516 > //!electron valueLookup
1517   double
1518   OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1519  
# Line 1380 | Line 1685 | OSUAnalysis::valueLookup (const BNelectr
1685      if (met)
1686        {
1687          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1688 <                       p2 (met->px, met->py, 0.0, met->pt);
1688 >          p2 (met->px, met->py, 0.0, met->pt);
1689  
1690          value = (p1 + p2).Mt ();
1691        }
# Line 1546 | Line 1851 | OSUAnalysis::valueLookup (const BNelectr
1851        }
1852    }
1853  
1854 +
1855 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1856 +
1857 +  else if(variable == "genMatchedPdgId"){
1858 +    int index = getGenMatchedParticleIndex(object);
1859 +    if(index == -1) value = 0;
1860 +    else value = mcparticles->at(index).id;
1861 +  }
1862 +
1863 +
1864    else if(variable == "genMatchedId"){
1865      int index = getGenMatchedParticleIndex(object);
1866      if(index == -1) value = 0;
# Line 1556 | Line 1871 | OSUAnalysis::valueLookup (const BNelectr
1871      if(index == -1) value = 0;
1872      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1873    }
1874 +  else if(variable == "genMatchedMotherIdReverse"){
1875 +    int index = getGenMatchedParticleIndex(object);
1876 +    if(index == -1) value = 23;
1877 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1878 +  }
1879    else if(variable == "genMatchedGrandmotherId"){
1880      int index = getGenMatchedParticleIndex(object);
1881      if(index == -1) value = 0;
# Line 1566 | Line 1886 | OSUAnalysis::valueLookup (const BNelectr
1886      }
1887      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1888    }
1889 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1890 +    int index = getGenMatchedParticleIndex(object);
1891 +    if(index == -1) value = 23;
1892 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1893 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1894 +      if(motherIndex == -1) value = 23;
1895 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1896 +    }
1897 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1898 +  }
1899  
1900  
1901  
# Line 1576 | Line 1906 | OSUAnalysis::valueLookup (const BNelectr
1906    return value;
1907   }
1908  
1909 <
1909 > //!event valueLookup
1910   double
1911   OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1912  
# Line 1664 | Line 1994 | OSUAnalysis::valueLookup (const BNevent*
1994      else
1995        value = 1.0;
1996    }
1997 +  else if(variable == "cTauScaleFactor")
1998 +    value = cTauScaleFactor_;
1999  
2000    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2001  
# Line 1672 | Line 2004 | OSUAnalysis::valueLookup (const BNevent*
2004    return value;
2005   }
2006  
2007 + //!tau valueLookup
2008   double
2009   OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2010  
# Line 1718 | Line 2051 | OSUAnalysis::valueLookup (const BNtau* o
2051    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2052  
2053  
2054 +
2055 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2056 +
2057 +  else if(variable == "genMatchedPdgId"){
2058 +    int index = getGenMatchedParticleIndex(object);
2059 +    if(index == -1) value = 0;
2060 +    else value = mcparticles->at(index).id;
2061 +  }
2062 +
2063    else if(variable == "genMatchedId"){
2064      int index = getGenMatchedParticleIndex(object);
2065      if(index == -1) value = 0;
# Line 1728 | Line 2070 | OSUAnalysis::valueLookup (const BNtau* o
2070      if(index == -1) value = 0;
2071      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2072    }
2073 +  else if(variable == "genMatchedMotherIdReverse"){
2074 +    int index = getGenMatchedParticleIndex(object);
2075 +    if(index == -1) value = 23;
2076 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2077 +  }
2078    else if(variable == "genMatchedGrandmotherId"){
2079      int index = getGenMatchedParticleIndex(object);
2080      if(index == -1) value = 0;
# Line 1738 | Line 2085 | OSUAnalysis::valueLookup (const BNtau* o
2085      }
2086      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2087    }
2088 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2089 +    int index = getGenMatchedParticleIndex(object);
2090 +    if(index == -1) value = 23;
2091 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2092 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2093 +      if(motherIndex == -1) value = 23;
2094 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2095 +    }
2096 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2097 +  }
2098  
2099  
2100    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1747 | Line 2104 | OSUAnalysis::valueLookup (const BNtau* o
2104    return value;
2105   }
2106  
2107 + //!met valueLookup
2108   double
2109   OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2110  
# Line 1819 | Line 2177 | OSUAnalysis::valueLookup (const BNmet* o
2177    return value;
2178   }
2179  
2180 + //!track valueLookup
2181   double
2182   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2183  
2184    double value = 0.0;
2185    double pMag = sqrt(object->pt * object->pt +
2186 <                         object->pz * object->pz);
2187 <
2186 >                     object->pz * object->pz);
2187 >  
2188    if(variable == "pt") value = object->pt;
2189    else if(variable == "px") value = object->px;
2190    else if(variable == "py") value = object->py;
# Line 1846 | Line 2205 | OSUAnalysis::valueLookup (const BNtrack*
2205  
2206  
2207    //additional BNs info for disappTrks
1849  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2208    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2209    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2210    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
# Line 1856 | Line 2214 | OSUAnalysis::valueLookup (const BNtrack*
2214    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2215    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2216    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2217 +  
2218 +
2219    //user defined variables
2220    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;
2221    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2222 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2223 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2224 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2225 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2226 <  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2227 <  else if(variable == "ptError") value = object->ptError;
2228 <  else if(variable == "ptRes") value = getTrkPtRes(object);
2222 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2223 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2224 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2225 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2226 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2227 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2228 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2229 >  else if(variable == "ptError")                    value = object->ptError;
2230 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2231 >  else if (variable == "d0wrtPV"){      
2232 >    double vx = object->vx - chosenVertex ()->x,        
2233 >      vy = object->vy - chosenVertex ()->y,      
2234 >      px = object->px,  
2235 >      py = object->py,  
2236 >      pt = object->pt;  
2237 >    value = (-vx * py + vy * px) / pt;  
2238 >  }      
2239 >  else if (variable == "dZwrtPV"){      
2240 >    double vx = object->vx - chosenVertex ()->x,        
2241 >      vy = object->vy - chosenVertex ()->y,      
2242 >      vz = object->vz - chosenVertex ()->z,      
2243 >      px = object->px,  
2244 >      py = object->py,  
2245 >      pz = object->pz,  
2246 >      pt = object->pt;  
2247 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2248 >  }    
2249 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2250 >
2251 >  else if(variable == "genMatchedPdgId"){
2252 >    int index = getGenMatchedParticleIndex(object);
2253 >    if(index == -1) value = 0;
2254 >    else value = mcparticles->at(index).id;
2255 >  }
2256  
2257  
2258    else if(variable == "genMatchedId"){
# Line 1878 | Line 2265 | OSUAnalysis::valueLookup (const BNtrack*
2265      if(index == -1) value = 0;
2266      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2267    }
2268 +  else if(variable == "genMatchedMotherIdReverse"){
2269 +    int index = getGenMatchedParticleIndex(object);
2270 +    if(index == -1) value = 23;
2271 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2272 +  }
2273    else if(variable == "genMatchedGrandmotherId"){
2274      int index = getGenMatchedParticleIndex(object);
2275      if(index == -1) value = 0;
# Line 1888 | Line 2280 | OSUAnalysis::valueLookup (const BNtrack*
2280      }
2281      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2282    }
2283 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2284 +    int index = getGenMatchedParticleIndex(object);
2285 +    if(index == -1) value = 23;
2286 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2287 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2288 +      if(motherIndex == -1) value = 23;
2289 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2290 +    }
2291 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2292 +  }
2293  
2294  
2295  
# Line 1898 | Line 2300 | OSUAnalysis::valueLookup (const BNtrack*
2300    return value;
2301   }
2302  
2303 + //!genjet valueLookup
2304   double
2305   OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2306  
# Line 1926 | Line 2329 | OSUAnalysis::valueLookup (const BNgenjet
2329    return value;
2330   }
2331  
2332 + //!mcparticle valueLookup
2333   double
2334   OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2335  
# Line 2059 | Line 2463 | OSUAnalysis::valueLookup (const BNmcpart
2463    return value;
2464   }
2465  
2466 + //!primaryvertex valueLookup
2467   double
2468   OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2469  
# Line 2086 | Line 2491 | OSUAnalysis::valueLookup (const BNprimar
2491    return value;
2492   }
2493  
2494 + //!bxlumi valueLookup
2495   double
2496   OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2497  
# Line 2103 | Line 2509 | OSUAnalysis::valueLookup (const BNbxlumi
2509    return value;
2510   }
2511  
2512 + //!photon valueLookup
2513   double
2514   OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2515  
# Line 2179 | Line 2586 | OSUAnalysis::valueLookup (const BNphoton
2586    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2587  
2588  
2589 +
2590 +
2591 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2592 +
2593 +  else if(variable == "genMatchedPdgId"){
2594 +    int index = getGenMatchedParticleIndex(object);
2595 +    if(index == -1) value = 0;
2596 +    else value = mcparticles->at(index).id;
2597 +  }
2598 +
2599 +
2600 +
2601    else if(variable == "genMatchedId"){
2602      int index = getGenMatchedParticleIndex(object);
2603      if(index == -1) value = 0;
# Line 2189 | Line 2608 | OSUAnalysis::valueLookup (const BNphoton
2608      if(index == -1) value = 0;
2609      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2610    }
2611 +  else if(variable == "genMatchedMotherIdReverse"){
2612 +    int index = getGenMatchedParticleIndex(object);
2613 +    if(index == -1) value = 23;
2614 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2615 +  }
2616    else if(variable == "genMatchedGrandmotherId"){
2617      int index = getGenMatchedParticleIndex(object);
2618      if(index == -1) value = 0;
# Line 2199 | Line 2623 | OSUAnalysis::valueLookup (const BNphoton
2623      }
2624      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2625    }
2626 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2627 +    int index = getGenMatchedParticleIndex(object);
2628 +    if(index == -1) value = 23;
2629 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2630 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2631 +      if(motherIndex == -1) value = 23;
2632 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2633 +    }
2634 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2635 +  }
2636  
2637  
2638    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2208 | Line 2642 | OSUAnalysis::valueLookup (const BNphoton
2642    return value;
2643   }
2644  
2645 + //!supercluster valueLookup
2646   double
2647   OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2648  
# Line 2230 | Line 2665 | OSUAnalysis::valueLookup (const BNsuperc
2665    return value;
2666   }
2667  
2668 <
2668 > //!muon-muon pair valueLookup
2669   double
2670   OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2671  
2672    double value = 0.0;
2673  
2674    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2675 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2676    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2677    else if(variable == "invMass"){
2678      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2679      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2680      value = (fourVector1 + fourVector2).M();
2681    }
2682 +  else if(variable == "pt"){
2683 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2684 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2685 +    value = (fourVector1 + fourVector2).Pt();
2686 +  }
2687    else if(variable == "threeDAngle")
2688      {
2689        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2273 | Line 2714 | OSUAnalysis::valueLookup (const BNmuon*
2714    else if(variable == "muon2CorrectedD0Vertex"){
2715      value = object2->correctedD0Vertex;
2716    }
2717 < else if(variable == "muon1timeAtIpInOut"){
2717 >  else if(variable == "muon1timeAtIpInOut"){
2718      value = object1->timeAtIpInOut;
2719    }
2720 < else if(variable == "muon2timeAtIpInOut"){
2720 >  else if(variable == "muon2timeAtIpInOut"){
2721      value = object2->timeAtIpInOut;
2722    }
2723 +  else if(variable == "muon1correctedD0")
2724 +    {
2725 +      value = object1->correctedD0;
2726 +    }
2727 +  else if(variable == "muon2correctedD0")
2728 +    {
2729 +      value = object2->correctedD0;
2730 +    }
2731 +
2732    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2733  
2734    value = applyFunction(function, value);
# Line 2286 | Line 2736 | OSUAnalysis::valueLookup (const BNmuon*
2736    return value;
2737   }
2738  
2739 + //!electron-electron pair valueLookup
2740   double
2741   OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2742  
2743    double value = 0.0;
2744  
2745    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2746 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2747    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2748    else if(variable == "invMass"){
2749      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2750      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2751      value = (fourVector1 + fourVector2).M();
2752    }
2753 +  else if(variable == "pt"){
2754 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2755 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2756 +    value = (fourVector1 + fourVector2).Pt();
2757 +  }
2758    else if(variable == "threeDAngle")
2759      {
2760        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2321 | Line 2778 | OSUAnalysis::valueLookup (const BNelectr
2778    else if(variable == "electron2CorrectedD0Vertex"){
2779      value = object2->correctedD0Vertex;
2780    }
2781 +  else if(variable == "electron1CorrectedD0"){
2782 +    value = object1->correctedD0;
2783 +  }
2784 +  else if(variable == "electron2CorrectedD0"){
2785 +    value = object2->correctedD0;
2786 +  }
2787  
2788    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2789  
# Line 2328 | Line 2791 | OSUAnalysis::valueLookup (const BNelectr
2791  
2792    return value;
2793   }
2794 <
2794 > //!electron-muon pair valueLookup
2795   double
2796   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2797  
2798    double value = 0.0;
2799  
2800    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2801 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2802    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2803    else if(variable == "invMass"){
2804      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2805      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2806      value = (fourVector1 + fourVector2).M();
2807    }
2808 +  else if(variable == "pt"){
2809 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2810 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2811 +    value = (fourVector1 + fourVector2).Pt();
2812 +  }
2813    else if(variable == "threeDAngle")
2814      {
2815        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2376 | Line 2845 | OSUAnalysis::valueLookup (const BNelectr
2845    else if(variable == "muonDetIso"){
2846      value = (object2->trackIsoDR03) / object2->pt;
2847    }
2848 +  else if(variable == "electronRelPFrhoIso"){
2849 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2850 +  }
2851 +  else if(variable == "muonRelPFdBetaIso"){
2852 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2853 +  }
2854 +
2855 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2856 +
2857 +  value = applyFunction(function, value);
2858 +
2859 +  return value;
2860 + }
2861 +
2862 + //!electron-jet pair valueLookup
2863 + double
2864 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function){
2865 +
2866 +  double value = 0.0;
2867 +
2868 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2869 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2870 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2871 +  else if(variable == "invMass"){
2872 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2873 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2874 +    value = (fourVector1 + fourVector2).M();
2875 +  }
2876 +  else if(variable == "pt"){
2877 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2878 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2879 +    value = (fourVector1 + fourVector2).Pt();
2880 +  }
2881 +  else if(variable == "threeDAngle")
2882 +    {
2883 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2884 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2885 +      value = (threeVector1.Angle(threeVector2));
2886 +    }
2887 +  else if(variable == "chargeProduct"){
2888 +    value = object1->charge*object2->charge;
2889 +  }
2890 +
2891 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2892 +
2893 +  value = applyFunction(function, value);
2894 +
2895 +  return value;
2896 + }
2897 +
2898 + //!muon-jet pair valueLookup
2899 + double
2900 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function){
2901 +
2902 +  double value = 0.0;
2903 +
2904 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2905 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2906 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2907 +  else if(variable == "invMass"){
2908 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2909 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2910 +    value = (fourVector1 + fourVector2).M();
2911 +  }
2912 +  else if(variable == "pt"){
2913 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2914 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2915 +    value = (fourVector1 + fourVector2).Pt();
2916 +  }
2917 +  else if(variable == "threeDAngle")
2918 +    {
2919 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2920 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2921 +      value = (threeVector1.Angle(threeVector2));
2922 +    }
2923    else if(variable == "chargeProduct"){
2924 <    value = object1->charge * object2->charge;
2924 >    value = object1->charge*object2->charge;
2925 >  }
2926 >
2927 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2928 >
2929 >  value = applyFunction(function, value);
2930 >
2931 >  return value;
2932 > }
2933 >
2934 > //!jet-jet pair valueLookup
2935 > double
2936 > OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function){
2937 >
2938 >  double value = 0.0;
2939 >
2940 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2941 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2942 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2943 >  else if(variable == "invMass"){
2944 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2945 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2946 >    value = (fourVector1 + fourVector2).M();
2947 >  }
2948 >  else if(variable == "pt"){
2949 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2950 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2951 >    value = (fourVector1 + fourVector2).Pt();
2952 >  }
2953 >  else if(variable == "threeDAngle")
2954 >    {
2955 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2956 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2957 >      value = (threeVector1.Angle(threeVector2));
2958 >    }
2959 >  else if(variable == "chargeProduct"){
2960 >    value = object1->charge*object2->charge;
2961 >  }
2962 >  
2963 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2964 >
2965 >  value = applyFunction(function, value);
2966 >
2967 >  return value;
2968 > }
2969 > //!electron-track pair valueLookup
2970 > double  
2971 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2972 >  double electronMass = 0.000511;        
2973 >  double value = 0.0;    
2974 >  TLorentzVector fourVector1(0, 0, 0, 0);        
2975 >  TLorentzVector fourVector2(0, 0, 0, 0);        
2976 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2977 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2978 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2979 >  else if(variable == "invMass"){        
2980 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2981 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2982 >        
2983 >    value = (fourVector1 + fourVector2).M();    
2984 >  }
2985 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2986 >  value = applyFunction(function, value);        
2987 >  return value;  
2988 > }
2989 >
2990 >
2991 > //!muon-track pair valueLookup
2992 > double
2993 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2994 >  double pionMass = 0.140;
2995 >  double muonMass = 0.106;
2996 >  double value = 0.0;
2997 >  TLorentzVector fourVector1(0, 0, 0, 0);
2998 >  TLorentzVector fourVector2(0, 0, 0, 0);
2999 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3000 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3001 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3002 >  else if(variable == "invMass"){
3003 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
3004 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
3005 >
3006 >    value = (fourVector1 + fourVector2).M();
3007 >  }
3008 >
3009 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3010 >  value = applyFunction(function, value);
3011 >  return value;
3012 > }
3013 >
3014 > //!tau-tau pair valueLookup
3015 > double
3016 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3017 >  double value = 0.0;
3018 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3019 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3020 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3021 >  else if(variable == "invMass"){
3022 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3023 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3024 >    value = (fourVector1 + fourVector2).M();
3025 >  }
3026 >
3027 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3028 >  value = applyFunction(function, value);
3029 >  return value;
3030 > }
3031 >
3032 > //!muon-tau pair valueLookup
3033 > double
3034 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3035 >  double value = 0.0;
3036 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3037 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3038 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3039 >  else if(variable == "invMass"){
3040 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3041 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3042 >    value = (fourVector1 + fourVector2).M();
3043    }
3044  
3045 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3046 +  value = applyFunction(function, value);
3047 +  return value;
3048 + }
3049 +
3050 + //!tau-track pair valueLookup
3051 + double
3052 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3053 +  double value = 0.0;
3054 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3055 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3056  
3057    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3058 +  value = applyFunction(function, value);
3059 +  return value;
3060 + }
3061 +
3062 +
3063 + //!track-event pair valueLookup
3064 + double
3065 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3066 +
3067 +  double value = 0.0;
3068 +  double pMag = sqrt(object1->pt * object1->pt +
3069 +                     object1->pz * object1->pz);  
3070 +
3071 +  if      (variable == "numPV")                      value = object2->numPV;
3072 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3073 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3074 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3075 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3076 +
3077 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3078  
3079    value = applyFunction(function, value);
3080  
3081    return value;
3082 +
3083   }
3084  
3085 + //!stop valueLookup
3086 + double
3087 + OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
3088 +
3089 +
3090 +  double value = 0.0;
3091 +
3092 +  if(variable == "ctau") value = object->ctau;
3093 +
3094 +  else if (variable == "d0"){
3095 +    double vx = object->vx - chosenVertex ()->x,
3096 +      vy = object->vy - chosenVertex ()->y,
3097 +      px = object->px,
3098 +      py = object->py,
3099 +      pt = object->pt;
3100 +    value = (-vx * py + vy * px) / pt;
3101 +  }
3102 +
3103 +  else if (variable == "dz"){
3104 +    double vx = object->vx - chosenVertex ()->x,
3105 +      vy = object->vy - chosenVertex ()->y,
3106 +      vz = object->vz - chosenVertex ()->z,
3107 +      px = object->px,
3108 +      py = object->py,
3109 +      pz = object->pz,
3110 +      pt = object->pt;
3111 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3112 +  }
3113 +
3114 +  else if (variable == "minD0"){
3115 +    double minD0=999;
3116 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3117 +      double vx = object->vx - vertex->x,
3118 +        vy = object->vy - vertex->y,
3119 +        px = object->px,
3120 +        py = object->py,
3121 +        pt = object->pt;
3122 +      value = (-vx * py + vy * px) / pt;
3123 +      if(abs(value) < abs(minD0)) minD0 = value;
3124 +    }
3125 +    value = minD0;
3126 +  }
3127 +  else if (variable == "minDz"){
3128 +    double minDz=999;
3129 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3130 +      double vx = object->vx - vertex->x,
3131 +        vy = object->vy - vertex->y,
3132 +        vz = object->vz - vertex->z,
3133 +        px = object->px,
3134 +        py = object->py,
3135 +        pz = object->pz,
3136 +        pt = object->pt;
3137 +      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3138 +      if(abs(value) < abs(minDz)) minDz = value;
3139 +    }
3140 +    value = minDz;
3141 +  }
3142 +  else if(variable == "distToVertex"){
3143 +    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3144 +                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3145 +                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3146 +  }
3147 +  else if (variable == "minDistToVertex"){
3148 +    double minDistToVertex=999;
3149 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3150 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3151 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3152 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3153 +      
3154 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3155 +    }
3156 +    value = minDistToVertex;
3157 +  }
3158 +  else if (variable == "distToVertexDifference"){
3159 +    double minDistToVertex=999;
3160 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3161 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3162 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3163 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3164 +      
3165 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3166 +    }
3167 +    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3168 +                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3169 +                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3170 +
3171 +    value = distToChosenVertex - minDistToVertex;
3172 +  }
3173 +
3174 +  else if (variable == "closestVertexRank"){
3175 +    double minDistToVertex=999;
3176 +    int vertex_rank = 0;
3177 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3178 +      vertex_rank++;
3179 +      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3180 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3181 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3182 +      
3183 +      if(abs(dist) < abs(minDistToVertex)){
3184 +        value = vertex_rank;
3185 +        minDistToVertex = dist;
3186 +      }
3187 +    }
3188 +  }
3189 +
3190 +
3191 +
3192 +
3193 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3194 +
3195 +  value = applyFunction(function, value);
3196 +
3197 +  return value;
3198 +
3199 + }  
3200 +
3201 +
3202 +
3203  
3204   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3205   // Return true iff no other tracks are found in this cone.
# Line 2434 | Line 3246 | OSUAnalysis::getTrkPtTrue (const BNtrack
3246  
3247   }
3248  
3249 + double
3250 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3251 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3252 +  if (!useTrackCaloRhoCorr_) return -99;  
3253 +  // if (!rhokt6CaloJetsHandle_) {
3254 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3255 +  //   return -99;  
3256 +  // }
3257 +  double radDeltaRCone = 0.5;  
3258 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3259 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3260 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3261 +  return caloTotRhoCorrCalo;  
3262 +
3263 + }
3264 +
3265 +
3266 +
3267 +
3268   //creates a map of the dead Ecal channels in the barrel and endcap
3269   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
3270   //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
# Line 2477 | Line 3308 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3308    return value;
3309   }
3310  
3311 <
3312 <
3311 > // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3312 > template <class InputObject>
3313 > double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3314 >  double genDeltaRLowest = 999.;
3315 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3316 >    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3317 >    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3318 >  }
3319 >  return genDeltaRLowest;
3320 > }
3321  
3322   double
3323   OSUAnalysis::applyFunction(string function, double value){
# Line 2498 | Line 3337 | OSUAnalysis::applyFunction(string functi
3337  
3338   template <class InputCollection>
3339   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3340 <
3340 >
3341 >  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3342 >    string obj1, obj2;
3343 >    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3344 >    if (inputType==obj1 ||
3345 >        inputType==obj2) {
3346 >      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3347 >      // and the inputType is a member of the pair.  
3348 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3349 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3350 >      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3351 >      return;
3352 >    }  
3353 >  }    
3354  
3355    for (uint object = 0; object != inputCollection->size(); object++){
3356  
2505
3357      bool decision = true;//object passes if this cut doesn't cut on that type of object
3358  
2508
3359      if(currentCut.inputCollection == inputType){
3360  
3361        vector<bool> subcutDecisions;
3362        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3363          double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3364          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3365 +
3366        }
3367        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3368        else{
# Line 2525 | Line 3376 | void OSUAnalysis::setObjectFlags(cut &cu
3376          decision = tempDecision;
3377        }
3378      }
2528    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3379  
3380 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3381  
3382      //set flags for objects that pass each cut AND all the previous cuts
3383      bool previousCumulativeFlag = true;
# Line 2536 | Line 3387 | void OSUAnalysis::setObjectFlags(cut &cu
3387      }
3388      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3389  
2539
3390    }
3391  
3392   }
# Line 2550 | Line 3400 | void OSUAnalysis::setObjectFlags(cut &cu
3400    bool sameObjects = false;
3401    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3402  
3403 <
3403 >  // Get the strings for the two objects that make up the pair.  
3404 >  string obj1Type, obj2Type;
3405 >  getTwoObjs(inputType, obj1Type, obj2Type);
3406 >  bool isTwoTypesOfObject = true;
3407 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3408 >
3409 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3410 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3411 >  if (currentCut.inputCollection == inputType) {    
3412 >    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3413 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3414 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3415 >    }
3416 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3417 >      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3418 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3419 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3420 >      }
3421 >    }
3422 >  }
3423 >  
3424    int counter = 0;
3425 +
3426    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3427      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3428  
# Line 2580 | Line 3451 | void OSUAnalysis::setObjectFlags(cut &cu
3451            decision = tempDecision;
3452          }
3453        }
3454 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3454 >      // if (decision) isPassObj1.at(object1) = true;
3455 >      // if (decision) isPassObj2.at(object2) = true;
3456 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3457 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3458 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3459 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3460 >      }  
3461  
3462        //set flags for objects that pass each cut AND all the previous cuts
3463        bool previousCumulativeFlag = true;
# Line 2595 | Line 3472 | void OSUAnalysis::setObjectFlags(cut &cu
3472        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3473        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3474        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3475 <
3475 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3476 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3477 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3478 >      }
3479        counter++;
2600    }
2601
2602  }
3480  
3481 +    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3482 +  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3483  
3484   }
3485  
3486  
3487 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3488 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3489 +  // all cuts up to currentCutIndex  
3490 +  bool previousCumulativeFlag = true;  
3491 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3492 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3493 +    else {  
3494 +      previousCumulativeFlag = false; break;  
3495 +    }
3496 +  }
3497 +  return previousCumulativeFlag;  
3498 + }  
3499 +
3500 +
3501   template <class InputCollection>
3502   void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3503  
# Line 2627 | Line 3520 | void OSUAnalysis::fill1DHistogram(TH1* h
3520      double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3521      histo->Fill(value,scaleFactor);
3522  
3523 +    if (printEventInfo_) {
3524 +      // Write information about event to screen, for testing purposes.  
3525 +      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3526 +    }
3527 +    
3528    }
2631
3529   }
3530  
3531   template <class InputCollection1, class InputCollection2>
# Line 2637 | Line 3534 | void OSUAnalysis::fill1DHistogram(TH1* h
3534    bool sameObjects = false;
3535    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3536  
3537 <  int pairCounter = 0;
3537 >  int pairCounter = -1;
3538    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3539      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3540  
3541        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3542  
3543 +      pairCounter++;
3544        //only take objects which have passed all cuts and pairs which have passed all cuts
3545        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3546        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2663 | Line 3561 | void OSUAnalysis::fill1DHistogram(TH1* h
3561        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3562        histo->Fill(value,scaleFactor);
3563  
2666      pairCounter++;
3564      }
3565    }
3566  
# Line 2716 | Line 3613 | void OSUAnalysis::fill2DHistogram(TH2* h
3613    bool sameObjects = false;
3614    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3615  
3616 <  int pairCounter = 0;
3616 >  int pairCounter = -1;
3617    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3618      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3619  
3620        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3621  
3622 +      pairCounter++;
3623 +
3624        //only take objects which have passed all cuts and pairs which have passed all cuts
3625        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3626        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2756 | Line 3655 | void OSUAnalysis::fill2DHistogram(TH2* h
3655  
3656        histo->Fill(valueX,valueY,scaleFactor);
3657  
2759      pairCounter++;
2760
3658      }
3659    }
3660  
# Line 2774 | Line 3671 | int OSUAnalysis::getGenMatchedParticleIn
3671  
3672      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3673      if(currentDeltaR > 0.05) continue;
3674 < //     cout << std::setprecision(3) << std::setw(20)
3675 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3676 < //          << std::setw(20)
3677 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3678 < //          << std::setw(20)
3679 < //          << "\tdeltaR = " << currentDeltaR
3680 < //          << std::setprecision(1)
3681 < //          << std::setw(20)
3682 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3683 < //          << std::setw(20)
3684 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3685 < //          << std::setw(20)
3686 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3674 >    //     cout << std::setprecision(3) << std::setw(20)
3675 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3676 >    //          << std::setw(20)
3677 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3678 >    //          << std::setw(20)
3679 >    //          << "\tdeltaR = " << currentDeltaR
3680 >    //          << std::setprecision(1)
3681 >    //          << std::setw(20)
3682 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3683 >    //          << std::setw(20)
3684 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3685 >    //          << std::setw(20)
3686 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3687      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3688        bestMatchIndex = mcparticle - mcparticles->begin();
3689        bestMatchDeltaR = currentDeltaR;
3690      }
3691  
3692    }
3693 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3694 < //   else cout << "no match found..." << endl;
3693 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3694 >  //   else cout << "no match found..." << endl;
3695    return bestMatchIndex;
3696  
3697   }
# Line 2884 | Line 3781 | OSUAnalysis::chosenVertex ()
3781   {
3782    const BNprimaryvertex *chosenVertex = 0;
3783    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3784 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3785 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3784 >    vector<bool> vertexFlags;
3785 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3786 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
3787 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
3788 >        break;
3789 >      }
3790 >    }
3791      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3792        if(!vertexFlags.at(vertexIndex)) continue;
3793        chosenVertex = & primaryvertexs->at(vertexIndex);
# Line 2904 | Line 3806 | OSUAnalysis::chosenMET ()
3806   {
3807    const BNmet *chosenMET = 0;
3808    if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3809 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3810 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3809 >    vector<bool> metFlags;
3810 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
3811 >      if (cumulativeFlags.at("mets").at(i).size()){
3812 >        metFlags = cumulativeFlags.at("mets").at(i);
3813 >        break;
3814 >      }
3815 >    }
3816      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3817        if(!metFlags.at(metIndex)) continue;
3818        chosenMET = & mets->at(metIndex);
# Line 2924 | Line 3831 | OSUAnalysis::chosenElectron ()
3831   {
3832    const BNelectron *chosenElectron = 0;
3833    if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3834 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3835 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3834 >    vector<bool> electronFlags;
3835 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
3836 >      if (cumulativeFlags.at("electrons").at(i).size()){
3837 >        electronFlags = cumulativeFlags.at("electrons").at(i);
3838 >        break;
3839 >      }
3840 >    }
3841      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3842        if(!electronFlags.at(electronIndex)) continue;
3843        chosenElectron = & electrons->at(electronIndex);
# Line 2944 | Line 3856 | OSUAnalysis::chosenMuon ()
3856   {
3857    const BNmuon *chosenMuon = 0;
3858    if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3859 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3860 <                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3859 >    vector<bool> muonFlags;
3860 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
3861 >      if (cumulativeFlags.at("muons").at(i).size()){
3862 >        muonFlags = cumulativeFlags.at("muons").at(i);
3863 >        break;
3864 >      }
3865 >    }
3866      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3867        if(!muonFlags.at(muonIndex)) continue;
3868        chosenMuon = & muons->at(muonIndex);
# Line 2959 | Line 3876 | OSUAnalysis::chosenMuon ()
3876    return chosenMuon;
3877   }
3878  
2962
3879   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines