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.3 by ceballos, Wed Nov 5 14:06:09 2008 UTC vs.
Revision 1.8 by loizides, Fri Nov 28 09:56:42 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 +  fCombIsolationCut(5.0),
22    fMuonPtMin(10),
23 <  fNEventsProcessed(0)
23 >  fMuons(0)
24   {
25    // Constructor.
26   }
27  
30 //--------------------------------------------------------------------------------------------------
31 void MuonIDMod::Begin()
32 {
33  // Run startup code on the client machine. For this module, we dont do
34  // anything here.
35 }
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);
47 <
48 <    cerr << endl << "MuonIDMod : Process Event " << fNEventsProcessed << "  Time: " << ctime(&systime) << endl;  
49 <  }  
50 <
51 <  //Get Muons
52 <  LoadBranch(fMuonName);
53 <  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 <    bool allCuts = false;
51 <
52 <    if(MuonClass == 0) allCuts = true;
53 <
54 <    if(mu->IsoR03SumPt() >= fTrackIsolationCut) allCuts = false;
55 <
56 <    if(mu->IsoR03EmEt() +
57 <       mu->IsoR03HadEt() >= fCaloIsolationCut) allCuts = false;
58 <
59 <    if(mu->Pt() <= fMuonPtMin) allCuts = false;
60 <        
61 <    if(allCuts) {    
62 <      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) ||
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      }
118 +
119 +    if (!isopass)
120 +      continue;
121 +
122 +    // add good muon
123 +    CleanMuons->Add(mu);
124    }
125  
126 <  //Final Summary Debug Output  
127 <  if ( fPrintDebug ) {
83 <    cerr << "Event Dump: " << fNEventsProcessed << endl;  
84 <    cerr << "Muons" << endl;
85 <    for (UInt_t i = 0; i < CleanMuons->GetEntries(); i++) {
86 <      cerr << i << " " << CleanMuons->At(i)->Pt() << " " << CleanMuons->At(i)->Eta()
87 <           << " " << CleanMuons->At(i)->Phi() << endl;    
88 <    }  
89 <  }  
90 <  
91 <  //Save Objects for Other Modules to use
92 <  AddObjThisEvt(CleanMuons, fCleanMuonsName.Data());  
126 >  // add objects for other modules to use
127 >  AddObjThisEvt(CleanMuons);  
128   }
129  
130  
# Line 97 | Line 132 | void MuonIDMod::Process()
132   void MuonIDMod::SlaveBegin()
133   {
134    // Run startup code on the computer (slave) doing the actual analysis. Here,
135 <  // we typically initialize histograms and other analysis objects and request
101 <  // branches. For this module, we request a branch of the MitTree.
135 >  // we just request the muon collection branch.
136  
137 <  ReqBranch(fMuonName,              fMuons);
104 < }
137 >  ReqBranch(fMuonBranchName, fMuons);
138  
139 < //--------------------------------------------------------------------------------------------------
107 < void MuonIDMod::SlaveTerminate()
108 < {
109 <  // Run finishing code on the computer (slave) that did the analysis. For this
110 <  // module, we dont do anything here.
139 >  fMuonTools = new MuonTools;
140  
141 < }
141 >  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  
156 < //--------------------------------------------------------------------------------------------------
157 < void MuonIDMod::Terminate()
158 < {
159 <  // Run finishing code on the client computer. For this module, we dont do
160 <  // anything here.
156 >  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 >
175 >  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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines