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.39 by jbrinson, Wed Mar 27 16:52:25 2013 UTC vs.
Revision 1.50 by lantonel, Thu Apr 25 07:52:02 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 18 | Line 19 | OSUAnalysis::OSUAnalysis (const edm::Par
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20    puFile_ (cfg.getParameter<std::string> ("puFile")),
21    deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 <  
22 < muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
22 >  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23    dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24    electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25    muonSF_ (cfg.getParameter<std::string> ("muonSF")),
# Line 29 | Line 29 | muonSFFile_ (cfg.getParameter<std::strin
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo"))
32 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
33 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
34 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
35 >
36   {
37  
38    TH1::SetDefaultSumw2 ();
# Line 40 | Line 43 | muonSFFile_ (cfg.getParameter<std::strin
43      //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
44      //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45    }
46 + #ifdef DISPLACED_SUSY
47 +  if (datasetType_ == "signalMC")
48 +    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 + #endif
50  
51  
52    // Construct Cutflow Objects. These store the results of cut decisions and
# Line 50 | Line 57 | muonSFFile_ (cfg.getParameter<std::strin
57    //always get vertex collection so we can assign the primary vertex in the event
58    objectsToGet.push_back("primaryvertexs");
59  
60 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
60 >  //always make the plot of number of primary vertices (to check pile-up reweighting)
61    objectsToPlot.push_back("primaryvertexs");
62  
63    //always get the MC particles to do GEN-matching
# Line 64 | Line 71 | muonSFFile_ (cfg.getParameter<std::strin
71  
72      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
73      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
74 +    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
75 +    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
76 +    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
77      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
78 <      objectsToGet.push_back(tempInputCollection);
78 >      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
79 >        int spaceIndex = tempInputCollection.find(" ");
80 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
81 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
82 >      }
83 >      else{
84 >        objectsToGet.push_back(tempInputCollection);
85 >      }
86        objectsToPlot.push_back(tempInputCollection);
87        objectsToCut.push_back(tempInputCollection);
88      }
89 <    else{//pair of objects, need to add them both to the things to objectsToGet
90 <      int dashIndex = tempInputCollection.find("-");
91 <      int spaceIndex = tempInputCollection.find(" ");
92 <      int secondWordLength = spaceIndex - dashIndex;
93 <      objectsToGet.push_back(tempInputCollection);
77 <      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
78 <      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
79 <      objectsToPlot.push_back(tempInputCollection);
80 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
81 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
89 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
90 >      string obj1;
91 >      string obj2;
92 >      getTwoObjs(tempInputCollection, obj1, obj2);
93 >      string obj2ToGet = getObjToGet(obj2);  
94        objectsToCut.push_back(tempInputCollection);
95 <      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
96 <      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
95 >      objectsToCut.push_back(obj1);
96 >      objectsToCut.push_back(obj2);  
97 >      objectsToPlot.push_back(tempInputCollection);
98 >      objectsToPlot.push_back(obj1);
99 >      objectsToPlot.push_back(obj2);  
100 >      objectsToGet.push_back(tempInputCollection);
101 >      objectsToGet.push_back(obj1);
102 >      objectsToGet.push_back(obj2ToGet);
103  
104 <      }
104 >    }
105  
106      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
107  
# Line 110 | Line 128 | muonSFFile_ (cfg.getParameter<std::strin
128    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
129  
130      string currentObject = objectsToPlot.at(currentObjectIndex);
131 <    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
131 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
132  
133      histogram tempIdHisto;
134      histogram tempMomIdHisto;
135      histogram tempGmaIdHisto;
136      histogram tempIdVsMomIdHisto;
137 +    histogram tempIdVsGmaIdHisto;
138  
139      tempIdHisto.inputCollection = currentObject;
140      tempMomIdHisto.inputCollection = currentObject;
141      tempGmaIdHisto.inputCollection = currentObject;
142      tempIdVsMomIdHisto.inputCollection = currentObject;
143 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
144 +
145 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
146 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
147  
148      currentObject = currentObject.substr(0, currentObject.size()-1);
149      tempIdHisto.name = currentObject+"GenMatchId";
150      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
151      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
152      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
153 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
154  
155      currentObject.at(0) = toupper(currentObject.at(0));
156      tempIdHisto.title = currentObject+" Gen-matched Particle";
157      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
158      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
159      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
160 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
161 +
162  
163      int maxNum = 24;
164      vector<double> binVector;
# Line 152 | Line 178 | muonSFFile_ (cfg.getParameter<std::strin
178      tempIdVsMomIdHisto.bins = binVector;
179      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
180      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
181 +    tempIdVsGmaIdHisto.bins = binVector;
182 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
183 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
184  
185      histograms.push_back(tempIdHisto);
186      histograms.push_back(tempMomIdHisto);
187      histograms.push_back(tempGmaIdHisto);
188      histograms.push_back(tempIdVsMomIdHisto);
189 +    histograms.push_back(tempIdVsGmaIdHisto);
190    }
191  
192  
# Line 222 | Line 252 | muonSFFile_ (cfg.getParameter<std::strin
252  
253        if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
254  
255 < // bin      particle type
256 < // ---      -------------
257 < //  0        unmatched
258 < //  1        u
259 < //  2        d
260 < //  3        s
261 < //  4        c
262 < //  5        b
263 < //  6        t
264 < //  7        e
265 < //  8        mu
266 < //  9        tau
267 < // 10        nu
268 < // 11        g
269 < // 12        gamma
270 < // 13        Z
271 < // 14        W
272 < // 15        light meson
273 < // 16        K meson
274 < // 17        D meson
275 < // 18        B meson
276 < // 19        light baryon
277 < // 20        strange baryon
278 < // 21        charm baryon
279 < // 22        bottom baryon
280 < // 23        other
255 >      // bin      particle type
256 >      // ---      -------------
257 >      //  0        unmatched
258 >      //  1        u
259 >      //  2        d
260 >      //  3        s
261 >      //  4        c
262 >      //  5        b
263 >      //  6        t
264 >      //  7        e
265 >      //  8        mu
266 >      //  9        tau
267 >      // 10        nu
268 >      // 11        g
269 >      // 12        gamma
270 >      // 13        Z
271 >      // 14        W
272 >      // 15        light meson
273 >      // 16        K meson
274 >      // 17        D meson
275 >      // 18        B meson
276 >      // 19        light baryon
277 >      // 20        strange baryon
278 >      // 21        charm baryon
279 >      // 22        bottom baryon
280 >      // 23        other
281  
282        vector<TString> labelArray;
283        labelArray.push_back("unmatched");
# Line 276 | Line 306 | muonSFFile_ (cfg.getParameter<std::strin
306        labelArray.push_back("other");
307  
308        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
309 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
309 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
310            oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
311          }
312          else {
# Line 284 | Line 314 | muonSFFile_ (cfg.getParameter<std::strin
314            twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
315          }
316        }
317 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
317 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
318          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
319          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
320        }
321  
322      }
323  
324 <    //book a histogram for the number of each object type to be plotted
325 <
324 >    // Book a histogram for the number of each object type to be plotted.  
325 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
326      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
327        string currentObject = objectsToPlot.at(currentObjectIndex);
328        int maxNum = 10;
329        if(currentObject == "mcparticles") maxNum = 50;
330        else if(currentObject == "primaryvertexs") maxNum = 50;
301      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
302      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
303      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
304
305      else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
306      else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
307      else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
308      else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
331  
332 <      currentObject.at(0) = toupper(currentObject.at(0));
332 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
333 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
334 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
335 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
336 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
337 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
338 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
339 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
340 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
341 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
342 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
343 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
344 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
345 >
346 >      currentObject.at(0) = toupper(currentObject.at(0));  
347        string histoName = "num" + currentObject;
348  
349        if(histoName == "numPrimaryvertexs"){
# Line 331 | Line 367 | muonSFFile_ (cfg.getParameter<std::strin
367        cut tempCut;
368        //store input collection for cut
369        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
370 +      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
371 +      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
372 +      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
373 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
374        tempCut.inputCollection = tempInputCollection;
375        if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
376 <        objectsToGet.push_back(tempInputCollection);
377 <        objectsToCut.push_back(tempInputCollection);
376 >        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
377 >          int spaceIndex = tempInputCollection.find(" ");
378 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
379 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
380 >        }
381 >        else{
382 >          objectsToGet.push_back(tempInputCollection);
383 >        }
384 >        objectsToCut.push_back(tempInputCollection);
385        }
386 <      else{//pair of objects, need to add them both to the things to objectsToGet
387 <        int dashIndex = tempInputCollection.find("-");
388 <        int spaceIndex = tempInputCollection.find(" ");
389 <        int secondWordLength = spaceIndex - dashIndex;
390 <        objectsToGet.push_back(tempInputCollection);
344 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
345 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
386 >      else{//pair of objects, need to add them both to objectsToGet
387 >        string obj1;
388 >        string obj2;
389 >        getTwoObjs(tempInputCollection, obj1, obj2);
390 >        string obj2ToGet = getObjToGet(obj2);  
391          objectsToCut.push_back(tempInputCollection);
392 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
393 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
392 >        objectsToCut.push_back(obj1);
393 >        objectsToCut.push_back(obj2);  
394 >        objectsToGet.push_back(tempInputCollection);
395 >        objectsToGet.push_back(obj1);
396 >        objectsToGet.push_back(obj2ToGet);
397  
398        }
399  
# Line 402 | Line 450 | muonSFFile_ (cfg.getParameter<std::strin
450        }
451        tempCut.name = tempCutName;
452  
405
453        tempChannel.cuts.push_back(tempCut);
454  
455  
409
456      }//end loop over cuts
457  
458      channels.push_back(tempChannel);
# Line 482 | Line 528 | OSUAnalysis::analyze (const edm::Event &
528    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
529      event.getByLabel (superclusters_, superclusters);
530  
531 +  if (datasetType_ == "signalMC"){
532 +    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
533 +      event.getByLabel (stops_, stops);
534 +  }
535 +
536 +
537 +  if (useTrackCaloRhoCorr_) {  
538 +    // Used only for pile-up correction of by-hand calculation of isolation energy.  
539 +    // This rho collection is not available in all BEANs.  
540 +    // For description of rho values for different jet reconstruction algorithms, see
541 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
542 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
543 +  }
544 +
545 +
546    //get pile-up event weight
547    double scaleFactor = 1.00;
548    if(doPileupReweighting_ && datasetType_ != "data")
549      scaleFactor = puWeight_->at (events->at (0).numTruePV);
550  
551 +  cTauScaleFactor_ = 1.0;
552 + #ifdef DISPLACED_SUSY
553 +  if (datasetType_ == "signalMC")
554 +    cTauScaleFactor_ = cTauWeight_->at (event);
555 + #endif
556 +  scaleFactor *= cTauScaleFactor_;
557  
558    //loop over all channels
559  
# Line 525 | Line 592 | OSUAnalysis::analyze (const edm::Event &
592  
593  
594          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
595 +
596          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
597 +
598 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
599 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
600          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
601          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
602          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 538 | Line 609 | OSUAnalysis::analyze (const edm::Event &
609          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
610          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
611  
612 +        else if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
613 +
614  
615          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
616                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
617                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
618                                                                     "muon-muon pairs");
619 +
620 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
621 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
622 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
623 +                                                                   "muon-secondary muon pairs");
624 +
625 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
626 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
627 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
628 +                                                                   "electron-secondary electron pairs");
629 +
630          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
631                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
632                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 551 | Line 635 | OSUAnalysis::analyze (const edm::Event &
635                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
636                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
637                                                                         "electron-muon pairs");
638 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(), \
639 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
640 <                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
641 <                                                                       "electron-track pairs");
642 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(), \
643 <                                                                        cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
644 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
645 <                                                                        "muon-track pairs");
646 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(), \
647 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
648 <                                                                    cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
649 <                                                                    "muon-tau pairs");
650 <
651 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(), \
652 <                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
653 <                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
654 <                                                                        "tau-tau pairs");
655 <
656 <
638 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
639 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
640 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
641 >                                                                     "track-event pairs");
642 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
643 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
644 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
645 >                                                                        "electron-track pairs");
646 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
647 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
648 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
649 >                                                                    "muon-track pairs");
650 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
651 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
652 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
653 >                                                                  "muon-tau pairs");
654 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
655 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
656 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
657 >                                                                 "tau-tau pairs");
658 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
659 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
660 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
661 >                                                                 "tau-track pairs");
662 >        
663 >        
664        }
665  
666  
# Line 585 | Line 676 | OSUAnalysis::analyze (const edm::Event &
676      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
677  
678  
588
679      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
680  
681        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 593 | Line 683 | OSUAnalysis::analyze (const edm::Event &
683        int numberPassing = 0;
684  
685        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
686 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
686 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
687        }
598
688        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
689        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
601
690        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
691  
692      }
693  
694 +    //     if(datasetType_ != "data") {
695 +    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
696 +    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
697 +    //     }
698 +
699      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
700  
701  
# Line 619 | Line 712 | OSUAnalysis::analyze (const edm::Event &
712      }
713  
714  
622 //     if(datasetType_ != "data") {
623 //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
624 //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
625 //     }
626
715      //filling histograms
716      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
717        histogram currentHistogram = histograms.at(histogramIndex);
# Line 632 | Line 720 | OSUAnalysis::analyze (const edm::Event &
720          TH1D* histo;
721          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
722  
635
636
723          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
724 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
724 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
725 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
726 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
727          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
728                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
729                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
730 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
731 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
732 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
733          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
734          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
735                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
736                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
737 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
738 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
739 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
740          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
741 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
742 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
743 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), \
744 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
745 <                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
746 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), \
747 <                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
748 <                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
749 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), \
750 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
751 <                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
752 <
753 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), \
754 <                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
755 <                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
741 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
742 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
743 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
744 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
745 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
746 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
747 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
748 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
749 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
750 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
751 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
752 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
753 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
754 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
755 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
756 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
757 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
758 >
759          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
760          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
761          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 669 | Line 766 | OSUAnalysis::analyze (const edm::Event &
766          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
767          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
768          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
769 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
770 +
771        }
772        else if(currentHistogram.inputVariables.size() == 2){
773          TH2D* histo;
774          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
775  
677
678
776          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
777          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
778 +        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
779          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
780                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
781                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
782 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
783 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
784 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
785          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
786 +        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
787          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
788                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
789                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
790 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
791 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
792 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
793          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
794 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
795 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
796 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), \
797 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), \
798 <                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
799 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), \
800 <                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), \
801 <                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
802 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), \
803 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), \
804 <                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
805 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), \
806 <                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), \
807 <                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
808 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
794 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
795 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
796 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
797 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
798 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
799 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
800 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
801 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
802 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
803 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
804 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
805 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
806 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
807 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
808 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
809 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
810 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
811 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
812          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
813          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
814          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
815 +        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
816 +                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
817 +                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
818          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
819          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
820          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
821          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
822          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
823          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
824 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
825 +
826        }
827      }
828  
829 +
830 +
831      //fills histograms with the sizes of collections
832      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
833 +
834        string currentObject = objectsToPlot.at(currentObjectIndex);
835  
836 <      string objectToPlot = "";
836 >      string objectToPlot = "";  
837  
838 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
839        if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
840        else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
841 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
842 <      else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
843 <      else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
844 <      else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
845 <      else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
841 >      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
842 >      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
843 >      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
844 >      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
845 >      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
846 >      else if(currentObject == "tau-track pairs")         objectToPlot = "tauTrackPairs";
847 >      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
848 >      else if(currentObject == "muon-secondary muon pairs")       objectToPlot = "muonSecondaryMuonPairs";  
849 >      else if(currentObject == "secondary muons")         objectToPlot = "secondaryMuons";  
850 >      else if(currentObject == "electron-secondary electron pairs")       objectToPlot = "electronSecondaryElectronPairs";  
851 >      else if(currentObject == "secondary electrons")         objectToPlot = "secondaryElectrons";  
852        else objectToPlot = currentObject;
853 +
854        string tempCurrentObject = objectToPlot;
855 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
855 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
856        string histoName = "num" + tempCurrentObject;
857  
734
735
736
858        //set position of primary vertex in event, in order to calculate quantities relative to it
859        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
860          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
861 <        int numToPlot = 0;
861 >        int numToPlot = 0;
862          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
863            if(lastCutFlags.at(currentFlag)) numToPlot++;
864          }
# Line 745 | Line 866 | OSUAnalysis::analyze (const edm::Event &
866            oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
867            oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
868          }
869 <        else
869 >        else {
870            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
871 +        }
872        }
873        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
874        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
875 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
876        else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
877 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
878        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
879 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
880        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
881 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
882        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
883        else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
884        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
# Line 764 | Line 890 | OSUAnalysis::analyze (const edm::Event &
890        else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
891        else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
892        else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
893 +      else if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
894        else if(objectToPlot == "primaryvertexs"){
895          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
896          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
897 <      }
771 <
772 <    }
773 <
774 <
897 >      }
898  
899 +    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
900  
901    } //end loop over channel
902  
903    masterCutFlow_->fillCutFlow(scaleFactor);
904  
905 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
906  
907  
783 }
784
908  
909   bool
910   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 828 | Line 951 | OSUAnalysis::splitString (string inputSt
951  
952   }
953  
954 +
955 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
956 +  // Set two object strings from the tempInputCollection string,
957 +  // For example, if tempInputCollection is "electron-muon pairs",
958 +  // then obj1 = "electrons" and obj2 = "muons".  
959 +  // Note that the objects have an "s" appended.  
960 +
961 +  int dashIndex = tempInputCollection.find("-");
962 +  int spaceIndex = tempInputCollection.find_last_of(" ");
963 +  int secondWordLength = spaceIndex - dashIndex;
964 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
965 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
966 +  
967 + }
968 +
969 +
970 + string OSUAnalysis::getObjToGet(string obj) {
971 +  // Return the string corresponding to the object to get for the given obj string.
972 +  // Right now this only handles the case in which obj contains "secondary",
973 +  // e.g, "secondary muons".  
974 +  // Note that "s" is NOT appended.  
975 +  
976 +  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
977 +  int firstSpaceIndex = obj.find_first_of(" ");  
978 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
979 +
980 + }  
981 +
982 +
983 +
984   double
985   OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
986  
# Line 1124 | Line 1277 | OSUAnalysis::valueLookup (const BNmuon*
1277      if (met)
1278        {
1279          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1280 <                       p2 (met->px, met->py, 0.0, met->pt);
1280 >          p2 (met->px, met->py, 0.0, met->pt);
1281  
1282          value = (p1 + p2).Mt ();
1283        }
# Line 1244 | Line 1397 | OSUAnalysis::valueLookup (const BNmuon*
1397      value = object->isGlobalMuon > 0                \
1398        && object->isPFMuon > 0                        \
1399        && object->normalizedChi2 < 10                \
1400 <      && object->numberOfValidMuonHits > 0        \
1400 >                                  && object->numberOfValidMuonHits > 0        \
1401        && object->numberOfMatchedStations > 1        \
1402        && fabs(object->correctedD0Vertex) < 0.2        \
1403        && fabs(object->correctedDZ) < 0.5        \
# Line 1254 | Line 1407 | OSUAnalysis::valueLookup (const BNmuon*
1407    else if(variable == "tightIDdisplaced"){
1408      value = object->isGlobalMuon > 0                \
1409        && object->normalizedChi2 < 10                \
1410 <      && object->numberOfValidMuonHits > 0        \
1410 >                                  && object->numberOfValidMuonHits > 0        \
1411        && object->numberOfMatchedStations > 1        \
1412        && object->numberOfValidPixelHits > 0        \
1413        && object->numberOfLayersWithMeasurement > 5;
# Line 1281 | Line 1434 | OSUAnalysis::valueLookup (const BNmuon*
1434    else if(variable == "genMatchedMotherIdReverse"){
1435      int index = getGenMatchedParticleIndex(object);
1436      if(index == -1) value = 23;
1437 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1437 >    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1438    }
1439    else if(variable == "genMatchedGrandmotherId"){
1440      int index = getGenMatchedParticleIndex(object);
# Line 1293 | Line 1446 | OSUAnalysis::valueLookup (const BNmuon*
1446      }
1447      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1448    }
1449 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1450 +    int index = getGenMatchedParticleIndex(object);
1451 +    if(index == -1) value = 23;
1452 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1453 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1454 +      if(motherIndex == -1) value = 23;
1455 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1456 +    }
1457 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1458 +  }
1459  
1460  
1461  
# Line 1475 | Line 1638 | OSUAnalysis::valueLookup (const BNelectr
1638      if (met)
1639        {
1640          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1641 <                       p2 (met->px, met->py, 0.0, met->pt);
1641 >          p2 (met->px, met->py, 0.0, met->pt);
1642  
1643          value = (p1 + p2).Mt ();
1644        }
# Line 1676 | Line 1839 | OSUAnalysis::valueLookup (const BNelectr
1839      }
1840      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1841    }
1842 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1843 +    int index = getGenMatchedParticleIndex(object);
1844 +    if(index == -1) value = 23;
1845 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1846 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1847 +      if(motherIndex == -1) value = 23;
1848 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1849 +    }
1850 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1851 +  }
1852  
1853  
1854  
# Line 1765 | Line 1938 | OSUAnalysis::valueLookup (const BNevent*
1938    else if(variable == "muonScaleFactor"){
1939      if(datasetType_ != "data")
1940        //      value = muonSFWeight_->at (chosenMuon ()->eta);
1941 <    value = 1.0;
1941 >      value = 1.0;
1942      else
1943        value = 1.0;
1944    }
1945    else if(variable == "electronScaleFactor"){
1946      if(datasetType_ != "data")
1947        //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1948 <    value = 1.0;
1948 >      value = 1.0;
1949      else
1950        value = 1.0;
1951    }
1952 +  else if(variable == "cTauScaleFactor")
1953 +    value = cTauScaleFactor_;
1954  
1955    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1956  
# Line 1864 | Line 2039 | OSUAnalysis::valueLookup (const BNtau* o
2039      }
2040      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2041    }
2042 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2043 +    int index = getGenMatchedParticleIndex(object);
2044 +    if(index == -1) value = 23;
2045 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2046 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2047 +      if(motherIndex == -1) value = 23;
2048 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2049 +    }
2050 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2051 +  }
2052  
2053  
2054    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1950 | Line 2135 | OSUAnalysis::valueLookup (const BNtrack*
2135  
2136    double value = 0.0;
2137    double pMag = sqrt(object->pt * object->pt +
2138 <                         object->pz * object->pz);
2139 <
2138 >                     object->pz * object->pz);
2139 >  
2140    if(variable == "pt") value = object->pt;
2141    else if(variable == "px") value = object->px;
2142    else if(variable == "py") value = object->py;
# Line 1987 | Line 2172 | OSUAnalysis::valueLookup (const BNtrack*
2172    //user defined variables
2173    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;
2174    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2175 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2176 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2177 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2178 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2179 <  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2180 <  else if(variable == "ptError") value = object->ptError;
2181 <  else if(variable == "ptRes") value = getTrkPtRes(object);
2182 <
2183 <  else if (variable == "d0wrtPV"){
2184 <    double vx = object->vx - chosenVertex ()->x,
2185 <      vy = object->vy - chosenVertex ()->y,
2186 <      px = object->px,
2187 <      py = object->py,
2188 <      pt = object->pt;
2189 <    value = (-vx * py + vy * px) / pt;
2190 <  }
2191 <  else if (variable == "dZwrtPV"){
2192 <    double vx = object->vx - chosenVertex ()->x,
2193 <      vy = object->vy - chosenVertex ()->y,
2194 <      vz = object->vz - chosenVertex ()->z,
2195 <      px = object->px,
2196 <      py = object->py,
2197 <      pz = object->pz,
2198 <      pt = object->pt;
2199 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2200 <  }
2201 <
2017 <
2018 <
2175 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2176 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2177 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2178 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2179 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2180 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2181 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2182 >  else if(variable == "ptError")                    value = object->ptError;
2183 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2184 >  else if (variable == "d0wrtPV"){      
2185 >    double vx = object->vx - chosenVertex ()->x,        
2186 >      vy = object->vy - chosenVertex ()->y,      
2187 >      px = object->px,  
2188 >      py = object->py,  
2189 >      pt = object->pt;  
2190 >    value = (-vx * py + vy * px) / pt;  
2191 >  }      
2192 >  else if (variable == "dZwrtPV"){      
2193 >    double vx = object->vx - chosenVertex ()->x,        
2194 >      vy = object->vy - chosenVertex ()->y,      
2195 >      vz = object->vz - chosenVertex ()->z,      
2196 >      px = object->px,  
2197 >      py = object->py,  
2198 >      pz = object->pz,  
2199 >      pt = object->pt;  
2200 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2201 >  }    
2202    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2203  
2204    else if(variable == "genMatchedPdgId"){
# Line 2024 | Line 2207 | OSUAnalysis::valueLookup (const BNtrack*
2207      else value = mcparticles->at(index).id;
2208    }
2209  
2210 +
2211    else if(variable == "genMatchedId"){
2212      int index = getGenMatchedParticleIndex(object);
2213      if(index == -1) value = 0;
# Line 2049 | Line 2233 | OSUAnalysis::valueLookup (const BNtrack*
2233      }
2234      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2235    }
2236 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2237 +    int index = getGenMatchedParticleIndex(object);
2238 +    if(index == -1) value = 23;
2239 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2240 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2241 +      if(motherIndex == -1) value = 23;
2242 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2243 +    }
2244 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2245 +  }
2246  
2247  
2248  
# Line 2338 | Line 2532 | OSUAnalysis::valueLookup (const BNphoton
2532    else if(variable == "isEEGap") value = object->isEEGap;
2533    else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
2534    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2535 +
2536 +
2537  
2538  
2539    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
# Line 2347 | Line 2543 | OSUAnalysis::valueLookup (const BNphoton
2543      if(index == -1) value = 0;
2544      else value = mcparticles->at(index).id;
2545    }
2546 +
2547 +
2548 +
2549    else if(variable == "genMatchedId"){
2550      int index = getGenMatchedParticleIndex(object);
2551      if(index == -1) value = 0;
# Line 2372 | Line 2571 | OSUAnalysis::valueLookup (const BNphoton
2571      }
2572      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2573    }
2574 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2575 +    int index = getGenMatchedParticleIndex(object);
2576 +    if(index == -1) value = 23;
2577 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2578 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2579 +      if(motherIndex == -1) value = 23;
2580 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2581 +    }
2582 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2583 +  }
2584  
2585  
2586    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2410 | Line 2619 | OSUAnalysis::valueLookup (const BNmuon*
2619    double value = 0.0;
2620  
2621    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2622 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2623    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2624    else if(variable == "invMass"){
2625      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2419 | Line 2629 | OSUAnalysis::valueLookup (const BNmuon*
2629    else if(variable == "pt"){
2630      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2631      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2632 <    value = (fourVector1 + fourVector2).Et();
2632 >    value = (fourVector1 + fourVector2).Pt();
2633    }
2634    else if(variable == "threeDAngle")
2635      {
# Line 2451 | Line 2661 | OSUAnalysis::valueLookup (const BNmuon*
2661    else if(variable == "muon2CorrectedD0Vertex"){
2662      value = object2->correctedD0Vertex;
2663    }
2664 < else if(variable == "muon1timeAtIpInOut"){
2664 >  else if(variable == "muon1timeAtIpInOut"){
2665      value = object1->timeAtIpInOut;
2666    }
2667 < else if(variable == "muon2timeAtIpInOut"){
2667 >  else if(variable == "muon2timeAtIpInOut"){
2668      value = object2->timeAtIpInOut;
2669    }
2670 < else if(variable == "muon1correctedD0")
2671 <   {
2672 <     value = object1->correctedD0;
2673 <   }
2674 < else if(variable == "muon2correctedD0")
2675 <   {
2676 <     value = object2->correctedD0;
2677 <   }
2670 >  else if(variable == "muon1correctedD0")
2671 >    {
2672 >      value = object1->correctedD0;
2673 >    }
2674 >  else if(variable == "muon2correctedD0")
2675 >    {
2676 >      value = object2->correctedD0;
2677 >    }
2678  
2679    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2680  
# Line 2479 | Line 2689 | OSUAnalysis::valueLookup (const BNelectr
2689    double value = 0.0;
2690  
2691    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2692 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2693    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2694    else if(variable == "invMass"){
2695      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2488 | Line 2699 | OSUAnalysis::valueLookup (const BNelectr
2699    else if(variable == "pt"){
2700      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2701      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2702 <    value = (fourVector1 + fourVector2).Et();
2702 >    value = (fourVector1 + fourVector2).Pt();
2703    }
2704    else if(variable == "threeDAngle")
2705      {
# Line 2533 | Line 2744 | OSUAnalysis::valueLookup (const BNelectr
2744    double value = 0.0;
2745  
2746    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2747 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2748    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2749    else if(variable == "invMass"){
2750      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2542 | Line 2754 | OSUAnalysis::valueLookup (const BNelectr
2754    else if(variable == "pt"){
2755      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2756      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2757 <    value = (fourVector1 + fourVector2).Et();
2757 >    value = (fourVector1 + fourVector2).Pt();
2758    }
2759    else if(variable == "threeDAngle")
2760      {
# Line 2579 | Line 2791 | OSUAnalysis::valueLookup (const BNelectr
2791    else if(variable == "muonDetIso"){
2792      value = (object2->trackIsoDR03) / object2->pt;
2793    }
2794 <
2794 >  else if(variable == "electronRelPFrhoIso"){
2795 >    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2796 >  }
2797 >  else if(variable == "muonRelPFdBetaIso"){
2798 >    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2799 >  }
2800  
2801    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2802  
# Line 2589 | Line 2806 | OSUAnalysis::valueLookup (const BNelectr
2806   }
2807  
2808  
2809 < double
2810 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){
2811 <  double electronMass = 0.000511;
2812 <  double value = 0.0;
2813 <  TLorentzVector fourVector1(0, 0, 0, 0);  
2814 <  TLorentzVector fourVector2(0, 0, 0, 0);  
2815 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2816 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2817 <  else if(variable == "invMass"){
2818 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
2819 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
2820 <    
2821 <    value = (fourVector1 + fourVector2).M();
2822 <  }
2823 <  
2824 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2825 <  value = applyFunction(function, value);
2826 <  return value;
2809 > double  
2810 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2811 >  double electronMass = 0.000511;        
2812 >  double value = 0.0;    
2813 >  TLorentzVector fourVector1(0, 0, 0, 0);        
2814 >  TLorentzVector fourVector2(0, 0, 0, 0);        
2815 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2816 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2817 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2818 >  else if(variable == "invMass"){        
2819 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2820 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2821 >        
2822 >    value = (fourVector1 + fourVector2).M();    
2823 >  }
2824 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2825 >  value = applyFunction(function, value);        
2826 >  return value;  
2827   }
2828  
2829 +
2830 +
2831   double
2832   OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2833    double pionMass = 0.140;
# Line 2617 | Line 2836 | OSUAnalysis::valueLookup (const BNmuon*
2836    TLorentzVector fourVector1(0, 0, 0, 0);
2837    TLorentzVector fourVector2(0, 0, 0, 0);
2838    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2839 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2840    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2841    else if(variable == "invMass"){
2842      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
# Line 2635 | Line 2855 | double
2855   OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2856    double value = 0.0;
2857    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2858 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2859    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2860    else if(variable == "invMass"){
2861 <  TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2862 <  TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2863 <     value = (fourVector1 + fourVector2).M();
2861 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2862 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2863 >    value = (fourVector1 + fourVector2).M();
2864    }
2865  
2866    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2647 | Line 2868 | OSUAnalysis::valueLookup (const BNtau* o
2868    return value;
2869   }
2870  
2871 +
2872   double
2873   OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2874    double value = 0.0;
2875    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2876 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2877    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2878    else if(variable == "invMass"){
2879      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2663 | Line 2886 | OSUAnalysis::valueLookup (const BNmuon*
2886    return value;
2887   }
2888  
2889 + double
2890 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
2891 +  double value = 0.0;
2892 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2893 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2894 +
2895 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2896 +  value = applyFunction(function, value);
2897 +  return value;
2898 + }
2899 +
2900 +
2901 +
2902 + double
2903 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2904 +
2905 +  double value = 0.0;
2906 +  double pMag = sqrt(object1->pt * object1->pt +
2907 +                     object1->pz * object1->pz);  
2908 +
2909 +  if      (variable == "numPV")                      value = object2->numPV;
2910 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2911 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2912 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2913 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2914 +
2915 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2916 +
2917 +  value = applyFunction(function, value);
2918 +
2919 +  return value;
2920 +
2921 + }  
2922 +
2923 + double
2924 + OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
2925 +
2926 +
2927 +  double value = 0.0;
2928 +
2929 +  if(variable == "ctau") value = object->ctau;
2930 +
2931 +  else if (variable == "d0"){
2932 +    double vx = object->vx - chosenVertex ()->x,
2933 +      vy = object->vy - chosenVertex ()->y,
2934 +      px = object->px,
2935 +      py = object->py,
2936 +      pt = object->pt;
2937 +    value = (-vx * py + vy * px) / pt;
2938 +  }
2939 +
2940 +  else if (variable == "dz"){
2941 +    double vx = object->vx - chosenVertex ()->x,
2942 +      vy = object->vy - chosenVertex ()->y,
2943 +      vz = object->vz - chosenVertex ()->z,
2944 +      px = object->px,
2945 +      py = object->py,
2946 +      pz = object->pz,
2947 +      pt = object->pt;
2948 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2949 +  }
2950 +
2951 +  else if (variable == "minD0"){
2952 +    double minD0=999;
2953 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2954 +      double vx = object->vx - vertex->x,
2955 +        vy = object->vy - vertex->y,
2956 +        px = object->px,
2957 +        py = object->py,
2958 +        pt = object->pt;
2959 +      value = (-vx * py + vy * px) / pt;
2960 +      if(abs(value) < abs(minD0)) minD0 = value;
2961 +    }
2962 +    value = minD0;
2963 +  }
2964 +  else if (variable == "minDz"){
2965 +    double minDz=999;
2966 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2967 +      double vx = object->vx - vertex->x,
2968 +        vy = object->vy - vertex->y,
2969 +        vz = object->vz - vertex->z,
2970 +        px = object->px,
2971 +        py = object->py,
2972 +        pz = object->pz,
2973 +        pt = object->pt;
2974 +      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2975 +      if(abs(value) < abs(minDz)) minDz = value;
2976 +    }
2977 +    value = minDz;
2978 +  }
2979 +  else if(variable == "distToVertex"){
2980 +    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
2981 +                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
2982 +                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
2983 +  }
2984 +  else if (variable == "minDistToVertex"){
2985 +    double minDistToVertex=999;
2986 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2987 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
2988 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
2989 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
2990 +      
2991 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
2992 +    }
2993 +    value = minDistToVertex;
2994 +  }
2995 +  else if (variable == "distToVertexDifference"){
2996 +    double minDistToVertex=999;
2997 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2998 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
2999 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3000 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3001 +      
3002 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3003 +    }
3004 +    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3005 +                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3006 +                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3007 +
3008 +    value = distToChosenVertex - minDistToVertex;
3009 +  }
3010 +
3011 +  else if (variable == "closestVertexRank"){
3012 +    double minDistToVertex=999;
3013 +    int vertex_rank = 0;
3014 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3015 +      vertex_rank++;
3016 +      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3017 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3018 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3019 +      
3020 +      if(abs(dist) < abs(minDistToVertex)){
3021 +        value = vertex_rank;
3022 +        minDistToVertex = dist;
3023 +      }
3024 +    }
3025 +  }
3026 +
3027 +
3028 +
3029 +
3030 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3031 +
3032 +  value = applyFunction(function, value);
3033 +
3034 +  return value;
3035 +
3036 + }  
3037 +
3038 +
3039  
3040  
3041   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
# Line 2710 | Line 3083 | OSUAnalysis::getTrkPtTrue (const BNtrack
3083  
3084   }
3085  
3086 + double
3087 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3088 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3089 +  if (!useTrackCaloRhoCorr_) return -99;  
3090 +  // if (!rhokt6CaloJetsHandle_) {
3091 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3092 +  //   return -99;  
3093 +  // }
3094 +  double radDeltaRCone = 0.5;  
3095 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3096 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3097 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3098 +  return caloTotRhoCorrCalo;  
3099 +
3100 + }
3101 +
3102 +
3103 +
3104 +
3105   //creates a map of the dead Ecal channels in the barrel and endcap
3106   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
3107   //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
# Line 2753 | Line 3145 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3145    return value;
3146   }
3147  
2756
3148   // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3149   template <class InputObject>
3150   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
# Line 2761 | Line 3152 | double OSUAnalysis::getGenDeltaRLowest(I
3152    for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3153      double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3154      if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3155 < }
3155 >  }
3156    return genDeltaRLowest;
3157   }
3158  
2768
3159   double
3160   OSUAnalysis::applyFunction(string function, double value){
3161  
# Line 2784 | Line 3174 | OSUAnalysis::applyFunction(string functi
3174  
3175   template <class InputCollection>
3176   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3177 <
3177 >
3178 >  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3179 >    string obj1, obj2;
3180 >    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3181 >    if (inputType==obj1 ||
3182 >        inputType==obj2) {
3183 >      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3184 >      // and the inputType is a member of the pair.  
3185 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3186 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3187 >      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3188 >      return;
3189 >    }  
3190 >  }    
3191  
3192    for (uint object = 0; object != inputCollection->size(); object++){
3193  
2791
3194      bool decision = true;//object passes if this cut doesn't cut on that type of object
3195  
2794
3196      if(currentCut.inputCollection == inputType){
3197  
3198        vector<bool> subcutDecisions;
3199        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3200          double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3201          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3202 +
3203        }
3204        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3205        else{
# Line 2811 | Line 3213 | void OSUAnalysis::setObjectFlags(cut &cu
3213          decision = tempDecision;
3214        }
3215      }
2814    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3216  
3217 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3218  
3219      //set flags for objects that pass each cut AND all the previous cuts
3220      bool previousCumulativeFlag = true;
# Line 2822 | Line 3224 | void OSUAnalysis::setObjectFlags(cut &cu
3224      }
3225      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3226  
2825
3227    }
3228  
3229   }
# Line 2836 | Line 3237 | void OSUAnalysis::setObjectFlags(cut &cu
3237    bool sameObjects = false;
3238    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3239  
3240 <
3240 >  // Get the strings for the two objects that make up the pair.  
3241 >  string obj1Type, obj2Type;
3242 >  getTwoObjs(inputType, obj1Type, obj2Type);
3243 >  bool isTwoTypesOfObject = true;
3244 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3245 >
3246 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3247 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3248 >  if (currentCut.inputCollection == inputType) {    
3249 >    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3250 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3251 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3252 >    }
3253 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3254 >      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3255 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3256 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3257 >      }
3258 >    }
3259 >  }
3260 >  
3261    int counter = 0;
3262 +
3263    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3264      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3265  
# Line 2866 | Line 3288 | void OSUAnalysis::setObjectFlags(cut &cu
3288            decision = tempDecision;
3289          }
3290        }
3291 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3291 >      // if (decision) isPassObj1.at(object1) = true;
3292 >      // if (decision) isPassObj2.at(object2) = true;
3293 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3294 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3295 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3296 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3297 >      }  
3298  
3299        //set flags for objects that pass each cut AND all the previous cuts
3300        bool previousCumulativeFlag = true;
# Line 2881 | Line 3309 | void OSUAnalysis::setObjectFlags(cut &cu
3309        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3310        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3311        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3312 <
3312 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3313 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3314 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3315 >      }
3316        counter++;
2886    }
2887
2888  }
3317  
3318 +    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3319 +  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3320  
3321   }
3322  
3323  
3324 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3325 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3326 +  // all cuts up to currentCutIndex  
3327 +  bool previousCumulativeFlag = true;  
3328 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3329 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3330 +    else {  
3331 +      previousCumulativeFlag = false; break;  
3332 +    }
3333 +  }
3334 +  return previousCumulativeFlag;  
3335 + }  
3336 +
3337 +
3338   template <class InputCollection>
3339   void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3340  
# Line 2927 | Line 3371 | void OSUAnalysis::fill1DHistogram(TH1* h
3371    bool sameObjects = false;
3372    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3373  
3374 <  int pairCounter = 0;
3374 >  int pairCounter = -1;
3375    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3376      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3377  
3378        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3379  
3380 +      pairCounter++;
3381        //only take objects which have passed all cuts and pairs which have passed all cuts
3382        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3383        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2953 | Line 3398 | void OSUAnalysis::fill1DHistogram(TH1* h
3398        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3399        histo->Fill(value,scaleFactor);
3400  
2956      pairCounter++;
3401      }
3402    }
3403  
# Line 3006 | Line 3450 | void OSUAnalysis::fill2DHistogram(TH2* h
3450    bool sameObjects = false;
3451    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3452  
3453 <  int pairCounter = 0;
3453 >  int pairCounter = -1;
3454    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3455      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3456  
3457        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3458  
3459 +      pairCounter++;
3460 +
3461        //only take objects which have passed all cuts and pairs which have passed all cuts
3462        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3463        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 3046 | Line 3492 | void OSUAnalysis::fill2DHistogram(TH2* h
3492  
3493        histo->Fill(valueX,valueY,scaleFactor);
3494  
3049      pairCounter++;
3050
3495      }
3496    }
3497  
# Line 3064 | Line 3508 | int OSUAnalysis::getGenMatchedParticleIn
3508  
3509      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3510      if(currentDeltaR > 0.05) continue;
3511 < //     cout << std::setprecision(3) << std::setw(20)
3512 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3513 < //          << std::setw(20)
3514 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3515 < //          << std::setw(20)
3516 < //          << "\tdeltaR = " << currentDeltaR
3517 < //          << std::setprecision(1)
3518 < //          << std::setw(20)
3519 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3520 < //          << std::setw(20)
3521 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3522 < //          << std::setw(20)
3523 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3511 >    //     cout << std::setprecision(3) << std::setw(20)
3512 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3513 >    //          << std::setw(20)
3514 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3515 >    //          << std::setw(20)
3516 >    //          << "\tdeltaR = " << currentDeltaR
3517 >    //          << std::setprecision(1)
3518 >    //          << std::setw(20)
3519 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3520 >    //          << std::setw(20)
3521 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3522 >    //          << std::setw(20)
3523 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3524      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3525        bestMatchIndex = mcparticle - mcparticles->begin();
3526        bestMatchDeltaR = currentDeltaR;
3527      }
3528  
3529    }
3530 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3531 < //   else cout << "no match found..." << endl;
3530 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3531 >  //   else cout << "no match found..." << endl;
3532    return bestMatchIndex;
3533  
3534   }
# Line 3175 | Line 3619 | OSUAnalysis::chosenVertex ()
3619    const BNprimaryvertex *chosenVertex = 0;
3620    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3621      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3622 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3622 >      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3623      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3624        if(!vertexFlags.at(vertexIndex)) continue;
3625        chosenVertex = & primaryvertexs->at(vertexIndex);
# Line 3195 | Line 3639 | OSUAnalysis::chosenMET ()
3639    const BNmet *chosenMET = 0;
3640    if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3641      vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3642 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3642 >      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3643      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3644        if(!metFlags.at(metIndex)) continue;
3645        chosenMET = & mets->at(metIndex);
# Line 3215 | Line 3659 | OSUAnalysis::chosenElectron ()
3659    const BNelectron *chosenElectron = 0;
3660    if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3661      vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3662 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3662 >      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3663      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3664        if(!electronFlags.at(electronIndex)) continue;
3665        chosenElectron = & electrons->at(electronIndex);
# Line 3235 | Line 3679 | OSUAnalysis::chosenMuon ()
3679    const BNmuon *chosenMuon = 0;
3680    if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3681      vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3682 <                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3682 >      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3683      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3684        if(!muonFlags.at(muonIndex)) continue;
3685        chosenMuon = & muons->at(muonIndex);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines