1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTracker
21 /// Steering class for use in global tracking framework;
22 /// reconstruct tracks from recpoints
24 /// Actual tracking is performed by some AliMUONVTrackReconstructor children
25 /// Tracking modes (ORIGINAL, KALMAN) and associated options and parameters
26 /// can be changed by using:
27 /// AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLow(High)FluxParam();
28 /// muonRecoParam->Set...(); // see methods in AliMUONRecoParam.h for details
29 /// AliMUONReconstructor::SetRecoParam(muonRecoParam);
31 /// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
32 //-----------------------------------------------------------------------------
34 #include "AliMUONTracker.h"
36 #include "AliMUONReconstructor.h"
37 #include "AliMUONRecoParam.h"
38 #include "AliMUONTrack.h"
39 #include "AliMUONTrackExtrap.h"
40 #include "AliMUONTrackHitPattern.h"
41 #include "AliMUONTrackParam.h"
42 #include "AliMUONVCluster.h"
43 #include "AliMUONVClusterServer.h"
44 #include "AliMUONTrackReconstructor.h"
45 #include "AliMUONTrackReconstructorK.h"
46 #include "AliMUONTrackStoreV1.h"
47 #include "AliMUONTriggerTrackStoreV1.h"
48 #include "AliMUONClusterStoreV2.h"
49 #include "AliMUONVTriggerStore.h"
51 #include "AliESDEvent.h"
52 #include "AliESDMuonTrack.h"
53 #include "AliESDMuonCluster.h"
54 #include "AliESDVertex.h"
56 #include "AliCodeTimer.h"
58 #include <Riostream.h>
62 ClassImp(AliMUONTracker)
66 //_____________________________________________________________________________
67 AliMUONTracker::AliMUONTracker(AliMUONVClusterServer& clusterServer,
68 const AliMUONDigitMaker* digitMaker,
69 const AliMUONGeometryTransformer* transformer,
70 const AliMUONTriggerCircuit* triggerCircuit)
72 fDigitMaker(digitMaker), // not owner
73 fTransformer(transformer), // not owner
74 fTriggerCircuit(triggerCircuit), // not owner
75 fTrackHitPatternMaker(0x0),
79 fClusterServer(clusterServer)
82 if (fTransformer && fDigitMaker)
83 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
86 //_____________________________________________________________________________
87 AliMUONTracker::~AliMUONTracker()
91 delete fTrackHitPatternMaker;
96 //_____________________________________________________________________________
98 AliMUONTracker::ClusterStore() const
100 /// Return (and create if necessary) the cluster container
103 fClusterStore = new AliMUONClusterStoreV2;
105 return fClusterStore;
108 //_____________________________________________________________________________
109 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
111 /// Load triggerStore from clustersTree
113 ClusterStore()->Clear();
115 delete fTriggerStore;
117 if ( ! clustersTree ) {
118 AliFatal("No clustersTree");
122 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
126 AliError("Could not get triggerStore");
130 ClusterStore()->Connect(*clustersTree,kFALSE);
131 fTriggerStore->Connect(*clustersTree,kFALSE);
133 clustersTree->GetEvent(0);
138 //_____________________________________________________________________________
139 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
141 /// Performs the tracking and store the resulting tracks in the ESD
145 if (!fTrackReco) CreateTrackReconstructor();
147 // if the required tracking mode does not exist
148 if (!fTrackReco) return 1;
150 if ( ! ClusterStore() )
152 AliError("ClusterStore is NULL");
156 if (!fTriggerStore) {
157 AliError("TriggerStore is NULL");
161 // Make tracker tracks
162 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
163 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
165 // Make trigger tracks
166 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
167 if ( fTriggerCircuit ) {
168 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
169 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
172 // Match tracker/trigger tracks
173 if ( triggerTrackStore && fTrackHitPatternMaker ) {
174 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
178 FillESD(*trackStore,esd);
182 delete triggerTrackStore;
187 //_____________________________________________________________________________
188 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
190 /// Fill the ESD from the trackStore
195 Double_t vertex[3] = {0};
196 Double_t errXVtx = 0., errYVtx = 0.;
197 const AliESDVertex* esdVert = esd->GetVertex();
198 if (esdVert->GetNContributors())
200 esdVert->GetXYZ(vertex);
201 errXVtx = esdVert->GetXRes();
202 errYVtx = esdVert->GetYRes();
203 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
206 // setting ESD MUON class
207 AliESDMuonTrack esdTrack;
208 AliESDMuonCluster esdCluster;
211 AliMUONVCluster* cluster;
212 TIter next(trackStore.CreateIterator());
214 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
216 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
218 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
219 AliMUONTrackParam trackParamAtVtx(*trackParam);
220 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], errXVtx, errYVtx);
222 /// Extrapolate to vertex plan (which is set to z=0 if not available, see above)
223 AliMUONTrackParam trackParamAtDCA(*trackParam);
224 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&trackParamAtDCA, vertex[2]);
226 // setting data member of ESD MUON
227 esdTrack.Clear("C"); // remove already attached clusters
228 esdTrack.SetMuonClusterMap(0); // important to use the Add..() methods
231 trackParam->SetParamForUncorrected(esdTrack);
232 trackParam->SetCovFor(esdTrack);
234 trackParamAtVtx.SetParamFor(esdTrack);
235 // at Distance of Closest Approach
236 trackParamAtDCA.SetParamForDCA(esdTrack);
238 esdTrack.SetChi2(track->GetGlobalChi2());
239 esdTrack.SetNHit(track->GetNClusters());
240 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
241 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
242 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
245 cluster = trackParam->GetClusterPtr();
246 esdCluster.SetUniqueID(cluster->GetUniqueID());
247 esdCluster.SetXYZ(cluster->GetX(), cluster->GetY(), cluster->GetZ());
248 esdCluster.SetErrXY(cluster->GetErrX(), cluster->GetErrY());
249 esdTrack.AddCluster(esdCluster);
250 esdTrack.AddInMuonClusterMap(cluster->GetChamberId());
251 trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
254 // storing ESD MUON Track into ESD Event
255 esd->AddMuonTrack(&esdTrack);
256 } // end of loop on tracks
259 //_____________________________________________________________________________
260 void AliMUONTracker::CreateTrackReconstructor()
262 /// Create track reconstructor, depending on tracking mode set in RecoParam
264 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
267 if (strstr(opt,"ORIGINAL"))
269 fTrackReco = new AliMUONTrackReconstructor(fClusterServer);
271 else if (strstr(opt,"KALMAN"))
273 fTrackReco = new AliMUONTrackReconstructorK(fClusterServer);
277 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
281 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
284 //_____________________________________________________________________________
285 void AliMUONTracker::UnloadClusters()
287 /// Clear internal clusterStore
289 ClusterStore()->Clear();