1 |
+ |
//-------------------------------------------------------------------------------------------------- |
2 |
+ |
// $Id$ |
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/ |
9 |
+ |
// Authors: P.Harris, C.Loizides |
10 |
+ |
//-------------------------------------------------------------------------------------------------- |
11 |
+ |
|
12 |
|
#ifndef MITPHYSICS_UTIL_MUONTOOLS_H |
13 |
|
#define MITPHYSICS_UTIL_MUONTOOLS_H |
3 |
– |
#include <vector> |
4 |
– |
#include <iostream> |
14 |
|
|
15 |
< |
#include "TH2D.h" |
7 |
< |
#include "TFile.h" |
8 |
< |
#include "MitAna/DataTree/interface/Collections.h" |
15 |
> |
#include "MitAna/DataTree/interface/Muon.h" |
16 |
|
#include "MitCommon/MathTools/interface/MathUtils.h" |
17 |
+ |
#include "TH2D.h" |
18 |
|
|
19 |
|
namespace mithep { |
20 |
|
class MuonTools { |
21 |
< |
public: |
22 |
< |
MuonTools(); |
23 |
< |
~MuonTools(); |
24 |
< |
double getCaloCompatability(mithep::Muon* iMuon,bool iEMSpecial, bool iCorrectedHCAL); |
25 |
< |
enum selection { |
26 |
< |
AllArbitrated, |
27 |
< |
PromptTight, |
28 |
< |
TMLastStationLoose, |
29 |
< |
TMLastStationTight, |
30 |
< |
TMOneStationLoose, |
31 |
< |
TMOneStationTight, |
32 |
< |
TM2DCompatibilityLoose, |
33 |
< |
TM2DCompatibilityTight |
34 |
< |
}; |
35 |
< |
static inline double sigWeight(double iVal0,double iVal1) { |
36 |
< |
if(iVal1 < 1.) return 1; |
37 |
< |
if(iVal0 < 3. && iVal1 > 3.) { |
38 |
< |
double lVal = TMath::Max(iVal0,1.); |
39 |
< |
return 1/TMath::Power(lVal,0.25); |
40 |
< |
} |
41 |
< |
double lVal = TMath::Max(iVal1,1.); |
42 |
< |
return 1/TMath::Power(lVal,0.25); |
43 |
< |
} |
44 |
< |
static inline int lastHit(mithep::Muon *iMuon) { |
45 |
< |
int lId = -1; |
46 |
< |
for(int i0 = 0; i0 < 8; i0++) { |
47 |
< |
if(iMuon->GetDX(i0) < 99999 || iMuon->GetDY(i0) < 99999) lId = i0; |
48 |
< |
} |
49 |
< |
return lId; |
50 |
< |
} |
51 |
< |
static inline int maxChamberId(mithep::Muon* iMuon,double iMaxD,double iMaxP) { |
52 |
< |
int lId = -1; |
53 |
< |
for(int i0 = 0; i0 < 8; i0++) { |
54 |
< |
if(iMuon->GetTrackDist(i0) < iMaxD && |
55 |
< |
iMuon->GetTrackDist(i0)/iMuon->GetTrackDistErr(i0) < iMaxP) { |
56 |
< |
if(iMuon->GetDX(i0) >= 999999) {lId = i0;} else {lId = -1;} |
57 |
< |
} |
58 |
< |
} |
59 |
< |
return lId; |
60 |
< |
} |
61 |
< |
static inline int lastStation(mithep::Muon* iMuon,double iMaxD,double iMaxP) { |
62 |
< |
int lId = -1; |
63 |
< |
for(int i0 = 0; i0 < 8; i0++) { |
64 |
< |
if((lId % 4) > (i0 % 4)) continue; |
65 |
< |
if(iMuon->GetTrackDist(i0) < iMaxD && |
66 |
< |
iMuon->GetTrackDist(i0)/iMuon->GetTrackDistErr(i0) < iMaxP) lId = i0; |
67 |
< |
} |
68 |
< |
return lId; |
69 |
< |
} |
70 |
< |
static inline int lastStation(mithep::Muon* iMuon,int iMax=8) { |
71 |
< |
int lId = -1; if(iMax > 8) iMax = 8; |
72 |
< |
for(int i0 = 0; i0 < iMax; i0++) {if(iMuon->StationBit(i0) && ((lId % 4) < (i0 % 4)))lId = i0;} |
73 |
< |
return lId; |
74 |
< |
} |
75 |
< |
static inline bool overflow(TH2D *iHist,double lVal0,double lVal1) { |
76 |
< |
if(iHist == 0) return true; |
77 |
< |
if(iHist ->GetXaxis()->FindBin(lVal0) == 0 || |
78 |
< |
iHist ->GetXaxis()->FindBin(lVal0) > iHist->GetNbinsX() || |
79 |
< |
iHist ->GetYaxis()->FindBin(lVal0) == 0 || |
80 |
< |
iHist ->GetYaxis()->FindBin(lVal0) > iHist->GetNbinsY()) return true; |
81 |
< |
return false; |
82 |
< |
} |
21 |
> |
public: |
22 |
> |
MuonTools(const char *mutemp="$CMSSW_BASE/src/MitPhysics/data/MuonCaloTemplate.root", |
23 |
> |
const char *pitemp="$CMSSW_BASE/src/MitPhysics/data/PionCaloTemplate.root"); |
24 |
> |
~MuonTools(); |
25 |
> |
|
26 |
> |
enum ESelType { |
27 |
> |
kAllArbitrated, |
28 |
> |
kPromptTight, |
29 |
> |
kTMLastStationLoose, |
30 |
> |
kTMLastStationTight, |
31 |
> |
kTMOneStationLoose, |
32 |
> |
kTMOneStationTight, |
33 |
> |
kTM2DCompatibilityLoose, |
34 |
> |
kTM2DCompatibilityTight |
35 |
> |
}; |
36 |
> |
|
37 |
> |
Bool_t Init(const char *mutemp, const char *pitemp); |
38 |
> |
Bool_t IsGood(const mithep::Muon *iMuon, ESelType iSel) const; |
39 |
> |
|
40 |
> |
protected: |
41 |
> |
void DeleteHistos(); |
42 |
> |
Double_t GetCaloCompatability(const mithep::Muon *iMuon, |
43 |
> |
Bool_t iEMSpecial, Bool_t iCorrectedHCAL) const; |
44 |
> |
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 |
> |
|
48 |
> |
private: |
49 |
> |
Bool_t fIsInit; //! |
50 |
> |
TH2D *fmuon_em_etaEmi; //! |
51 |
> |
TH2D *fmuon_had_etaEmi; //! |
52 |
> |
TH2D *fmuon_had_etaTmi; //! |
53 |
> |
TH2D *fmuon_em_etaB; //! |
54 |
> |
TH2D *fmuon_had_etaB; //! |
55 |
> |
TH2D *fmuon_ho_etaB; //! |
56 |
> |
TH2D *fmuon_had_etaTpl; //! |
57 |
> |
TH2D *fmuon_em_etaEpl; //! |
58 |
> |
TH2D *fmuon_had_etaEpl; //! |
59 |
> |
TH2D *fpion_em_etaEmi; //! |
60 |
> |
TH2D *fpion_had_etaEmi; //! |
61 |
> |
TH2D *fpion_had_etaTmi; //! |
62 |
> |
TH2D *fpion_em_etaB; //! |
63 |
> |
TH2D *fpion_had_etaB; //! |
64 |
> |
TH2D *fpion_ho_etaB; //! |
65 |
> |
TH2D *fpion_had_etaTpl; //! |
66 |
> |
TH2D *fpion_em_etaEpl; //! |
67 |
> |
TH2D *fpion_had_etaEpl; //! |
68 |
> |
|
69 |
> |
TH2D *LoadHisto(const char *fname, TFile *file) const; |
70 |
> |
}; |
71 |
> |
} |
72 |
> |
|
73 |
> |
//-------------------------------------------------------------------------------------------------- |
74 |
> |
inline Double_t mithep::MuonTools::SigWeight(Double_t iVal0, Double_t iVal1) const |
75 |
> |
{ |
76 |
> |
// |
77 |
> |
|
78 |
> |
if (iVal1 < 1.) |
79 |
> |
return 1.; |
80 |
> |
if (iVal0 < 3. && iVal1 > 3.) { |
81 |
> |
Double_t lVal = TMath::Max(iVal0,1.); |
82 |
> |
return 1./TMath::Power(lVal,0.25); |
83 |
> |
} |
84 |
> |
|
85 |
> |
Double_t lVal = TMath::Max(iVal1,1.); |
86 |
> |
return 1./TMath::Power(lVal,0.25); |
87 |
> |
} |
88 |
> |
|
89 |
> |
//-------------------------------------------------------------------------------------------------- |
90 |
> |
inline Bool_t mithep::MuonTools::Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1) const |
91 |
> |
{ |
92 |
> |
// Check if values are in overflow bins of given histogram. |
93 |
> |
|
94 |
> |
if(iHist == 0) |
95 |
> |
return kTRUE; |
96 |
> |
|
97 |
> |
if (iHist ->GetXaxis()->FindBin(lVal0) == 0 || |
98 |
> |
iHist ->GetXaxis()->FindBin(lVal0) > iHist->GetNbinsX() || |
99 |
> |
iHist ->GetYaxis()->FindBin(lVal0) == 0 || |
100 |
> |
iHist ->GetYaxis()->FindBin(lVal0) > iHist->GetNbinsY()) { |
101 |
> |
return kTRUE; |
102 |
> |
} |
103 |
> |
return kFALSE; |
104 |
> |
} |
105 |
> |
#endif |
106 |
> |
|
107 |
> |
#if 0 |
108 |
|
static inline MCParticle* etaPhiMatch(MCParticleCol* iMCParts,Muon *iMuon) { |
109 |
< |
mithep::MCParticle *lMC = 0; double lDR = 1.; double lPt = -1.; |
110 |
< |
for(unsigned int i0 = 0; i0 < iMCParts->GetEntries(); i0++) { |
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 pDR = mithep::MathUtils::DeltaR(pMC->Mom(),iMuon->Mom()); |
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; |
120 |
|
return lMC; |
121 |
|
} |
122 |
|
static inline Muon* match(MuonCol* iMuons,Track *iTrack) { |
123 |
< |
mithep::Muon *lMuon = 0; double lDR = 1.; double lPt = -1.; |
124 |
< |
for(unsigned int i0 = 0; i0 < iMuons->GetEntries(); i0++) { |
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 pDR = mithep::MathUtils::DeltaR(pMuon->Mom(),iTrack->Mom4(0.109)); |
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; |
132 |
|
} |
133 |
|
return lMuon; |
134 |
|
} |
102 |
– |
static inline int NSegments(mithep::Muon *iMuon) { |
103 |
– |
int lNSegs = 0; |
104 |
– |
for(int i0 = 0; i0 < 8; i0++) { |
105 |
– |
if(iMuon->StationBit(i0)) lNSegs++; |
106 |
– |
} |
107 |
– |
return lNSegs; |
108 |
– |
} |
109 |
– |
static inline bool promptTight(int iId,Muon *iMuon) { |
110 |
– |
const mithep::Track *lTrack = 0; |
111 |
– |
if(iId == 0 ) lTrack = iMuon->GlobalTrk(); |
112 |
– |
if(iId == 1 || (iId == -1 && lTrack == 0)) lTrack = iMuon->TrackerTrk(); |
113 |
– |
if(iId == 2 || (iId == -1 && lTrack == 0)) lTrack = iMuon->StandaloneTrk(); |
114 |
– |
if(lTrack == 0) return 0; |
115 |
– |
if(lTrack->NHits() < 11) return false; |
116 |
– |
if(lTrack->Chi2()/lTrack->Ndof() > 10.) return false; |
117 |
– |
if(lTrack->D0() > 0.2) return false; |
118 |
– |
if((lastHit(iMuon)% 4) == 0) return false; |
119 |
– |
return true; |
120 |
– |
} |
121 |
– |
static inline bool TMLastStation(Muon *iMuon,double iDYMin = 3., double iPYMin = 3.,double iDXMin = 3., double iPXMin = 3.,int iN = 2) { |
122 |
– |
if(iMuon->NSegments() < iN) return false; //2Last 1One |
123 |
– |
int lLast = lastStation(iMuon,-3.,-3.); //Last Required Station |
124 |
– |
if(lLast < 0) return false; |
125 |
– |
if(iMuon->GetDX(lLast) > 9999.) return false; |
126 |
– |
lLast = lastStation(iMuon); //No Requirements Imply StationMask (Segment and Track Arbitrated) |
127 |
– |
if(lLast < 0) return false; |
128 |
– |
if(!(fabs(iMuon->GetDX(lLast)) < iDXMin || |
129 |
– |
fabs(iMuon->GetPullX(lLast)) < iPXMin)) return false; |
130 |
– |
if(lLast == 3) lLast = lastStation(iMuon,3); |
131 |
– |
if(lLast < 0) return false; |
132 |
– |
if(!(fabs(iMuon->GetDY(lLast)) < iDYMin || //Old Code it was 9999 |
133 |
– |
fabs(iMuon->GetPullY(lLast)) < iPYMin)) return false; |
134 |
– |
return true; |
135 |
– |
} |
136 |
– |
static inline bool TMOneStation(Muon *iMuon,double iDYMin = 3., double iPYMin = 3.,double iDXMin = 3., double iPXMin = 3.,int iN = 1) { |
137 |
– |
if(iMuon->NSegments() < iN) return false; //2Last 1One |
138 |
– |
bool pGoodX = false; bool pBadY = false; |
139 |
– |
for(int i0 = 0; i0 < 8; i0++) { |
140 |
– |
if((fabs(iMuon->GetDX(i0)) < iDXMin || |
141 |
– |
fabs(iMuon->GetPullX(i0)) < iPXMin)) pGoodX = true; |
142 |
– |
if(pGoodX && |
143 |
– |
(fabs(iMuon->GetDY(i0)) < iDYMin || |
144 |
– |
fabs(iMuon->GetPullY(i0)) < iPYMin)) return true; |
145 |
– |
if(fabs(iMuon->GetDY(i0)) < 999999) pBadY = true; |
146 |
– |
if(i0 == 3 && pGoodX && !pBadY) return true; |
147 |
– |
} |
148 |
– |
return false; |
149 |
– |
} |
150 |
– |
static inline double getCaloCompatabilitySlowly(mithep::Muon* iMuon,bool iEMSpecial, bool iCorrectedHCAL) { |
151 |
– |
//if(fpion_em_etaEmi == 0) { |
152 |
– |
std::cout << "Warning Loading Compatability Slowly" << std::endl; |
153 |
– |
TFile* lPion_templates = new TFile("MitCommon/MuonTools/data/PionCaloTemplate.root","READ"); |
154 |
– |
TFile* lMuon_templates = new TFile("MitCommon/MuonTools/data/MuonCaloTemplate.root","READ"); |
155 |
– |
TH2D* lpion_em_etaEmi = (TH2D*) lPion_templates->Get("em_etaEmi"); |
156 |
– |
TH2D* lpion_had_etaEmi = (TH2D*) lPion_templates->Get("had_etaEmi"); |
157 |
– |
TH2D* lpion_had_etaTmi = (TH2D*) lPion_templates->Get("had_etaTmi"); |
158 |
– |
TH2D* lpion_em_etaB = (TH2D*) lPion_templates->Get("em_etaB") ; |
159 |
– |
TH2D* lpion_had_etaB = (TH2D*) lPion_templates->Get("had_etaB") ; |
160 |
– |
TH2D* lpion_ho_etaB = (TH2D*) lPion_templates->Get("ho_etaB") ; |
161 |
– |
TH2D* lpion_had_etaTpl = (TH2D*) lPion_templates->Get("had_etaTpl"); |
162 |
– |
TH2D* lpion_em_etaEpl = (TH2D*) lPion_templates->Get("em_etaEpl") ; |
163 |
– |
TH2D* lpion_had_etaEpl = (TH2D*) lPion_templates->Get("had_etaEpl"); |
164 |
– |
TH2D* lmuon_em_etaEmi = (TH2D*) lMuon_templates->Get("em_etaEmi") ; |
165 |
– |
TH2D* lmuon_had_etaEmi = (TH2D*) lMuon_templates->Get("had_etaEmi"); |
166 |
– |
TH2D* lmuon_had_etaTmi = (TH2D*) lMuon_templates->Get("had_etaTmi"); |
167 |
– |
TH2D* lmuon_em_etaB = (TH2D*) lMuon_templates->Get("em_etaB") ; |
168 |
– |
TH2D* lmuon_had_etaB = (TH2D*) lMuon_templates->Get("had_etaB") ; |
169 |
– |
TH2D* lmuon_ho_etaB = (TH2D*) lMuon_templates->Get("ho_etaB") ; |
170 |
– |
TH2D* lmuon_had_etaTpl = (TH2D*) lMuon_templates->Get("had_etaTpl"); |
171 |
– |
TH2D* lmuon_em_etaEpl = (TH2D*) lMuon_templates->Get("em_etaEpl"); |
172 |
– |
TH2D* lmuon_had_etaEpl = (TH2D*) lMuon_templates->Get("had_etaEpl"); |
173 |
– |
//} |
174 |
– |
double lEta = -1.; double lP = -1; |
175 |
– |
double lEM = -5.; double lHad = 0; double lHO = 0; |
176 |
– |
lEta = iMuon->Eta(); |
177 |
– |
lP = iMuon->P(); |
178 |
– |
if(lP >= 2000.) lP = 1999.9; |
179 |
– |
if(!iEMSpecial || iMuon->EmEnergy() != 0.) lEM = iMuon->EmEnergy(); |
180 |
– |
lHad = iMuon->HadEnergy(); |
181 |
– |
lHO = iMuon->HoEnergy(); |
182 |
– |
if(lP < 0. ) return 0.5; |
183 |
– |
if(fabs(lEta) > 2.5 ) return 0.5; |
184 |
– |
TH2D* lTMuonHad = NULL; |
185 |
– |
TH2D* lTPionHad = NULL; |
186 |
– |
TH2D* lTMuonHo = NULL; |
187 |
– |
TH2D* lTPionHo = NULL; |
188 |
– |
TH2D* lTMuonEm = NULL; |
189 |
– |
TH2D* lTPionEm = NULL; |
190 |
– |
|
191 |
– |
if(fabs(lEta) >= 1.27) { |
192 |
– |
if(iCorrectedHCAL) lHad *= 1.8/2.2; |
193 |
– |
if(lEta > 0) { |
194 |
– |
lTPionHad = lpion_had_etaEpl; |
195 |
– |
lTMuonHad = lmuon_had_etaEpl; |
196 |
– |
} else { |
197 |
– |
lTPionHad = lpion_had_etaEmi; |
198 |
– |
lTMuonHad = lmuon_had_etaEmi; |
199 |
– |
} |
200 |
– |
} |
201 |
– |
if(fabs(lEta) < 1.27 && fabs(lEta) >= 1.1 ) { |
202 |
– |
if(iCorrectedHCAL) lHad *= (1.8/(-2.2*fabs(lEta)+5.5)); |
203 |
– |
if(lEta > 0) { |
204 |
– |
lTPionHad = lpion_had_etaTpl; |
205 |
– |
lTMuonHad = lmuon_had_etaTpl; |
206 |
– |
} else { |
207 |
– |
lTPionHad = lpion_had_etaTmi; |
208 |
– |
lTMuonHad = lmuon_had_etaTmi; |
209 |
– |
} |
210 |
– |
} |
211 |
– |
if(fabs(lEta) < 1.1) { |
212 |
– |
if(iCorrectedHCAL) lHad *= sin(2*atan(exp(iMuon->Eta()))); |
213 |
– |
lTPionHad = lpion_had_etaB; |
214 |
– |
lTMuonHad = lmuon_had_etaB; |
215 |
– |
} |
216 |
– |
if(lEta > 1.479 ) { |
217 |
– |
lTPionEm = lpion_em_etaEpl; |
218 |
– |
lTMuonEm = lmuon_em_etaEpl; |
219 |
– |
} |
220 |
– |
if(fabs(lEta) <= 1.479) { |
221 |
– |
lTPionEm = lpion_em_etaB; |
222 |
– |
lTMuonEm = lmuon_em_etaB; |
223 |
– |
} |
224 |
– |
if(lEta < -1.479 ) { |
225 |
– |
lTPionEm = lpion_em_etaEmi; |
226 |
– |
lTMuonEm = lmuon_em_etaEmi; |
227 |
– |
} |
228 |
– |
if(fabs(lEta) < 1.28) { |
229 |
– |
lTPionHo = lpion_ho_etaB; |
230 |
– |
lTMuonHo = lmuon_ho_etaB; |
231 |
– |
} |
232 |
– |
|
233 |
– |
double lPBX = 1.; double lPSX = 1.; |
234 |
– |
double lPBY = 1.; double lPSY = 1.; |
235 |
– |
double lPBZ = 1.; double lPSZ = 1.; |
236 |
– |
if(!overflow(lTPionEm, lP,lEM)) lPBX = lTPionEm ->GetBinContent(lTPionEm ->GetXaxis()->FindBin(lP),lTPionEm ->GetYaxis()->FindBin(lEM) ); |
237 |
– |
if(!overflow(lTPionHad,lP,lHad)) lPBY = lTPionHad->GetBinContent(lTPionHad->GetXaxis()->FindBin(lP),lTPionHad->GetYaxis()->FindBin(lHad)); |
238 |
– |
if(!overflow(lTPionHo, lP,lHO)) lPBZ = lTPionHo ->GetBinContent(lTPionHo ->GetXaxis()->FindBin(lP),lTPionHo ->GetYaxis()->FindBin(lHO) ); |
239 |
– |
if(!overflow(lTMuonEm, lP,lEM )) lPSX = lTMuonEm ->GetBinContent(lTMuonEm ->GetXaxis()->FindBin(lP),lTMuonEm ->GetYaxis()->FindBin(lEM) ); |
240 |
– |
if(!overflow(lTMuonHad,lP,lHad)) lPSY = lTMuonHad->GetBinContent(lTMuonHad->GetXaxis()->FindBin(lP),lTMuonHad->GetYaxis()->FindBin(lHad)); |
241 |
– |
if(!overflow(lTMuonHo ,lP,lHO)) lPSZ = lTMuonHo ->GetBinContent(lTMuonHo ->GetXaxis()->FindBin(lP),lTMuonHo ->GetYaxis()->FindBin(lHO) ); |
242 |
– |
|
243 |
– |
if(lPSX == 0. || lPBX == 0. || (lEM <= 0. && !iEMSpecial)) {lPSX = 1.; lPBX = 1.;} |
244 |
– |
if(lPSY == 0. || lPBY == 0. || lHad == 0.) {lPSY = 1.; lPBY = 1.;} |
245 |
– |
if(lPSZ == 0. || lPBZ == 0. || lHO == 0.) {lPSZ = 1.; lPBZ = 1.;} |
246 |
– |
lPion_templates->Close(); |
247 |
– |
lMuon_templates->Close(); |
248 |
– |
if((lPSX*lPSY*lPSZ+lPBX*lPBY*lPBZ) > 0.) return lPSX*lPSY*lPSZ/(lPSX*lPSY*lPSZ+lPBX*lPBY*lPBZ); |
249 |
– |
return 0.5; |
250 |
– |
} |
251 |
– |
static inline float getSegmentCompatability(const mithep::Muon* iMuon) { |
252 |
– |
int lNStationsCrossed = 0; |
253 |
– |
int lNStationsSegment = 0; |
254 |
– |
|
255 |
– |
std::vector<int> lStTrack(8); |
256 |
– |
std::vector<int> lStSegmentmatch(8); |
257 |
– |
std::vector<int> lStCrossed(8); |
258 |
– |
std::vector<float> lStBoundary(8); |
259 |
– |
std::vector<float> lStWeight(8); |
260 |
– |
float lWeight = 0.; |
261 |
– |
bool lAdjust = true; |
262 |
– |
for(int i0 = 0; i0 < 8; i0++) { |
263 |
– |
if(iMuon->GetTrackDist(i0) < 999999. ) { |
264 |
– |
lNStationsCrossed++; |
265 |
– |
lStCrossed[i0] = 1; |
266 |
– |
lStBoundary[i0] = 0.; |
267 |
– |
if(iMuon->GetTrackDist(i0) > -10. ) lStBoundary[i0] = iMuon->GetTrackDist(i0); |
268 |
– |
} |
269 |
– |
if(iMuon->GetDX(i0) < 999999.) { //Use iMuon->GetSegmentX--> CHECK |
270 |
– |
lNStationsSegment++; |
271 |
– |
lStSegmentmatch[i0] = 1; |
272 |
– |
} |
273 |
– |
if(iMuon->GetDY(i0) < 999999.) lAdjust = false; |
274 |
– |
} |
275 |
– |
int lPCross = -1; |
276 |
– |
const float lAtWeight = 0.5; |
277 |
– |
for(int i0 = 0; i0< 8; i0++) { |
278 |
– |
lStWeight[i0] = 0; |
279 |
– |
if(lStCrossed[i0] > 0 ) { lPCross++; |
280 |
– |
switch ( lNStationsCrossed ) { |
281 |
– |
case 1 : |
282 |
– |
lStWeight[i0] = 1.; |
283 |
– |
break; |
284 |
– |
case 2 : |
285 |
– |
if ( lPCross == 0 ) lStWeight[i0] = 0.33; |
286 |
– |
else lStWeight[i0] = 0.67; |
287 |
– |
break; |
288 |
– |
case 3 : |
289 |
– |
if ( lPCross == 0 ) lStWeight[i0] = 0.23; |
290 |
– |
else if( lPCross == 1 ) lStWeight[i0] = 0.33; |
291 |
– |
else lStWeight[i0] = 0.44; |
292 |
– |
break; |
293 |
– |
case 4 : |
294 |
– |
if ( lPCross == 0 ) lStWeight[i0] = 0.10; |
295 |
– |
else if( lPCross == 1 ) lStWeight[i0] = 0.20; |
296 |
– |
else if( lPCross == 2 ) lStWeight[i0] = 0.30; |
297 |
– |
else lStWeight[i0] = 0.40; |
298 |
– |
break; |
299 |
– |
|
300 |
– |
default : |
301 |
– |
lStWeight[i0] = 1./lNStationsCrossed; |
302 |
– |
} |
303 |
– |
|
304 |
– |
if(lStSegmentmatch[i0] <= 0 && lStBoundary[i0] != 0. ) { |
305 |
– |
lStWeight[i0] *= lAtWeight*0.5*(TMath::Erf(lStBoundary[i0]/6.)+1.); |
306 |
– |
} else if(lStSegmentmatch[i0] <= 0 && lStBoundary[i0] == 0) {lStWeight[i0] = 0.;} |
307 |
– |
|
308 |
– |
if( lStSegmentmatch[i0] > 0) { |
309 |
– |
double lP2X = TMath::Power(iMuon->GetPullX(i0),2.); |
310 |
– |
double lP2Y = TMath::Power(iMuon->GetPullY(i0),2.); |
311 |
– |
double lD2X = TMath::Power(iMuon->GetDX(i0),2.); |
312 |
– |
double lD2Y = TMath::Power(iMuon->GetDY(i0),2.); |
313 |
– |
if( iMuon->GetDY(i0) < 999999 && iMuon->GetDX(i0) < 999999) { |
314 |
– |
lStWeight[i0] *= sigWeight(sqrt(lD2X+lD2Y),sqrt(lP2X+lP2Y)); |
315 |
– |
} else if (iMuon->GetDY(i0) >= 999999 && i0 < 4) { |
316 |
– |
lStWeight[i0] *= sigWeight(iMuon->GetDX(i0),iMuon->GetPullX(i0)); |
317 |
– |
} else if(i0 < 4) { |
318 |
– |
lStWeight[i0] *= sigWeight(iMuon->GetDY(i0),iMuon->GetPullY(i0)); |
319 |
– |
} |
320 |
– |
} |
321 |
– |
} |
322 |
– |
lWeight += lStWeight[i0]; |
323 |
– |
} |
324 |
– |
if(lNStationsCrossed == 0) lWeight = 0.5; |
325 |
– |
return lWeight; |
326 |
– |
} |
327 |
– |
static inline bool isGoodMuon(mithep::Muon *iMuon,selection iSelection) { |
328 |
– |
double lVal = 0; |
329 |
– |
switch(iSelection) { |
330 |
– |
case AllArbitrated: |
331 |
– |
if(iMuon->StandaloneTrk() != 0 || iMuon->GlobalTrk()!= 0) return true; |
332 |
– |
if(iMuon->NSegments() > 0) return true; |
333 |
– |
return false; |
334 |
– |
break; |
335 |
– |
case PromptTight: |
336 |
– |
return promptTight(-1,iMuon); |
337 |
– |
break; |
338 |
– |
case TMOneStationLoose: |
339 |
– |
return TMOneStation(iMuon,99999,999999); |
340 |
– |
case TMOneStationTight: |
341 |
– |
return TMOneStation(iMuon); |
342 |
– |
case TMLastStationLoose: |
343 |
– |
return TMLastStation(iMuon,999999,999999); |
344 |
– |
break; |
345 |
– |
case TMLastStationTight: |
346 |
– |
return TMLastStation(iMuon); |
347 |
– |
break; |
348 |
– |
case TM2DCompatibilityLoose: |
349 |
– |
lVal = 1.2*getSegmentCompatability(iMuon); |
350 |
– |
if(lVal/1.2 == 0.5) return false; |
351 |
– |
//if(fClass ) lVal += 0.8*getCaloCompatability(iMuon,true,true); |
352 |
– |
lVal += 0.8*getCaloCompatabilitySlowly(iMuon,true,true); |
353 |
– |
if(lVal > 0.7) return true; |
354 |
– |
return false; |
355 |
– |
break; |
356 |
– |
case TM2DCompatibilityTight: |
357 |
– |
lVal = 1.2*getSegmentCompatability(iMuon); |
358 |
– |
if(lVal/1.2 == 0.5) return false; |
359 |
– |
//if(fClass ) lVal += 0.8*getCaloCompatability(iMuon,true,true); |
360 |
– |
lVal += 0.8*getCaloCompatabilitySlowly(iMuon,true,true); |
361 |
– |
if(lVal > 1.0) return true; |
362 |
– |
return false; |
363 |
– |
break; |
364 |
– |
default: |
365 |
– |
return false; |
366 |
– |
} |
367 |
– |
return false; |
368 |
– |
} |
369 |
– |
bool isGood(mithep::Muon *iMuon,selection iSelection); |
370 |
– |
private: |
371 |
– |
TFile *fMuon_templates; |
372 |
– |
TFile *fPion_templates; |
373 |
– |
TH2D* fpion_em_etaEmi; |
374 |
– |
TH2D* fpion_had_etaEmi; |
375 |
– |
TH2D* fpion_had_etaTmi; |
376 |
– |
TH2D* fpion_em_etaB; |
377 |
– |
TH2D* fpion_had_etaB; |
378 |
– |
TH2D* fpion_ho_etaB; |
379 |
– |
TH2D* fpion_had_etaTpl; |
380 |
– |
TH2D* fpion_em_etaEpl; |
381 |
– |
TH2D* fpion_had_etaEpl; |
382 |
– |
TH2D* fmuon_em_etaEmi; |
383 |
– |
TH2D* fmuon_had_etaEmi; |
384 |
– |
TH2D* fmuon_had_etaTmi; |
385 |
– |
TH2D* fmuon_em_etaB; |
386 |
– |
TH2D* fmuon_had_etaB; |
387 |
– |
TH2D* fmuon_ho_etaB; |
388 |
– |
TH2D* fmuon_had_etaTpl; |
389 |
– |
TH2D* fmuon_em_etaEpl; |
390 |
– |
TH2D* fmuon_had_etaEpl; |
391 |
– |
}; |
392 |
– |
} |
393 |
– |
|
135 |
|
#endif |
136 |
+ |
|
137 |
+ |
|