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 | |
ea94c18b |
16 | /* $Id$ */ |
17 | |
ee8a8d65 |
18 | //----------------------------------------------------------------------------- |
27bf410b |
19 | /// \class AliMUONTracker |
e64fdf8a |
20 | /// |
21 | /// Steering class for use in global tracking framework; |
27bf410b |
22 | /// reconstruct tracks from recpoints |
23 | /// |
e64fdf8a |
24 | /// Actual tracking is performed by some AliMUONVTrackReconstructor children |
96ebe67e |
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); |
e64fdf8a |
30 | /// |
31 | /// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes |
ee8a8d65 |
32 | //----------------------------------------------------------------------------- |
196471e9 |
33 | |
34 | #include "AliMUONTracker.h" |
e64fdf8a |
35 | |
3304fa09 |
36 | #include "AliMUONReconstructor.h" |
37 | #include "AliMUONRecoParam.h" |
e64fdf8a |
38 | #include "AliMUONTrack.h" |
39 | #include "AliMUONTrackExtrap.h" |
40 | #include "AliMUONTrackHitPattern.h" |
41 | #include "AliMUONTrackParam.h" |
96ebe67e |
42 | #include "AliMUONVCluster.h" |
1fef78c8 |
43 | #include "AliMUONVClusterServer.h" |
196471e9 |
44 | #include "AliMUONTrackReconstructor.h" |
e64fdf8a |
45 | #include "AliMUONTrackReconstructorK.h" |
46 | #include "AliMUONTrackStoreV1.h" |
47 | #include "AliMUONTriggerTrackStoreV1.h" |
1fef78c8 |
48 | #include "AliMUONClusterStoreV2.h" |
e64fdf8a |
49 | #include "AliMUONVTriggerStore.h" |
ea94c18b |
50 | |
af885e0f |
51 | #include "AliESDEvent.h" |
ea94c18b |
52 | #include "AliESDMuonTrack.h" |
61fed964 |
53 | #include "AliESDMuonCluster.h" |
ea94c18b |
54 | #include "AliESDVertex.h" |
ea94c18b |
55 | #include "AliLog.h" |
2060b217 |
56 | #include "AliCodeTimer.h" |
ea94c18b |
57 | |
e64fdf8a |
58 | #include <Riostream.h> |
59 | #include <TTree.h> |
196471e9 |
60 | |
ee8a8d65 |
61 | /// \cond CLASSIMP |
62 | ClassImp(AliMUONTracker) |
63 | /// \endcond |
64 | |
65 | |
196471e9 |
66 | //_____________________________________________________________________________ |
1fef78c8 |
67 | AliMUONTracker::AliMUONTracker(AliMUONVClusterServer& clusterServer, |
68 | const AliMUONDigitMaker* digitMaker, |
e64fdf8a |
69 | const AliMUONGeometryTransformer* transformer, |
683cb6c5 |
70 | const AliMUONTriggerCircuit* triggerCircuit) |
e64fdf8a |
71 | : AliTracker(), |
e64fdf8a |
72 | fDigitMaker(digitMaker), // not owner |
73 | fTransformer(transformer), // not owner |
74 | fTriggerCircuit(triggerCircuit), // not owner |
75 | fTrackHitPatternMaker(0x0), |
76 | fTrackReco(0x0), |
77 | fClusterStore(0x0), |
1fef78c8 |
78 | fTriggerStore(0x0), |
79 | fClusterServer(clusterServer) |
196471e9 |
80 | { |
81 | /// constructor |
e64fdf8a |
82 | if (fTransformer && fDigitMaker) |
e64fdf8a |
83 | fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker); |
196471e9 |
84 | } |
e64fdf8a |
85 | |
196471e9 |
86 | //_____________________________________________________________________________ |
87 | AliMUONTracker::~AliMUONTracker() |
88 | { |
e64fdf8a |
89 | /// dtor |
196471e9 |
90 | delete fTrackReco; |
e64fdf8a |
91 | delete fTrackHitPatternMaker; |
92 | delete fClusterStore; |
93 | delete fTriggerStore; |
196471e9 |
94 | } |
95 | |
1fef78c8 |
96 | //_____________________________________________________________________________ |
97 | AliMUONVClusterStore* |
98 | AliMUONTracker::ClusterStore() const |
99 | { |
100 | /// Return (and create if necessary) the cluster container |
101 | if (!fClusterStore) |
102 | { |
103 | fClusterStore = new AliMUONClusterStoreV2; |
104 | } |
105 | return fClusterStore; |
106 | } |
107 | |
196471e9 |
108 | //_____________________________________________________________________________ |
3304fa09 |
109 | Int_t AliMUONTracker::LoadClusters(TTree* clustersTree) |
196471e9 |
110 | { |
1fef78c8 |
111 | /// Load triggerStore from clustersTree |
112 | |
113 | ClusterStore()->Clear(); |
114 | |
e64fdf8a |
115 | delete fTriggerStore; |
196471e9 |
116 | |
6cfc11c3 |
117 | if ( ! clustersTree ) { |
118 | AliFatal("No clustersTree"); |
119 | return 1; |
120 | } |
121 | |
e64fdf8a |
122 | fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree); |
123 | |
e64fdf8a |
124 | if (!fTriggerStore) |
125 | { |
126 | AliError("Could not get triggerStore"); |
127 | return 2; |
128 | } |
129 | |
1fef78c8 |
130 | ClusterStore()->Connect(*clustersTree,kFALSE); |
e64fdf8a |
131 | fTriggerStore->Connect(*clustersTree,kFALSE); |
132 | |
133 | clustersTree->GetEvent(0); |
196471e9 |
134 | |
e64fdf8a |
135 | return 0; |
136 | } |
196471e9 |
137 | |
e64fdf8a |
138 | //_____________________________________________________________________________ |
3304fa09 |
139 | Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd) |
e64fdf8a |
140 | { |
3304fa09 |
141 | /// Performs the tracking and store the resulting tracks in the ESD |
142 | AliDebug(1,""); |
143 | AliCodeTimerAuto("") |
e64fdf8a |
144 | |
3304fa09 |
145 | if (!fTrackReco) CreateTrackReconstructor(); |
146 | |
147 | // if the required tracking mode does not exist |
148 | if (!fTrackReco) return 1; |
149 | |
1fef78c8 |
150 | if ( ! ClusterStore() ) |
151 | { |
e64fdf8a |
152 | AliError("ClusterStore is NULL"); |
6cfc11c3 |
153 | return 2; |
e64fdf8a |
154 | } |
6cfc11c3 |
155 | |
3304fa09 |
156 | if (!fTriggerStore) { |
e64fdf8a |
157 | AliError("TriggerStore is NULL"); |
6cfc11c3 |
158 | return 3; |
e64fdf8a |
159 | } |
1fef78c8 |
160 | |
e64fdf8a |
161 | // Make tracker tracks |
3304fa09 |
162 | AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1; |
1fef78c8 |
163 | fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore); |
e64fdf8a |
164 | |
3304fa09 |
165 | // Make trigger tracks |
166 | AliMUONVTriggerTrackStore* triggerTrackStore(0x0); |
167 | if ( fTriggerCircuit ) { |
e64fdf8a |
168 | triggerTrackStore = new AliMUONTriggerTrackStoreV1; |
e64fdf8a |
169 | fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore); |
170 | } |
171 | |
3304fa09 |
172 | // Match tracker/trigger tracks |
173 | if ( triggerTrackStore && fTrackHitPatternMaker ) { |
e64fdf8a |
174 | fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker); |
175 | } |
176 | |
3304fa09 |
177 | // Fill ESD |
e64fdf8a |
178 | FillESD(*trackStore,esd); |
179 | |
180 | // cleanup |
181 | delete trackStore; |
182 | delete triggerTrackStore; |
183 | |
184 | return 0; |
185 | } |
196471e9 |
186 | |
e64fdf8a |
187 | //_____________________________________________________________________________ |
3304fa09 |
188 | void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const |
e64fdf8a |
189 | { |
190 | /// Fill the ESD from the trackStore |
e64fdf8a |
191 | AliDebug(1,""); |
2060b217 |
192 | AliCodeTimerAuto("") |
e64fdf8a |
193 | |
194 | // Get vertex |
195 | Double_t vertex[3] = {0}; |
690d2205 |
196 | Double_t errXVtx = 0., errYVtx = 0.; |
e64fdf8a |
197 | const AliESDVertex* esdVert = esd->GetVertex(); |
198 | if (esdVert->GetNContributors()) |
199 | { |
200 | esdVert->GetXYZ(vertex); |
690d2205 |
201 | errXVtx = esdVert->GetXRes(); |
202 | errYVtx = esdVert->GetYRes(); |
e64fdf8a |
203 | AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2])); |
204 | } |
205 | |
206 | // setting ESD MUON class |
207 | AliESDMuonTrack esdTrack; |
61fed964 |
208 | AliESDMuonCluster esdCluster; |
e64fdf8a |
209 | |
210 | AliMUONTrack* track; |
61fed964 |
211 | AliMUONVCluster* cluster; |
e64fdf8a |
212 | TIter next(trackStore.CreateIterator()); |
213 | |
214 | while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) |
215 | { |
96ebe67e |
216 | AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First()); |
e64fdf8a |
217 | |
218 | /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above) |
61fed964 |
219 | AliMUONTrackParam trackParamAtVtx(*trackParam); |
220 | AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], errXVtx, errYVtx); |
221 | |
222 | /// Extrapolate to vertex plan (which is set to z=0 if not available, see above) |
223 | AliMUONTrackParam trackParamAtDCA(*trackParam); |
224 | AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&trackParamAtDCA, vertex[2]); |
e64fdf8a |
225 | |
226 | // setting data member of ESD MUON |
61fed964 |
227 | esdTrack.Clear("C"); // remove already attached clusters |
228 | esdTrack.SetMuonClusterMap(0); // important to use the Add..() methods |
e64fdf8a |
229 | |
230 | // at first station |
60765b06 |
231 | trackParam->SetParamForUncorrected(esdTrack); |
232 | trackParam->SetCovFor(esdTrack); |
e64fdf8a |
233 | // at vertex |
60765b06 |
234 | trackParamAtVtx.SetParamFor(esdTrack); |
61fed964 |
235 | // at Distance of Closest Approach |
236 | trackParamAtDCA.SetParamForDCA(esdTrack); |
e64fdf8a |
237 | // global info |
96ebe67e |
238 | esdTrack.SetChi2(track->GetGlobalChi2()); |
239 | esdTrack.SetNHit(track->GetNClusters()); |
e64fdf8a |
240 | esdTrack.SetLocalTrigger(track->GetLocalTrigger()); |
241 | esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger()); |
242 | esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh()); |
61fed964 |
243 | // muon cluster info |
96ebe67e |
244 | while (trackParam) { |
61fed964 |
245 | cluster = trackParam->GetClusterPtr(); |
246 | esdCluster.SetUniqueID(cluster->GetUniqueID()); |
247 | esdCluster.SetXYZ(cluster->GetX(), cluster->GetY(), cluster->GetZ()); |
248 | esdCluster.SetErrXY(cluster->GetErrX(), cluster->GetErrY()); |
249 | esdTrack.AddCluster(esdCluster); |
250 | esdTrack.AddInMuonClusterMap(cluster->GetChamberId()); |
96ebe67e |
251 | trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam)); |
60765b06 |
252 | } |
e64fdf8a |
253 | |
254 | // storing ESD MUON Track into ESD Event |
255 | esd->AddMuonTrack(&esdTrack); |
256 | } // end of loop on tracks |
196471e9 |
257 | } |
258 | |
259 | //_____________________________________________________________________________ |
3304fa09 |
260 | void AliMUONTracker::CreateTrackReconstructor() |
196471e9 |
261 | { |
3304fa09 |
262 | /// Create track reconstructor, depending on tracking mode set in RecoParam |
263 | |
264 | TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode()); |
265 | opt.ToUpper(); |
e64fdf8a |
266 | |
3304fa09 |
267 | if (strstr(opt,"ORIGINAL")) |
e64fdf8a |
268 | { |
1fef78c8 |
269 | fTrackReco = new AliMUONTrackReconstructor(fClusterServer); |
e64fdf8a |
270 | } |
3304fa09 |
271 | else if (strstr(opt,"KALMAN")) |
e64fdf8a |
272 | { |
1fef78c8 |
273 | fTrackReco = new AliMUONTrackReconstructorK(fClusterServer); |
e64fdf8a |
274 | } |
3304fa09 |
275 | else |
276 | { |
277 | AliError(Form("tracking mode \"%s\" does not exist",opt.Data())); |
278 | return; |
279 | } |
280 | |
281 | AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName())); |
e64fdf8a |
282 | } |
196471e9 |
283 | |
e64fdf8a |
284 | //_____________________________________________________________________________ |
3304fa09 |
285 | void AliMUONTracker::UnloadClusters() |
e64fdf8a |
286 | { |
1fef78c8 |
287 | /// Clear internal clusterStore |
288 | |
289 | ClusterStore()->Clear(); |
196471e9 |
290 | } |