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.13 by loizides, Thu Dec 11 15:53:03 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  
28   //--------------------------------------------------------------------------------------------------
31 void MuonIDMod::Begin()
32 {
33  // Run startup code on the client machine. For this module, we dont do
34  // anything here.
35 }
36
37 //--------------------------------------------------------------------------------------------------
29   void MuonIDMod::Process()
30   {
31    // Process entries of the tree.
32  
33 <  fNEventsProcessed++;
34 <
35 <  if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
36 <    time_t systime;
37 <    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>;
33 >  LoadBranch(fMuonBranchName);
34 >
35 >  MuonOArr *CleanMuons = new MuonOArr;
36 >  CleanMuons->SetName(fCleanMuonsName);
37 >
38    for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
39 <    Muon *mu = fMuons->At(i);
40 <  
41 <    Double_t MuonClass = -1;    
42 <    if (mu->GlobalTrk())      
43 <      MuonClass = 0;
44 <    else if (mu->StandaloneTrk())      
45 <      MuonClass = 1;
46 <    else if (mu->TrackerTrk())
47 <      MuonClass = 2;
48 <
49 <    bool allCuts = false;
50 <
51 <    if(MuonClass == 0) allCuts = true;
52 <
53 <    if(mu->IsoR03SumPt() >= fTrackIsolationCut) allCuts = false;
54 <
55 <    if(mu->IsoR03EmEt() +
56 <       mu->IsoR03HadEt() >= fCaloIsolationCut) allCuts = false;
57 <
58 <    if(mu->Pt() <= fMuonPtMin) allCuts = false;
59 <        
60 <    if(allCuts) {    
61 <      CleanMuons->Add(mu);
39 >    const Muon *mu = fMuons->At(i);
40 >
41 >    Bool_t pass = kFALSE;
42 >    Double_t pt = -1; // make sure pt is taken from the correct track!
43 >    switch (fMuClassType) {
44 >      case kAll:
45 >        pass = kTRUE;
46 >        pt = mu->Pt();
47 >        break;
48 >      case kGlobal:
49 >        pass = (mu->GlobalTrk() != 0);
50 >        if (pass)
51 >          pt = mu->GlobalTrk()->Pt();
52 >        break;
53 >      case kSta:
54 >        pass = (mu->StandaloneTrk() != 0);
55 >        if (pass)
56 >          pt = mu->StandaloneTrk()->Pt();
57 >        break;
58 >      case kTrackerOnly:
59 >        pass = (mu->TrackerTrk() != 0);
60 >        if (pass)
61 >          pt = mu->TrackerTrk()->Pt();
62 >        break;
63 >      default:
64 >        break;
65 >    }
66 >
67 >    if (!pass)
68 >      continue;
69 >
70 >    if (pt <= fMuonPtMin)
71 >      continue;
72 >
73 >    Bool_t idpass = kFALSE;
74 >    switch (fMuIDType) {
75 >      case kLoose:
76 >        idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationLoose) &&
77 >                 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityLoose);
78 >        break;
79 >      case kTight:
80 >        idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationTight) &&
81 >                 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityTight);
82 >        break;
83 >      default:
84 >        break;
85 >    }
86 >
87 >    if (!idpass)
88 >      continue;
89 >
90 >    Bool_t isopass = kFALSE;
91 >    switch (fMuIsoType) {
92 >      case kTrackCalo:
93 >        isopass = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
94 >          (mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut);
95 >        break;
96 >      case kTrackCaloCombined:
97 >        isopass = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
98 >                   1.0 * mu->IsoR03HadEt() < fCombIsolationCut);
99 >        break;
100 >      case kTrackCaloSliding:
101 >        {
102 >          Double_t totalIso = 1.0 * mu->IsoR03SumPt() +
103 >                              1.0 * mu->IsoR03EmEt() +
104 >                              1.0 * mu->IsoR03HadEt();
105 >          if ((totalIso < (mu->Pt()-10.0)*5.0/15.0 && mu->Pt() <= 25) ||
106 >              (totalIso < 5.0 && mu->Pt() > 25) ||
107 >               totalIso <= 0)
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());  
93 < }
126 >  // sort according to pt
127 >  CleanMuons->Sort();
128  
129 +  // add objects for other modules to use
130 +  AddObjThisEvt(CleanMuons);  
131 + }
132  
133   //--------------------------------------------------------------------------------------------------
134   void MuonIDMod::SlaveBegin()
135   {
136    // Run startup code on the computer (slave) doing the actual analysis. Here,
137 <  // we typically initialize histograms and other analysis objects and request
101 <  // branches. For this module, we request a branch of the MitTree.
137 >  // we just request the muon collection branch.
138  
139 <  ReqBranch(fMuonName,              fMuons);
104 < }
139 >  ReqBranch(fMuonBranchName, fMuons);
140  
141 < //--------------------------------------------------------------------------------------------------
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.
141 >  fMuonTools = new MuonTools;
142  
143 < }
143 >  if (fMuonIDType.CompareTo("Tight") == 0)
144 >    fMuIDType = kTight;
145 >  else if (fMuonIDType.CompareTo("Loose") == 0)
146 >    fMuIDType = kLoose;
147 >  else if (fMuonIDType.CompareTo("NoId") == 0)
148 >    fMuIDType = kNoId;
149 >  else if (fMuonIDType.CompareTo("Custom") == 0) {
150 >    fMuIDType = kCustomId;
151 >    SendError(kWarning, "SlaveBegin",
152 >              "Custom muon identification is not yet implemented.");
153 >  } else {
154 >    SendError(kAbortAnalysis, "SlaveBegin",
155 >              "The specified muon identification %s is not defined.",
156 >              fMuonIDType.Data());
157 >    return;
158 >  }
159  
160 < //--------------------------------------------------------------------------------------------------
161 < void MuonIDMod::Terminate()
162 < {
163 <  // Run finishing code on the client computer. For this module, we dont do
164 <  // anything here.
160 >  if (fMuonIsoType.CompareTo("TrackCalo") == 0)
161 >    fMuIsoType = kTrackCalo;
162 >  else if (fMuonIsoType.CompareTo("TrackCaloCombined") == 0)
163 >    fMuIsoType = kTrackCaloCombined;
164 >  else if (fMuonIsoType.CompareTo("TrackCaloSliding") == 0)
165 >    fMuIsoType = kTrackCaloSliding;
166 >  else if (fMuonIsoType.CompareTo("NoIso") == 0)
167 >    fMuIsoType = kNoIso;
168 >  else if (fMuonIsoType.CompareTo("Custom") == 0) {
169 >    fMuIsoType = kCustomIso;
170 >    SendError(kWarning, "SlaveBegin",
171 >              "Custom muon isolation is not yet implemented.");
172 >  } else {
173 >    SendError(kAbortAnalysis, "SlaveBegin",
174 >              "The specified muon isolation %s is not defined.",
175 >              fMuonIsoType.Data());
176 >    return;
177 >  }
178 >
179 >  if (fMuonClassType.CompareTo("All") == 0)
180 >    fMuClassType = kAll;
181 >  else if (fMuonClassType.CompareTo("Global") == 0)
182 >    fMuClassType = kGlobal;
183 >  else if (fMuonClassType.CompareTo("Standalone") == 0)
184 >    fMuClassType = kSta;
185 >  else if (fMuonClassType.CompareTo("TrackerOnly") == 0)
186 >    fMuClassType = kTrackerOnly;
187 >  else {
188 >    SendError(kAbortAnalysis, "SlaveBegin",
189 >              "The specified muon class %s is not defined.",
190 >              fMuonClassType.Data());
191 >    return;
192 >  }
193   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines