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.38 by lantonel, Wed Mar 27 15:45:41 2013 UTC vs.
Revision 1.43 by wulsin, Thu Mar 28 10:17:32 2013 UTC

# Line 28 | Line 28 | OSUAnalysis::OSUAnalysis (const edm::Par
28    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
29    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
30    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
31 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo"))
31 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
32 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr"))
33 >
34   {
35  
36    TH1::SetDefaultSumw2 ();
# Line 63 | Line 65 | OSUAnalysis::OSUAnalysis (const edm::Par
65  
66      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
67      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
68 +    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
69      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
70        objectsToGet.push_back(tempInputCollection);
71        objectsToPlot.push_back(tempInputCollection);
# Line 82 | Line 85 | OSUAnalysis::OSUAnalysis (const edm::Par
85        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
86        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
87  
88 <      }
88 >    }
89  
90      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
91  
# Line 221 | Line 224 | OSUAnalysis::OSUAnalysis (const edm::Par
224  
225        if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
226  
227 < // bin      particle type
228 < // ---      -------------
229 < //  0        unmatched
230 < //  1        u
231 < //  2        d
232 < //  3        s
233 < //  4        c
234 < //  5        b
235 < //  6        t
236 < //  7        e
237 < //  8        mu
238 < //  9        tau
239 < // 10        nu
240 < // 11        g
241 < // 12        gamma
242 < // 13        Z
243 < // 14        W
244 < // 15        light meson
245 < // 16        K meson
246 < // 17        D meson
247 < // 18        B meson
248 < // 19        light baryon
249 < // 20        strange baryon
250 < // 21        charm baryon
251 < // 22        bottom baryon
252 < // 23        other
227 >      // bin      particle type
228 >      // ---      -------------
229 >      //  0        unmatched
230 >      //  1        u
231 >      //  2        d
232 >      //  3        s
233 >      //  4        c
234 >      //  5        b
235 >      //  6        t
236 >      //  7        e
237 >      //  8        mu
238 >      //  9        tau
239 >      // 10        nu
240 >      // 11        g
241 >      // 12        gamma
242 >      // 13        Z
243 >      // 14        W
244 >      // 15        light meson
245 >      // 16        K meson
246 >      // 17        D meson
247 >      // 18        B meson
248 >      // 19        light baryon
249 >      // 20        strange baryon
250 >      // 21        charm baryon
251 >      // 22        bottom baryon
252 >      // 23        other
253  
254        vector<TString> labelArray;
255        labelArray.push_back("unmatched");
# Line 290 | Line 293 | OSUAnalysis::OSUAnalysis (const edm::Par
293  
294      }
295  
296 <    //book a histogram for the number of each object type to be plotted
297 <
296 >    // Book a histogram for the number of each object type to be plotted.  
297 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
298      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
299        string currentObject = objectsToPlot.at(currentObjectIndex);
300        int maxNum = 10;
# Line 299 | Line 302 | OSUAnalysis::OSUAnalysis (const edm::Par
302        else if(currentObject == "primaryvertexs") maxNum = 50;
303        else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
304        else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
305 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
306 <
307 <      currentObject.at(0) = toupper(currentObject.at(0));
305 >      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
306 >      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
307 >      else if(currentObject == "electron-track pairs")    currentObject = "electronTrackPairs";  
308 >      else if(currentObject == "muon-track pairs")        currentObject = "muonTrackPairs";      
309 >      else if(currentObject == "muon-tau pairs")          currentObject = "muonTauPairs";        
310 >      else if(currentObject == "tau-tau pairs")           currentObject = "ditauPairs";
311 >      currentObject.at(0) = toupper(currentObject.at(0));  
312        string histoName = "num" + currentObject;
313  
314        if(histoName == "numPrimaryvertexs"){
# Line 476 | Line 483 | OSUAnalysis::analyze (const edm::Event &
483    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
484      event.getByLabel (superclusters_, superclusters);
485  
486 +  if (useTrackCaloRhoCorr_) {  
487 +    // Used only for pile-up correction of by-hand calculation of isolation energy.  
488 +    // This rho collection is not available in all BEANs.  
489 +    // For description of rho values for different jet reconstruction algorithms, see
490 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
491 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
492 +  }
493 +
494 +
495    //get pile-up event weight
496    double scaleFactor = 1.00;
497    if(doPileupReweighting_ && datasetType_ != "data")
# Line 545 | Line 561 | OSUAnalysis::analyze (const edm::Event &
561                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
562                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
563                                                                         "electron-muon pairs");
564 <
565 <
564 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
565 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
566 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
567 >                                                                     "track-event pairs");
568 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
569 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
570 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
571 >                                                                        "electron-track pairs");
572 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
573 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
574 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
575 >                                                                    "muon-track pairs");
576 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
577 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
578 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
579 >                                                                  "muon-tau pairs");
580 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
581 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
582 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
583 >                                                                 "tau-tau pairs");
584 >        
585 >        
586        }
587  
588  
# Line 570 | Line 606 | OSUAnalysis::analyze (const edm::Event &
606        int numberPassing = 0;
607  
608        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
609 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
609 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
610        }
611  
612        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
# Line 596 | Line 632 | OSUAnalysis::analyze (const edm::Event &
632      }
633  
634  
635 < //     if(datasetType_ != "data") {
636 < //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
637 < //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
638 < //     }
635 >    //     if(datasetType_ != "data") {
636 >    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
637 >    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
638 >    //     }
639  
640      //filling histograms
641      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
# Line 612 | Line 648 | OSUAnalysis::analyze (const edm::Event &
648  
649  
650          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
651 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
651 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
652          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
653                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
654                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
# Line 621 | Line 657 | OSUAnalysis::analyze (const edm::Event &
657                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
658                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
659          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
660 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
661 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
660 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
661 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
662 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
663 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
664 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
665 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
666 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
667 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
668 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
669 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
670 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
671 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
672 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
673 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
674          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
675          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
676          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 650 | Line 698 | OSUAnalysis::analyze (const edm::Event &
698                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
699                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
700          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
701 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
702 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
703 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
701 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
702 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
703 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
704 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
705 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
706 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
707 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
708 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
709 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
710 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
711 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
712 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
713 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
714 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
715 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
716          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
717          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
718          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
719 +        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
720 +                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
721 +                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
722          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
723          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
724          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
# Line 667 | Line 730 | OSUAnalysis::analyze (const edm::Event &
730  
731      //fills histograms with the sizes of collections
732      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
733 +
734        string currentObject = objectsToPlot.at(currentObjectIndex);
735  
736 <      string objectToPlot = "";
736 >      string objectToPlot = "";  
737  
738 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
739        if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
740        else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
741 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
741 >      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
742 >      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
743 >      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
744 >      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
745 >      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
746 >      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
747        else objectToPlot = currentObject;
748        string tempCurrentObject = objectToPlot;
749 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
749 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
750        string histoName = "num" + tempCurrentObject;
751  
752  
683
684
753        //set position of primary vertex in event, in order to calculate quantities relative to it
754        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
755          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
# Line 693 | Line 761 | OSUAnalysis::analyze (const edm::Event &
761            oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
762            oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
763          }
764 <        else
764 >        else {
765            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
766 +        }
767        }
768        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
769        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
# Line 702 | Line 771 | OSUAnalysis::analyze (const edm::Event &
771        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
772        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
773        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
774 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
775        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
776        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
777        else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
# Line 714 | Line 784 | OSUAnalysis::analyze (const edm::Event &
784        else if(objectToPlot == "primaryvertexs"){
785          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
786          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
787 <      }
718 <
719 <    }
720 <
721 <
787 >      }
788  
789 +    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
790  
791    } //end loop over channel
792  
793    masterCutFlow_->fillCutFlow(scaleFactor);
794  
795 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
796  
797  
730 }
731
798  
799   bool
800   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 1071 | Line 1137 | OSUAnalysis::valueLookup (const BNmuon*
1137      if (met)
1138        {
1139          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1140 <                       p2 (met->px, met->py, 0.0, met->pt);
1140 >          p2 (met->px, met->py, 0.0, met->pt);
1141  
1142          value = (p1 + p2).Mt ();
1143        }
# Line 1191 | Line 1257 | OSUAnalysis::valueLookup (const BNmuon*
1257      value = object->isGlobalMuon > 0                \
1258        && object->isPFMuon > 0                        \
1259        && object->normalizedChi2 < 10                \
1260 <      && object->numberOfValidMuonHits > 0        \
1260 >                                  && object->numberOfValidMuonHits > 0        \
1261        && object->numberOfMatchedStations > 1        \
1262        && fabs(object->correctedD0Vertex) < 0.2        \
1263        && fabs(object->correctedDZ) < 0.5        \
# Line 1201 | Line 1267 | OSUAnalysis::valueLookup (const BNmuon*
1267    else if(variable == "tightIDdisplaced"){
1268      value = object->isGlobalMuon > 0                \
1269        && object->normalizedChi2 < 10                \
1270 <      && object->numberOfValidMuonHits > 0        \
1270 >                                  && object->numberOfValidMuonHits > 0        \
1271        && object->numberOfMatchedStations > 1        \
1272        && object->numberOfValidPixelHits > 0        \
1273        && object->numberOfLayersWithMeasurement > 5;
# Line 1422 | Line 1488 | OSUAnalysis::valueLookup (const BNelectr
1488      if (met)
1489        {
1490          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1491 <                       p2 (met->px, met->py, 0.0, met->pt);
1491 >          p2 (met->px, met->py, 0.0, met->pt);
1492  
1493          value = (p1 + p2).Mt ();
1494        }
# Line 1712 | Line 1778 | OSUAnalysis::valueLookup (const BNevent*
1778    else if(variable == "muonScaleFactor"){
1779      if(datasetType_ != "data")
1780        //      value = muonSFWeight_->at (chosenMuon ()->eta);
1781 <    value = 1.0;
1781 >      value = 1.0;
1782      else
1783        value = 1.0;
1784    }
1785    else if(variable == "electronScaleFactor"){
1786      if(datasetType_ != "data")
1787        //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1788 <    value = 1.0;
1788 >      value = 1.0;
1789      else
1790        value = 1.0;
1791    }
# Line 1897 | Line 1963 | OSUAnalysis::valueLookup (const BNtrack*
1963  
1964    double value = 0.0;
1965    double pMag = sqrt(object->pt * object->pt +
1966 <                         object->pz * object->pz);
1967 <
1966 >                     object->pz * object->pz);
1967 >  
1968    if(variable == "pt") value = object->pt;
1969    else if(variable == "px") value = object->px;
1970    else if(variable == "py") value = object->py;
# Line 1934 | Line 2000 | OSUAnalysis::valueLookup (const BNtrack*
2000    //user defined variables
2001    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;
2002    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2003 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2004 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2005 <
2006 <
2007 <
2008 <
2009 <
2010 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2011 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2012 <  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2013 <  else if(variable == "ptError") value = object->ptError;
2014 <  else if(variable == "ptRes") value = getTrkPtRes(object);
2015 <
2003 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2004 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2005 >  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2006 >  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2007 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2008 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2009 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2010 >  else if(variable == "ptError")                    value = object->ptError;
2011 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2012 >  else if (variable == "d0wrtPV"){      
2013 >    double vx = object->vx - chosenVertex ()->x,        
2014 >      vy = object->vy - chosenVertex ()->y,      
2015 >      px = object->px,  
2016 >      py = object->py,  
2017 >      pt = object->pt;  
2018 >    value = (-vx * py + vy * px) / pt;  
2019 >  }      
2020 >  else if (variable == "dZwrtPV"){      
2021 >    double vx = object->vx - chosenVertex ()->x,        
2022 >      vy = object->vy - chosenVertex ()->y,      
2023 >      vz = object->vz - chosenVertex ()->z,      
2024 >      px = object->px,  
2025 >      py = object->py,  
2026 >      pz = object->pz,  
2027 >      pt = object->pt;  
2028 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2029 >  }    
2030    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2031  
2032    else if(variable == "genMatchedPdgId"){
# Line 2356 | Line 2436 | OSUAnalysis::valueLookup (const BNmuon*
2436    else if(variable == "pt"){
2437      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2438      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2439 <    value = (fourVector1 + fourVector2).Et();
2439 >    value = (fourVector1 + fourVector2).Pt();
2440    }
2441    else if(variable == "threeDAngle")
2442      {
# Line 2388 | Line 2468 | OSUAnalysis::valueLookup (const BNmuon*
2468    else if(variable == "muon2CorrectedD0Vertex"){
2469      value = object2->correctedD0Vertex;
2470    }
2471 < else if(variable == "muon1timeAtIpInOut"){
2471 >  else if(variable == "muon1timeAtIpInOut"){
2472      value = object1->timeAtIpInOut;
2473    }
2474 < else if(variable == "muon2timeAtIpInOut"){
2474 >  else if(variable == "muon2timeAtIpInOut"){
2475      value = object2->timeAtIpInOut;
2476    }
2477 < else if(variable == "muon1correctedD0")
2478 <   {
2479 <     value = object1->correctedD0;
2480 <   }
2481 < else if(variable == "muon2correctedD0")
2482 <   {
2483 <     value = object2->correctedD0;
2484 <   }
2477 >  else if(variable == "muon1correctedD0")
2478 >    {
2479 >      value = object1->correctedD0;
2480 >    }
2481 >  else if(variable == "muon2correctedD0")
2482 >    {
2483 >      value = object2->correctedD0;
2484 >    }
2485  
2486    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2487  
# Line 2425 | Line 2505 | OSUAnalysis::valueLookup (const BNelectr
2505    else if(variable == "pt"){
2506      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2507      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2508 <    value = (fourVector1 + fourVector2).Et();
2508 >    value = (fourVector1 + fourVector2).Pt();
2509    }
2510    else if(variable == "threeDAngle")
2511      {
# Line 2479 | Line 2559 | OSUAnalysis::valueLookup (const BNelectr
2559    else if(variable == "pt"){
2560      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2561      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2562 <    value = (fourVector1 + fourVector2).Et();
2562 >    value = (fourVector1 + fourVector2).Pt();
2563    }
2564    else if(variable == "threeDAngle")
2565      {
# Line 2526 | Line 2606 | OSUAnalysis::valueLookup (const BNelectr
2606   }
2607  
2608  
2609 + double  
2610 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2611 +  double electronMass = 0.000511;        
2612 +  double value = 0.0;    
2613 +  TLorentzVector fourVector1(0, 0, 0, 0);        
2614 +  TLorentzVector fourVector2(0, 0, 0, 0);        
2615 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2616 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2617 +  else if(variable == "invMass"){        
2618 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2619 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2620 +        
2621 +    value = (fourVector1 + fourVector2).M();    
2622 +  }
2623 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2624 +  value = applyFunction(function, value);        
2625 +  return value;  
2626 + }
2627 +
2628 +
2629 +
2630 + double
2631 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2632 +  double pionMass = 0.140;
2633 +  double muonMass = 0.106;
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, muonMass);
2641 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
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;
2649 + }
2650 +
2651 +
2652 + double
2653 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2654 +  double value = 0.0;
2655 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2656 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2657 +  else if(variable == "invMass"){
2658 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2659 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2660 +    value = (fourVector1 + fourVector2).M();
2661 +  }
2662 +
2663 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2664 +  value = applyFunction(function, value);
2665 +  return value;
2666 + }
2667 +
2668 +
2669 + double
2670 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2671 +  double value = 0.0;
2672 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2673 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2674 +  else if(variable == "invMass"){
2675 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2676 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2677 +    value = (fourVector1 + fourVector2).M();
2678 +  }
2679 +
2680 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2681 +  value = applyFunction(function, value);
2682 +  return value;
2683 + }
2684 +
2685 +
2686 + double
2687 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2688 +
2689 +  double value = 0.0;
2690 +  double pMag = sqrt(object1->pt * object1->pt +
2691 +                     object1->pz * object1->pz);  
2692 +
2693 +  if      (variable == "numPV")                      value = object2->numPV;
2694 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2695 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2696 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2697 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2698 +
2699 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2700 +
2701 +  value = applyFunction(function, value);
2702 +
2703 +  return value;
2704 +
2705 + }  
2706 +
2707   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2708   // Return true iff no other tracks are found in this cone.
2709   int
# Line 2571 | Line 2749 | OSUAnalysis::getTrkPtTrue (const BNtrack
2749  
2750   }
2751  
2752 + double
2753 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
2754 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
2755 +  if (!useTrackCaloRhoCorr_) return -99;  
2756 +  // if (!rhokt6CaloJetsHandle_) {
2757 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
2758 +  //   return -99;  
2759 +  // }
2760 +  double radDeltaRCone = 0.5;  
2761 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
2762 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
2763 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
2764 +  return caloTotRhoCorrCalo;  
2765 +
2766 + }
2767 +
2768 +
2769 +
2770 +
2771   //creates a map of the dead Ecal channels in the barrel and endcap
2772   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2773   //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
# Line 2621 | Line 2818 | double OSUAnalysis::getGenDeltaRLowest(I
2818    for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2819      double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2820      if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2821 < }
2821 >  }
2822    return genDeltaRLowest;
2823   }
2824  
# Line 2923 | Line 3120 | int OSUAnalysis::getGenMatchedParticleIn
3120  
3121      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3122      if(currentDeltaR > 0.05) continue;
3123 < //     cout << std::setprecision(3) << std::setw(20)
3124 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3125 < //          << std::setw(20)
3126 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3127 < //          << std::setw(20)
3128 < //          << "\tdeltaR = " << currentDeltaR
3129 < //          << std::setprecision(1)
3130 < //          << std::setw(20)
3131 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3132 < //          << std::setw(20)
3133 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3134 < //          << std::setw(20)
3135 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3123 >    //     cout << std::setprecision(3) << std::setw(20)
3124 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3125 >    //          << std::setw(20)
3126 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3127 >    //          << std::setw(20)
3128 >    //          << "\tdeltaR = " << currentDeltaR
3129 >    //          << std::setprecision(1)
3130 >    //          << std::setw(20)
3131 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3132 >    //          << std::setw(20)
3133 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3134 >    //          << std::setw(20)
3135 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3136      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3137        bestMatchIndex = mcparticle - mcparticles->begin();
3138        bestMatchDeltaR = currentDeltaR;
3139      }
3140  
3141    }
3142 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3143 < //   else cout << "no match found..." << endl;
3142 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3143 >  //   else cout << "no match found..." << endl;
3144    return bestMatchIndex;
3145  
3146   }
# Line 3034 | Line 3231 | OSUAnalysis::chosenVertex ()
3231    const BNprimaryvertex *chosenVertex = 0;
3232    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3233      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3234 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3234 >      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3235      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3236        if(!vertexFlags.at(vertexIndex)) continue;
3237        chosenVertex = & primaryvertexs->at(vertexIndex);
# Line 3054 | Line 3251 | OSUAnalysis::chosenMET ()
3251    const BNmet *chosenMET = 0;
3252    if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3253      vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3254 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3254 >      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3255      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3256        if(!metFlags.at(metIndex)) continue;
3257        chosenMET = & mets->at(metIndex);
# Line 3074 | Line 3271 | OSUAnalysis::chosenElectron ()
3271    const BNelectron *chosenElectron = 0;
3272    if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3273      vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3274 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3274 >      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3275      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3276        if(!electronFlags.at(electronIndex)) continue;
3277        chosenElectron = & electrons->at(electronIndex);
# Line 3094 | Line 3291 | OSUAnalysis::chosenMuon ()
3291    const BNmuon *chosenMuon = 0;
3292    if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3293      vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3294 <                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3294 >      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3295      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3296        if(!muonFlags.at(muonIndex)) continue;
3297        chosenMuon = & muons->at(muonIndex);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines