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 "AliMUONTriggerTrack.h"
55 #include "AliMUONLocalTrigger.h"
56 #include "AliMUONVCluster.h"
57 #include "AliMUONVClusterServer.h"
58 #include "AliMUONVDigitStore.h"
59 #include "AliMUONVTriggerStore.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),
84 fIsOwnerOfClusterServer(kFALSE),
85 fDigitStore(digitStore), // not owner
86 fInputClusterStore(0x0),
87 fTriggerTrackStore(0x0)
90 if (fTransformer && fDigitMaker)
91 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
95 AliInfo("No cluster server given. Will use AliMUONLegacyClusterServer");
96 fIsOwnerOfClusterServer = kTRUE;
100 TIter next(fDigitStore.CreateIterator());
101 fClusterServer->UseDigits(next);
103 SetupClusterServer(*fClusterServer);
107 //_____________________________________________________________________________
108 AliMUONTracker::~AliMUONTracker()
112 delete fTrackHitPatternMaker;
113 delete fClusterStore;
114 delete fTriggerStore;
115 if ( fIsOwnerOfClusterServer ) delete fClusterServer;
116 delete fInputClusterStore;
117 delete fTriggerTrackStore;
120 //_____________________________________________________________________________
121 AliMUONVClusterStore*
122 AliMUONTracker::ClusterStore() const
124 /// Return (and create if necessary) the cluster container
127 fClusterStore = new AliMUONClusterStoreV2;
129 return fClusterStore;
132 //_____________________________________________________________________________
133 AliMUONVTriggerTrackStore*
134 AliMUONTracker::TriggerTrackStore() const
136 /// Return (and create if necessary) the trigger track container
137 if (!fTriggerTrackStore)
139 fTriggerTrackStore = new AliMUONTriggerTrackStoreV1;
141 return fTriggerTrackStore;
144 //_____________________________________________________________________________
145 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
147 /// Load triggerStore from clustersTree
149 delete fTriggerStore;
150 delete fInputClusterStore;
151 fInputClusterStore=0x0;
153 if ( ! clustersTree ) {
154 AliFatal("No clustersTree");
158 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
162 AliError("Could not get triggerStore");
166 if ( fIsOwnerOfClusterServer )
168 fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
169 if ( fInputClusterStore )
171 AliInfo(Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
172 fInputClusterStore->Clear();
173 fInputClusterStore->Connect(*clustersTree,kFALSE);
175 delete fClusterServer;
176 fClusterServer = new AliMUONLegacyClusterServer(*fTransformer,fInputClusterStore);
177 SetupClusterServer(*fClusterServer);
180 fTriggerStore->Connect(*clustersTree,kFALSE);
182 clustersTree->GetEvent(0);
187 //_____________________________________________________________________________
188 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
190 /// Performs the tracking and store the resulting tracks in the ESD
196 fTrackReco = CreateTrackReconstructor(AliMUONReconstructor::GetRecoParam()->GetTrackingMode(),fClusterServer);
199 // if the required tracking mode does not exist
200 if (!fTrackReco) return 1;
202 if ( ! ClusterStore() )
204 AliError("ClusterStore is NULL");
208 if (!fTriggerStore) {
209 AliError("TriggerStore is NULL");
213 // Make trigger tracks
214 if ( fTriggerCircuit )
216 TriggerTrackStore()->Clear();
217 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
220 if ( AliMUONReconstructor::GetRecoParam()->BypassSt45() && TriggerTrackStore()->GetSize() > 5 )
222 // Hard cut to reject shower events
224 AliCodeTimerAuto("MUON Shower events");
226 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
227 TriggerTrackStore()->GetSize()));
232 // Make tracker tracks
233 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
234 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
236 // Match tracker/trigger tracks
237 if ( fTrackHitPatternMaker )
239 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
243 FillESD(*trackStore,esd);
251 //_____________________________________________________________________________
252 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
254 /// Fill the ESD from the trackStore
259 Double_t vertex[3] = {0., 0., 0.};
260 const AliESDVertex* esdVert = esd->GetVertex();
261 if (esdVert->GetNContributors()) {
262 esdVert->GetXYZ(vertex);
263 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
266 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
268 AliMUONLocalTrigger* locTrg;
269 AliESDMuonTrack esdTrack;
270 TIter next(trackStore.CreateIterator());
271 if (AliMUONReconstructor::GetRecoParam()->SaveFullClusterInESD() &&
272 gRandom->Uniform(100.) <= AliMUONReconstructor::GetRecoParam()->GetPercentOfFullClusterInESD()) {
274 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
276 if (track->GetMatchTrigger() > 0) {
277 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
278 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore, locTrg);
279 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore);
281 esd->AddMuonTrack(&esdTrack);
286 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
288 if (track->GetMatchTrigger() > 0) {
289 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
290 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
291 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
293 esd->AddMuonTrack(&esdTrack);
298 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
299 UInt_t ghostId = 0xFFFFFFFF - 1;
300 Bool_t matched = kFALSE;
301 AliMUONTriggerTrack *triggerTrack;
302 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
303 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
305 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
307 // check if this local trigger has already been matched
308 TIter itTrack(trackStore.CreateIterator());
309 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
310 matched = (track->LoCircuit() == locTrg->LoCircuit());
313 if (matched) continue;
315 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId);
317 esd->AddMuonTrack(&esdTrack);
323 //_____________________________________________________________________________
324 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const char* trackingMode, AliMUONVClusterServer* clusterServer)
326 /// Create track reconstructor, depending on tracking mode set in RecoParam
328 AliMUONVTrackReconstructor* trackReco(0x0);
330 TString opt(trackingMode);
333 if (strstr(opt,"ORIGINAL"))
335 trackReco = new AliMUONTrackReconstructor(clusterServer);
337 else if (strstr(opt,"KALMAN"))
339 trackReco = new AliMUONTrackReconstructorK(clusterServer);
343 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
347 AliInfoClass(Form("Will use %s for tracking",trackReco->ClassName()));
352 //_____________________________________________________________________________
353 void AliMUONTracker::UnloadClusters()
355 /// Clear internal clusterStore
357 delete fInputClusterStore;
358 fInputClusterStore = 0x0;
362 //_____________________________________________________________________________
364 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
366 /// Setup the cluster server
368 if ( AliMUONReconstructor::GetRecoParam()->BypassSt45() )
370 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
375 AliWarning("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN STATIONS 4 AND 5, THUS BYPASSING REAL CLUSTERS IN THOSE TWO STATIONS !!!");
379 AliWarning("BYPASSING OF ST45 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");