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.2 by ceballos, Sat Oct 25 19:25:09 2008 UTC vs.
Revision 1.9 by ceballos, Fri Nov 28 10:31:38 2008 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitPhysics/Mods/interface/MuonIDMod.h"
4 #include "MitAna/DataTree/interface/Names.h"
5 #include "MitAna/DataCont/interface/ObjArray.h"
6 #include "MitPhysics/Utils/interface/IsolationTools.h"
4   #include "MitCommon/MathTools/interface/MathUtils.h"
5 + #include "MitPhysics/Init/interface/ModNames.h"
6  
7   using namespace mithep;
8  
# Line 13 | Line 11 | ClassImp(mithep::MuonIDMod)
11   //--------------------------------------------------------------------------------------------------
12    MuonIDMod::MuonIDMod(const char *name, const char *title) :
13    BaseMod(name,title),
14 <  fPrintDebug(false),
15 <  fMuonName(Names::gkMuonBrn),
16 <  fCleanMuonsName(Names::gkCleanMuonsName),  
17 <  fMuonIDType("Tight"),
18 <  fMuonIsoType("TrackCalo"),  
21 <  fMuons(0),
14 >  fMuonBranchName(Names::gkMuonBrn),
15 >  fCleanMuonsName(ModNames::gkCleanMuonsName),  
16 >  fMuonIDType("Loose"),
17 >  fMuonIsoType("TrackCaloSliding"),  
18 >  fMuonClassType("Global"),  
19    fTrackIsolationCut(3.0),
20    fCaloIsolationCut(3.0),
21 <  fNEventsProcessed(0)
21 >  fCombIsolationCut(5.0),
22 >  fMuonPtMin(10),
23 >  fMuons(0)
24   {
25    // Constructor.
26   }
27  
29 //--------------------------------------------------------------------------------------------------
30 void MuonIDMod::Begin()
31 {
32  // Run startup code on the client machine. For this module, we dont do
33  // anything here.
34 }
28  
29   //--------------------------------------------------------------------------------------------------
30   void MuonIDMod::Process()
31   {
32    // Process entries of the tree.
33  
34 <  fNEventsProcessed++;
35 <
36 <  if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
37 <    time_t systime;
38 <    systime = time(NULL);
46 <
47 <    cerr << endl << "MuonIDMod : Process Event " << fNEventsProcessed << "  Time: " << ctime(&systime) << endl;  
48 <  }  
49 <
50 <  //Get Muons
51 <  LoadBranch(fMuonName);
52 <  ObjArray<Muon> *CleanMuons = new ObjArray<Muon>;
34 >  LoadBranch(fMuonBranchName);
35 >
36 >  MuonOArr *CleanMuons = new MuonOArr;
37 >  CleanMuons->SetName(fCleanMuonsName);
38 >
39    for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
40 <    Muon *mu = fMuons->At(i);
41 <  
42 <    Double_t MuonClass = -1;    
43 <    if (mu->GlobalTrk())      
44 <      MuonClass = 0;
45 <    else if (mu->StandaloneTrk())      
46 <      MuonClass = 1;
47 <    else if (mu->TrackerTrk())
48 <      MuonClass = 2;
49 <
50 <    //These cuts are from the 1.6.X analysis. I'm waiting for Phil to finalize his Muon ID class
51 <    const int nCuts = 4;
52 <    double cutValue[nCuts] = {0.2, fTrackIsolationCut, fCaloIsolationCut, 1.5 };
53 <    bool passCut[nCuts] = {false, false, false, false};
54 <    double muonD0 = fabs(mu->BestTrk()->D0());
55 <    if(muonD0 < cutValue[0] &&  MuonClass == 0 )
56 <      passCut[0] = true;
57 <    if(mu->IsoR03SumPt() < cutValue[1]) passCut[1] = true;
58 <    if(mu->IsoR03EmEt() +
59 <       mu->IsoR03HadEt() < cutValue[2]) passCut[2] = true;    
60 <    if(mu->Pt() > 10)
61 <      passCut[3] = true;  
62 <    
63 <    // Final decision
64 <    bool allCuts = true;
65 <    for(int c=0; c<nCuts; c++) {
66 <      allCuts = allCuts & passCut[c];
67 <    }      
68 <    
69 <    if ( allCuts
70 <         && abs(mu->Eta()) < 2.5
71 <      ) {    
72 <      CleanMuons->Add(mu);
40 >    const Muon *mu = fMuons->At(i);
41 >
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 >    }
67 >
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 >    }
87 >
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 && mu->Pt() <= 25) ||
107 >              (totalIso < 5.0 && mu->Pt() > 25) ||
108 >               totalIso <= 0)
109 >            isopass = kTRUE;
110 >        }
111 >        break;
112 >        case kNoIso:
113 >          isopass = kTRUE;
114 >          break;
115 >      case kCustomIso:
116 >      default:
117 >        break;
118      }
119 +
120 +    if (!isopass)
121 +      continue;
122 +
123 +    // add good muon
124 +    CleanMuons->Add(mu);
125    }
126  
127 <  //Final Summary Debug Output  
128 <  if ( fPrintDebug ) {
92 <    cerr << "Event Dump: " << fNEventsProcessed << endl;  
93 <    cerr << "Muons" << endl;
94 <    for (UInt_t i = 0; i < CleanMuons->GetEntries(); i++) {
95 <      cerr << i << " " << CleanMuons->At(i)->Pt() << " " << CleanMuons->At(i)->Eta()
96 <           << " " << CleanMuons->At(i)->Phi() << endl;    
97 <    }  
98 <  }  
99 <  
100 <  //Save Objects for Other Modules to use
101 <  AddObjThisEvt(CleanMuons, fCleanMuonsName.Data());  
127 >  // add objects for other modules to use
128 >  AddObjThisEvt(CleanMuons);  
129   }
130  
131  
# Line 106 | Line 133 | void MuonIDMod::Process()
133   void MuonIDMod::SlaveBegin()
134   {
135    // Run startup code on the computer (slave) doing the actual analysis. Here,
136 <  // we typically initialize histograms and other analysis objects and request
110 <  // branches. For this module, we request a branch of the MitTree.
136 >  // we just request the muon collection branch.
137  
138 <  ReqBranch(fMuonName,              fMuons);
113 < }
138 >  ReqBranch(fMuonBranchName, fMuons);
139  
140 < //--------------------------------------------------------------------------------------------------
116 < void MuonIDMod::SlaveTerminate()
117 < {
118 <  // Run finishing code on the computer (slave) that did the analysis. For this
119 <  // module, we dont do anything here.
140 >  fMuonTools = new MuonTools;
141  
142 < }
142 >  if (fMuonIDType.CompareTo("Tight") == 0)
143 >    fMuIDType = kTight;
144 >  else if (fMuonIDType.CompareTo("Loose") == 0)
145 >    fMuIDType = kLoose;
146 >  else if (fMuonIDType.CompareTo("Custom") == 0) {
147 >    fMuIDType = kCustomId;
148 >    SendError(kWarning, "SlaveBegin",
149 >              "Custom muon identification is not yet implemented.");
150 >  } else {
151 >    SendError(kAbortAnalysis, "SlaveBegin",
152 >              "The specified muon identification %s is not defined.",
153 >              fMuonIDType.Data());
154 >    return;
155 >  }
156  
157 < //--------------------------------------------------------------------------------------------------
158 < void MuonIDMod::Terminate()
159 < {
160 <  // Run finishing code on the client computer. For this module, we dont do
161 <  // anything here.
157 >  if (fMuonIsoType.CompareTo("TrackCalo") == 0)
158 >    fMuIsoType = kTrackCalo;
159 >  else if (fMuonIsoType.CompareTo("TrackCaloCombined") == 0)
160 >    fMuIsoType = kTrackCaloCombined;
161 >  else if (fMuonIsoType.CompareTo("TrackCaloSliding") == 0)
162 >    fMuIsoType = kTrackCaloSliding;
163 >  else if (fMuonIsoType.CompareTo("NoIso") == 0)
164 >    fMuIsoType = kNoIso;
165 >  else if (fMuonIsoType.CompareTo("Custom") == 0) {
166 >    fMuIsoType = kCustomIso;
167 >    SendError(kWarning, "SlaveBegin",
168 >              "Custom muon isolation is not yet implemented.");
169 >  } else {
170 >    SendError(kAbortAnalysis, "SlaveBegin",
171 >              "The specified muon isolation %s is not defined.",
172 >              fMuonIsoType.Data());
173 >    return;
174 >  }
175 >
176 >  if (fMuonClassType.CompareTo("All") == 0)
177 >    fMuClassType = kAll;
178 >  else if (fMuonClassType.CompareTo("Global") == 0)
179 >    fMuClassType = kGlobal;
180 >  else if (fMuonClassType.CompareTo("Standalone") == 0)
181 >    fMuClassType = kSta;
182 >  else if (fMuonClassType.CompareTo("TrackerOnly") == 0)
183 >    fMuClassType = kTrackerOnly;
184 >  else {
185 >    SendError(kAbortAnalysis, "SlaveBegin",
186 >              "The specified muon class %s is not defined.",
187 >              fMuonClassType.Data());
188 >    return;
189 >  }
190   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines