ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MuonIDMod.cc
(Generate patch)

Comparing UserCode/MitPhysics/Mods/src/MuonIDMod.cc (file contents):
Revision 1.13 by loizides, Thu Dec 11 15:53:03 2008 UTC vs.
Revision 1.33 by ceballos, Sun Aug 22 11:17:42 2010 UTC

# Line 2 | Line 2
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;
# Line 13 | Line 15 | ClassImp(mithep::MuonIDMod)
15    BaseMod(name,title),
16    fMuonBranchName(Names::gkMuonBrn),
17    fCleanMuonsName(ModNames::gkCleanMuonsName),  
18 <  fMuonIDType("Loose"),
18 >  fVertexName("PrimaryVertexes"),
19 >  fMuonIDType("Minimal"),
20    fMuonIsoType("TrackCaloSliding"),  
21    fMuonClassType("Global"),  
22    fTrackIsolationCut(3.0),
23    fCaloIsolationCut(3.0),
24    fCombIsolationCut(5.0),
25    fMuonPtMin(10),
26 <  fMuons(0)
26 >  fApplyD0Cut(kTRUE),
27 >  fD0Cut(0.020),
28 >  fEtaCut(2.4),
29 >  fReverseIsoCut(kFALSE),
30 >  fReverseD0Cut(kFALSE),
31 >  fMuIDType(kIdUndef),
32 >  fMuIsoType(kIsoUndef),
33 >  fMuClassType(kClassUndef),
34 >  fMuons(0),
35 >  fVertices(0),
36 >  fMuonTools(0)
37   {
38    // Constructor.
39   }
# Line 30 | Line 43 | void MuonIDMod::Process()
43   {
44    // Process entries of the tree.
45  
46 <  LoadBranch(fMuonBranchName);
46 >  LoadEventObject(fMuonBranchName, fMuons);
47 >  if (fApplyD0Cut) {
48 >    LoadEventObject(fVertexName,     fVertices);
49 >  }
50  
51    MuonOArr *CleanMuons = new MuonOArr;
52    CleanMuons->SetName(fCleanMuonsName);
# Line 39 | Line 55 | void MuonIDMod::Process()
55      const Muon *mu = fMuons->At(i);
56  
57      Bool_t pass = kFALSE;
58 <    Double_t pt = -1; // make sure pt is taken from the correct track!
58 >    Double_t pt = 0;  // make sure pt is taken from the correct track!
59 >    Double_t eta = 0; // make sure eta is taken from the correct track!
60      switch (fMuClassType) {
61        case kAll:
62          pass = kTRUE;
63 <        pt = mu->Pt();
63 >        if (mu->HasTrk()) {
64 >          pt  = mu->Pt();
65 >          eta = TMath::Abs(mu->Eta());
66 >        }
67          break;
68        case kGlobal:
69 <        pass = (mu->GlobalTrk() != 0);
70 <        if (pass)
71 <          pt = mu->GlobalTrk()->Pt();
72 <        break;
69 >        pass = mu->HasGlobalTrk() && mu->IsTrackerMuon();
70 >        if (pass && mu->TrackerTrk()) {
71 >          pt  = mu->TrackerTrk()->Pt();
72 >          eta = TMath::Abs(mu->TrackerTrk()->Eta());
73 >        }
74 >        else {
75 >          pt  = mu->Pt();
76 >          eta = TMath::Abs(mu->Eta());
77 >        }
78 >        break;
79        case kSta:
80 <        pass = (mu->StandaloneTrk() != 0);
81 <        if (pass)
82 <          pt = mu->StandaloneTrk()->Pt();
83 <        break;
84 <      case kTrackerOnly:
85 <        pass = (mu->TrackerTrk() != 0);
86 <        if (pass)
87 <          pt = mu->TrackerTrk()->Pt();
80 >        pass = mu->HasStandaloneTrk();
81 >        if (pass) {
82 >          pt  = mu->StandaloneTrk()->Pt();
83 >          eta = TMath::Abs(mu->StandaloneTrk()->Eta());
84 >        }
85 >        break;
86 >      case kTrackerMuon:
87 >        pass = mu->HasTrackerTrk() && mu->IsTrackerMuon() &&
88 >               mu->Quality().Quality(MuonQuality::TrackerMuonArbitrated);
89 >        if (pass) {
90 >          pt  = mu->TrackerTrk()->Pt();
91 >          eta = TMath::Abs(mu->TrackerTrk()->Eta());
92 >        }
93 >        break;
94 >      case kCaloMuon:
95 >        pass = mu->HasTrackerTrk() && mu->IsCaloMuon();
96 >        if (pass) {
97 >          pt  = mu->TrackerTrk()->Pt();
98 >          eta = TMath::Abs(mu->TrackerTrk()->Eta());
99 >        }
100 >        break;
101 >      case kTrackerBased:
102 >        pass = mu->HasTrackerTrk();
103 >        if (pass) {
104 >          pt  = mu->TrackerTrk()->Pt();
105 >          eta = TMath::Abs(mu->TrackerTrk()->Eta());
106 >        }
107          break;
108        default:
109          break;
# Line 70 | Line 115 | void MuonIDMod::Process()
115      if (pt <= fMuonPtMin)
116        continue;
117  
118 +    if (eta >= fEtaCut)
119 +      continue;
120 +
121      Bool_t idpass = kFALSE;
122      switch (fMuIDType) {
123        case kLoose:
124 <        idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationLoose) &&
125 <                 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityLoose);
124 >        idpass = mu->BestTrk() != 0 &&
125 >                 mu->Quality().Quality(MuonQuality::TMOneStationLoose) &&
126 >                 mu->Quality().Quality(MuonQuality::TM2DCompatibilityLoose) &&
127 >                 mu->BestTrk()->NHits() > 10 &&
128 >                 mu->BestTrk()->Chi2()/mu->BestTrk()->Ndof() < 10 &&
129 >                 //mu->NSegments() > 0 &&
130 >                 mu->Quality().Quality(MuonQuality::GlobalMuonPromptTight);
131          break;
132        case kTight:
133 <        idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationTight) &&
134 <                 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityTight);
133 >        idpass = mu->BestTrk() !=  0 &&
134 >                 mu->Quality().Quality(MuonQuality::TMOneStationTight) &&
135 >                 mu->Quality().Quality(MuonQuality::TM2DCompatibilityTight) &&
136 >                 mu->BestTrk()->NHits() > 10 &&
137 >                 mu->BestTrk()->Chi2()/mu->BestTrk()->Ndof() < 10 &&
138 >                 //mu->NSegments() > 0 &&
139 >                 mu->Quality().Quality(MuonQuality::GlobalMuonPromptTight);
140 >        break;
141 >      case kMinimal:
142 >        idpass = mu->BestTrk() != 0 &&
143 >                 mu->BestTrk()->NHits() > 10 &&
144 >                 mu->BestTrk()->Chi2()/mu->BestTrk()->Ndof() < 10 &&
145 >                 //mu->NSegments() > 0 &&
146 >                 mu->Quality().Quality(MuonQuality::GlobalMuonPromptTight);
147 >        break;
148 >      case kNoId:
149 >        idpass = kTRUE;
150          break;
151        default:
152          break;
# Line 87 | Line 155 | void MuonIDMod::Process()
155      if (!idpass)
156        continue;
157  
158 <    Bool_t isopass = kFALSE;
158 >    Bool_t isocut = kFALSE;
159      switch (fMuIsoType) {
160        case kTrackCalo:
161 <        isopass = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
161 >        isocut = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
162            (mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut);
163          break;
164        case kTrackCaloCombined:
165 <        isopass = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
166 <                   1.0 * mu->IsoR03HadEt() < fCombIsolationCut);
165 >        isocut = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
166 >                  1.0 * mu->IsoR03HadEt() < fCombIsolationCut);
167          break;
168        case kTrackCaloSliding:
169          {
170            Double_t totalIso = 1.0 * mu->IsoR03SumPt() +
171                                1.0 * mu->IsoR03EmEt() +
172                                1.0 * mu->IsoR03HadEt();
173 <          if ((totalIso < (mu->Pt()-10.0)*5.0/15.0 && mu->Pt() <= 25) ||
174 <              (totalIso < 5.0 && mu->Pt() > 25) ||
175 <               totalIso <= 0)
176 <            isopass = kTRUE;
177 <        }
173 >          if (totalIso < (mu->Pt()*0.15) )
174 >            isocut = kTRUE;
175 >
176 >          if     (fReverseIsoCut == kTRUE &&
177 >                  isocut == kFALSE && totalIso < 10)
178 >            isocut = kTRUE;
179 >          else if(fReverseIsoCut == kTRUE)
180 >            isocut = kFALSE;
181 >        }
182          break;
183        case kNoIso:
184 <        isopass = kTRUE;
184 >        isocut = kTRUE;
185          break;
186        case kCustomIso:
187        default:
188          break;
189      }
190  
191 <    if (!isopass)
191 >    if (isocut == kFALSE)
192        continue;
193  
194 +    if (fApplyD0Cut) {
195 +      Bool_t passD0cut = MuonTools::PassD0Cut(mu, fVertices, fD0Cut, fReverseD0Cut);
196 +      if (!passD0cut)
197 +        continue;
198 +    }
199 +
200      // add good muon
201      CleanMuons->Add(mu);
202    }
# Line 136 | Line 214 | void MuonIDMod::SlaveBegin()
214    // Run startup code on the computer (slave) doing the actual analysis. Here,
215    // we just request the muon collection branch.
216  
217 <  ReqBranch(fMuonBranchName, fMuons);
217 >  ReqEventObject(fMuonBranchName, fMuons, kTRUE);
218 >
219 >  if (fApplyD0Cut)
220 >    ReqEventObject(fVertexName, fVertices, kTRUE);
221  
222    fMuonTools = new MuonTools;
223  
# Line 144 | Line 225 | void MuonIDMod::SlaveBegin()
225      fMuIDType = kTight;
226    else if (fMuonIDType.CompareTo("Loose") == 0)
227      fMuIDType = kLoose;
228 +  else if (fMuonIDType.CompareTo("Minimal") == 0)
229 +    fMuIDType = kMinimal;
230    else if (fMuonIDType.CompareTo("NoId") == 0)
231      fMuIDType = kNoId;
232    else if (fMuonIDType.CompareTo("Custom") == 0) {
# Line 182 | Line 265 | void MuonIDMod::SlaveBegin()
265      fMuClassType = kGlobal;
266    else if (fMuonClassType.CompareTo("Standalone") == 0)
267      fMuClassType = kSta;
268 <  else if (fMuonClassType.CompareTo("TrackerOnly") == 0)
269 <    fMuClassType = kTrackerOnly;
268 >  else if (fMuonClassType.CompareTo("TrackerMuon") == 0)
269 >    fMuClassType = kTrackerMuon;
270 >  else if (fMuonClassType.CompareTo("CaloMuon") == 0)
271 >    fMuClassType = kCaloMuon;
272 >  else if (fMuonClassType.CompareTo("TrackerBased") == 0)
273 >    fMuClassType = kTrackerBased;
274    else {
275      SendError(kAbortAnalysis, "SlaveBegin",
276                "The specified muon class %s is not defined.",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines