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.5 by ceballos, Wed Nov 26 10:55:51 2008 UTC vs.
Revision 1.6 by loizides, Thu Nov 27 16:30:27 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"
4 > #include "MitCommon/MathTools/interface/MathUtils.h"
5 > #include "MitPhysics/Init/interface/ModNames.h"
6   #include "MitPhysics/Utils/interface/IsolationTools.h"
7 + #include "MitPhysics/Utils/interface/MuonTools.h"
8   #include "MitCommon/MathTools/interface/MathUtils.h"
9  
10   using namespace mithep;
# Line 13 | Line 14 | ClassImp(mithep::MuonIDMod)
14   //--------------------------------------------------------------------------------------------------
15    MuonIDMod::MuonIDMod(const char *name, const char *title) :
16    BaseMod(name,title),
17 <  fPrintDebug(false),
18 <  fMuonName(Names::gkMuonBrn),
19 <  fCleanMuonsName(Names::gkCleanMuonsName),  
20 <  fMuons(0),
17 >  fMuonBranchName(Names::gkMuonBrn),
18 >  fCleanMuonsName(ModNames::gkCleanMuonsName),  
19 >  fMuonIDType("Tight"),
20 >  fMuonIsoType("TrackCalo"),  
21 >  fMuonClassType("Global"),  
22    fTrackIsolationCut(3.0),
23    fCaloIsolationCut(3.0),
24    fCombIsolationCut(-1.0),
23  fTMOneStationLooseCut(true),
24  fTMOneStationTightCut (false),  
25  fTM2DCompatibilityLooseCut(true),
26  fTM2DCompatibilityTightCut(false),
27  fMuonSlidingIso(true),  
25    fMuonPtMin(10),
26 <  fNEventsProcessed(0)
26 >  fMuons(0)
27   {
28    // Constructor.
29   }
30  
34 //--------------------------------------------------------------------------------------------------
35 void MuonIDMod::Begin()
36 {
37  // Run startup code on the client machine. For this module, we dont do
38  // anything here.
39 }
31  
32   //--------------------------------------------------------------------------------------------------
33   void MuonIDMod::Process()
34   {
35    // Process entries of the tree.
36  
37 <  fNEventsProcessed++;
47 <
48 <  if (fNEventsProcessed % 1000000 == 0 || fPrintDebug) {
49 <    time_t systime;
50 <    systime = time(NULL);
51 <
52 <    cerr << endl << "MuonIDMod : Process Event " << fNEventsProcessed << "  Time: " << ctime(&systime) << endl;  
53 <  }  
37 >  LoadBranch(fMuonBranchName);
38  
55  //Get Muons
56  LoadBranch(fMuonName);
39    ObjArray<Muon> *CleanMuons = new ObjArray<Muon>;
40 +
41    for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
42 +    //const Muon *mu = fMuons->At(i);
43      Muon *mu = fMuons->At(i);
44 <  
45 <    Double_t MuonClass = -1;    
46 <    if (mu->GlobalTrk())      
47 <      MuonClass = 0;
48 <    else if (mu->StandaloneTrk())      
49 <      MuonClass = 1;
50 <    else if (mu->TrackerTrk())
51 <      MuonClass = 2;
52 <
53 <    bool allCuts = false;
54 <
55 <    // We always want global muons
56 <    if(MuonClass == 0) allCuts = true;
57 <
58 <    // Isolation requirements
59 <    if(fMuonSlidingIso == true){ // Fix version
60 <      double totalIso = 1.0 * mu->IsoR03SumPt() +
61 <                        1.0 * mu->IsoR03EmEt() +
62 <                        1.0 * mu->IsoR03HadEt();
63 <      bool theIso = false;
64 <      if((totalIso < (mu->Pt()-10.0)*5.0/15.0) ||
65 <         (totalIso < 5.0 && mu->Pt() > 25)) theIso = true;
66 <      if(theIso == false) allCuts = false;
67 <    }
68 <    else if(fCombIsolationCut < 0.0){ // Different tracker and Cal iso
85 <      if(mu->IsoR03SumPt() >= fTrackIsolationCut) allCuts = false;
86 <      if(mu->IsoR03EmEt() +
87 <         mu->IsoR03HadEt() >= fCaloIsolationCut) allCuts = false;
44 >
45 >    Bool_t pass = kFALSE;
46 >    Double_t pt = -1; // make sure pt is taken from the correct track!
47 >    switch (fMuClassType) {
48 >      case kAll:
49 >        pass = kTRUE;
50 >        pt = mu->Pt();
51 >        break;
52 >      case kGlobal:
53 >        pass = (mu->GlobalTrk() != 0);
54 >        if (pass)
55 >          pt = mu->GlobalTrk()->Pt();
56 >        break;
57 >      case kSta:
58 >        pass = (mu->StandaloneTrk() != 0);
59 >        if (pass)
60 >          pt = mu->StandaloneTrk()->Pt();
61 >        break;
62 >      case kTrackerOnly:
63 >        pass = (mu->TrackerTrk() != 0);
64 >        if (pass)
65 >          pt = mu->TrackerTrk()->Pt();
66 >        break;
67 >      default:
68 >        break;
69      }
70 <    else { // Combined iso
71 <      if(1.0 * mu->IsoR03SumPt() +
72 <         1.0 * mu->IsoR03EmEt() +
73 <         1.0 * mu->IsoR03HadEt() >= fCombIsolationCut) allCuts = false;    
70 >
71 >    if (!pass)
72 >      continue;
73 >
74 >    if (pt <= fMuonPtMin)
75 >      continue;
76 >
77 >    Bool_t idpass = kFALSE;
78 >    switch (fMuIDType) {
79 >      case kLoose:
80 >        idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationLoose) &&
81 >                 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityLoose);
82 >        break;
83 >      case kTight:
84 >        idpass = fMuonTools->IsGood(mu, MuonTools::kTMOneStationTight) &&
85 >                 fMuonTools->IsGood(mu, MuonTools::kTM2DCompatibilityTight);
86 >        break;
87 >      default:
88 >        break;
89      }
90  
91 <    // Muon chambers and calo compatibility requirements
92 <    if(fTMOneStationLooseCut == true &&
93 <       myMuonTools.isGood(mu, MuonTools::TMOneStationLoose) == false)
94 <      allCuts = false;
95 <
96 <    if(fTMOneStationTightCut == true &&
97 <       myMuonTools.isGood(mu, MuonTools::TMOneStationTight) == false)
98 <      allCuts = false;
99 <
100 <    if(fTM2DCompatibilityLooseCut == true &&
101 <       myMuonTools.isGood(mu, MuonTools::TM2DCompatibilityLoose) == false)
102 <      allCuts = false;
103 <
104 <    if(fTM2DCompatibilityTightCut == true &&
105 <       myMuonTools.isGood(mu, MuonTools::TM2DCompatibilityTight) == false)
106 <      allCuts = false;
107 <
108 <    // Min Pt requirement
109 <    if(mu->Pt() <= fMuonPtMin) allCuts = false;
110 <        
111 <    if(allCuts) {    
112 <      CleanMuons->Add(mu);
91 >    if (!idpass)
92 >      continue;
93 >
94 >    Bool_t isopass = kFALSE;
95 >    switch (fMuIsoType) {
96 >      case kTrackCalo:
97 >        isopass = (mu->IsoR03SumPt() < fTrackIsolationCut) &&
98 >          (mu->IsoR03EmEt() + mu->IsoR03HadEt() < fCaloIsolationCut);
99 >        break;
100 >      case kTrackCaloCombined:
101 >        isopass = (1.0 * mu->IsoR03SumPt() + 1.0 * mu->IsoR03EmEt() +
102 >                   1.0 * mu->IsoR03HadEt() < fCombIsolationCut);
103 >        break;
104 >      case kTrackCaloSliding:
105 >        {
106 >          Double_t totalIso = 1.0 * mu->IsoR03SumPt() +
107 >                              1.0 * mu->IsoR03EmEt() +
108 >                              1.0 * mu->IsoR03HadEt();
109 >          if ((totalIso < (mu->Pt()-10.0)*5.0/15.0) ||
110 >              (totalIso < 5.0 && mu->Pt() > 25))
111 >            isopass = kTRUE;
112 >        }
113 >        break;
114 >        case kNoIso:
115 >          isopass = kTRUE;
116 >          break;
117 >      case kCustomIso:
118 >      default:
119 >        break;
120      }
121 +
122 +    if (!isopass)
123 +      continue;
124 +
125 +    // add good muon
126 +    CleanMuons->Add(mu);
127    }
128  
129 <  //Final Summary Debug Output  
130 <  if ( fPrintDebug ) {
122 <    cerr << "Event Dump: " << fNEventsProcessed << endl;  
123 <    cerr << "Muons" << endl;
124 <    for (UInt_t i = 0; i < CleanMuons->GetEntries(); i++) {
125 <      cerr << i << " " << CleanMuons->At(i)->Pt() << " " << CleanMuons->At(i)->Eta()
126 <           << " " << CleanMuons->At(i)->Phi() << endl;    
127 <    }  
128 <  }  
129 <  
130 <  //Save Objects for Other Modules to use
131 <  AddObjThisEvt(CleanMuons, fCleanMuonsName.Data());  
129 >  // add objects for other modules to use
130 >  AddObjThisEvt(CleanMuons, fCleanMuonsName);  
131   }
132  
133  
# Line 136 | Line 135 | void MuonIDMod::Process()
135   void MuonIDMod::SlaveBegin()
136   {
137    // Run startup code on the computer (slave) doing the actual analysis. Here,
138 <  // we typically initialize histograms and other analysis objects and request
140 <  // branches. For this module, we request a branch of the MitTree.
138 >  // we just request the muon collection branch.
139  
140 <  ReqBranch(fMuonName,              fMuons);
143 < }
140 >  ReqBranch(fMuonBranchName, fMuons);
141  
142 < //--------------------------------------------------------------------------------------------------
146 < void MuonIDMod::SlaveTerminate()
147 < {
148 <  // Run finishing code on the computer (slave) that did the analysis. For this
149 <  // module, we dont do anything here.
142 >  fMuonTools = new MuonTools;
143  
144 < }
144 >  if (fMuonIDType.CompareTo("Tight") == 0)
145 >    fMuIDType = kTight;
146 >  else if (fMuonIDType.CompareTo("Loose") == 0)
147 >    fMuIDType = kLoose;
148 >  else if (fMuonIDType.CompareTo("Custom") == 0) {
149 >    fMuIDType = kCustomId;
150 >    SendError(kWarning, "SlaveBegin",
151 >              "Custom muon identification is not yet implemented.");
152 >  } else {
153 >    SendError(kAbortAnalysis, "SlaveBegin",
154 >              "The specified muon identification %s is not defined.",
155 >              fMuonIDType.Data());
156 >    return;
157 >  }
158  
159 < //--------------------------------------------------------------------------------------------------
160 < void MuonIDMod::Terminate()
161 < {
162 <  // Run finishing code on the client computer. For this module, we dont do
163 <  // anything here.
159 >  if (fMuonIsoType.CompareTo("TrackCalo") == 0)
160 >    fMuIsoType = kTrackCalo;
161 >  else if (fMuonIsoType.CompareTo("TrackCaloCombined") == 0)
162 >    fMuIsoType = kTrackCaloCombined;
163 >  else if (fMuonIsoType.CompareTo("TrackCaloSliding") == 0)
164 >    fMuIsoType = kTrackCaloSliding;
165 >  else if (fMuonIsoType.CompareTo("NoIso") == 0)
166 >    fMuIsoType = kNoIso;
167 >  else if (fMuonIsoType.CompareTo("Custom") == 0) {
168 >    fMuIsoType = kCustomIso;
169 >    SendError(kWarning, "SlaveBegin",
170 >              "Custom muon isolation is not yet implemented.");
171 >  } else {
172 >    SendError(kAbortAnalysis, "SlaveBegin",
173 >              "The specified muon isolation %s is not defined.",
174 >              fMuonIsoType.Data());
175 >    return;
176 >  }
177 >
178 >  if (fMuonClassType.CompareTo("All") == 0)
179 >    fMuClassType = kAll;
180 >  else if (fMuonClassType.CompareTo("Global") == 0)
181 >    fMuClassType = kGlobal;
182 >  else if (fMuonClassType.CompareTo("Standalone") == 0)
183 >    fMuClassType = kSta;
184 >  else if (fMuonClassType.CompareTo("TrackerOnly") == 0)
185 >    fMuClassType = kTrackerOnly;
186 >  else {
187 >    SendError(kAbortAnalysis, "SlaveBegin",
188 >              "The specified muon class %s is not defined.",
189 >              fMuonClassType.Data());
190 >    return;
191 >  }
192   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines