ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/interface/MuonTools.h
Revision: 1.22
Committed: Sun Apr 15 12:07:00 2012 UTC (13 years ago) by sixie
Content type: text/plain
Branch: MAIN
Changes since 1.21: +21 -3 lines
Log Message:
add effective areas

File Contents

# User Rev Content
1 loizides 1.3 //--------------------------------------------------------------------------------------------------
2 sixie 1.22 // $Id: MuonTools.h,v 1.21 2012/01/23 20:05:20 sixie Exp $
3 loizides 1.3 //
4     // MuonTools
5     //
6 loizides 1.4 // 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 loizides 1.3 // Authors: P.Harris, C.Loizides
16     //--------------------------------------------------------------------------------------------------
17    
18 loizides 1.8 #ifndef MITPHYSICS_UTILS_MUONTOOLS_H
19     #define MITPHYSICS_UTILS_MUONTOOLS_H
20 pharris 1.1
21 loizides 1.3 #include "MitAna/DataTree/interface/Muon.h"
22 ceballos 1.12 #include "MitAna/DataTree/interface/VertexCol.h"
23     #include "MitAna/DataTree/interface/BeamSpotCol.h"
24 loizides 1.3 #include "MitCommon/MathTools/interface/MathUtils.h"
25 pharris 1.1 #include "TH2D.h"
26    
27     namespace mithep {
28     class MuonTools {
29 loizides 1.3 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 loizides 1.10 virtual ~MuonTools();
33 loizides 1.3
34     enum ESelType {
35 loizides 1.7 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 pharris 1.6 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 loizides 1.7 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 loizides 1.3 };
47    
48 sixie 1.20 enum EMuonEffectiveAreaType {
49     kMuChargedIso03,
50     kMuNeutralIso03,
51     kMuChargedIso04,
52     kMuNeutralIso04,
53     kMuHadEnergy,
54     kMuHoEnergy,
55     kMuEmEnergy,
56     kMuHadS9Energy,
57     kMuHoS9Energy,
58 sixie 1.21 kMuEmS9Energy,
59     kMuTrkIso03,
60     kMuEMIso03,
61     kMuHadIso03,
62     kMuTrkIso05,
63     kMuEMIso05,
64 sixie 1.22 kMuHadIso05,
65     kMuGammaIsoDR0p0To0p1,
66     kMuGammaIsoDR0p1To0p2,
67     kMuGammaIsoDR0p2To0p3,
68     kMuGammaIsoDR0p3To0p4,
69     kMuGammaIsoDR0p4To0p5,
70     kMuNeutralHadronIsoDR0p0To0p1,
71     kMuNeutralHadronIsoDR0p1To0p2,
72     kMuNeutralHadronIsoDR0p2To0p3,
73     kMuNeutralHadronIsoDR0p3To0p4,
74     kMuNeutralHadronIsoDR0p4To0p5
75     };
76    
77     enum EMuonEffectiveAreaTarget {
78     kMuEANoCorr,
79     kMuEAData2011,
80     kMuEASummer11MC,
81     kMuEAFall11MC
82 sixie 1.20 };
83    
84     Bool_t Init(const char *mutemp, const char *pitemp);
85     Bool_t IsGood(const mithep::Muon *iMuon, ESelType iSel) const;
86     Double_t GetCaloCompatability(const mithep::Muon *iMuon,
87 ceballos 1.12 Bool_t iEMSpecial, Bool_t iCorrectedHCAL) const;
88 sixie 1.20 Double_t GetSegmentCompatability(const mithep::Muon *iMuon) const;
89     static Bool_t PassD0Cut(const Muon *mu, const VertexCol *vertices, Double_t fD0Cut, Int_t nVertex = 0);
90     static Bool_t PassD0Cut(const Muon *mu, const BeamSpotCol *beamspots, Double_t fD0Cut);
91     static Bool_t PassDZCut(const Muon *mu, const VertexCol *vertices, Double_t fDZCut, Int_t nVertex = 0);
92     static Bool_t PassSoftMuonCut(const Muon *mu, const VertexCol *vertices, const Double_t fDZCut = 0.2,
93 ceballos 1.19 const Bool_t applyIso = kTRUE);
94 sixie 1.22 static Double_t MuonEffectiveArea(EMuonEffectiveAreaType type, Double_t Eta,
95     EMuonEffectiveAreaTarget EffectiveAreaTarget = kMuEAData2011);
96 loizides 1.3
97     protected:
98     void DeleteHistos();
99 pharris 1.6 Bool_t Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1) const;
100     Double_t SigWeight(Double_t iVal0, Double_t iVal1) const;
101    
102 loizides 1.3 private:
103 loizides 1.4 Bool_t fIsInit; //!=true if histograms are loaded
104 loizides 1.7 TH2D *fmuon_em_etaEmi; //!Neg Endcap EM Calo Deposit Template for Muons
105     TH2D *fmuon_had_etaEmi; //!Neg Endcap Hadronic Calo Deposit Template for Muons
106     TH2D *fmuon_had_etaTmi; //!Neg Transition Hadronic Calo Deposit Template for Muons
107     TH2D *fmuon_em_etaB; //!Barrel EM Calo Deposit Template for Muons
108     TH2D *fmuon_had_etaB; //!Barrel Hadronic Calo Deposit Template for Muons
109     TH2D *fmuon_ho_etaB; //!Barrel HO Calo Deposit Template for Muons
110     TH2D *fmuon_had_etaTpl; //!Plus Transition Hadronic Calo Deposit Template for Muons
111     TH2D *fmuon_em_etaEpl; //!Plus Endcap EM Calo Deposit Template for Muons
112     TH2D *fmuon_had_etaEpl; //!Plus Endcap Hadronic Calo Deposit Template for Muons
113     TH2D *fpion_em_etaEmi; //!Neg Endcap EM Calo Deposit Template for Pions
114     TH2D *fpion_had_etaEmi; //!Neg Endcap Hadronic Calo Deposit Template for Pions
115     TH2D *fpion_had_etaTmi; //!Neg Transition Hadronic Calo Deposit Template for Pions
116     TH2D *fpion_em_etaB; //!Barrel EM Calo Deposit Template for Pions
117     TH2D *fpion_had_etaB; //!Barrel Hadronic Calo Deposit Template for Pions
118     TH2D *fpion_ho_etaB; //!Barrel HO Calo Deposit Template for Pions
119     TH2D *fpion_had_etaTpl; //!Plus Transition Hadronic Calo Deposit Template for Pions
120     TH2D *fpion_em_etaEpl; //!Plus Endcap EM Calo Deposit Template for Pions
121     TH2D *fpion_had_etaEpl; //!Plus Endcap Hadronic Calo Deposit Template for Pions
122 loizides 1.3
123     TH2D *LoadHisto(const char *fname, TFile *file) const;
124 loizides 1.10
125     ClassDef(MuonTools, 0) // Muon tools
126 loizides 1.3 };
127     }
128    
129     //--------------------------------------------------------------------------------------------------
130     inline Double_t mithep::MuonTools::SigWeight(Double_t iVal0, Double_t iVal1) const
131     {
132 loizides 1.7 // Returns weighted uncertainty given segment matching uncertainty (iVal0) and
133     // segment matching pull (iVal1).
134 loizides 1.3
135 loizides 1.7 if (iVal1 < 1.) //if pull defined and within range
136 loizides 1.3 return 1.;
137 loizides 1.7 if (iVal0 < 3. && iVal1 > 3.) { //if pull not well defined and uncertainty defined
138 loizides 1.3 Double_t lVal = TMath::Max(iVal0,1.);
139     return 1./TMath::Power(lVal,0.25);
140     }
141    
142 loizides 1.7 Double_t lVal = TMath::Max(iVal1,1.); //if pull > 1 and pull < 3 return 1/pull^4
143 loizides 1.3 return 1./TMath::Power(lVal,0.25);
144     }
145     //--------------------------------------------------------------------------------------------------
146     inline Bool_t mithep::MuonTools::Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1) const
147     {
148     // Check if values are in overflow bins of given histogram.
149    
150     if(iHist == 0)
151     return kTRUE;
152    
153     if (iHist ->GetXaxis()->FindBin(lVal0) == 0 ||
154     iHist ->GetXaxis()->FindBin(lVal0) > iHist->GetNbinsX() ||
155 ceballos 1.11 iHist ->GetYaxis()->FindBin(lVal1) == 0 ||
156     iHist ->GetYaxis()->FindBin(lVal1) > iHist->GetNbinsY()) {
157 loizides 1.3 return kTRUE;
158     }
159     return kFALSE;
160     }
161     #endif