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
26 /// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
27 //-----------------------------------------------------------------------------
29 #include "AliMUONTracker.h"
31 #include "AliMUONReconstructor.h"
32 #include "AliMUONRecoParam.h"
33 #include "AliMUONTrack.h"
34 #include "AliMUONTrackExtrap.h"
35 #include "AliMUONTrackHitPattern.h"
36 #include "AliMUONTrackParam.h"
37 #include "AliMUONHitForRec.h"
38 #include "AliMUONTrackReconstructor.h"
39 #include "AliMUONTrackReconstructorK.h"
40 #include "AliMUONTrackStoreV1.h"
41 #include "AliMUONTriggerChamberEff.h"
42 #include "AliMUONTriggerTrackStoreV1.h"
43 #include "AliMUONVClusterStore.h"
44 #include "AliMUONVTriggerStore.h"
46 #include "AliESDEvent.h"
47 #include "AliESDMuonTrack.h"
48 #include "AliESDVertex.h"
50 #include "AliCodeTimer.h"
52 #include <Riostream.h>
56 ClassImp(AliMUONTracker)
60 //_____________________________________________________________________________
61 AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
62 const AliMUONGeometryTransformer* transformer,
63 const AliMUONTriggerCircuit* triggerCircuit,
64 AliMUONTriggerChamberEff* chamberEff)
66 fDigitMaker(digitMaker), // not owner
67 fTransformer(transformer), // not owner
68 fTriggerCircuit(triggerCircuit), // not owner
69 fTrigChamberEff(chamberEff), // not owner
70 fTrackHitPatternMaker(0x0),
76 if (fTransformer && fDigitMaker)
77 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
80 //_____________________________________________________________________________
81 AliMUONTracker::~AliMUONTracker()
85 delete fTrackHitPatternMaker;
90 //_____________________________________________________________________________
91 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
93 /// Load clusterStore and triggerStore from clustersTree
97 if ( ! clustersTree ) {
98 AliFatal("No clustersTree");
102 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
103 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
107 AliError("Could not get clusterStore");
112 AliError("Could not get triggerStore");
116 fClusterStore->Connect(*clustersTree,kFALSE);
117 fTriggerStore->Connect(*clustersTree,kFALSE);
119 clustersTree->GetEvent(0);
124 //_____________________________________________________________________________
125 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
127 /// Performs the tracking and store the resulting tracks in the ESD
131 if (!fTrackReco) CreateTrackReconstructor();
133 // if the required tracking mode does not exist
134 if (!fTrackReco) return 1;
136 if (!fClusterStore) {
137 AliError("ClusterStore is NULL");
141 if (!fTriggerStore) {
142 AliError("TriggerStore is NULL");
146 // Make tracker tracks
147 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
148 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
150 // Make trigger tracks
151 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
152 if ( fTriggerCircuit ) {
153 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
154 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
157 // Match tracker/trigger tracks
158 if ( triggerTrackStore && fTrackHitPatternMaker ) {
159 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
162 // Compute trigger chamber efficiency
163 if( triggerTrackStore && fTrigChamberEff){
164 AliCodeTimerStart("EventChamberEff");
165 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
166 AliCodeTimerStop("EventChamberEff");
170 FillESD(*trackStore,esd);
174 delete triggerTrackStore;
179 //_____________________________________________________________________________
180 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
182 /// Fill the ESD from the trackStore
187 Double_t vertex[3] = {0};
188 const AliESDVertex* esdVert = esd->GetVertex();
189 if (esdVert->GetNContributors())
191 esdVert->GetXYZ(vertex);
192 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
195 // setting ESD MUON class
196 AliESDMuonTrack esdTrack;
199 TIter next(trackStore.CreateIterator());
201 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
203 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtHit())->First());
204 AliMUONTrackParam trackParamAtVtx(*trackParam);
206 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
207 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2]);
209 // setting data member of ESD MUON
212 trackParam->SetParamForUncorrected(esdTrack);
213 trackParam->SetCovFor(esdTrack);
215 trackParamAtVtx.SetParamFor(esdTrack);
217 esdTrack.SetChi2(track->GetFitFMin());
218 esdTrack.SetNHit(track->GetNTrackHits());
219 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
220 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
221 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
223 AliMUONHitForRec* cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->First());
225 esdTrack.AddInMuonClusterMap(cluster->GetChamberNumber());
226 cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->After(cluster));
229 // storing ESD MUON Track into ESD Event
230 esd->AddMuonTrack(&esdTrack);
231 } // end of loop on tracks
234 //_____________________________________________________________________________
235 void AliMUONTracker::CreateTrackReconstructor()
237 /// Create track reconstructor, depending on tracking mode set in RecoParam
239 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
242 if (strstr(opt,"ORIGINAL"))
244 fTrackReco = new AliMUONTrackReconstructor();
246 else if (strstr(opt,"KALMAN"))
248 fTrackReco = new AliMUONTrackReconstructorK();
252 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
256 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
259 //_____________________________________________________________________________
260 void AliMUONTracker::UnloadClusters()
262 /// Delete internal clusterStore
263 delete fClusterStore;