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 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),
89 if (fTransformer && fDigitMaker)
90 fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fTransformer,*fDigitMaker);
94 AliInfo("No cluster server given. Will use AliMUONLegacyClusterServer");
95 fIsOwnerOfClusterServer = kTRUE;
99 TIter next(fDigitStore.CreateIterator());
100 fClusterServer->UseDigits(next);
102 SetupClusterServer(*fClusterServer);
106 //_____________________________________________________________________________
107 AliMUONTracker::~AliMUONTracker()
111 delete fTrackHitPatternMaker;
112 delete fClusterStore;
113 delete fTriggerStore;
114 if ( fIsOwnerOfClusterServer ) delete fClusterServer;
115 delete fInputClusterStore;
116 delete fTriggerTrackStore;
119 //_____________________________________________________________________________
120 AliMUONVClusterStore*
121 AliMUONTracker::ClusterStore() const
123 /// Return (and create if necessary) the cluster container
126 fClusterStore = new AliMUONClusterStoreV2;
128 return fClusterStore;
131 //_____________________________________________________________________________
132 AliMUONVTriggerTrackStore*
133 AliMUONTracker::TriggerTrackStore() const
135 /// Return (and create if necessary) the trigger track container
136 if (!fTriggerTrackStore)
138 fTriggerTrackStore = new AliMUONTriggerTrackStoreV1;
140 return fTriggerTrackStore;
143 //_____________________________________________________________________________
144 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
146 /// Load triggerStore from clustersTree
148 delete fTriggerStore;
149 delete fInputClusterStore;
150 fInputClusterStore=0x0;
152 if ( ! clustersTree ) {
153 AliFatal("No clustersTree");
157 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
161 AliError("Could not get triggerStore");
165 if ( fIsOwnerOfClusterServer )
167 fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
168 if ( fInputClusterStore )
170 AliInfo(Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
171 fInputClusterStore->Clear();
172 fInputClusterStore->Connect(*clustersTree,kFALSE);
174 delete fClusterServer;
175 fClusterServer = new AliMUONLegacyClusterServer(*fTransformer,fInputClusterStore,
176 GetRecoParam()->BypassSt4(),
177 GetRecoParam()->BypassSt5());
178 SetupClusterServer(*fClusterServer);
181 fTriggerStore->Connect(*clustersTree,kFALSE);
183 clustersTree->GetEvent(0);
188 //_____________________________________________________________________________
189 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
191 /// Performs the tracking and store the resulting tracks in the ESD
197 fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer);
200 // if the required tracking mode does not exist
201 if (!fTrackReco) return 1;
203 if ( ! ClusterStore() )
205 AliError("ClusterStore is NULL");
209 if (!fTriggerStore) {
210 AliError("TriggerStore is NULL");
214 // Make trigger tracks
215 if ( fTriggerCircuit )
217 TriggerTrackStore()->Clear();
218 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
221 if ( ( GetRecoParam()->BypassSt4() ||
222 GetRecoParam()->BypassSt5() ) &&
223 TriggerTrackStore()->GetSize() > 5 )
225 // Hard cut to reject shower events
227 AliCodeTimerAuto("MUON Shower events");
229 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
230 TriggerTrackStore()->GetSize()));
235 // Make tracker tracks
236 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
237 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
239 // Match tracker/trigger tracks
240 if ( fTrackHitPatternMaker )
242 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
246 FillESD(*trackStore,esd);
254 //_____________________________________________________________________________
255 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
257 /// Fill the ESD from the trackStore
262 Double_t vertex[3] = {0., 0., 0.};
263 const AliESDVertex* esdVert = esd->GetVertex();
264 if (esdVert->GetNContributors()) {
265 esdVert->GetXYZ(vertex);
266 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
269 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
271 AliMUONLocalTrigger* locTrg;
272 AliESDMuonTrack esdTrack;
273 TIter next(trackStore.CreateIterator());
274 if (GetRecoParam()->SaveFullClusterInESD() &&
275 gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
277 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
279 if (track->GetMatchTrigger() > 0) {
280 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
281 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore, locTrg);
282 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore);
284 esd->AddMuonTrack(&esdTrack);
289 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
291 if (track->GetMatchTrigger() > 0) {
292 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
293 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
294 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
296 esd->AddMuonTrack(&esdTrack);
301 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
302 UInt_t ghostId = 0xFFFFFFFF - 1;
303 Bool_t matched = kFALSE;
304 AliMUONTriggerTrack *triggerTrack;
305 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
306 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
308 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
310 // check if this local trigger has already been matched
311 TIter itTrack(trackStore.CreateIterator());
312 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
313 matched = (track->LoCircuit() == locTrg->LoCircuit());
316 if (matched) continue;
318 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId);
320 esd->AddMuonTrack(&esdTrack);
326 //_____________________________________________________________________________
327 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
329 /// Create track reconstructor, depending on tracking mode set in RecoParam
331 AliMUONVTrackReconstructor* trackReco(0x0);
333 TString opt(recoParam->GetTrackingMode());
336 if (strstr(opt,"ORIGINAL"))
338 trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
340 else if (strstr(opt,"KALMAN"))
342 trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
346 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
350 AliInfoClass(Form("Will use %s for tracking",trackReco->ClassName()));
355 //_____________________________________________________________________________
356 void AliMUONTracker::UnloadClusters()
358 /// Clear internal clusterStore
360 delete fInputClusterStore;
361 fInputClusterStore = 0x0;
365 //_____________________________________________________________________________
367 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
369 /// Setup the cluster server
371 if ( GetRecoParam()->BypassSt4() ||
372 GetRecoParam()->BypassSt5() )
374 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
379 if ( GetRecoParam()->BypassSt45() )
381 msg1 = "STATIONS 4 AND 5";
382 msg2 = "THOSE TWO STATIONS";
384 else if ( GetRecoParam()->BypassSt4() )
387 msg2 = "THAT STATION";
389 else if ( GetRecoParam()->BypassSt5() )
392 msg2 = "THAT STATION";
397 AliWarning(Form("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN %s, "
398 "THUS BYPASSING REAL CLUSTERS IN %s!!!",msg1.Data(),msg2.Data()));
402 AliWarning("BYPASSING OF ST4 AND/OR 5 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");