ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/interface/MuonTools.h
(Generate patch)

Comparing UserCode/MitPhysics/Utils/interface/MuonTools.h (file contents):
Revision 1.3 by loizides, Thu Nov 27 16:28:58 2008 UTC vs.
Revision 1.23 by ceballos, Sun May 6 12:27:38 2012 UTC

# Line 3 | Line 3
3   //
4   // MuonTools
5   //
6 < // Isolation functions to compute various kinds of isolation.
7 < // http://cmslxr.fnal.gov/lxr/source/RecoMuon/MuonIdentification/
8 < // http://cmslxr.fnal.gov/lxr/source/DataFormats/MuonReco/
6 > // This class allows you to classify a given muon according to defined criteria. For this purpose
7 > // is loads histograms from two ROOT files, specified in the constructor. The main function then
8 > // is "IsGood(*muon, selection)" which returns true if the given muon fulfills the selection
9 > // criteria.
10 > //
11 > // Logically, the code has been put together by Phil who took most of the ideas from
12 > //  http://cmslxr.fnal.gov/lxr/source/RecoMuon/MuonIdentification/
13 > //  http://cmslxr.fnal.gov/lxr/source/DataFormats/MuonReco/
14 > //
15   // Authors: P.Harris, C.Loizides
16   //--------------------------------------------------------------------------------------------------
17  
18 < #ifndef MITPHYSICS_UTIL_MUONTOOLS_H
19 < #define MITPHYSICS_UTIL_MUONTOOLS_H
18 > #ifndef MITPHYSICS_UTILS_MUONTOOLS_H
19 > #define MITPHYSICS_UTILS_MUONTOOLS_H
20  
21   #include "MitAna/DataTree/interface/Muon.h"
22 + #include "MitAna/DataTree/interface/VertexCol.h"
23 + #include "MitAna/DataTree/interface/BeamSpotCol.h"
24   #include "MitCommon/MathTools/interface/MathUtils.h"
25   #include "TH2D.h"
26  
# Line 21 | Line 29 | namespace mithep {
29      public:
30        MuonTools(const char *mutemp="$CMSSW_BASE/src/MitPhysics/data/MuonCaloTemplate.root",
31                  const char *pitemp="$CMSSW_BASE/src/MitPhysics/data/PionCaloTemplate.root");
32 <      ~MuonTools();
32 >      virtual ~MuonTools();
33  
34        enum ESelType {
35 <        kAllArbitrated,
36 <        kPromptTight,
37 <        kTMLastStationLoose,
38 <        kTMLastStationTight,
39 <        kTMOneStationLoose,
40 <        kTMOneStationTight,
41 <        kTM2DCompatibilityLoose,
42 <        kTM2DCompatibilityTight
35 >        kAllArbitrated,          //All arbitration (DT/CSC/RPC Hits) put on at least one
36 >                                 //  segments given a global Muon
37 >        kPromptTight,            //Standard global muon identification
38 >        kTMLastStationLoose,     //Loose matching requirements on lastmost muon station of reco
39 >        kTMLastStationTight,     //Tight matching requirements on lastmost muon station of reco
40 >        kTMOneStationLoose,      //Loose matching requirements on at least one muon station of reco
41 >        kTMOneStationTight,      //Tight matching requirements on at least one muon station of reco
42 >        kTM2DCompatibilityLoose, //Loose requirement on sum of compatabiliity variables
43 >                                 //  ===> 1.2 Segment compatability + 0.8 calo compatability > 0.8
44 >        kTM2DCompatibilityTight  //Tight requirement on sum of compatabiliity variables
45 >                                 //  ===> 1.2 Segment compatability + 0.8 calo compatability > 1.2
46 >      };
47 >
48 >      enum EMuonEffectiveAreaType {
49 >        kMuTrkIso03,
50 >        kMuEcalIso03,
51 >        kMuHcalIso03,
52 >        kMuTrkIso05,
53 >        kMuEcalIso05,
54 >        kMuHcalIso05,
55 >        kMuChargedIso03,
56 >        kMuGammaIso03,
57 >        kMuNeutralHadronIso03,
58 >        kMuGammaAndNeutralHadronIso03,
59 >        kMuGammaIso03Tight,
60 >        kMuNeutralHadronIso03Tight,
61 >        kMuGammaAndNeutralHadronIso03Tight,
62 >        kMuChargedIso04,
63 >        kMuGammaIso04,
64 >        kMuNeutralHadronIso04,
65 >        kMuGammaAndNeutralHadronIso04,
66 >        kMuGammaIso04Tight,
67 >        kMuNeutralHadronIso04Tight,
68 >        kMuGammaAndNeutralHadronIso04Tight,
69 >        kMuGammaIsoDR0p0To0p1,
70 >        kMuGammaIsoDR0p1To0p2,
71 >        kMuGammaIsoDR0p2To0p3,
72 >        kMuGammaIsoDR0p3To0p4,
73 >        kMuGammaIsoDR0p4To0p5,
74 >        kMuNeutralHadronIsoDR0p0To0p1,
75 >        kMuNeutralHadronIsoDR0p1To0p2,
76 >        kMuNeutralHadronIsoDR0p2To0p3,
77 >        kMuNeutralHadronIsoDR0p3To0p4,
78 >        kMuNeutralHadronIsoDR0p4To0p5,
79 >        kMuGammaIso05,
80 >        kMuNeutralIso05,
81 >        kMuNeutralIso03,
82 >        kMuNeutralIso04,
83 >        kMuHadEnergy,
84 >        kMuHoEnergy,
85 >        kMuEmEnergy,
86 >        kMuHadS9Energy,
87 >        kMuHoS9Energy,
88 >        kMuEmS9Energy,
89 >        kMuEMIso03,
90 >        kMuHadIso03,
91 >        kMuEMIso05,
92 >        kMuHadIso05
93        };
94  
95 <      Bool_t      Init(const char *mutemp, const char *pitemp);
96 <      Bool_t      IsGood(const mithep::Muon *iMuon, ESelType iSel) const;
95 >      enum EMuonEffectiveAreaTarget {
96 >        kMuEANoCorr,
97 >        kMuEAData2011,
98 >        kMuEASummer11MC,
99 >        kMuEAFall11MC,
100 >        kMuEAData2012
101 >      };
102 >
103 >      Bool_t          Init(const char *mutemp, const char *pitemp);
104 >      Bool_t          IsGood(const mithep::Muon *iMuon, ESelType iSel) const;
105 >      Double_t        GetCaloCompatability(const mithep::Muon *iMuon,
106 >                                         Bool_t iEMSpecial, Bool_t iCorrectedHCAL) const;
107 >      Double_t        GetSegmentCompatability(const mithep::Muon *iMuon)             const;
108 >      static Bool_t   PassD0Cut(const Muon *mu, const VertexCol *vertices, Double_t fD0Cut, Int_t nVertex = 0);
109 >      static Bool_t   PassD0Cut(const Muon *mu, const BeamSpotCol *beamspots, Double_t fD0Cut);
110 >      static Bool_t   PassDZCut(const Muon *mu, const VertexCol *vertices, Double_t fDZCut, Int_t nVertex = 0);
111 >      static Bool_t   PassSoftMuonCut(const Muon *mu, const VertexCol *vertices, const Double_t fDZCut = 0.2,
112 >                                    const Bool_t applyIso = kTRUE);
113 >      static Double_t MuonEffectiveArea(EMuonEffectiveAreaType type, Double_t Eta,
114 >                                        EMuonEffectiveAreaTarget EffectiveAreaTarget = kMuEAData2011);
115  
116      protected:
117        void        DeleteHistos();
118 <      Double_t    GetCaloCompatability(const mithep::Muon *iMuon,
119 <                                       Bool_t iEMSpecial, Bool_t iCorrectedHCAL) const;
120 <      Double_t    GetSegmentCompatability(const mithep::Muon *iMuon)             const;
45 <      Bool_t      Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1)    const;
46 <      Double_t    SigWeight(Double_t iVal0, Double_t iVal1)                      const;
47 <
118 >      Bool_t      Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1)    const;
119 >      Double_t    SigWeight(Double_t iVal0, Double_t iVal1)                      const;
120 >  
121      private:
122 <      Bool_t      fIsInit;              //!
123 <      TH2D       *fmuon_em_etaEmi;      //!
124 <      TH2D       *fmuon_had_etaEmi;     //!
125 <      TH2D       *fmuon_had_etaTmi;     //!
126 <      TH2D       *fmuon_em_etaB;        //!
127 <      TH2D       *fmuon_had_etaB;       //!
128 <      TH2D       *fmuon_ho_etaB;        //!
129 <      TH2D       *fmuon_had_etaTpl;     //!
130 <      TH2D       *fmuon_em_etaEpl;      //!
131 <      TH2D       *fmuon_had_etaEpl;     //!
132 <      TH2D       *fpion_em_etaEmi;      //!
133 <      TH2D       *fpion_had_etaEmi;     //!
134 <      TH2D       *fpion_had_etaTmi;     //!
135 <      TH2D       *fpion_em_etaB;        //!
136 <      TH2D       *fpion_had_etaB;       //!
137 <      TH2D       *fpion_ho_etaB;        //!
138 <      TH2D       *fpion_had_etaTpl;     //!
139 <      TH2D       *fpion_em_etaEpl;      //!
140 <      TH2D       *fpion_had_etaEpl;     //!
122 >      Bool_t      fIsInit;              //!=true if histograms are loaded
123 >      TH2D       *fmuon_em_etaEmi;      //!Neg Endcap EM       Calo Deposit Template for Muons
124 >      TH2D       *fmuon_had_etaEmi;     //!Neg Endcap Hadronic Calo Deposit Template for Muons
125 >      TH2D       *fmuon_had_etaTmi;     //!Neg Transition Hadronic Calo Deposit Template for Muons
126 >      TH2D       *fmuon_em_etaB;        //!Barrel EM       Calo Deposit Template for Muons
127 >      TH2D       *fmuon_had_etaB;       //!Barrel Hadronic Calo Deposit Template for Muons
128 >      TH2D       *fmuon_ho_etaB;        //!Barrel HO       Calo Deposit Template for Muons
129 >      TH2D       *fmuon_had_etaTpl;     //!Plus Transition Hadronic Calo Deposit Template for Muons
130 >      TH2D       *fmuon_em_etaEpl;      //!Plus Endcap EM       Calo Deposit Template for Muons
131 >      TH2D       *fmuon_had_etaEpl;     //!Plus Endcap Hadronic Calo Deposit Template for Muons
132 >      TH2D       *fpion_em_etaEmi;      //!Neg  Endcap EM       Calo Deposit Template for Pions
133 >      TH2D       *fpion_had_etaEmi;     //!Neg  Endcap Hadronic Calo Deposit Template for Pions
134 >      TH2D       *fpion_had_etaTmi;     //!Neg Transition Hadronic Calo Deposit Template for Pions
135 >      TH2D       *fpion_em_etaB;        //!Barrel EM       Calo Deposit Template for Pions
136 >      TH2D       *fpion_had_etaB;       //!Barrel Hadronic Calo Deposit Template for Pions
137 >      TH2D       *fpion_ho_etaB;        //!Barrel HO       Calo Deposit Template for Pions
138 >      TH2D       *fpion_had_etaTpl;     //!Plus Transition Hadronic Calo Deposit Template for Pions
139 >      TH2D       *fpion_em_etaEpl;      //!Plus Endcap EM       Calo Deposit Template for Pions
140 >      TH2D       *fpion_had_etaEpl;     //!Plus Endcap Hadronic Calo Deposit Template for Pions
141  
142        TH2D       *LoadHisto(const char *fname, TFile *file)                      const;
143 +
144 +    ClassDef(MuonTools, 0) // Muon tools
145    };
146   }
147  
148   //--------------------------------------------------------------------------------------------------
149   inline Double_t mithep::MuonTools::SigWeight(Double_t iVal0, Double_t iVal1) const
150   {
151 <  //
151 >  // Returns weighted uncertainty given segment matching uncertainty (iVal0) and
152 >  // segment matching pull (iVal1).
153  
154 <  if (iVal1 < 1.)
154 >  if (iVal1 < 1.)  //if pull defined and within range
155      return 1.;
156 <  if (iVal0 < 3. && iVal1 > 3.) {
156 >  if (iVal0 < 3. && iVal1 > 3.) {       //if pull not well defined and uncertainty defined
157      Double_t lVal = TMath::Max(iVal0,1.);
158      return 1./TMath::Power(lVal,0.25);
159    }
160  
161 <  Double_t lVal = TMath::Max(iVal1,1.);
161 >  Double_t lVal = TMath::Max(iVal1,1.); //if pull > 1 and pull < 3 return 1/pull^4
162    return 1./TMath::Power(lVal,0.25);
163   }
88
164   //--------------------------------------------------------------------------------------------------
165   inline Bool_t mithep::MuonTools::Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1) const
166   {
# Line 96 | Line 171 | inline Bool_t mithep::MuonTools::Overflo
171  
172    if (iHist ->GetXaxis()->FindBin(lVal0) == 0                  ||
173        iHist ->GetXaxis()->FindBin(lVal0) >  iHist->GetNbinsX() ||
174 <      iHist ->GetYaxis()->FindBin(lVal0) == 0                  ||
175 <      iHist ->GetYaxis()->FindBin(lVal0) >  iHist->GetNbinsY()) {
174 >      iHist ->GetYaxis()->FindBin(lVal1) == 0                  ||
175 >      iHist ->GetYaxis()->FindBin(lVal1) >  iHist->GetNbinsY()) {
176      return kTRUE;
177    }
178    return kFALSE;
179   }
180   #endif
106
107 #if 0
108    static inline MCParticle* etaPhiMatch(MCParticleCol* iMCParts,Muon *iMuon) {
109      mithep::MCParticle *lMC = 0; Double_t lDR = 1.; Double_t lPt = -1.;
110      for(unsigned Int_t i0 = 0; i0 < iMCParts->GetEntries(); i0++) {
111        mithep::MCParticle* pMC = iMCParts->At(i0);
112        if(pMC->Status() != 1) continue;
113        Double_t pDR = mithep::MathUtils::DeltaR(pMC->Mom(),iMuon->Mom());
114        if(pDR > lDR && pDR > 0.01) continue;
115        if(fabs(pMC->Pt()) < lPt)   continue;
116        lDR = pDR;
117        lMC = pMC;
118        lPt = pMC->Pt();
119      }
120      return lMC;
121    }
122    static inline Muon* match(MuonCol* iMuons,Track *iTrack) {
123      mithep::Muon *lMuon = 0; Double_t lDR = 1.; Double_t lPt = -1.;
124      for(unsigned Int_t i0 = 0; i0 < iMuons->GetEntries(); i0++) {
125        mithep::Muon* pMuon = iMuons->At(i0);
126        Double_t pDR = mithep::MathUtils::DeltaR(pMuon->Mom(),iTrack->Mom4(0.109));
127        if(pDR > lDR && pDR > 0.01) continue;
128        if(fabs(pMuon->Pt()) < lPt)   continue;
129        lDR   = pDR;
130        lMuon = pMuon;
131        lPt   = pMuon->Pt();
132      }
133      return lMuon;
134    }
135 #endif
136
137

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines