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 "AliMUONTriggerUtilities.h"
58 #include <Riostream.h>
63 ClassImp(AliMUONTracker)
67 //_____________________________________________________________________________
68 AliMUONTracker::AliMUONTracker(const AliMUONRecoParam* recoParam,
69 AliMUONVClusterServer* clusterServer,
70 AliMUONVDigitStore& digitStore,
71 const AliMUONGeometryTransformer* transformer,
72 const AliMUONTriggerCircuit* triggerCircuit,
73 const AliMUONTriggerUtilities* triggerUtilities)
75 fkTransformer(transformer), // not owner
76 fkTriggerCircuit(triggerCircuit), // not owner
77 fTrackHitPatternMaker(0x0),
81 fClusterServer(clusterServer),
82 fIsOwnerOfClusterServer(kFALSE),
83 fkDigitStore(digitStore), // not owner
84 fInputClusterStore(0x0),
85 fTriggerTrackStore(0x0),
86 fkRecoParam(recoParam)
90 fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fkTransformer,fkDigitStore,triggerUtilities);
94 AliDebug(1,"No cluster server given. Will use AliMUONLegacyClusterServer");
95 fIsOwnerOfClusterServer = kTRUE;
99 TIter next(fkDigitStore.CreateIterator());
100 fClusterServer->UseDigits(next,&digitStore);
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 AliDebug(1,Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
171 fInputClusterStore->Clear();
172 fInputClusterStore->Connect(*clustersTree,kFALSE);
174 delete fClusterServer;
175 fClusterServer = new AliMUONLegacyClusterServer(*fkTransformer,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
193 AliCodeTimerAuto("",0)
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 ( fkTriggerCircuit )
217 TriggerTrackStore()->Clear();
218 fTrackReco->EventReconstructTrigger(*fkTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
221 if ( TriggerTrackStore()->GetSize() > GetRecoParam()->GetMaxTriggerTracks() )
223 // cut to reject shower events
225 AliCodeTimerAuto("MUON Shower events",1);
227 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
228 TriggerTrackStore()->GetSize()));
233 // Make tracker tracks
234 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
235 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
237 // Match tracker/trigger tracks
238 if ( fTrackHitPatternMaker )
240 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
244 FillESD(*trackStore,esd);
252 //_____________________________________________________________________________
253 void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
255 /// Fill the ESD from the trackStore
257 AliCodeTimerAuto("",0)
260 Double_t vertex[3] = {0., 0., 0.};
261 const AliESDVertex* esdVert = esd->GetVertex();
262 if (esdVert->GetNContributors() > 0 || !strcmp(esdVert->GetTitle(),"vertexer: smearMC")) {
263 esdVert->GetXYZ(vertex);
264 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
267 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
269 AliMUONLocalTrigger* locTrg;
270 AliESDMuonTrack esdTrack;
271 TIter next(trackStore.CreateIterator());
272 if (GetRecoParam()->SaveFullClusterInESD() &&
273 gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
275 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
277 if (track->GetMatchTrigger() > 0) {
278 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
279 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore, locTrg);
280 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore);
282 esd->AddMuonTrack(&esdTrack);
287 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
289 if (track->GetMatchTrigger() > 0) {
290 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
291 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
292 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
294 esd->AddMuonTrack(&esdTrack);
299 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
300 UInt_t ghostId = 0xFFFFFFFF - 1;
301 Bool_t matched = kFALSE;
302 AliMUONTriggerTrack *triggerTrack;
303 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
304 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
306 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
308 // check if this local trigger has already been matched
309 TIter itTrack(trackStore.CreateIterator());
310 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
311 matched = (track->LoCircuit() == locTrg->LoCircuit());
314 if (matched) continue;
316 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId, triggerTrack);
318 esd->AddMuonTrack(&esdTrack);
324 //_____________________________________________________________________________
325 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
327 /// Create track reconstructor, depending on tracking mode set in RecoParam
329 AliMUONVTrackReconstructor* trackReco(0x0);
331 TString opt(recoParam->GetTrackingMode());
334 if (strstr(opt,"ORIGINAL"))
336 trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
338 else if (strstr(opt,"KALMAN"))
340 trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
344 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
348 AliDebugClass(1,Form("Will use %s for tracking",trackReco->ClassName()));
353 //_____________________________________________________________________________
354 void AliMUONTracker::UnloadClusters()
356 /// Clear internal clusterStore
358 delete fInputClusterStore;
359 fInputClusterStore = 0x0;
363 //_____________________________________________________________________________
365 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
367 /// Setup the cluster server
369 if ( GetRecoParam()->BypassSt4() ||
370 GetRecoParam()->BypassSt5() )
372 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
377 if ( GetRecoParam()->BypassSt45() )
379 msg1 = "STATIONS 4 AND 5";
380 msg2 = "THOSE TWO STATIONS";
382 else if ( GetRecoParam()->BypassSt4() )
385 msg2 = "THAT STATION";
387 else if ( GetRecoParam()->BypassSt5() )
390 msg2 = "THAT STATION";
395 AliWarning(Form("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN %s, "
396 "THUS BYPASSING REAL CLUSTERS IN %s!!!",msg1.Data(),msg2.Data()));
400 AliWarning("BYPASSING OF ST4 AND/OR 5 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");