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 "AliMUONVTriggerStore.h"
57 #include "AliMUONDigitMaker.h"
58 #include <Riostream.h>
63 ClassImp(AliMUONTracker)
67 //_____________________________________________________________________________
68 AliMUONTracker::AliMUONTracker(const AliMUONRecoParam* recoParam,
69 AliMUONVClusterServer* clusterServer,
70 AliMUONVDigitStore& digitStore,
71 const AliMUONDigitMaker* digitMaker,
72 const AliMUONGeometryTransformer* transformer,
73 const AliMUONTriggerCircuit* triggerCircuit)
75 fkDigitMaker(digitMaker), // not owner
76 fkTransformer(transformer), // not owner
77 fkTriggerCircuit(triggerCircuit), // not owner
78 fTrackHitPatternMaker(0x0),
82 fClusterServer(clusterServer),
83 fIsOwnerOfClusterServer(kFALSE),
84 fkDigitStore(digitStore), // not owner
85 fInputClusterStore(0x0),
86 fTriggerTrackStore(0x0),
87 fkRecoParam(recoParam)
90 if (fkTransformer && fkDigitMaker)
91 fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fkTransformer,*fkDigitMaker);
95 AliInfo("No cluster server given. Will use AliMUONLegacyClusterServer");
96 fIsOwnerOfClusterServer = kTRUE;
100 TIter next(fkDigitStore.CreateIterator());
101 fClusterServer->UseDigits(next,&digitStore);
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(*fkTransformer,fInputClusterStore,
177 GetRecoParam()->BypassSt4(),
178 GetRecoParam()->BypassSt5());
179 SetupClusterServer(*fClusterServer);
182 fTriggerStore->Connect(*clustersTree,kFALSE);
184 clustersTree->GetEvent(0);
189 //_____________________________________________________________________________
190 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
192 /// Performs the tracking and store the resulting tracks in the ESD
198 fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer);
201 // if the required tracking mode does not exist
202 if (!fTrackReco) return 1;
204 if ( ! ClusterStore() )
206 AliError("ClusterStore is NULL");
210 if (!fTriggerStore) {
211 AliError("TriggerStore is NULL");
215 // Make trigger tracks
216 if ( fkTriggerCircuit )
218 TriggerTrackStore()->Clear();
219 fTrackReco->EventReconstructTrigger(*fkTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
222 if ( ( GetRecoParam()->BypassSt4() ||
223 GetRecoParam()->BypassSt5() ) &&
224 TriggerTrackStore()->GetSize() > 5 )
226 // Hard cut to reject shower events
228 AliCodeTimerAuto("MUON Shower events");
230 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
231 TriggerTrackStore()->GetSize()));
236 // Make tracker tracks
237 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
238 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
240 // Match tracker/trigger tracks
241 if ( fTrackHitPatternMaker )
243 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
247 FillESD(*trackStore,esd);
255 //_____________________________________________________________________________
256 void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
258 /// Fill the ESD from the trackStore
263 Double_t vertex[3] = {0., 0., 0.};
264 const AliESDVertex* esdVert = esd->GetVertex();
265 if (esdVert->GetNContributors()) {
266 esdVert->GetXYZ(vertex);
267 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
270 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
272 AliMUONLocalTrigger* locTrg;
273 AliESDMuonTrack esdTrack;
274 TIter next(trackStore.CreateIterator());
275 if (GetRecoParam()->SaveFullClusterInESD() &&
276 gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
278 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
280 if (track->GetMatchTrigger() > 0) {
281 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
282 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore, locTrg);
283 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore);
285 esd->AddMuonTrack(&esdTrack);
290 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
292 if (track->GetMatchTrigger() > 0) {
293 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
294 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
295 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
297 esd->AddMuonTrack(&esdTrack);
302 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
303 UInt_t ghostId = 0xFFFFFFFF - 1;
304 Bool_t matched = kFALSE;
305 AliMUONTriggerTrack *triggerTrack;
306 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
307 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
309 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
311 // check if this local trigger has already been matched
312 TIter itTrack(trackStore.CreateIterator());
313 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
314 matched = (track->LoCircuit() == locTrg->LoCircuit());
317 if (matched) continue;
319 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId, triggerTrack);
321 esd->AddMuonTrack(&esdTrack);
327 //_____________________________________________________________________________
328 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
330 /// Create track reconstructor, depending on tracking mode set in RecoParam
332 AliMUONVTrackReconstructor* trackReco(0x0);
334 TString opt(recoParam->GetTrackingMode());
337 if (strstr(opt,"ORIGINAL"))
339 trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
341 else if (strstr(opt,"KALMAN"))
343 trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
347 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
351 AliInfoClass(Form("Will use %s for tracking",trackReco->ClassName()));
356 //_____________________________________________________________________________
357 void AliMUONTracker::UnloadClusters()
359 /// Clear internal clusterStore
361 delete fInputClusterStore;
362 fInputClusterStore = 0x0;
366 //_____________________________________________________________________________
368 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
370 /// Setup the cluster server
372 if ( GetRecoParam()->BypassSt4() ||
373 GetRecoParam()->BypassSt5() )
375 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
380 if ( GetRecoParam()->BypassSt45() )
382 msg1 = "STATIONS 4 AND 5";
383 msg2 = "THOSE TWO STATIONS";
385 else if ( GetRecoParam()->BypassSt4() )
388 msg2 = "THAT STATION";
390 else if ( GetRecoParam()->BypassSt5() )
393 msg2 = "THAT STATION";
398 AliWarning(Form("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN %s, "
399 "THUS BYPASSING REAL CLUSTERS IN %s!!!",msg1.Data(),msg2.Data()));
403 AliWarning("BYPASSING OF ST4 AND/OR 5 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");