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 "AliMUONVDigitStore.h"
45 #include "AliMUONTrackReconstructor.h"
46 #include "AliMUONTrackReconstructorK.h"
47 #include "AliMUONTrackStoreV1.h"
48 #include "AliMUONTriggerTrackStoreV1.h"
49 #include "AliMUONClusterStoreV2.h"
50 #include "AliMUONVTriggerStore.h"
52 #include "AliESDEvent.h"
53 #include "AliESDMuonTrack.h"
54 #include "AliESDMuonCluster.h"
55 #include "AliESDMuonPad.h"
56 #include "AliESDVertex.h"
58 #include "AliCodeTimer.h"
60 #include <Riostream.h>
65 ClassImp(AliMUONTracker)
69 //_____________________________________________________________________________
70 AliMUONTracker::AliMUONTracker(AliMUONVClusterServer& clusterServer,
71 const AliMUONVDigitStore& digitStore,
72 const AliMUONDigitMaker* digitMaker,
73 const AliMUONGeometryTransformer* transformer,
74 const AliMUONTriggerCircuit* triggerCircuit)
76 fDigitMaker(digitMaker), // not owner
77 fTransformer(transformer), // not owner
78 fTriggerCircuit(triggerCircuit), // not owner
79 fTrackHitPatternMaker(0x0),
83 fClusterServer(clusterServer), // not owner
84 fDigitStore(digitStore) // not owner
87 if (fTransformer && fDigitMaker)
88 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
90 fClusterServer.UseDigitStore(fDigitStore);
93 //_____________________________________________________________________________
94 AliMUONTracker::~AliMUONTracker()
98 delete fTrackHitPatternMaker;
100 delete fTriggerStore;
103 //_____________________________________________________________________________
104 AliMUONVClusterStore*
105 AliMUONTracker::ClusterStore() const
107 /// Return (and create if necessary) the cluster container
110 fClusterStore = new AliMUONClusterStoreV2;
112 return fClusterStore;
115 //_____________________________________________________________________________
116 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
118 /// Load triggerStore from clustersTree
120 ClusterStore()->Clear();
122 delete fTriggerStore;
124 if ( ! clustersTree ) {
125 AliFatal("No clustersTree");
129 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
133 AliError("Could not get triggerStore");
137 ClusterStore()->Connect(*clustersTree,kFALSE);
138 fTriggerStore->Connect(*clustersTree,kFALSE);
140 clustersTree->GetEvent(0);
145 //_____________________________________________________________________________
146 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
148 /// Performs the tracking and store the resulting tracks in the ESD
152 if (!fTrackReco) CreateTrackReconstructor();
154 // if the required tracking mode does not exist
155 if (!fTrackReco) return 1;
157 if ( ! ClusterStore() )
159 AliError("ClusterStore is NULL");
163 if (!fTriggerStore) {
164 AliError("TriggerStore is NULL");
168 // Make tracker tracks
169 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
170 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
172 // Make trigger tracks
173 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
174 if ( fTriggerCircuit ) {
175 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
176 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
179 // Match tracker/trigger tracks
180 if ( triggerTrackStore && fTrackHitPatternMaker ) {
181 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
185 FillESD(*trackStore,esd);
189 delete triggerTrackStore;
194 //_____________________________________________________________________________
195 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
197 /// Fill the ESD from the trackStore
201 // Random number to decide whether to save additional cluster info or not for the current event
203 if (AliMUONReconstructor::GetRecoParam()->SaveFullClusterInESD()) rand = gRandom->Uniform(0.,100.);
206 Double_t vertex[3] = {0};
207 Double_t errXVtx = 0., errYVtx = 0.;
208 const AliESDVertex* esdVert = esd->GetVertex();
209 if (esdVert->GetNContributors())
211 esdVert->GetXYZ(vertex);
212 errXVtx = esdVert->GetXRes();
213 errYVtx = esdVert->GetYRes();
214 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
218 AliMUONVCluster* cluster;
219 AliMUONVDigit* digit;
220 TIter next(trackStore.CreateIterator());
222 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
224 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
226 // new ESD muon track
227 AliESDMuonTrack esdTrack;
229 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
230 AliMUONTrackParam trackParamAtVtx(*trackParam);
231 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], errXVtx, errYVtx);
233 /// Extrapolate to vertex plan (which is set to z=0 if not available, see above)
234 AliMUONTrackParam trackParamAtDCA(*trackParam);
235 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&trackParamAtDCA, vertex[2]);
238 trackParam->SetParamForUncorrected(esdTrack);
239 trackParam->SetCovFor(esdTrack);
242 trackParamAtVtx.SetParamFor(esdTrack);
244 // at Distance of Closest Approach
245 trackParamAtDCA.SetParamForDCA(esdTrack);
248 esdTrack.SetChi2(track->GetGlobalChi2());
249 esdTrack.SetNHit(track->GetNClusters());
250 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
251 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
252 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
256 cluster = trackParam->GetClusterPtr();
258 // new ESD muon cluster
259 AliESDMuonCluster esdCluster;
261 // fill minimum info in ESD cluster
262 esdCluster.SetUniqueID(cluster->GetUniqueID());
263 esdCluster.SetXYZ(cluster->GetX(), cluster->GetY(), cluster->GetZ());
264 esdCluster.SetErrXY(cluster->GetErrX(), cluster->GetErrY());
266 // fill additional info in ESD cluster if required and only for a fraction of events
267 if (AliMUONReconstructor::GetRecoParam()->SaveFullClusterInESD() &&
268 rand <= AliMUONReconstructor::GetRecoParam()->GetPercentOfFullClusterInESD()) {
270 esdCluster.SetCharge(cluster->GetCharge());
271 esdCluster.SetChi2(cluster->GetChi2());
273 // fill ESD pad with digit info
274 for (Int_t i=0; i<cluster->GetNDigits(); i++) {
275 digit = fDigitStore.FindObject(cluster->GetDigitId(i));
278 AliESDMuonPad esdPad;
280 esdPad.SetUniqueID(digit->GetUniqueID());
281 esdPad.SetADC(digit->ADC());
282 esdPad.SetCharge(digit->Charge());
284 // add pad info in ESD cluster
285 esdCluster.AddPad(esdPad);
290 // add cluster info in ESD track
291 esdTrack.AddCluster(esdCluster);
292 esdTrack.AddInMuonClusterMap(cluster->GetChamberId());
294 trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
297 // storing ESD MUON Track into ESD Event
298 esd->AddMuonTrack(&esdTrack);
299 } // end of loop on tracks
302 //_____________________________________________________________________________
303 void AliMUONTracker::CreateTrackReconstructor()
305 /// Create track reconstructor, depending on tracking mode set in RecoParam
307 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
310 if (strstr(opt,"ORIGINAL"))
312 fTrackReco = new AliMUONTrackReconstructor(fClusterServer);
314 else if (strstr(opt,"KALMAN"))
316 fTrackReco = new AliMUONTrackReconstructorK(fClusterServer);
320 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
324 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
327 //_____________________________________________________________________________
328 void AliMUONTracker::UnloadClusters()
330 /// Clear internal clusterStore
332 ClusterStore()->Clear();