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.45 by ahart, Thu Apr 11 00:56:48 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
# 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 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.find("pairs")==std::string::npos){ //just a single object
76        objectsToGet.push_back(tempInputCollection);
77        objectsToPlot.push_back(tempInputCollection);
# Line 83 | Line 91 | muonSFFile_ (cfg.getParameter<std::strin
91        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
92        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
93  
94 <      }
94 >    }
95  
96      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
97  
# Line 222 | Line 230 | muonSFFile_ (cfg.getParameter<std::strin
230  
231        if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
232  
233 < // bin      particle type
234 < // ---      -------------
235 < //  0        unmatched
236 < //  1        u
237 < //  2        d
238 < //  3        s
239 < //  4        c
240 < //  5        b
241 < //  6        t
242 < //  7        e
243 < //  8        mu
244 < //  9        tau
245 < // 10        nu
246 < // 11        g
247 < // 12        gamma
248 < // 13        Z
249 < // 14        W
250 < // 15        light meson
251 < // 16        K meson
252 < // 17        D meson
253 < // 18        B meson
254 < // 19        light baryon
255 < // 20        strange baryon
256 < // 21        charm baryon
257 < // 22        bottom baryon
258 < // 23        other
233 >      // bin      particle type
234 >      // ---      -------------
235 >      //  0        unmatched
236 >      //  1        u
237 >      //  2        d
238 >      //  3        s
239 >      //  4        c
240 >      //  5        b
241 >      //  6        t
242 >      //  7        e
243 >      //  8        mu
244 >      //  9        tau
245 >      // 10        nu
246 >      // 11        g
247 >      // 12        gamma
248 >      // 13        Z
249 >      // 14        W
250 >      // 15        light meson
251 >      // 16        K meson
252 >      // 17        D meson
253 >      // 18        B meson
254 >      // 19        light baryon
255 >      // 20        strange baryon
256 >      // 21        charm baryon
257 >      // 22        bottom baryon
258 >      // 23        other
259  
260        vector<TString> labelArray;
261        labelArray.push_back("unmatched");
# Line 291 | Line 299 | muonSFFile_ (cfg.getParameter<std::strin
299  
300      }
301  
302 <    //book a histogram for the number of each object type to be plotted
303 <
302 >    // Book a histogram for the number of each object type to be plotted.  
303 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
304      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
305        string currentObject = objectsToPlot.at(currentObjectIndex);
306        int maxNum = 10;
# Line 300 | Line 308 | muonSFFile_ (cfg.getParameter<std::strin
308        else if(currentObject == "primaryvertexs") maxNum = 50;
309        else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
310        else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
311 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
312 <
313 <      else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
314 <      else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
315 <      else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
316 <      else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
317 <
310 <      currentObject.at(0) = toupper(currentObject.at(0));
311 >      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
312 >      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
313 >      else if(currentObject == "electron-track pairs")    currentObject = "electronTrackPairs";  
314 >      else if(currentObject == "muon-track pairs")        currentObject = "muonTrackPairs";      
315 >      else if(currentObject == "muon-tau pairs")          currentObject = "muonTauPairs";        
316 >      else if(currentObject == "tau-tau pairs")           currentObject = "ditauPairs";
317 >      currentObject.at(0) = toupper(currentObject.at(0));  
318        string histoName = "num" + currentObject;
319  
320        if(histoName == "numPrimaryvertexs"){
# Line 482 | Line 489 | OSUAnalysis::analyze (const edm::Event &
489    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
490      event.getByLabel (superclusters_, superclusters);
491  
492 +  if (useTrackCaloRhoCorr_) {  
493 +    // Used only for pile-up correction of by-hand calculation of isolation energy.  
494 +    // This rho collection is not available in all BEANs.  
495 +    // For description of rho values for different jet reconstruction algorithms, see
496 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
497 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
498 +  }
499 +
500 +
501    //get pile-up event weight
502    double scaleFactor = 1.00;
503    if(doPileupReweighting_ && datasetType_ != "data")
504      scaleFactor = puWeight_->at (events->at (0).numTruePV);
505  
506 +  cTauScaleFactor_ = 1.0;
507 + #ifdef DISPLACED_SUSY
508 +  if (datasetType_ == "signalMC")
509 +    cTauScaleFactor_ = cTauWeight_->at (event);
510 + #endif
511 +  scaleFactor *= cTauScaleFactor_;
512  
513    //loop over all channels
514  
# Line 551 | Line 573 | OSUAnalysis::analyze (const edm::Event &
573                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
574                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
575                                                                         "electron-muon pairs");
576 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(), \
577 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
578 <                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
579 <                                                                       "electron-track pairs");
580 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(), \
581 <                                                                        cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
582 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
583 <                                                                        "muon-track pairs");
584 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(), \
585 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
586 <                                                                    cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
587 <                                                                    "muon-tau pairs");
588 <
589 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(), \
590 <                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
591 <                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
592 <                                                                        "tau-tau pairs");
593 <
594 <
576 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
577 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
578 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
579 >                                                                     "track-event pairs");
580 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
581 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
582 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
583 >                                                                        "electron-track pairs");
584 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
585 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
586 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
587 >                                                                    "muon-track pairs");
588 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
589 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
590 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
591 >                                                                  "muon-tau pairs");
592 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
593 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
594 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
595 >                                                                 "tau-tau pairs");
596 >        
597 >        
598        }
599  
600  
# Line 593 | Line 618 | OSUAnalysis::analyze (const edm::Event &
618        int numberPassing = 0;
619  
620        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
621 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
621 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
622        }
623  
624        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
# Line 603 | Line 628 | OSUAnalysis::analyze (const edm::Event &
628  
629      }
630  
631 +    //     if(datasetType_ != "data") {
632 +    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
633 +    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
634 +    //     }
635 +
636      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
637  
638  
# Line 619 | Line 649 | OSUAnalysis::analyze (const edm::Event &
649      }
650  
651  
622 //     if(datasetType_ != "data") {
623 //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
624 //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
625 //     }
626
652      //filling histograms
653      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
654        histogram currentHistogram = histograms.at(histogramIndex);
# Line 635 | Line 660 | OSUAnalysis::analyze (const edm::Event &
660  
661  
662          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
663 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
663 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
664          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
665                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
666                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
# Line 644 | Line 669 | OSUAnalysis::analyze (const edm::Event &
669                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
670                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
671          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
672 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
673 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
674 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), \
675 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
676 <                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
677 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), \
678 <                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
679 <                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
680 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), \
681 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
682 <                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
683 <
684 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), \
685 <                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
661 <                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
672 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
673 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
674 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
675 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
676 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
677 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
678 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
679 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
680 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
681 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
682 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
683 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
684 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
685 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
686          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
687          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
688          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 686 | Line 710 | OSUAnalysis::analyze (const edm::Event &
710                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
711                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
712          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
713 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
714 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
715 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), \
716 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), \
717 <                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
718 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), \
719 <                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), \
720 <                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
721 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), \
722 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), \
723 <                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
724 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), \
725 <                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), \
726 <                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
727 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
713 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
714 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
715 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
716 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
717 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
718 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
719 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
720 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
721 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
722 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
723 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
724 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
725 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
726 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
727 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
728          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
729          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
730          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
731 +        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
732 +                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
733 +                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
734          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
735          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
736          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
# Line 715 | Line 742 | OSUAnalysis::analyze (const edm::Event &
742  
743      //fills histograms with the sizes of collections
744      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
745 +
746        string currentObject = objectsToPlot.at(currentObjectIndex);
747  
748 <      string objectToPlot = "";
748 >      string objectToPlot = "";  
749  
750 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
751        if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
752        else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
753 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
754 <      else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
755 <      else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
756 <      else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
757 <      else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
753 >      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
754 >      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
755 >      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
756 >      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
757 >      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
758 >      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
759        else objectToPlot = currentObject;
760        string tempCurrentObject = objectToPlot;
761 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
761 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
762        string histoName = "num" + tempCurrentObject;
763  
764  
735
736
765        //set position of primary vertex in event, in order to calculate quantities relative to it
766        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
767          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
# Line 745 | Line 773 | OSUAnalysis::analyze (const edm::Event &
773            oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
774            oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
775          }
776 <        else
776 >        else {
777            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
778 +        }
779        }
780        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
781        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
# Line 767 | Line 796 | OSUAnalysis::analyze (const edm::Event &
796        else if(objectToPlot == "primaryvertexs"){
797          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
798          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
799 <      }
771 <
772 <    }
773 <
774 <
799 >      }
800  
801 +    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
802  
803    } //end loop over channel
804  
805    masterCutFlow_->fillCutFlow(scaleFactor);
806  
807 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
808  
809  
783 }
784
810  
811   bool
812   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 1124 | Line 1149 | OSUAnalysis::valueLookup (const BNmuon*
1149      if (met)
1150        {
1151          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1152 <                       p2 (met->px, met->py, 0.0, met->pt);
1152 >          p2 (met->px, met->py, 0.0, met->pt);
1153  
1154          value = (p1 + p2).Mt ();
1155        }
# Line 1244 | Line 1269 | OSUAnalysis::valueLookup (const BNmuon*
1269      value = object->isGlobalMuon > 0                \
1270        && object->isPFMuon > 0                        \
1271        && object->normalizedChi2 < 10                \
1272 <      && object->numberOfValidMuonHits > 0        \
1272 >                                  && object->numberOfValidMuonHits > 0        \
1273        && object->numberOfMatchedStations > 1        \
1274        && fabs(object->correctedD0Vertex) < 0.2        \
1275        && fabs(object->correctedDZ) < 0.5        \
# Line 1254 | Line 1279 | OSUAnalysis::valueLookup (const BNmuon*
1279    else if(variable == "tightIDdisplaced"){
1280      value = object->isGlobalMuon > 0                \
1281        && object->normalizedChi2 < 10                \
1282 <      && object->numberOfValidMuonHits > 0        \
1282 >                                  && object->numberOfValidMuonHits > 0        \
1283        && object->numberOfMatchedStations > 1        \
1284        && object->numberOfValidPixelHits > 0        \
1285        && object->numberOfLayersWithMeasurement > 5;
# Line 1475 | Line 1500 | OSUAnalysis::valueLookup (const BNelectr
1500      if (met)
1501        {
1502          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1503 <                       p2 (met->px, met->py, 0.0, met->pt);
1503 >          p2 (met->px, met->py, 0.0, met->pt);
1504  
1505          value = (p1 + p2).Mt ();
1506        }
# Line 1765 | Line 1790 | OSUAnalysis::valueLookup (const BNevent*
1790    else if(variable == "muonScaleFactor"){
1791      if(datasetType_ != "data")
1792        //      value = muonSFWeight_->at (chosenMuon ()->eta);
1793 <    value = 1.0;
1793 >      value = 1.0;
1794      else
1795        value = 1.0;
1796    }
1797    else if(variable == "electronScaleFactor"){
1798      if(datasetType_ != "data")
1799        //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1800 <    value = 1.0;
1800 >      value = 1.0;
1801      else
1802        value = 1.0;
1803    }
1804 +  else if(variable == "cTauScaleFactor")
1805 +    value = cTauScaleFactor_;
1806  
1807    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1808  
# Line 1950 | Line 1977 | OSUAnalysis::valueLookup (const BNtrack*
1977  
1978    double value = 0.0;
1979    double pMag = sqrt(object->pt * object->pt +
1980 <                         object->pz * object->pz);
1981 <
1980 >                     object->pz * object->pz);
1981 >  
1982    if(variable == "pt") value = object->pt;
1983    else if(variable == "px") value = object->px;
1984    else if(variable == "py") value = object->py;
# Line 1987 | Line 2014 | OSUAnalysis::valueLookup (const BNtrack*
2014    //user defined variables
2015    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;
2016    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2017 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2018 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2019 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2020 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2021 <  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2022 <  else if(variable == "ptError") value = object->ptError;
2023 <  else if(variable == "ptRes") value = getTrkPtRes(object);
2024 <
2025 <  else if (variable == "d0wrtPV"){
2026 <    double vx = object->vx - chosenVertex ()->x,
2027 <      vy = object->vy - chosenVertex ()->y,
2028 <      px = object->px,
2029 <      py = object->py,
2030 <      pt = object->pt;
2031 <    value = (-vx * py + vy * px) / pt;
2032 <  }
2033 <  else if (variable == "dZwrtPV"){
2034 <    double vx = object->vx - chosenVertex ()->x,
2035 <      vy = object->vy - chosenVertex ()->y,
2036 <      vz = object->vz - chosenVertex ()->z,
2037 <      px = object->px,
2038 <      py = object->py,
2039 <      pz = object->pz,
2040 <      pt = object->pt;
2041 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2042 <  }
2043 <
2017 <
2018 <
2017 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2018 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2019 >  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2020 >  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2021 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2022 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2023 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2024 >  else if(variable == "ptError")                    value = object->ptError;
2025 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2026 >  else if (variable == "d0wrtPV"){      
2027 >    double vx = object->vx - chosenVertex ()->x,        
2028 >      vy = object->vy - chosenVertex ()->y,      
2029 >      px = object->px,  
2030 >      py = object->py,  
2031 >      pt = object->pt;  
2032 >    value = (-vx * py + vy * px) / pt;  
2033 >  }      
2034 >  else if (variable == "dZwrtPV"){      
2035 >    double vx = object->vx - chosenVertex ()->x,        
2036 >      vy = object->vy - chosenVertex ()->y,      
2037 >      vz = object->vz - chosenVertex ()->z,      
2038 >      px = object->px,  
2039 >      py = object->py,  
2040 >      pz = object->pz,  
2041 >      pt = object->pt;  
2042 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2043 >  }    
2044    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2045  
2046    else if(variable == "genMatchedPdgId"){
# Line 2024 | Line 2049 | OSUAnalysis::valueLookup (const BNtrack*
2049      else value = mcparticles->at(index).id;
2050    }
2051  
2052 +
2053    else if(variable == "genMatchedId"){
2054      int index = getGenMatchedParticleIndex(object);
2055      if(index == -1) value = 0;
# Line 2338 | Line 2364 | OSUAnalysis::valueLookup (const BNphoton
2364    else if(variable == "isEEGap") value = object->isEEGap;
2365    else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
2366    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2367 +
2368 +
2369  
2370  
2371    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
# Line 2347 | Line 2375 | OSUAnalysis::valueLookup (const BNphoton
2375      if(index == -1) value = 0;
2376      else value = mcparticles->at(index).id;
2377    }
2378 +
2379 +
2380 +
2381    else if(variable == "genMatchedId"){
2382      int index = getGenMatchedParticleIndex(object);
2383      if(index == -1) value = 0;
# Line 2410 | Line 2441 | OSUAnalysis::valueLookup (const BNmuon*
2441    double value = 0.0;
2442  
2443    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2444 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2445    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2446    else if(variable == "invMass"){
2447      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2419 | Line 2451 | OSUAnalysis::valueLookup (const BNmuon*
2451    else if(variable == "pt"){
2452      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2453      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2454 <    value = (fourVector1 + fourVector2).Et();
2454 >    value = (fourVector1 + fourVector2).Pt();
2455    }
2456    else if(variable == "threeDAngle")
2457      {
# Line 2451 | Line 2483 | OSUAnalysis::valueLookup (const BNmuon*
2483    else if(variable == "muon2CorrectedD0Vertex"){
2484      value = object2->correctedD0Vertex;
2485    }
2486 < else if(variable == "muon1timeAtIpInOut"){
2486 >  else if(variable == "muon1timeAtIpInOut"){
2487      value = object1->timeAtIpInOut;
2488    }
2489 < else if(variable == "muon2timeAtIpInOut"){
2489 >  else if(variable == "muon2timeAtIpInOut"){
2490      value = object2->timeAtIpInOut;
2491    }
2492 < else if(variable == "muon1correctedD0")
2493 <   {
2494 <     value = object1->correctedD0;
2495 <   }
2496 < else if(variable == "muon2correctedD0")
2497 <   {
2498 <     value = object2->correctedD0;
2499 <   }
2492 >  else if(variable == "muon1correctedD0")
2493 >    {
2494 >      value = object1->correctedD0;
2495 >    }
2496 >  else if(variable == "muon2correctedD0")
2497 >    {
2498 >      value = object2->correctedD0;
2499 >    }
2500  
2501    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2502  
# Line 2479 | Line 2511 | OSUAnalysis::valueLookup (const BNelectr
2511    double value = 0.0;
2512  
2513    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2514 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2515    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2516    else if(variable == "invMass"){
2517      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2488 | Line 2521 | OSUAnalysis::valueLookup (const BNelectr
2521    else if(variable == "pt"){
2522      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2523      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2524 <    value = (fourVector1 + fourVector2).Et();
2524 >    value = (fourVector1 + fourVector2).Pt();
2525    }
2526    else if(variable == "threeDAngle")
2527      {
# Line 2533 | Line 2566 | OSUAnalysis::valueLookup (const BNelectr
2566    double value = 0.0;
2567  
2568    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2569 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2570    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2571    else if(variable == "invMass"){
2572      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2542 | Line 2576 | OSUAnalysis::valueLookup (const BNelectr
2576    else if(variable == "pt"){
2577      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2578      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2579 <    value = (fourVector1 + fourVector2).Et();
2579 >    value = (fourVector1 + fourVector2).Pt();
2580    }
2581    else if(variable == "threeDAngle")
2582      {
# Line 2579 | Line 2613 | OSUAnalysis::valueLookup (const BNelectr
2613    else if(variable == "muonDetIso"){
2614      value = (object2->trackIsoDR03) / object2->pt;
2615    }
2616 <
2616 >  else if(variable == "electronRelPFrhoIso"){
2617 >    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2618 >  }
2619 >  else if(variable == "muonRelPFdBetaIso"){
2620 >    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2621 >  }
2622  
2623    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2624  
# Line 2589 | Line 2628 | OSUAnalysis::valueLookup (const BNelectr
2628   }
2629  
2630  
2631 < double
2632 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){
2633 <  double electronMass = 0.000511;
2634 <  double value = 0.0;
2635 <  TLorentzVector fourVector1(0, 0, 0, 0);  
2636 <  TLorentzVector fourVector2(0, 0, 0, 0);  
2637 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2638 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2639 <  else if(variable == "invMass"){
2640 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
2641 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
2642 <    
2643 <    value = (fourVector1 + fourVector2).M();
2644 <  }
2645 <  
2646 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2647 <  value = applyFunction(function, value);
2648 <  return value;
2631 > double  
2632 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2633 >  double electronMass = 0.000511;        
2634 >  double value = 0.0;    
2635 >  TLorentzVector fourVector1(0, 0, 0, 0);        
2636 >  TLorentzVector fourVector2(0, 0, 0, 0);        
2637 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2638 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2639 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2640 >  else if(variable == "invMass"){        
2641 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2642 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2643 >        
2644 >    value = (fourVector1 + fourVector2).M();    
2645 >  }
2646 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2647 >  value = applyFunction(function, value);        
2648 >  return value;  
2649   }
2650  
2651 +
2652 +
2653   double
2654   OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2655    double pionMass = 0.140;
# Line 2617 | Line 2658 | OSUAnalysis::valueLookup (const BNmuon*
2658    TLorentzVector fourVector1(0, 0, 0, 0);
2659    TLorentzVector fourVector2(0, 0, 0, 0);
2660    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2661 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2662    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2663    else if(variable == "invMass"){
2664      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
# Line 2635 | Line 2677 | double
2677   OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2678    double value = 0.0;
2679    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2680 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2681    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2682    else if(variable == "invMass"){
2683 <  TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2684 <  TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2685 <     value = (fourVector1 + fourVector2).M();
2683 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2684 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2685 >    value = (fourVector1 + fourVector2).M();
2686    }
2687  
2688    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2647 | Line 2690 | OSUAnalysis::valueLookup (const BNtau* o
2690    return value;
2691   }
2692  
2693 +
2694   double
2695   OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2696    double value = 0.0;
2697    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2698 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2699    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2700    else if(variable == "invMass"){
2701      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2664 | Line 2709 | OSUAnalysis::valueLookup (const BNmuon*
2709   }
2710  
2711  
2712 + double
2713 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2714 +
2715 +  double value = 0.0;
2716 +  double pMag = sqrt(object1->pt * object1->pt +
2717 +                     object1->pz * object1->pz);  
2718 +
2719 +  if      (variable == "numPV")                      value = object2->numPV;
2720 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2721 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2722 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2723 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2724 +
2725 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2726 +
2727 +  value = applyFunction(function, value);
2728 +
2729 +  return value;
2730 +
2731 + }  
2732  
2733   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2734   // Return true iff no other tracks are found in this cone.
# Line 2710 | Line 2775 | OSUAnalysis::getTrkPtTrue (const BNtrack
2775  
2776   }
2777  
2778 + double
2779 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
2780 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
2781 +  if (!useTrackCaloRhoCorr_) return -99;  
2782 +  // if (!rhokt6CaloJetsHandle_) {
2783 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
2784 +  //   return -99;  
2785 +  // }
2786 +  double radDeltaRCone = 0.5;  
2787 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
2788 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
2789 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
2790 +  return caloTotRhoCorrCalo;  
2791 +
2792 + }
2793 +
2794 +
2795 +
2796 +
2797   //creates a map of the dead Ecal channels in the barrel and endcap
2798   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2799   //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 2837 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
2837    return value;
2838   }
2839  
2756
2840   // Returns the smallest DeltaR between the object and any generated true particle in the event.  
2841   template <class InputObject>
2842   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
# Line 2761 | Line 2844 | double OSUAnalysis::getGenDeltaRLowest(I
2844    for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2845      double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2846      if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2847 < }
2847 >  }
2848    return genDeltaRLowest;
2849   }
2850  
2768
2851   double
2852   OSUAnalysis::applyFunction(string function, double value){
2853  
# Line 3064 | Line 3146 | int OSUAnalysis::getGenMatchedParticleIn
3146  
3147      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3148      if(currentDeltaR > 0.05) continue;
3149 < //     cout << std::setprecision(3) << std::setw(20)
3150 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3151 < //          << std::setw(20)
3152 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3153 < //          << std::setw(20)
3154 < //          << "\tdeltaR = " << currentDeltaR
3155 < //          << std::setprecision(1)
3156 < //          << std::setw(20)
3157 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3158 < //          << std::setw(20)
3159 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3160 < //          << std::setw(20)
3161 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3149 >    //     cout << std::setprecision(3) << std::setw(20)
3150 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3151 >    //          << std::setw(20)
3152 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3153 >    //          << std::setw(20)
3154 >    //          << "\tdeltaR = " << currentDeltaR
3155 >    //          << std::setprecision(1)
3156 >    //          << std::setw(20)
3157 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3158 >    //          << std::setw(20)
3159 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3160 >    //          << std::setw(20)
3161 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3162      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3163        bestMatchIndex = mcparticle - mcparticles->begin();
3164        bestMatchDeltaR = currentDeltaR;
3165      }
3166  
3167    }
3168 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3169 < //   else cout << "no match found..." << endl;
3168 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3169 >  //   else cout << "no match found..." << endl;
3170    return bestMatchIndex;
3171  
3172   }
# Line 3175 | Line 3257 | OSUAnalysis::chosenVertex ()
3257    const BNprimaryvertex *chosenVertex = 0;
3258    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3259      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3260 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3260 >      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3261      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3262        if(!vertexFlags.at(vertexIndex)) continue;
3263        chosenVertex = & primaryvertexs->at(vertexIndex);
# Line 3195 | Line 3277 | OSUAnalysis::chosenMET ()
3277    const BNmet *chosenMET = 0;
3278    if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3279      vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3280 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3280 >      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3281      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3282        if(!metFlags.at(metIndex)) continue;
3283        chosenMET = & mets->at(metIndex);
# Line 3215 | Line 3297 | OSUAnalysis::chosenElectron ()
3297    const BNelectron *chosenElectron = 0;
3298    if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3299      vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3300 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3300 >      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3301      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3302        if(!electronFlags.at(electronIndex)) continue;
3303        chosenElectron = & electrons->at(electronIndex);
# Line 3235 | Line 3317 | OSUAnalysis::chosenMuon ()
3317    const BNmuon *chosenMuon = 0;
3318    if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3319      vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3320 <                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3320 >      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3321      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3322        if(!muonFlags.at(muonIndex)) continue;
3323        chosenMuon = & muons->at(muonIndex);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines