Introduction of the new SSD geometry in simulation (AliITSv11Hybrid) and suppression...
[u/mrichter/AliRoot.git] / MUON / AliMUONTracker.cxx
CommitLineData
196471e9 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
27bf410b 16/// \class AliMUONTracker
e64fdf8a 17///
18/// Steering class for use in global tracking framework;
27bf410b 19/// reconstruct tracks from recpoints
20///
e64fdf8a 21/// Actual tracking is performed by some AliMUONVTrackReconstructor children
22///
23/// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
196471e9 24
25#include "AliMUONTracker.h"
e64fdf8a 26
27#include "AliESD.h"
28#include "AliESDMuonTrack.h"
29#include "AliESDVertex.h"
30#include "AliLoader.h"
31#include "AliMUONTrack.h"
32#include "AliMUONTrackExtrap.h"
33#include "AliMUONTrackHitPattern.h"
34#include "AliMUONTrackParam.h"
196471e9 35#include "AliMUONTrackReconstructor.h"
e64fdf8a 36#include "AliMUONTrackReconstructorK.h"
37#include "AliMUONTrackStoreV1.h"
38#include "AliMUONTriggerTrackStoreV1.h"
39#include "AliMUONVClusterStore.h"
40#include "AliMUONVTriggerStore.h"
41#include <Riostream.h>
42#include <TTree.h>
196471e9 43#include "AliLog.h"
44
45//_____________________________________________________________________________
e64fdf8a 46AliMUONTracker::AliMUONTracker(AliLoader* loader,
47 const AliMUONDigitMaker* digitMaker,
48 const AliMUONGeometryTransformer* transformer,
32ab62c9 49 const AliMUONTriggerCircuit* triggerCircuit)
e64fdf8a 50: AliTracker(),
51 fLoader(loader),
52 fDigitMaker(digitMaker), // not owner
53 fTransformer(transformer), // not owner
54 fTriggerCircuit(triggerCircuit), // not owner
55 fTrackHitPatternMaker(0x0),
56 fTrackReco(0x0),
57 fClusterStore(0x0),
58 fTriggerStore(0x0)
196471e9 59{
60 /// constructor
e64fdf8a 61 if (fTransformer && fDigitMaker)
62 {
63 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
64 }
196471e9 65}
e64fdf8a 66
196471e9 67//_____________________________________________________________________________
68AliMUONTracker::~AliMUONTracker()
69{
e64fdf8a 70 /// dtor
196471e9 71 delete fTrackReco;
e64fdf8a 72 delete fTrackHitPatternMaker;
73 delete fClusterStore;
74 delete fTriggerStore;
196471e9 75}
76
77//_____________________________________________________________________________
e64fdf8a 78Int_t
79AliMUONTracker::LoadClusters(TTree* clustersTree)
196471e9 80{
e64fdf8a 81 /// Load clusterStore and triggerStore from clustersTree
82 delete fClusterStore;
83 delete fTriggerStore;
196471e9 84
e64fdf8a 85 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
86 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
87
88 if (!fClusterStore)
89 {
90 AliError("Could not get clusterStore");
91 return 1;
92 }
93 if (!fTriggerStore)
94 {
95 AliError("Could not get triggerStore");
96 return 2;
97 }
98
99 fClusterStore->Connect(*clustersTree,kFALSE);
100 fTriggerStore->Connect(*clustersTree,kFALSE);
101
102 clustersTree->GetEvent(0);
196471e9 103
e64fdf8a 104 return 0;
105}
196471e9 106
e64fdf8a 107//_____________________________________________________________________________
108Int_t
109AliMUONTracker::Clusters2Tracks(AliESD* esd)
110{
111 /// Performs the tracking and store the resulting tracks in both
112 /// the TreeT and the ESD
113
114 Int_t rv(0);
115
116 TTree* tracksTree = fLoader->TreeT();
117
118 if (!tracksTree)
119 {
120 AliError("Cannot get TreeT");
121 rv=1;
122 }
123 if (!fClusterStore)
124 {
125 AliError("ClusterStore is NULL");
126 rv=2;
127 }
128 if (!fTriggerStore)
129 {
130 AliError("TriggerStore is NULL");
131 rv=3;
132 }
133 if (!rv)
134 {
135 rv = Clusters2Tracks(*tracksTree,esd);
136 }
137 return rv;
138}
196471e9 139
e64fdf8a 140//_____________________________________________________________________________
141Int_t AliMUONTracker::Clusters2Tracks(TTree& tracksTree, AliESD* esd)
142{
143 /// Performs the tracking
144
145 AliDebug(1,"");
146
147 AliMUONVTrackStore* trackStore(0x0);
148 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
149
150 // Make tracker tracks
151 if ( fClusterStore )
152 {
153 trackStore = new AliMUONTrackStoreV1;
154 Bool_t alone = ( ( fTriggerStore && fTriggerCircuit ) ? kFALSE : kTRUE );
155 trackStore->Connect(tracksTree,alone);
156 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
157 }
158
159 if ( fTriggerStore && fTriggerCircuit )
160 {
161 // Make trigger tracks
162 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
163 Bool_t alone = ( fClusterStore ? kFALSE : kTRUE );
164 triggerTrackStore->Connect(tracksTree,alone);
165 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
166 }
167
168 if ( trackStore && triggerTrackStore && fTriggerStore && fTrackHitPatternMaker )
169 {
170 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
171 }
172
173 // Fills output TreeT
174 tracksTree.Fill();
175
176 FillESD(*trackStore,esd);
177
178 // cleanup
179 delete trackStore;
180 delete triggerTrackStore;
181
182 return 0;
183}
196471e9 184
e64fdf8a 185//_____________________________________________________________________________
186void
187AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESD* esd) const
188{
189 /// Fill the ESD from the trackStore
190
191 AliDebug(1,"");
192
193 // Get vertex
194 Double_t vertex[3] = {0};
195 const AliESDVertex* esdVert = esd->GetVertex();
196 if (esdVert->GetNContributors())
197 {
198 esdVert->GetXYZ(vertex);
199 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
200 }
201
202 // setting ESD MUON class
203 AliESDMuonTrack esdTrack;
204
205 AliMUONTrack* track;
206 TIter next(trackStore.CreateIterator());
207
208 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
209 {
210 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtHit())->First());
211 AliMUONTrackParam trackParamAtVtx(*trackParam);
212
213 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
214 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2]);
215
216 // setting data member of ESD MUON
217
218 // at first station
219 esdTrack.SetInverseBendingMomentumUncorrected(trackParam->GetInverseBendingMomentum());
220 esdTrack.SetThetaXUncorrected(TMath::ATan(trackParam->GetNonBendingSlope()));
221 esdTrack.SetThetaYUncorrected(TMath::ATan(trackParam->GetBendingSlope()));
222 esdTrack.SetZUncorrected(trackParam->GetZ());
223 esdTrack.SetBendingCoorUncorrected(trackParam->GetBendingCoor());
224 esdTrack.SetNonBendingCoorUncorrected(trackParam->GetNonBendingCoor());
225 // at vertex
226 esdTrack.SetInverseBendingMomentum(trackParamAtVtx.GetInverseBendingMomentum());
227 esdTrack.SetThetaX(TMath::ATan(trackParamAtVtx.GetNonBendingSlope()));
228 esdTrack.SetThetaY(TMath::ATan(trackParamAtVtx.GetBendingSlope()));
229 esdTrack.SetZ(trackParamAtVtx.GetZ());
230 esdTrack.SetBendingCoor(trackParamAtVtx.GetBendingCoor());
231 esdTrack.SetNonBendingCoor(trackParamAtVtx.GetNonBendingCoor());
232 // global info
233 esdTrack.SetChi2(track->GetFitFMin());
234 esdTrack.SetNHit(track->GetNTrackHits());
235 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
236 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
237 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
238
239 // storing ESD MUON Track into ESD Event
240 esd->AddMuonTrack(&esdTrack);
241 } // end of loop on tracks
196471e9 242}
243
244//_____________________________________________________________________________
e64fdf8a 245void AliMUONTracker::SetOption(Option_t* option)
196471e9 246{
e64fdf8a 247 /// set reconstructor class
248
249 if (strstr(option,"Original"))
250 {
251 fTrackReco = new AliMUONTrackReconstructor;
252 }
253 else if (strstr(option,"Combi"))
254 {
255 fTrackReco = new AliMUONTrackReconstructorK("Combi");
256 }
257 else
258 {
259 fTrackReco = new AliMUONTrackReconstructorK("Kalman");
260 }
261}
196471e9 262
e64fdf8a 263//_____________________________________________________________________________
264void
265AliMUONTracker::UnloadClusters()
266{
267 /// Delete internal clusterStore
268 delete fClusterStore;
269 fClusterStore = 0x0;
196471e9 270}
e64fdf8a 271