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 "AliESDMuonCluster.h"
54 #include "AliESDVertex.h"
56 #include "AliCodeTimer.h"
58 #include <Riostream.h>
62 ClassImp(AliMUONTracker)
66 //_____________________________________________________________________________
67 AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
68 const AliMUONGeometryTransformer* transformer,
69 const AliMUONTriggerCircuit* triggerCircuit,
70 AliMUONTriggerChamberEff* chamberEff)
72 fDigitMaker(digitMaker), // not owner
73 fTransformer(transformer), // not owner
74 fTriggerCircuit(triggerCircuit), // not owner
75 fTrigChamberEff(chamberEff), // not owner
76 fTrackHitPatternMaker(0x0),
82 if (fTransformer && fDigitMaker)
83 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
86 //_____________________________________________________________________________
87 AliMUONTracker::~AliMUONTracker()
91 delete fTrackHitPatternMaker;
96 //_____________________________________________________________________________
97 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
99 /// Load clusterStore and triggerStore from clustersTree
100 delete fClusterStore;
101 delete fTriggerStore;
103 if ( ! clustersTree ) {
104 AliFatal("No clustersTree");
108 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
109 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
113 AliError("Could not get clusterStore");
118 AliError("Could not get triggerStore");
122 fClusterStore->Connect(*clustersTree,kFALSE);
123 fTriggerStore->Connect(*clustersTree,kFALSE);
125 clustersTree->GetEvent(0);
130 //_____________________________________________________________________________
131 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
133 /// Performs the tracking and store the resulting tracks in the ESD
137 if (!fTrackReco) CreateTrackReconstructor();
139 // if the required tracking mode does not exist
140 if (!fTrackReco) return 1;
142 if (!fClusterStore) {
143 AliError("ClusterStore is NULL");
147 if (!fTriggerStore) {
148 AliError("TriggerStore is NULL");
152 // Make tracker tracks
153 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
154 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
156 // Make trigger tracks
157 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
158 if ( fTriggerCircuit ) {
159 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
160 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
163 // Match tracker/trigger tracks
164 if ( triggerTrackStore && fTrackHitPatternMaker ) {
165 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
168 // Compute trigger chamber efficiency
169 if( triggerTrackStore && fTrigChamberEff){
170 AliCodeTimerStart("EventChamberEff");
171 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
172 AliCodeTimerStop("EventChamberEff");
176 FillESD(*trackStore,esd);
180 delete triggerTrackStore;
185 //_____________________________________________________________________________
186 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
188 /// Fill the ESD from the trackStore
193 Double_t vertex[3] = {0};
194 Double_t errXVtx = 0., errYVtx = 0.;
195 const AliESDVertex* esdVert = esd->GetVertex();
196 if (esdVert->GetNContributors())
198 esdVert->GetXYZ(vertex);
199 errXVtx = esdVert->GetXRes();
200 errYVtx = esdVert->GetYRes();
201 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
204 // setting ESD MUON class
205 AliESDMuonTrack esdTrack;
206 AliESDMuonCluster esdCluster;
209 AliMUONVCluster* cluster;
210 TIter next(trackStore.CreateIterator());
212 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
214 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
216 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
217 AliMUONTrackParam trackParamAtVtx(*trackParam);
218 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], errXVtx, errYVtx);
220 /// Extrapolate to vertex plan (which is set to z=0 if not available, see above)
221 AliMUONTrackParam trackParamAtDCA(*trackParam);
222 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&trackParamAtDCA, vertex[2]);
224 // setting data member of ESD MUON
225 esdTrack.Clear("C"); // remove already attached clusters
226 esdTrack.SetMuonClusterMap(0); // important to use the Add..() methods
229 trackParam->SetParamForUncorrected(esdTrack);
230 trackParam->SetCovFor(esdTrack);
232 trackParamAtVtx.SetParamFor(esdTrack);
233 // at Distance of Closest Approach
234 trackParamAtDCA.SetParamForDCA(esdTrack);
236 esdTrack.SetChi2(track->GetGlobalChi2());
237 esdTrack.SetNHit(track->GetNClusters());
238 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
239 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
240 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
243 cluster = trackParam->GetClusterPtr();
244 esdCluster.SetUniqueID(cluster->GetUniqueID());
245 esdCluster.SetXYZ(cluster->GetX(), cluster->GetY(), cluster->GetZ());
246 esdCluster.SetErrXY(cluster->GetErrX(), cluster->GetErrY());
247 esdTrack.AddCluster(esdCluster);
248 esdTrack.AddInMuonClusterMap(cluster->GetChamberId());
249 trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
252 // storing ESD MUON Track into ESD Event
253 esd->AddMuonTrack(&esdTrack);
254 } // end of loop on tracks
257 //_____________________________________________________________________________
258 void AliMUONTracker::CreateTrackReconstructor()
260 /// Create track reconstructor, depending on tracking mode set in RecoParam
262 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
265 if (strstr(opt,"ORIGINAL"))
267 fTrackReco = new AliMUONTrackReconstructor();
269 else if (strstr(opt,"KALMAN"))
271 fTrackReco = new AliMUONTrackReconstructorK();
275 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
279 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
282 //_____________________________________________________________________________
283 void AliMUONTracker::UnloadClusters()
285 /// Delete internal clusterStore
286 delete fClusterStore;