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 <Riostream.h>
62 ClassImp(AliMUONTracker)
66 //_____________________________________________________________________________
67 AliMUONTracker::AliMUONTracker(const AliMUONRecoParam* recoParam,
68 AliMUONVClusterServer* clusterServer,
69 AliMUONVDigitStore& digitStore,
70 const AliMUONGeometryTransformer* transformer,
71 const AliMUONTriggerCircuit* triggerCircuit)
73 fkTransformer(transformer), // not owner
74 fkTriggerCircuit(triggerCircuit), // not owner
75 fTrackHitPatternMaker(0x0),
79 fClusterServer(clusterServer),
80 fIsOwnerOfClusterServer(kFALSE),
81 fkDigitStore(digitStore), // not owner
82 fInputClusterStore(0x0),
83 fTriggerTrackStore(0x0),
84 fkRecoParam(recoParam)
88 fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fkTransformer,fkDigitStore);
92 AliDebug(1,"No cluster server given. Will use AliMUONLegacyClusterServer");
93 fIsOwnerOfClusterServer = kTRUE;
97 TIter next(fkDigitStore.CreateIterator());
98 fClusterServer->UseDigits(next,&digitStore);
100 SetupClusterServer(*fClusterServer);
104 //_____________________________________________________________________________
105 AliMUONTracker::~AliMUONTracker()
109 delete fTrackHitPatternMaker;
110 delete fClusterStore;
111 delete fTriggerStore;
112 if ( fIsOwnerOfClusterServer ) delete fClusterServer;
113 delete fInputClusterStore;
114 delete fTriggerTrackStore;
117 //_____________________________________________________________________________
118 AliMUONVClusterStore*
119 AliMUONTracker::ClusterStore() const
121 /// Return (and create if necessary) the cluster container
124 fClusterStore = new AliMUONClusterStoreV2;
126 return fClusterStore;
129 //_____________________________________________________________________________
130 AliMUONVTriggerTrackStore*
131 AliMUONTracker::TriggerTrackStore() const
133 /// Return (and create if necessary) the trigger track container
134 if (!fTriggerTrackStore)
136 fTriggerTrackStore = new AliMUONTriggerTrackStoreV1;
138 return fTriggerTrackStore;
141 //_____________________________________________________________________________
142 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
144 /// Load triggerStore from clustersTree
146 delete fTriggerStore;
147 delete fInputClusterStore;
148 fInputClusterStore=0x0;
150 if ( ! clustersTree ) {
151 AliFatal("No clustersTree");
155 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
159 AliError("Could not get triggerStore");
163 if ( fIsOwnerOfClusterServer )
165 fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
166 if ( fInputClusterStore )
168 AliDebug(1,Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
169 fInputClusterStore->Clear();
170 fInputClusterStore->Connect(*clustersTree,kFALSE);
172 delete fClusterServer;
173 fClusterServer = new AliMUONLegacyClusterServer(*fkTransformer,fInputClusterStore,
174 GetRecoParam()->BypassSt4(),
175 GetRecoParam()->BypassSt5());
176 SetupClusterServer(*fClusterServer);
179 fTriggerStore->Connect(*clustersTree,kFALSE);
181 clustersTree->GetEvent(0);
186 //_____________________________________________________________________________
187 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
189 /// Performs the tracking and store the resulting tracks in the ESD
191 AliCodeTimerAuto("",0)
195 fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer);
198 // if the required tracking mode does not exist
199 if (!fTrackReco) return 1;
201 if ( ! ClusterStore() )
203 AliError("ClusterStore is NULL");
207 if (!fTriggerStore) {
208 AliError("TriggerStore is NULL");
212 // Make trigger tracks
213 if ( fkTriggerCircuit )
215 TriggerTrackStore()->Clear();
216 fTrackReco->EventReconstructTrigger(*fkTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
219 if ( TriggerTrackStore()->GetSize() > GetRecoParam()->GetMaxTriggerTracks() )
221 // cut to reject shower events
223 AliCodeTimerAuto("MUON Shower events",1);
225 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
226 TriggerTrackStore()->GetSize()));
231 // Make tracker tracks
232 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
233 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
235 // Match tracker/trigger tracks
236 if ( fTrackHitPatternMaker )
238 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
242 FillESD(*trackStore,esd);
250 //_____________________________________________________________________________
251 void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
253 /// Fill the ESD from the trackStore
255 AliCodeTimerAuto("",0)
258 Double_t vertex[3] = {0., 0., 0.};
259 const AliESDVertex* esdVert = esd->GetVertex();
260 if (esdVert->GetNContributors()) {
261 esdVert->GetXYZ(vertex);
262 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
265 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
267 AliMUONLocalTrigger* locTrg;
268 AliESDMuonTrack esdTrack;
269 TIter next(trackStore.CreateIterator());
270 if (GetRecoParam()->SaveFullClusterInESD() &&
271 gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
273 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
275 if (track->GetMatchTrigger() > 0) {
276 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
277 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore, locTrg);
278 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore);
280 esd->AddMuonTrack(&esdTrack);
285 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
287 if (track->GetMatchTrigger() > 0) {
288 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
289 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
290 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
292 esd->AddMuonTrack(&esdTrack);
297 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
298 UInt_t ghostId = 0xFFFFFFFF - 1;
299 Bool_t matched = kFALSE;
300 AliMUONTriggerTrack *triggerTrack;
301 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
302 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
304 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
306 // check if this local trigger has already been matched
307 TIter itTrack(trackStore.CreateIterator());
308 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
309 matched = (track->LoCircuit() == locTrg->LoCircuit());
312 if (matched) continue;
314 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId, triggerTrack);
316 esd->AddMuonTrack(&esdTrack);
322 //_____________________________________________________________________________
323 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
325 /// Create track reconstructor, depending on tracking mode set in RecoParam
327 AliMUONVTrackReconstructor* trackReco(0x0);
329 TString opt(recoParam->GetTrackingMode());
332 if (strstr(opt,"ORIGINAL"))
334 trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
336 else if (strstr(opt,"KALMAN"))
338 trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
342 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
346 AliDebugClass(1,Form("Will use %s for tracking",trackReco->ClassName()));
351 //_____________________________________________________________________________
352 void AliMUONTracker::UnloadClusters()
354 /// Clear internal clusterStore
356 delete fInputClusterStore;
357 fInputClusterStore = 0x0;
361 //_____________________________________________________________________________
363 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
365 /// Setup the cluster server
367 if ( GetRecoParam()->BypassSt4() ||
368 GetRecoParam()->BypassSt5() )
370 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
375 if ( GetRecoParam()->BypassSt45() )
377 msg1 = "STATIONS 4 AND 5";
378 msg2 = "THOSE TWO STATIONS";
380 else if ( GetRecoParam()->BypassSt4() )
383 msg2 = "THAT STATION";
385 else if ( GetRecoParam()->BypassSt5() )
388 msg2 = "THAT STATION";
393 AliWarning(Form("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN %s, "
394 "THUS BYPASSING REAL CLUSTERS IN %s!!!",msg1.Data(),msg2.Data()));
398 AliWarning("BYPASSING OF ST4 AND/OR 5 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");