]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONTracker.cxx
Bug fix
[u/mrichter/AliRoot.git] / MUON / AliMUONTracker.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-----------------------------------------------------------------------------
19/// \class AliMUONTracker
20///
21/// Steering class for use in global tracking framework;
22/// reconstruct tracks from recpoints
23///
24/// Actual tracking is performed by some AliMUONVTrackReconstructor children
25///
26/// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
27//-----------------------------------------------------------------------------
28
29#include "AliMUONTracker.h"
30
31#include "AliMUONReconstructor.h"
32#include "AliMUONRecoParam.h"
33#include "AliMUONTrack.h"
34#include "AliMUONTrackExtrap.h"
35#include "AliMUONTrackHitPattern.h"
36#include "AliMUONTrackParam.h"
37#include "AliMUONHitForRec.h"
38#include "AliMUONTrackReconstructor.h"
39#include "AliMUONTrackReconstructorK.h"
40#include "AliMUONTrackStoreV1.h"
41#include "AliMUONTriggerChamberEff.h"
42#include "AliMUONTriggerTrackStoreV1.h"
43#include "AliMUONVClusterStore.h"
44#include "AliMUONVTriggerStore.h"
45
46#include "AliESDEvent.h"
47#include "AliESDMuonTrack.h"
48#include "AliESDVertex.h"
49#include "AliLog.h"
50#include "AliCodeTimer.h"
51
52#include <Riostream.h>
53#include <TTree.h>
54
55/// \cond CLASSIMP
56ClassImp(AliMUONTracker)
57/// \endcond
58
59
60//_____________________________________________________________________________
61AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
62 const AliMUONGeometryTransformer* transformer,
63 const AliMUONTriggerCircuit* triggerCircuit,
64 AliMUONTriggerChamberEff* chamberEff)
65: AliTracker(),
66 fDigitMaker(digitMaker), // not owner
67 fTransformer(transformer), // not owner
68 fTriggerCircuit(triggerCircuit), // not owner
69 fTrigChamberEff(chamberEff), // not owner
70 fTrackHitPatternMaker(0x0),
71 fTrackReco(0x0),
72 fClusterStore(0x0),
73 fTriggerStore(0x0)
74{
75 /// constructor
76 if (fTransformer && fDigitMaker)
77 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
78}
79
80//_____________________________________________________________________________
81AliMUONTracker::~AliMUONTracker()
82{
83 /// dtor
84 delete fTrackReco;
85 delete fTrackHitPatternMaker;
86 delete fClusterStore;
87 delete fTriggerStore;
88}
89
90//_____________________________________________________________________________
91Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
92{
93 /// Load clusterStore and triggerStore from clustersTree
94 delete fClusterStore;
95 delete fTriggerStore;
96
97 if ( ! clustersTree ) {
98 AliFatal("No clustersTree");
99 return 1;
100 }
101
102 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
103 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
104
105 if (!fClusterStore)
106 {
107 AliError("Could not get clusterStore");
108 return 1;
109 }
110 if (!fTriggerStore)
111 {
112 AliError("Could not get triggerStore");
113 return 2;
114 }
115
116 fClusterStore->Connect(*clustersTree,kFALSE);
117 fTriggerStore->Connect(*clustersTree,kFALSE);
118
119 clustersTree->GetEvent(0);
120
121 return 0;
122}
123
124//_____________________________________________________________________________
125Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
126{
127 /// Performs the tracking and store the resulting tracks in the ESD
128 AliDebug(1,"");
129 AliCodeTimerAuto("")
130
131 if (!fTrackReco) CreateTrackReconstructor();
132
133 // if the required tracking mode does not exist
134 if (!fTrackReco) return 1;
135
136 if (!fClusterStore) {
137 AliError("ClusterStore is NULL");
138 return 2;
139 }
140
141 if (!fTriggerStore) {
142 AliError("TriggerStore is NULL");
143 return 3;
144 }
145
146 // Make tracker tracks
147 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
148 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
149
150 // Make trigger tracks
151 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
152 if ( fTriggerCircuit ) {
153 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
154 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
155 }
156
157 // Match tracker/trigger tracks
158 if ( triggerTrackStore && fTrackHitPatternMaker ) {
159 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
160 }
161
162 // Compute trigger chamber efficiency
163 if( triggerTrackStore && fTrigChamberEff){
164 AliCodeTimerStart("EventChamberEff");
165 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
166 AliCodeTimerStop("EventChamberEff");
167 }
168
169 // Fill ESD
170 FillESD(*trackStore,esd);
171
172 // cleanup
173 delete trackStore;
174 delete triggerTrackStore;
175
176 return 0;
177}
178
179//_____________________________________________________________________________
180void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
181{
182 /// Fill the ESD from the trackStore
183 AliDebug(1,"");
184 AliCodeTimerAuto("")
185
186 // Get vertex
187 Double_t vertex[3] = {0};
188 const AliESDVertex* esdVert = esd->GetVertex();
189 if (esdVert->GetNContributors())
190 {
191 esdVert->GetXYZ(vertex);
192 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
193 }
194
195 // setting ESD MUON class
196 AliESDMuonTrack esdTrack;
197
198 AliMUONTrack* track;
199 TIter next(trackStore.CreateIterator());
200
201 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
202 {
203 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtHit())->First());
204 AliMUONTrackParam trackParamAtVtx(*trackParam);
205
206 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
207 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2]);
208
209 // setting data member of ESD MUON
210
211 // at first station
212 trackParam->SetParamForUncorrected(esdTrack);
213 trackParam->SetCovFor(esdTrack);
214 // at vertex
215 trackParamAtVtx.SetParamFor(esdTrack);
216 // global info
217 esdTrack.SetChi2(track->GetFitFMin());
218 esdTrack.SetNHit(track->GetNTrackHits());
219 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
220 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
221 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
222 // muon cluster map
223 AliMUONHitForRec* cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->First());
224 while (cluster) {
225 esdTrack.AddInMuonClusterMap(cluster->GetChamberNumber());
226 cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->After(cluster));
227 }
228
229 // storing ESD MUON Track into ESD Event
230 esd->AddMuonTrack(&esdTrack);
231 } // end of loop on tracks
232}
233
234//_____________________________________________________________________________
235void AliMUONTracker::CreateTrackReconstructor()
236{
237 /// Create track reconstructor, depending on tracking mode set in RecoParam
238
239 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
240 opt.ToUpper();
241
242 if (strstr(opt,"ORIGINAL"))
243 {
244 fTrackReco = new AliMUONTrackReconstructor();
245 }
246 else if (strstr(opt,"KALMAN"))
247 {
248 fTrackReco = new AliMUONTrackReconstructorK();
249 }
250 else
251 {
252 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
253 return;
254 }
255
256 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
257}
258
259//_____________________________________________________________________________
260void AliMUONTracker::UnloadClusters()
261{
262 /// Delete internal clusterStore
263 delete fClusterStore;
264 fClusterStore = 0x0;
265}
266