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
26 /// can be changed by using:
27 /// AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLow(High)FluxParam();
28 /// muonRecoParam->Set...(); // see methods in AliMUONRecoParam.h for details
29 /// AliMUONReconstructor::SetRecoParam(muonRecoParam);
31 /// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
32 //-----------------------------------------------------------------------------
34 #include "AliMUONTracker.h"
36 #include "AliCodeTimer.h"
37 #include "AliESDEvent.h"
38 #include "AliESDMuonTrack.h"
39 #include "AliESDVertex.h"
41 #include "AliMUONClusterStoreV2.h"
42 #include "AliMUONESDInterface.h"
43 #include "AliMUONLegacyClusterServer.h"
44 #include "AliMUONRecoParam.h"
45 #include "AliMUONReconstructor.h"
46 #include "AliMUONTrack.h"
47 #include "AliMUONTrackExtrap.h"
48 #include "AliMUONTrackHitPattern.h"
49 #include "AliMUONTrackParam.h"
50 #include "AliMUONTrackReconstructor.h"
51 #include "AliMUONTrackReconstructorK.h"
52 #include "AliMUONTrackStoreV1.h"
53 #include "AliMUONTriggerTrackStoreV1.h"
54 #include "AliMUONTriggerTrack.h"
55 #include "AliMUONLocalTrigger.h"
56 #include "AliMUONVCluster.h"
57 #include "AliMUONVClusterServer.h"
58 #include "AliMUONVDigitStore.h"
59 #include "AliMUONVTriggerStore.h"
60 #include <Riostream.h>
65 ClassImp(AliMUONTracker)
69 //_____________________________________________________________________________
70 AliMUONTracker::AliMUONTracker(const AliMUONRecoParam* recoParam,
71 AliMUONVClusterServer* clusterServer,
72 const AliMUONVDigitStore& digitStore,
73 const AliMUONDigitMaker* digitMaker,
74 const AliMUONGeometryTransformer* transformer,
75 const AliMUONTriggerCircuit* triggerCircuit)
77 fDigitMaker(digitMaker), // not owner
78 fTransformer(transformer), // not owner
79 fTriggerCircuit(triggerCircuit), // not owner
80 fTrackHitPatternMaker(0x0),
84 fClusterServer(clusterServer),
85 fIsOwnerOfClusterServer(kFALSE),
86 fDigitStore(digitStore), // not owner
87 fInputClusterStore(0x0),
88 fTriggerTrackStore(0x0),
92 if (fTransformer && fDigitMaker)
93 fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fTransformer,*fDigitMaker);
97 AliInfo("No cluster server given. Will use AliMUONLegacyClusterServer");
98 fIsOwnerOfClusterServer = kTRUE;
102 TIter next(fDigitStore.CreateIterator());
103 fClusterServer->UseDigits(next);
105 SetupClusterServer(*fClusterServer);
109 //_____________________________________________________________________________
110 AliMUONTracker::~AliMUONTracker()
114 delete fTrackHitPatternMaker;
115 delete fClusterStore;
116 delete fTriggerStore;
117 if ( fIsOwnerOfClusterServer ) delete fClusterServer;
118 delete fInputClusterStore;
119 delete fTriggerTrackStore;
122 //_____________________________________________________________________________
123 AliMUONVClusterStore*
124 AliMUONTracker::ClusterStore() const
126 /// Return (and create if necessary) the cluster container
129 fClusterStore = new AliMUONClusterStoreV2;
131 return fClusterStore;
134 //_____________________________________________________________________________
135 AliMUONVTriggerTrackStore*
136 AliMUONTracker::TriggerTrackStore() const
138 /// Return (and create if necessary) the trigger track container
139 if (!fTriggerTrackStore)
141 fTriggerTrackStore = new AliMUONTriggerTrackStoreV1;
143 return fTriggerTrackStore;
146 //_____________________________________________________________________________
147 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
149 /// Load triggerStore from clustersTree
151 delete fTriggerStore;
152 delete fInputClusterStore;
153 fInputClusterStore=0x0;
155 if ( ! clustersTree ) {
156 AliFatal("No clustersTree");
160 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
164 AliError("Could not get triggerStore");
168 if ( fIsOwnerOfClusterServer )
170 fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
171 if ( fInputClusterStore )
173 AliInfo(Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
174 fInputClusterStore->Clear();
175 fInputClusterStore->Connect(*clustersTree,kFALSE);
177 delete fClusterServer;
178 fClusterServer = new AliMUONLegacyClusterServer(*fTransformer,fInputClusterStore,
179 GetRecoParam()->BypassSt4(),
180 GetRecoParam()->BypassSt5());
181 SetupClusterServer(*fClusterServer);
184 fTriggerStore->Connect(*clustersTree,kFALSE);
186 clustersTree->GetEvent(0);
191 //_____________________________________________________________________________
192 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
194 /// Performs the tracking and store the resulting tracks in the ESD
200 fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer);
203 // if the required tracking mode does not exist
204 if (!fTrackReco) return 1;
206 if ( ! ClusterStore() )
208 AliError("ClusterStore is NULL");
212 if (!fTriggerStore) {
213 AliError("TriggerStore is NULL");
217 // Make trigger tracks
218 if ( fTriggerCircuit )
220 TriggerTrackStore()->Clear();
221 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*(TriggerTrackStore()));
224 if ( ( GetRecoParam()->BypassSt4() ||
225 GetRecoParam()->BypassSt5() ) &&
226 TriggerTrackStore()->GetSize() > 5 )
228 // Hard cut to reject shower events
230 AliCodeTimerAuto("MUON Shower events");
232 AliWarning(Form("Probably got a shower event (%d trigger tracks). Will not reconstruct tracks.",
233 TriggerTrackStore()->GetSize()));
238 // Make tracker tracks
239 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
240 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
242 // Match tracker/trigger tracks
243 if ( fTrackHitPatternMaker )
245 fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
249 FillESD(*trackStore,esd);
257 //_____________________________________________________________________________
258 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
260 /// Fill the ESD from the trackStore
265 Double_t vertex[3] = {0., 0., 0.};
266 const AliESDVertex* esdVert = esd->GetVertex();
267 if (esdVert->GetNContributors()) {
268 esdVert->GetXYZ(vertex);
269 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
272 // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
274 AliMUONLocalTrigger* locTrg;
275 AliESDMuonTrack esdTrack;
276 TIter next(trackStore.CreateIterator());
277 if (GetRecoParam()->SaveFullClusterInESD() &&
278 gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
280 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
282 if (track->GetMatchTrigger() > 0) {
283 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
284 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore, locTrg);
285 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fDigitStore);
287 esd->AddMuonTrack(&esdTrack);
292 while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) {
294 if (track->GetMatchTrigger() > 0) {
295 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
296 AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
297 } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
299 esd->AddMuonTrack(&esdTrack);
304 // fill the local trigger decisions not matched with tracks (associate them to "ghost" tracks)
305 UInt_t ghostId = 0xFFFFFFFF - 1;
306 Bool_t matched = kFALSE;
307 AliMUONTriggerTrack *triggerTrack;
308 TIter itTriggerTrack(fTriggerTrackStore->CreateIterator());
309 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack()) ) ) {
311 locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(triggerTrack->GetLoTrgNum()));
313 // check if this local trigger has already been matched
314 TIter itTrack(trackStore.CreateIterator());
315 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) {
316 matched = (track->LoCircuit() == locTrg->LoCircuit());
319 if (matched) continue;
321 AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId);
323 esd->AddMuonTrack(&esdTrack);
329 //_____________________________________________________________________________
330 AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
332 /// Create track reconstructor, depending on tracking mode set in RecoParam
334 AliMUONVTrackReconstructor* trackReco(0x0);
336 TString opt(recoParam->GetTrackingMode());
339 if (strstr(opt,"ORIGINAL"))
341 trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
343 else if (strstr(opt,"KALMAN"))
345 trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
349 AliErrorClass(Form("tracking mode \"%s\" does not exist",opt.Data()));
353 AliInfoClass(Form("Will use %s for tracking",trackReco->ClassName()));
358 //_____________________________________________________________________________
359 void AliMUONTracker::UnloadClusters()
361 /// Clear internal clusterStore
363 delete fInputClusterStore;
364 fInputClusterStore = 0x0;
368 //_____________________________________________________________________________
370 AliMUONTracker::SetupClusterServer(AliMUONVClusterServer& clusterServer)
372 /// Setup the cluster server
374 if ( GetRecoParam()->BypassSt4() ||
375 GetRecoParam()->BypassSt5() )
377 Bool_t ok = clusterServer.UseTriggerTrackStore(TriggerTrackStore());
382 if ( GetRecoParam()->BypassSt45() )
384 msg1 = "STATIONS 4 AND 5";
385 msg2 = "THOSE TWO STATIONS";
387 else if ( GetRecoParam()->BypassSt4() )
390 msg2 = "THAT STATION";
392 else if ( GetRecoParam()->BypassSt5() )
395 msg2 = "THAT STATION";
400 AliWarning(Form("WILL USE TRIGGER TRACKS TO GENERATE CLUSTERS IN %s, "
401 "THUS BYPASSING REAL CLUSTERS IN %s!!!",msg1.Data(),msg2.Data()));
405 AliWarning("BYPASSING OF ST4 AND/OR 5 REQUESTED, BUT CLUSTERSERVER DOES NOT SEEM TO SUPPORT IT !!!");