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 can be changed
26 /// through the AliMUONRecoParam object set in the reconstruction macro or read from the CDB
27 /// (see methods in AliMUONRecoParam.h file for details)
29 /// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
30 //-----------------------------------------------------------------------------
32 #include "AliMUONTracker.h"
34 #include "AliCodeTimer.h"
35 #include "AliESDEvent.h"
36 #include "AliESDMuonTrack.h"
37 #include "AliESDVertex.h"
39 #include "AliMUONClusterStoreV2.h"
40 #include "AliMUONESDInterface.h"
41 #include "AliMUONLegacyClusterServer.h"
42 #include "AliMUONRecoParam.h"
43 #include "AliMUONReconstructor.h"
44 #include "AliMUONTrack.h"
45 #include "AliMUONTrackExtrap.h"
46 #include "AliMUONTrackHitPattern.h"
47 #include "AliMUONTrackParam.h"
48 #include "AliMUONTrackReconstructor.h"
49 #include "AliMUONTrackReconstructorK.h"
50 #include "AliMUONTrackStoreV1.h"
51 #include "AliMUONTriggerTrackStoreV1.h"
52 #include "AliMUONTriggerTrack.h"
53 #include "AliMUONLocalTrigger.h"
54 #include "AliMUONVClusterServer.h"
55 #include "AliMUONVDigitStore.h"
56 #include "AliMUONDigitStoreV1.h"
57 #include "AliMUONVTriggerStore.h"
58 #include "AliMUONDigitMaker.h"
59 #include <Riostream.h>
64 ClassImp(AliMUONTracker)
68 //_____________________________________________________________________________
69 AliMUONTracker::AliMUONTracker(const AliMUONRecoParam* recoParam,
70 AliMUONVClusterServer* clusterServer,
71 AliMUONVDigitStore& digitStore,
72 const AliMUONDigitMaker* digitMaker,
73 const AliMUONGeometryTransformer* transformer,
74 const AliMUONTriggerCircuit* triggerCircuit)
76 fkDigitMaker(digitMaker), // not owner
77 fkTransformer(transformer), // not owner
78 fkTriggerCircuit(triggerCircuit), // not owner
79 fTrackHitPatternMaker(0x0),
83 fClusterServer(clusterServer),
84 fIsOwnerOfClusterServer(kFALSE),
85 fkDigitStore(digitStore), // not owner
86 fInputClusterStore(0x0),
87 fTriggerTrackStore(0x0),
88 fkRecoParam(recoParam)
91 if (fkTransformer && fkDigitMaker)
92 fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fkTransformer,*fkDigitMaker);
96 AliInfo("No cluster server given. Will use AliMUONLegacyClusterServer");
97 fIsOwnerOfClusterServer = kTRUE;
101 TIter next(fkDigitStore.CreateIterator());
102 fClusterServer->UseDigits(next,&digitStore);
104 SetupClusterServer(*fClusterServer);
108 //_____________________________________________________________________________
109 AliMUONTracker::~AliMUONTracker()
113 delete fTrackHitPatternMaker;
114 delete fClusterStore;
115 delete fTriggerStore;
116 if ( fIsOwnerOfClusterServer ) delete fClusterServer;
117 delete fInputClusterStore;
118 delete fTriggerTrackStore;
121 //_____________________________________________________________________________
122 AliMUONVClusterStore*
123 AliMUONTracker::ClusterStore() const
125 /// Return (and create if necessary) the cluster container
128 fClusterStore = new AliMUONClusterStoreV2;
130 return fClusterStore;
133 //_____________________________________________________________________________
134 AliMUONVTriggerTrackStore*
135 AliMUONTracker::TriggerTrackStore() const
137 /// Return (and create if necessary) the trigger track container
138 if (!fTriggerTrackStore)
140 fTriggerTrackStore = new AliMUONTriggerTrackStoreV1;
142 return fTriggerTrackStore;
145 //_____________________________________________________________________________
146 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
148 /// Load triggerStore from clustersTree
150 delete fTriggerStore;
151 delete fInputClusterStore;
152 fInputClusterStore=0x0;
154 if ( ! clustersTree ) {
155 AliFatal("No clustersTree");
159 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
163 AliError("Could not get triggerStore");
167 if ( fIsOwnerOfClusterServer )
169 fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
170 if ( fInputClusterStore )
172 AliInfo(Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
173 fInputClusterStore->Clear();
174 fInputClusterStore->Connect(*clustersTree,kFALSE);
176 delete fClusterServer;
177 fClusterServer = new AliMUONLegacyClusterServer(*fkTransformer,fInputClusterStore,
178 GetRecoParam()->BypassSt4(),
179 GetRecoParam()->BypassSt5());
180 SetupClusterServer(*fClusterServer);
183 fTriggerStore->Connect(*clustersTree,kFALSE);
185 clustersTree->GetEvent(0);
190 //_____________________________________________________________________________
191 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
193 /// Performs the tracking and store the resulting tracks in the ESD
199 fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer);
202 // if the required tracking mode does not exist
203 if (!fTrackReco) return 1;
205 if ( ! ClusterStore() )
207 AliError("ClusterStore is NULL");
211 if (!fTriggerStore) {
212 AliError("TriggerStore is NULL");
216 // Make trigger tracks
217 if ( fkTriggerCircuit )
219 TriggerTrackStore()->Clear();
220 fTrackReco->EventReconstructTrigger(*fkTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
223 if ( ( GetRecoParam()->BypassSt4() ||
224 GetRecoParam()->BypassSt5() ) &&
225 TriggerTrackStore()->GetSize() > 5 )
227 // Hard cut to reject shower events
229 AliCodeTimerAuto("MUON Shower events");
231 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
232 TriggerTrackStore()->GetSize()));
237 // Make tracker tracks
238 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
239 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
241 // Match tracker/trigger tracks
242 if ( fTrackHitPatternMaker )
244 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
248 FillESD(*trackStore,esd);
256 //_____________________________________________________________________________
257 void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
259 /// Fill the ESD from the trackStore
264 Double_t vertex[3] = {0., 0., 0.};
265 const AliESDVertex* esdVert = esd->GetVertex();
266 if (esdVert->GetNContributors()) {
267 esdVert->GetXYZ(vertex);
268 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
271 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
273 AliMUONLocalTrigger* locTrg;
274 AliESDMuonTrack esdTrack;
275 TIter next(trackStore.CreateIterator());
276 if (GetRecoParam()->SaveFullClusterInESD() &&
277 gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
279 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
281 if (track->GetMatchTrigger() > 0) {
282 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
283 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore, locTrg);
284 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore);
286 esd->AddMuonTrack(&esdTrack);
291 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
293 if (track->GetMatchTrigger() > 0) {
294 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
295 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
296 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
298 esd->AddMuonTrack(&esdTrack);
303 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
304 UInt_t ghostId = 0xFFFFFFFF - 1;
305 Bool_t matched = kFALSE;
306 AliMUONTriggerTrack *triggerTrack;
308 // Needed to calculate the hit pattern for ghosts
309 AliMUONDigitStoreV1 digitStore;
310 fkDigitMaker->TriggerToDigitsStore(*fTriggerStore,digitStore);
312 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
313 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
315 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
317 // check if this local trigger has already been matched
318 TIter itTrack(trackStore.CreateIterator());
319 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
320 matched = (track->LoCircuit() == locTrg->LoCircuit());
323 if (matched) continue;
325 UShort_t pattern = fTrackHitPatternMaker->GetHitPattern(triggerTrack, digitStore);
327 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId, pattern);
329 esd->AddMuonTrack(&esdTrack);
335 //_____________________________________________________________________________
336 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
338 /// Create track reconstructor, depending on tracking mode set in RecoParam
340 AliMUONVTrackReconstructor* trackReco(0x0);
342 TString opt(recoParam->GetTrackingMode());
345 if (strstr(opt,"ORIGINAL"))
347 trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
349 else if (strstr(opt,"KALMAN"))
351 trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
355 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
359 AliInfoClass(Form("Will use %s for tracking",trackReco->ClassName()));
364 //_____________________________________________________________________________
365 void AliMUONTracker::UnloadClusters()
367 /// Clear internal clusterStore
369 delete fInputClusterStore;
370 fInputClusterStore = 0x0;
374 //_____________________________________________________________________________
376 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
378 /// Setup the cluster server
380 if ( GetRecoParam()->BypassSt4() ||
381 GetRecoParam()->BypassSt5() )
383 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
388 if ( GetRecoParam()->BypassSt45() )
390 msg1 = "STATIONS 4 AND 5";
391 msg2 = "THOSE TWO STATIONS";
393 else if ( GetRecoParam()->BypassSt4() )
396 msg2 = "THAT STATION";
398 else if ( GetRecoParam()->BypassSt5() )
401 msg2 = "THAT STATION";
406 AliWarning(Form("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN %s, "
407 "THUS BYPASSING REAL CLUSTERS IN %s!!!",msg1.Data(),msg2.Data()));
411 AliWarning("BYPASSING OF ST4 AND/OR 5 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");