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 "AliMUONReconstructor.h"
37 #include "AliMUONRecoParam.h"
38 #include "AliMUONTrack.h"
39 #include "AliMUONTrackExtrap.h"
40 #include "AliMUONTrackHitPattern.h"
41 #include "AliMUONTrackParam.h"
42 #include "AliMUONVCluster.h"
43 #include "AliMUONTrackReconstructor.h"
44 #include "AliMUONTrackReconstructorK.h"
45 #include "AliMUONTrackStoreV1.h"
46 #include "AliMUONTriggerChamberEff.h"
47 #include "AliMUONTriggerTrackStoreV1.h"
48 #include "AliMUONVClusterStore.h"
49 #include "AliMUONVTriggerStore.h"
51 #include "AliESDEvent.h"
52 #include "AliESDMuonTrack.h"
53 #include "AliESDVertex.h"
55 #include "AliCodeTimer.h"
57 #include <Riostream.h>
61 ClassImp(AliMUONTracker)
65 //_____________________________________________________________________________
66 AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
67 const AliMUONGeometryTransformer* transformer,
68 const AliMUONTriggerCircuit* triggerCircuit,
69 AliMUONTriggerChamberEff* chamberEff)
71 fDigitMaker(digitMaker), // not owner
72 fTransformer(transformer), // not owner
73 fTriggerCircuit(triggerCircuit), // not owner
74 fTrigChamberEff(chamberEff), // not owner
75 fTrackHitPatternMaker(0x0),
81 if (fTransformer && fDigitMaker)
82 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
85 //_____________________________________________________________________________
86 AliMUONTracker::~AliMUONTracker()
90 delete fTrackHitPatternMaker;
95 //_____________________________________________________________________________
96 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
98 /// Load clusterStore and triggerStore from clustersTree
100 delete fTriggerStore;
102 if ( ! clustersTree ) {
103 AliFatal("No clustersTree");
107 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
108 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
112 AliError("Could not get clusterStore");
117 AliError("Could not get triggerStore");
121 fClusterStore->Connect(*clustersTree,kFALSE);
122 fTriggerStore->Connect(*clustersTree,kFALSE);
124 clustersTree->GetEvent(0);
129 //_____________________________________________________________________________
130 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
132 /// Performs the tracking and store the resulting tracks in the ESD
136 if (!fTrackReco) CreateTrackReconstructor();
138 // if the required tracking mode does not exist
139 if (!fTrackReco) return 1;
141 if (!fClusterStore) {
142 AliError("ClusterStore is NULL");
146 if (!fTriggerStore) {
147 AliError("TriggerStore is NULL");
151 // Make tracker tracks
152 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
153 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
155 // Make trigger tracks
156 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
157 if ( fTriggerCircuit ) {
158 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
159 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
162 // Match tracker/trigger tracks
163 if ( triggerTrackStore && fTrackHitPatternMaker ) {
164 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
167 // Compute trigger chamber efficiency
168 if( triggerTrackStore && fTrigChamberEff){
169 AliCodeTimerStart("EventChamberEff");
170 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
171 AliCodeTimerStop("EventChamberEff");
175 FillESD(*trackStore,esd);
179 delete triggerTrackStore;
184 //_____________________________________________________________________________
185 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
187 /// Fill the ESD from the trackStore
192 Double_t vertex[3] = {0};
193 Double_t errXVtx = 0., errYVtx = 0.;
194 const AliESDVertex* esdVert = esd->GetVertex();
195 if (esdVert->GetNContributors())
197 esdVert->GetXYZ(vertex);
198 errXVtx = esdVert->GetXRes();
199 errYVtx = esdVert->GetYRes();
200 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
203 // setting ESD MUON class
204 AliESDMuonTrack esdTrack;
207 TIter next(trackStore.CreateIterator());
209 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
211 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
212 AliMUONTrackParam trackParamAtVtx(*trackParam);
214 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
215 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2],errXVtx,errYVtx);
217 // setting data member of ESD MUON
220 trackParam->SetParamForUncorrected(esdTrack);
221 trackParam->SetCovFor(esdTrack);
223 trackParamAtVtx.SetParamFor(esdTrack);
225 esdTrack.SetChi2(track->GetGlobalChi2());
226 esdTrack.SetNHit(track->GetNClusters());
227 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
228 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
229 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
232 esdTrack.AddInMuonClusterMap(trackParam->GetClusterPtr()->GetChamberId());
233 trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
236 // storing ESD MUON Track into ESD Event
237 esd->AddMuonTrack(&esdTrack);
238 } // end of loop on tracks
241 //_____________________________________________________________________________
242 void AliMUONTracker::CreateTrackReconstructor()
244 /// Create track reconstructor, depending on tracking mode set in RecoParam
246 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
249 if (strstr(opt,"ORIGINAL"))
251 fTrackReco = new AliMUONTrackReconstructor();
253 else if (strstr(opt,"KALMAN"))
255 fTrackReco = new AliMUONTrackReconstructorK();
259 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
263 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
266 //_____________________________________________________________________________
267 void AliMUONTracker::UnloadClusters()
269 /// Delete internal clusterStore
270 delete fClusterStore;