2 |
|
|
3 |
|
#include "MitPhysics/Mods/interface/MuonIDMod.h" |
4 |
|
#include "MitCommon/MathTools/interface/MathUtils.h" |
5 |
+ |
#include "MitAna/DataTree/interface/MuonCol.h" |
6 |
+ |
#include "MitAna/DataTree/interface/VertexCol.h" |
7 |
|
#include "MitPhysics/Init/interface/ModNames.h" |
8 |
|
|
9 |
|
using namespace mithep; |
15 |
|
BaseMod(name,title), |
16 |
|
fMuonBranchName(Names::gkMuonBrn), |
17 |
|
fCleanMuonsName(ModNames::gkCleanMuonsName), |
18 |
+ |
fVertexName("PrimaryVertexesBeamSpot"), |
19 |
|
fMuonIDType("Loose"), |
20 |
|
fMuonIsoType("TrackCaloSliding"), |
21 |
|
fMuonClassType("Global"), |
23 |
|
fCaloIsolationCut(3.0), |
24 |
|
fCombIsolationCut(5.0), |
25 |
|
fMuonPtMin(10), |
26 |
< |
fMuons(0) |
26 |
> |
fApplyD0Cut(kTRUE), |
27 |
> |
fD0Cut(0.025), |
28 |
> |
fReverseIsoCut(kFALSE), |
29 |
> |
fReverseD0Cut(kFALSE), |
30 |
> |
fMuIDType(kIdUndef), |
31 |
> |
fMuIsoType(kIsoUndef), |
32 |
> |
fMuClassType(kClassUndef), |
33 |
> |
fMuons(0), |
34 |
> |
fVertices(0), |
35 |
> |
fMuonTools(0) |
36 |
|
{ |
37 |
|
// Constructor. |
38 |
|
} |
42 |
|
{ |
43 |
|
// Process entries of the tree. |
44 |
|
|
45 |
< |
LoadBranch(fMuonBranchName); |
45 |
> |
LoadEventObject(fMuonBranchName, fMuons); |
46 |
> |
if (fApplyD0Cut) { |
47 |
> |
LoadEventObject(fVertexName, fVertices); |
48 |
> |
} |
49 |
|
|
50 |
|
MuonOArr *CleanMuons = new MuonOArr; |
51 |
|
CleanMuons->SetName(fCleanMuonsName); |
54 |
|
const Muon *mu = fMuons->At(i); |
55 |
|
|
56 |
|
Bool_t pass = kFALSE; |
57 |
< |
Double_t pt = -1; // make sure pt is taken from the correct track! |
57 |
> |
Double_t pt = 0; // make sure pt is taken from the correct track! |
58 |
|
switch (fMuClassType) { |
59 |
|
case kAll: |
60 |
|
pass = kTRUE; |
61 |
< |
pt = mu->Pt(); |
61 |
> |
if (mu->HasTrk()) |
62 |
> |
pt = mu->Pt(); |
63 |
|
break; |
64 |
|
case kGlobal: |
65 |
< |
pass = (mu->GlobalTrk() != 0); |
65 |
> |
pass = mu->HasGlobalTrk(); |
66 |
|
if (pass) |
67 |
|
pt = mu->GlobalTrk()->Pt(); |
68 |
|
break; |
69 |
|
case kSta: |
70 |
< |
pass = (mu->StandaloneTrk() != 0); |
70 |
> |
pass = mu->HasStandaloneTrk(); |
71 |
|
if (pass) |
72 |
|
pt = mu->StandaloneTrk()->Pt(); |
73 |
|
break; |
74 |
< |
case kTrackerOnly: |
75 |
< |
pass = (mu->TrackerTrk() != 0); |
74 |
> |
case kTrackerMuon: |
75 |
> |
pass = mu->HasTrackerTrk() && mu->IsTrackerMuon(); |
76 |
> |
if (pass) |
77 |
> |
pt = mu->TrackerTrk()->Pt(); |
78 |
> |
break; |
79 |
> |
case kCaloMuon: |
80 |
> |
pass = mu->HasTrackerTrk() && mu->IsCaloMuon(); |
81 |
> |
if (pass) |
82 |
> |
pt = mu->TrackerTrk()->Pt(); |
83 |
> |
break; |
84 |
> |
case kTrackerBased: |
85 |
> |
pass = mu->HasTrackerTrk(); |
86 |
|
if (pass) |
87 |
|
pt = mu->TrackerTrk()->Pt(); |
88 |
|
break; |
106 |
|
idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationTight) && |
107 |
|
fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityTight); |
108 |
|
break; |
109 |
+ |
case kNoId: |
110 |
+ |
idpass = kTRUE; |
111 |
+ |
break; |
112 |
|
default: |
113 |
|
break; |
114 |
|
} |
116 |
|
if (!idpass) |
117 |
|
continue; |
118 |
|
|
119 |
< |
Bool_t isopass = kFALSE; |
119 |
> |
Bool_t isocut = kFALSE; |
120 |
|
switch (fMuIsoType) { |
121 |
|
case kTrackCalo: |
122 |
< |
isopass = (mu->IsoR03SumPt() < fTrackIsolationCut) && |
122 |
> |
isocut = (mu->IsoR03SumPt() < fTrackIsolationCut) && |
123 |
|
(mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut); |
124 |
|
break; |
125 |
|
case kTrackCaloCombined: |
126 |
< |
isopass = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() + |
126 |
> |
isocut = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() + |
127 |
|
1.0 * mu->IsoR03HadEt() < fCombIsolationCut); |
128 |
|
break; |
129 |
|
case kTrackCaloSliding: |
131 |
|
Double_t totalIso = 1.0 * mu->IsoR03SumPt() + |
132 |
|
1.0 * mu->IsoR03EmEt() + |
133 |
|
1.0 * mu->IsoR03HadEt(); |
134 |
< |
if ((totalIso < (mu->Pt()-10.0)*5.0/15.0 && mu->Pt() <= 25) || |
135 |
< |
(totalIso < 5.0 && mu->Pt() > 25) || |
136 |
< |
totalIso <= 0) |
137 |
< |
isopass = kTRUE; |
138 |
< |
} |
134 |
> |
if (totalIso < (mu->Pt()-10.0)*5.0/20.0 || |
135 |
> |
totalIso <= 0) |
136 |
> |
isocut = kTRUE; |
137 |
> |
|
138 |
> |
if (fReverseIsoCut == kTRUE && |
139 |
> |
isocut == kFALSE && totalIso < 10) |
140 |
> |
isocut = kTRUE; |
141 |
> |
else if(fReverseIsoCut == kTRUE) |
142 |
> |
isocut = kFALSE; |
143 |
> |
} |
144 |
|
break; |
145 |
|
case kNoIso: |
146 |
< |
isopass = kTRUE; |
146 |
> |
isocut = kTRUE; |
147 |
|
break; |
148 |
|
case kCustomIso: |
149 |
|
default: |
150 |
|
break; |
151 |
|
} |
152 |
|
|
153 |
< |
if (!isopass) |
153 |
> |
if (isocut == kFALSE) |
154 |
|
continue; |
155 |
|
|
156 |
+ |
if (fApplyD0Cut) { |
157 |
+ |
Bool_t d0cut = kFALSE; |
158 |
+ |
const Track *mt = mu->BestTrk(); |
159 |
+ |
if (!mt) |
160 |
+ |
continue; |
161 |
+ |
Double_t d0_real = 1e30; |
162 |
+ |
for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) { |
163 |
+ |
Double_t pD0 = mt->D0Corrected(*fVertices->At(i0)); |
164 |
+ |
if(TMath::Abs(pD0) < TMath::Abs(d0_real)) |
165 |
+ |
d0_real = TMath::Abs(pD0); |
166 |
+ |
} |
167 |
+ |
if(d0_real < fD0Cut) d0cut = kTRUE; |
168 |
+ |
|
169 |
+ |
if (fReverseD0Cut == kTRUE && |
170 |
+ |
d0cut == kFALSE && d0_real < 0.05) |
171 |
+ |
d0cut = kTRUE; |
172 |
+ |
else if(fReverseD0Cut == kTRUE) |
173 |
+ |
d0cut = kFALSE; |
174 |
+ |
|
175 |
+ |
if (d0cut == kFALSE) |
176 |
+ |
continue; |
177 |
+ |
} |
178 |
+ |
|
179 |
|
// add good muon |
180 |
|
CleanMuons->Add(mu); |
181 |
|
} |
193 |
|
// Run startup code on the computer (slave) doing the actual analysis. Here, |
194 |
|
// we just request the muon collection branch. |
195 |
|
|
196 |
< |
ReqBranch(fMuonBranchName, fMuons); |
196 |
> |
ReqEventObject(fMuonBranchName, fMuons, kTRUE); |
197 |
> |
|
198 |
> |
if (fApplyD0Cut) |
199 |
> |
ReqEventObject(fVertexName, fVertices, kTRUE); |
200 |
|
|
201 |
|
fMuonTools = new MuonTools; |
202 |
|
|
242 |
|
fMuClassType = kGlobal; |
243 |
|
else if (fMuonClassType.CompareTo("Standalone") == 0) |
244 |
|
fMuClassType = kSta; |
245 |
< |
else if (fMuonClassType.CompareTo("TrackerOnly") == 0) |
246 |
< |
fMuClassType = kTrackerOnly; |
245 |
> |
else if (fMuonClassType.CompareTo("TrackerMuon") == 0) |
246 |
> |
fMuClassType = kTrackerMuon; |
247 |
> |
else if (fMuonClassType.CompareTo("CaloMuon") == 0) |
248 |
> |
fMuClassType = kCaloMuon; |
249 |
> |
else if (fMuonClassType.CompareTo("TrackerBased") == 0) |
250 |
> |
fMuClassType = kTrackerBased; |
251 |
|
else { |
252 |
|
SendError(kAbortAnalysis, "SlaveBegin", |
253 |
|
"The specified muon class %s is not defined.", |