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 "AliCodeTimer.h"
37 #include "AliESDEvent.h"
38 #include "AliESDMuonTrack.h"
39 #include "AliESDVertex.h"
41 #include "AliMUONClusterStoreV2.h"
42 #include "AliMUONESDInterface.h"
43 #include "AliMUONLegacyClusterServer.h"
44 #include "AliMUONRecoParam.h"
45 #include "AliMUONReconstructor.h"
46 #include "AliMUONTrack.h"
47 #include "AliMUONTrackExtrap.h"
48 #include "AliMUONTrackHitPattern.h"
49 #include "AliMUONTrackParam.h"
50 #include "AliMUONTrackReconstructor.h"
51 #include "AliMUONTrackReconstructorK.h"
52 #include "AliMUONTrackStoreV1.h"
53 #include "AliMUONTriggerTrackStoreV1.h"
54 #include "AliMUONVCluster.h"
55 #include "AliMUONVClusterServer.h"
56 #include "AliMUONVDigitStore.h"
57 #include "AliMUONVTriggerStore.h"
58 #include <Riostream.h>
63 ClassImp(AliMUONTracker)
67 //_____________________________________________________________________________
68 AliMUONTracker::AliMUONTracker(AliMUONVClusterServer* clusterServer,
69 const AliMUONVDigitStore& digitStore,
70 const AliMUONDigitMaker* digitMaker,
71 const AliMUONGeometryTransformer* transformer,
72 const AliMUONTriggerCircuit* triggerCircuit)
74 fDigitMaker(digitMaker), // not owner
75 fTransformer(transformer), // not owner
76 fTriggerCircuit(triggerCircuit), // not owner
77 fTrackHitPatternMaker(0x0),
81 fClusterServer(clusterServer),
82 fIsOwnerOfClusterServer(kFALSE),
83 fDigitStore(digitStore), // not owner
84 fInputClusterStore(0x0),
85 fTriggerTrackStore(0x0)
88 if (fTransformer && fDigitMaker)
89 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
93 AliInfo("No cluster server given. Will use AliMUONLegacyClusterServer");
94 fIsOwnerOfClusterServer = kTRUE;
98 TIter next(fDigitStore.CreateIterator());
99 fClusterServer->UseDigits(next);
101 SetupClusterServer(*fClusterServer);
105 //_____________________________________________________________________________
106 AliMUONTracker::~AliMUONTracker()
110 delete fTrackHitPatternMaker;
111 delete fClusterStore;
112 delete fTriggerStore;
113 if ( fIsOwnerOfClusterServer ) delete fClusterServer;
114 delete fInputClusterStore;
115 delete fTriggerTrackStore;
118 //_____________________________________________________________________________
119 AliMUONVClusterStore*
120 AliMUONTracker::ClusterStore() const
122 /// Return (and create if necessary) the cluster container
125 fClusterStore = new AliMUONClusterStoreV2;
127 return fClusterStore;
130 //_____________________________________________________________________________
131 AliMUONVTriggerTrackStore*
132 AliMUONTracker::TriggerTrackStore() const
134 /// Return (and create if necessary) the trigger track container
135 if (!fTriggerTrackStore)
137 fTriggerTrackStore = new AliMUONTriggerTrackStoreV1;
139 return fTriggerTrackStore;
142 //_____________________________________________________________________________
143 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
145 /// Load triggerStore from clustersTree
147 delete fTriggerStore;
148 delete fInputClusterStore;
149 fInputClusterStore=0x0;
151 if ( ! clustersTree ) {
152 AliFatal("No clustersTree");
156 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
160 AliError("Could not get triggerStore");
164 if ( fIsOwnerOfClusterServer )
166 fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
167 if ( fInputClusterStore )
169 AliInfo(Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
170 fInputClusterStore->Clear();
171 fInputClusterStore->Connect(*clustersTree,kFALSE);
173 delete fClusterServer;
174 fClusterServer = new AliMUONLegacyClusterServer(*fTransformer,fInputClusterStore);
175 SetupClusterServer(*fClusterServer);
178 fTriggerStore->Connect(*clustersTree,kFALSE);
180 clustersTree->GetEvent(0);
185 //_____________________________________________________________________________
186 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
188 /// Performs the tracking and store the resulting tracks in the ESD
194 fTrackReco = CreateTrackReconstructor(AliMUONReconstructor::GetRecoParam()->GetTrackingMode(),fClusterServer);
197 // if the required tracking mode does not exist
198 if (!fTrackReco) return 1;
200 if ( ! ClusterStore() )
202 AliError("ClusterStore is NULL");
206 if (!fTriggerStore) {
207 AliError("TriggerStore is NULL");
211 // Make trigger tracks
212 if ( fTriggerCircuit )
214 TriggerTrackStore()->Clear();
215 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
218 // Make tracker tracks
219 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
220 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
222 // Match tracker/trigger tracks
223 if ( fTrackHitPatternMaker )
225 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
229 FillESD(*trackStore,esd);
237 //_____________________________________________________________________________
238 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
240 /// Fill the ESD from the trackStore
245 AliESDMuonTrack esdTrack;
246 Double_t vertex[3] = {0., 0., 0.};
247 TIter next(trackStore.CreateIterator());
250 const AliESDVertex* esdVert = esd->GetVertex();
251 if (esdVert->GetNContributors()) {
252 esdVert->GetXYZ(vertex);
253 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
256 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
257 if (AliMUONReconstructor::GetRecoParam()->SaveFullClusterInESD() &&
258 gRandom->Uniform(100.) <= AliMUONReconstructor::GetRecoParam()->GetPercentOfFullClusterInESD()) {
260 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
261 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore);
262 esd->AddMuonTrack(&esdTrack);
267 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
268 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
269 esd->AddMuonTrack(&esdTrack);
276 //_____________________________________________________________________________
277 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const char* trackingMode, AliMUONVClusterServer* clusterServer)
279 /// Create track reconstructor, depending on tracking mode set in RecoParam
281 AliMUONVTrackReconstructor* trackReco(0x0);
283 TString opt(trackingMode);
286 if (strstr(opt,"ORIGINAL"))
288 trackReco = new AliMUONTrackReconstructor(*clusterServer);
290 else if (strstr(opt,"KALMAN"))
292 trackReco = new AliMUONTrackReconstructorK(*clusterServer);
296 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
300 AliInfoClass(Form("Will use %s for tracking",trackReco->ClassName()));
305 //_____________________________________________________________________________
306 void AliMUONTracker::UnloadClusters()
308 /// Clear internal clusterStore
310 delete fInputClusterStore;
311 fInputClusterStore = 0x0;
315 //_____________________________________________________________________________
317 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
319 /// Setup the cluster server
321 if ( AliMUONReconstructor::GetRecoParam()->BypassSt45() )
323 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
328 AliWarning("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN STATIONS 4 AND 5, THUS BYPASSING REAL CLUSTERS IN THOSE TWO STATIONS !!!");
332 AliWarning("BYPASSING OF ST45 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");