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 "AliMUONVClusterServer.h"
44 #include "AliMUONTrackReconstructor.h"
45 #include "AliMUONTrackReconstructorK.h"
46 #include "AliMUONTrackStoreV1.h"
47 #include "AliMUONTriggerChamberEff.h"
48 #include "AliMUONTriggerTrackStoreV1.h"
49 #include "AliMUONClusterStoreV2.h"
50 #include "AliMUONVTriggerStore.h"
52 #include "AliESDEvent.h"
53 #include "AliESDMuonTrack.h"
54 #include "AliESDMuonCluster.h"
55 #include "AliESDVertex.h"
57 #include "AliCodeTimer.h"
59 #include <Riostream.h>
63 ClassImp(AliMUONTracker)
67 //_____________________________________________________________________________
68 AliMUONTracker::AliMUONTracker(AliMUONVClusterServer& clusterServer,
69 const AliMUONDigitMaker* digitMaker,
70 const AliMUONGeometryTransformer* transformer,
71 const AliMUONTriggerCircuit* triggerCircuit,
72 AliMUONTriggerChamberEff* chamberEff)
74 fDigitMaker(digitMaker), // not owner
75 fTransformer(transformer), // not owner
76 fTriggerCircuit(triggerCircuit), // not owner
77 fTrigChamberEff(chamberEff), // not owner
78 fTrackHitPatternMaker(0x0),
82 fClusterServer(clusterServer)
85 if (fTransformer && fDigitMaker)
86 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
89 //_____________________________________________________________________________
90 AliMUONTracker::~AliMUONTracker()
94 delete fTrackHitPatternMaker;
99 //_____________________________________________________________________________
100 AliMUONVClusterStore*
101 AliMUONTracker::ClusterStore() const
103 /// Return (and create if necessary) the cluster container
106 fClusterStore = new AliMUONClusterStoreV2;
108 return fClusterStore;
111 //_____________________________________________________________________________
112 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
114 /// Load triggerStore from clustersTree
116 ClusterStore()->Clear();
118 delete fTriggerStore;
120 if ( ! clustersTree ) {
121 AliFatal("No clustersTree");
125 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
129 AliError("Could not get triggerStore");
133 ClusterStore()->Connect(*clustersTree,kFALSE);
134 fTriggerStore->Connect(*clustersTree,kFALSE);
136 clustersTree->GetEvent(0);
141 //_____________________________________________________________________________
142 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
144 /// Performs the tracking and store the resulting tracks in the ESD
148 if (!fTrackReco) CreateTrackReconstructor();
150 // if the required tracking mode does not exist
151 if (!fTrackReco) return 1;
153 if ( ! ClusterStore() )
155 AliError("ClusterStore is NULL");
159 if (!fTriggerStore) {
160 AliError("TriggerStore is NULL");
164 // Make tracker tracks
165 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
166 fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
168 // Make trigger tracks
169 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
170 if ( fTriggerCircuit ) {
171 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
172 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
175 // Match tracker/trigger tracks
176 if ( triggerTrackStore && fTrackHitPatternMaker ) {
177 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
180 // Compute trigger chamber efficiency
181 if( triggerTrackStore && fTrigChamberEff){
182 AliCodeTimerStart("EventChamberEff");
183 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
184 AliCodeTimerStop("EventChamberEff");
188 FillESD(*trackStore,esd);
192 delete triggerTrackStore;
197 //_____________________________________________________________________________
198 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
200 /// Fill the ESD from the trackStore
205 Double_t vertex[3] = {0};
206 Double_t errXVtx = 0., errYVtx = 0.;
207 const AliESDVertex* esdVert = esd->GetVertex();
208 if (esdVert->GetNContributors())
210 esdVert->GetXYZ(vertex);
211 errXVtx = esdVert->GetXRes();
212 errYVtx = esdVert->GetYRes();
213 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
216 // setting ESD MUON class
217 AliESDMuonTrack esdTrack;
218 AliESDMuonCluster esdCluster;
221 AliMUONVCluster* cluster;
222 TIter next(trackStore.CreateIterator());
224 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
226 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
228 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
229 AliMUONTrackParam trackParamAtVtx(*trackParam);
230 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], errXVtx, errYVtx);
232 /// Extrapolate to vertex plan (which is set to z=0 if not available, see above)
233 AliMUONTrackParam trackParamAtDCA(*trackParam);
234 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&trackParamAtDCA, vertex[2]);
236 // setting data member of ESD MUON
237 esdTrack.Clear("C"); // remove already attached clusters
238 esdTrack.SetMuonClusterMap(0); // important to use the Add..() methods
241 trackParam->SetParamForUncorrected(esdTrack);
242 trackParam->SetCovFor(esdTrack);
244 trackParamAtVtx.SetParamFor(esdTrack);
245 // at Distance of Closest Approach
246 trackParamAtDCA.SetParamForDCA(esdTrack);
248 esdTrack.SetChi2(track->GetGlobalChi2());
249 esdTrack.SetNHit(track->GetNClusters());
250 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
251 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
252 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
255 cluster = trackParam->GetClusterPtr();
256 esdCluster.SetUniqueID(cluster->GetUniqueID());
257 esdCluster.SetXYZ(cluster->GetX(), cluster->GetY(), cluster->GetZ());
258 esdCluster.SetErrXY(cluster->GetErrX(), cluster->GetErrY());
259 esdTrack.AddCluster(esdCluster);
260 esdTrack.AddInMuonClusterMap(cluster->GetChamberId());
261 trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
264 // storing ESD MUON Track into ESD Event
265 esd->AddMuonTrack(&esdTrack);
266 } // end of loop on tracks
269 //_____________________________________________________________________________
270 void AliMUONTracker::CreateTrackReconstructor()
272 /// Create track reconstructor, depending on tracking mode set in RecoParam
274 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
277 if (strstr(opt,"ORIGINAL"))
279 fTrackReco = new AliMUONTrackReconstructor(fClusterServer);
281 else if (strstr(opt,"KALMAN"))
283 fTrackReco = new AliMUONTrackReconstructorK(fClusterServer);
287 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
291 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
294 //_____________________________________________________________________________
295 void AliMUONTracker::UnloadClusters()
297 /// Clear internal clusterStore
299 ClusterStore()->Clear();