ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MuonIDMod.cc
Revision: 1.8
Committed: Fri Nov 28 09:56:42 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.7: +5 -6 lines
Log Message:
Set better default values.

File Contents

# User Rev Content
1 loizides 1.8 // $Id: MuonIDMod.cc,v 1.7 2008/11/28 09:13:50 loizides Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/MuonIDMod.h"
4 loizides 1.6 #include "MitCommon/MathTools/interface/MathUtils.h"
5     #include "MitPhysics/Init/interface/ModNames.h"
6 loizides 1.1
7     using namespace mithep;
8    
9     ClassImp(mithep::MuonIDMod)
10    
11     //--------------------------------------------------------------------------------------------------
12     MuonIDMod::MuonIDMod(const char *name, const char *title) :
13     BaseMod(name,title),
14 loizides 1.6 fMuonBranchName(Names::gkMuonBrn),
15     fCleanMuonsName(ModNames::gkCleanMuonsName),
16 loizides 1.8 fMuonIDType("Loose"),
17     fMuonIsoType("TrackCaloSliding"),
18 loizides 1.6 fMuonClassType("Global"),
19 ceballos 1.2 fTrackIsolationCut(3.0),
20     fCaloIsolationCut(3.0),
21 loizides 1.8 fCombIsolationCut(5.0),
22 ceballos 1.3 fMuonPtMin(10),
23 loizides 1.6 fMuons(0)
24 loizides 1.1 {
25     // Constructor.
26     }
27    
28    
29     //--------------------------------------------------------------------------------------------------
30     void MuonIDMod::Process()
31     {
32     // Process entries of the tree.
33    
34 loizides 1.6 LoadBranch(fMuonBranchName);
35 loizides 1.1
36 loizides 1.7 MuonOArr *CleanMuons = new MuonOArr;
37     CleanMuons->SetName(fCleanMuonsName);
38 loizides 1.1
39     for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
40 loizides 1.8 const Muon *mu = fMuons->At(i);
41 loizides 1.6
42     Bool_t pass = kFALSE;
43     Double_t pt = -1; // make sure pt is taken from the correct track!
44     switch (fMuClassType) {
45     case kAll:
46     pass = kTRUE;
47     pt = mu->Pt();
48     break;
49     case kGlobal:
50     pass = (mu->GlobalTrk() != 0);
51     if (pass)
52     pt = mu->GlobalTrk()->Pt();
53     break;
54     case kSta:
55     pass = (mu->StandaloneTrk() != 0);
56     if (pass)
57     pt = mu->StandaloneTrk()->Pt();
58     break;
59     case kTrackerOnly:
60     pass = (mu->TrackerTrk() != 0);
61     if (pass)
62     pt = mu->TrackerTrk()->Pt();
63     break;
64     default:
65     break;
66 ceballos 1.5 }
67 loizides 1.6
68     if (!pass)
69     continue;
70    
71     if (pt <= fMuonPtMin)
72     continue;
73    
74     Bool_t idpass = kFALSE;
75     switch (fMuIDType) {
76     case kLoose:
77     idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationLoose) &&
78     fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityLoose);
79     break;
80     case kTight:
81     idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationTight) &&
82     fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityTight);
83     break;
84     default:
85     break;
86 ceballos 1.4 }
87 loizides 1.6
88     if (!idpass)
89     continue;
90    
91     Bool_t isopass = kFALSE;
92     switch (fMuIsoType) {
93     case kTrackCalo:
94     isopass = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
95     (mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut);
96     break;
97     case kTrackCaloCombined:
98     isopass = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
99     1.0 * mu->IsoR03HadEt() < fCombIsolationCut);
100     break;
101     case kTrackCaloSliding:
102     {
103     Double_t totalIso = 1.0 * mu->IsoR03SumPt() +
104     1.0 * mu->IsoR03EmEt() +
105     1.0 * mu->IsoR03HadEt();
106     if ((totalIso < (mu->Pt()-10.0)*5.0/15.0) ||
107     (totalIso < 5.0 && mu->Pt() > 25))
108     isopass = kTRUE;
109     }
110     break;
111     case kNoIso:
112     isopass = kTRUE;
113     break;
114     case kCustomIso:
115     default:
116     break;
117 ceballos 1.4 }
118 ceballos 1.3
119 loizides 1.6 if (!isopass)
120     continue;
121    
122     // add good muon
123     CleanMuons->Add(mu);
124 loizides 1.1 }
125    
126 loizides 1.6 // add objects for other modules to use
127 loizides 1.7 AddObjThisEvt(CleanMuons);
128 loizides 1.1 }
129    
130    
131     //--------------------------------------------------------------------------------------------------
132     void MuonIDMod::SlaveBegin()
133     {
134     // Run startup code on the computer (slave) doing the actual analysis. Here,
135 loizides 1.6 // we just request the muon collection branch.
136    
137     ReqBranch(fMuonBranchName, fMuons);
138 loizides 1.1
139 loizides 1.6 fMuonTools = new MuonTools;
140 loizides 1.1
141 loizides 1.6 if (fMuonIDType.CompareTo("Tight") == 0)
142     fMuIDType = kTight;
143     else if (fMuonIDType.CompareTo("Loose") == 0)
144     fMuIDType = kLoose;
145     else if (fMuonIDType.CompareTo("Custom") == 0) {
146     fMuIDType = kCustomId;
147     SendError(kWarning, "SlaveBegin",
148     "Custom muon identification is not yet implemented.");
149     } else {
150     SendError(kAbortAnalysis, "SlaveBegin",
151     "The specified muon identification %s is not defined.",
152     fMuonIDType.Data());
153     return;
154     }
155 loizides 1.1
156 loizides 1.6 if (fMuonIsoType.CompareTo("TrackCalo") == 0)
157     fMuIsoType = kTrackCalo;
158     else if (fMuonIsoType.CompareTo("TrackCaloCombined") == 0)
159     fMuIsoType = kTrackCaloCombined;
160     else if (fMuonIsoType.CompareTo("TrackCaloSliding") == 0)
161     fMuIsoType = kTrackCaloSliding;
162     else if (fMuonIsoType.CompareTo("NoIso") == 0)
163     fMuIsoType = kNoIso;
164     else if (fMuonIsoType.CompareTo("Custom") == 0) {
165     fMuIsoType = kCustomIso;
166     SendError(kWarning, "SlaveBegin",
167     "Custom muon isolation is not yet implemented.");
168     } else {
169     SendError(kAbortAnalysis, "SlaveBegin",
170     "The specified muon isolation %s is not defined.",
171     fMuonIsoType.Data());
172     return;
173     }
174 loizides 1.1
175 loizides 1.6 if (fMuonClassType.CompareTo("All") == 0)
176     fMuClassType = kAll;
177     else if (fMuonClassType.CompareTo("Global") == 0)
178     fMuClassType = kGlobal;
179     else if (fMuonClassType.CompareTo("Standalone") == 0)
180     fMuClassType = kSta;
181     else if (fMuonClassType.CompareTo("TrackerOnly") == 0)
182     fMuClassType = kTrackerOnly;
183     else {
184     SendError(kAbortAnalysis, "SlaveBegin",
185     "The specified muon class %s is not defined.",
186     fMuonClassType.Data());
187     return;
188     }
189 loizides 1.1 }