]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | ||
cc87ebcd | 16 | /* $Id$ */ |
17 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
7945aae7 | 19 | /// \class AliMUONTrackReconstructor |
20 | /// MUON track reconstructor using the original method | |
21 | /// | |
22 | /// This class contains as data: | |
23 | /// - the parameters for the track reconstruction | |
24 | /// | |
25 | /// It contains as methods, among others: | |
26 | /// - MakeTracks to build the tracks | |
3d1463c8 | 27 | //----------------------------------------------------------------------------- |
a9e2aefa | 28 | |
29f1b13a | 29 | #include "AliMUONTrackReconstructor.h" |
7ec3b9cf | 30 | |
29fc2c86 | 31 | #include "AliMUONConstants.h" |
96ebe67e | 32 | #include "AliMUONVCluster.h" |
1fef78c8 | 33 | #include "AliMUONVClusterServer.h" |
96ebe67e | 34 | #include "AliMUONVClusterStore.h" |
a9e2aefa | 35 | #include "AliMUONTrack.h" |
37827b29 | 36 | #include "AliMUONTrackParam.h" |
37 | #include "AliMUONTrackExtrap.h" | |
b709ac13 | 38 | |
1fef78c8 | 39 | #include "AliMpArea.h" |
40 | ||
8c343c7c | 41 | #include "AliLog.h" |
af743f54 | 42 | |
208f139e | 43 | #include <TMinuit.h> |
af743f54 | 44 | #include <Riostream.h> |
ea94c18b | 45 | #include <TMath.h> |
af743f54 | 46 | #include <TMatrixD.h> |
a9e2aefa | 47 | |
de2cd600 | 48 | // Functions to be minimized with Minuit |
ea94c18b | 49 | void TrackChi2(Int_t &nParam, Double_t *gradient, Double_t &chi2, Double_t *param, Int_t flag); |
de2cd600 | 50 | |
7945aae7 | 51 | /// \cond CLASSIMP |
29f1b13a | 52 | ClassImp(AliMUONTrackReconstructor) // Class implementation in ROOT context |
7945aae7 | 53 | /// \endcond |
a9e2aefa | 54 | |
019df241 | 55 | //__________________________________________________________________________ |
1fef78c8 | 56 | AliMUONTrackReconstructor::AliMUONTrackReconstructor(AliMUONVClusterServer& clusterServer) |
57 | : AliMUONVTrackReconstructor(clusterServer) | |
a9e2aefa | 58 | { |
96ebe67e | 59 | /// Constructor |
a9e2aefa | 60 | } |
9cbdf048 | 61 | |
019df241 | 62 | //__________________________________________________________________________ |
ea94c18b | 63 | AliMUONTrackReconstructor::~AliMUONTrackReconstructor() |
a9e2aefa | 64 | { |
ea94c18b | 65 | /// Destructor |
66 | } | |
276c44b7 | 67 | |
de2cd600 | 68 | //__________________________________________________________________________ |
1fef78c8 | 69 | void AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& clusterStore) |
de2cd600 | 70 | { |
019df241 | 71 | /// To make track candidates (assuming linear propagation if the flag fgkMakeTrackCandidatesFast is set to kTRUE): |
208f139e | 72 | /// Start with segments station(1..) 4 or 5 then follow track in station 5 or 4. |
96ebe67e | 73 | /// Good candidates are made of at least three clusters. |
208f139e | 74 | /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks. |
b709ac13 | 75 | |
208f139e | 76 | TClonesArray *segments; |
208f139e | 77 | AliMUONTrack *track; |
208f139e | 78 | Int_t iCandidate = 0; |
96ebe67e | 79 | Bool_t clusterFound; |
208f139e | 80 | |
de2cd600 | 81 | AliDebug(1,"Enter MakeTrackCandidates"); |
de2cd600 | 82 | |
3a7acd03 | 83 | // Unless we're doing combined tracking, we'll clusterize all stations at once |
84 | Int_t firstChamber(0); | |
85 | Int_t lastChamber(9); | |
86 | ||
1fef78c8 | 87 | if (AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco()) { |
3a7acd03 | 88 | // ... Here's the exception : ask the clustering to reconstruct |
89 | // clusters *only* in station 4 and 5 for combined tracking | |
90 | firstChamber = 6; | |
91 | } | |
92 | ||
93 | for (Int_t i = firstChamber; i <= lastChamber; ++i ) | |
94 | { | |
95 | fClusterServer.Clusterize(i, clusterStore, AliMpArea()); | |
1fef78c8 | 96 | } |
97 | ||
208f139e | 98 | // Loop over stations(1..) 5 and 4 and make track candidates |
ea94c18b | 99 | for (Int_t istat=4; istat>=3; istat--) { |
100 | ||
208f139e | 101 | // Make segments in the station |
96ebe67e | 102 | segments = MakeSegmentsInStation(clusterStore,istat); |
ea94c18b | 103 | |
208f139e | 104 | // Loop over segments |
7ec3b9cf | 105 | for (Int_t iseg=0; iseg<segments->GetEntriesFast(); iseg++) |
106 | { | |
208f139e | 107 | AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate)); |
ea94c18b | 108 | |
208f139e | 109 | // Transform segments to tracks and put them at the end of fRecTracksPtr |
ea94c18b | 110 | track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack((AliMUONObjectPair*)((*segments)[iseg])); |
a9e2aefa | 111 | fNRecTracks++; |
ea94c18b | 112 | |
208f139e | 113 | // Printout for debuging |
96ebe67e | 114 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { |
115 | cout<<endl<<"Track parameter covariances at first cluster:"<<endl; | |
116 | ((AliMUONTrackParam*) track->GetTrackParamAtCluster()->First())->GetCovariances().Print(); | |
208f139e | 117 | } |
ea94c18b | 118 | |
96ebe67e | 119 | // Look for compatible cluster(s) in the other station |
120 | if (AliMUONReconstructor::GetRecoParam()->MakeTrackCandidatesFast()) | |
121 | clusterFound = FollowLinearTrackInStation(*track, clusterStore, 7-istat); | |
122 | else clusterFound = FollowTrackInStation(*track, clusterStore, 7-istat); | |
019df241 | 123 | |
96ebe67e | 124 | // Remove track if no cluster found |
125 | if (!clusterFound) { | |
ea94c18b | 126 | fRecTracksPtr->Remove(track); |
127 | fNRecTracks--; | |
128 | } | |
129 | ||
a9e2aefa | 130 | } |
ea94c18b | 131 | |
208f139e | 132 | // delete the array of segments |
133 | delete segments; | |
134 | } | |
ea94c18b | 135 | |
208f139e | 136 | fRecTracksPtr->Compress(); // this is essential before checking tracks |
137 | ||
138 | // Keep all different tracks or only the best ones as required | |
3304fa09 | 139 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks(); |
208f139e | 140 | else RemoveDoubleTracks(); |
141 | ||
142 | AliDebug(1,Form("Number of good candidates = %d",fNRecTracks)); | |
143 | ||
a9e2aefa | 144 | } |
145 | ||
146 | //__________________________________________________________________________ | |
1fef78c8 | 147 | void AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore) |
a9e2aefa | 148 | { |
2457f726 | 149 | /// Follow tracks in stations(1..) 3, 2 and 1 |
208f139e | 150 | AliDebug(1,"Enter FollowTracks"); |
151 | ||
04b5ea16 | 152 | AliMUONTrack *track, *nextTrack; |
b709ac13 | 153 | AliMUONTrackParam *trackParam, *nextTrackParam; |
af743f54 | 154 | Int_t currentNRecTracks; |
96ebe67e | 155 | Bool_t clusterFound; |
208f139e | 156 | |
3304fa09 | 157 | Double_t sigmaCut2 = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * |
158 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); | |
159 | ||
208f139e | 160 | for (Int_t station = 2; station >= 0; station--) { |
ea94c18b | 161 | |
208f139e | 162 | // Save the actual number of reconstructed track in case of |
163 | // tracks are added or suppressed during the tracking procedure | |
164 | // !! Do not compress fRecTracksPtr until the end of the loop over tracks !! | |
af743f54 | 165 | currentNRecTracks = fNRecTracks; |
ea94c18b | 166 | |
af743f54 | 167 | for (Int_t iRecTrack = 0; iRecTrack <currentNRecTracks; iRecTrack++) { |
208f139e | 168 | AliDebug(1,Form("FollowTracks: track candidate(1..) %d", iRecTrack+1)); |
ea94c18b | 169 | |
208f139e | 170 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack); |
ea94c18b | 171 | |
208f139e | 172 | // Fit the track: |
173 | // Do not take into account the multiple scattering to speed up the fit | |
174 | // Calculate the track parameter covariance matrix | |
175 | // If "station" is station(1..) 3 then use the vertex to better constrain the fit | |
96ebe67e | 176 | if (station==2) Fit(*track, kFALSE, kTRUE, kTRUE); |
177 | else Fit(*track, kFALSE, kFALSE, kTRUE); | |
ea94c18b | 178 | |
208f139e | 179 | // Remove the track if the normalized chi2 is too high |
3304fa09 | 180 | if (track->GetNormalizedChi2() > sigmaCut2) { |
208f139e | 181 | fRecTracksPtr->Remove(track); |
182 | fNRecTracks--; | |
183 | continue; | |
184 | } | |
ea94c18b | 185 | |
b709ac13 | 186 | // save parameters from fit into smoothed parameters to complete track afterward |
3304fa09 | 187 | if (AliMUONReconstructor::GetRecoParam()->ComplementTracks()) { |
b709ac13 | 188 | |
189 | if (station==2) { // save track parameters on stations 4 and 5 | |
190 | ||
191 | // extrapolate track parameters and covariances at each cluster | |
96ebe67e | 192 | track->UpdateCovTrackParamAtCluster(); |
b709ac13 | 193 | |
194 | // save them | |
96ebe67e | 195 | trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First(); |
b709ac13 | 196 | while (trackParam) { |
197 | trackParam->SetSmoothParameters(trackParam->GetParameters()); | |
198 | trackParam->SetSmoothCovariances(trackParam->GetCovariances()); | |
96ebe67e | 199 | trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam); |
b709ac13 | 200 | } |
201 | ||
202 | } else { // or save track parameters on last station only | |
203 | ||
204 | // save parameters from fit | |
96ebe67e | 205 | trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First(); |
b709ac13 | 206 | trackParam->SetSmoothParameters(trackParam->GetParameters()); |
207 | trackParam->SetSmoothCovariances(trackParam->GetCovariances()); | |
208 | ||
209 | // save parameters extrapolated to the second chamber of the same station if it has been hit | |
96ebe67e | 210 | nextTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam); |
211 | if (nextTrackParam->GetClusterPtr()->GetChamberId() < 2*(station+2)) { | |
b709ac13 | 212 | |
213 | // reset parameters and covariances | |
214 | nextTrackParam->SetParameters(trackParam->GetParameters()); | |
215 | nextTrackParam->SetZ(trackParam->GetZ()); | |
216 | nextTrackParam->SetCovariances(trackParam->GetCovariances()); | |
217 | ||
218 | // extrapolate them to the z of the corresponding cluster | |
96ebe67e | 219 | AliMUONTrackExtrap::ExtrapToZCov(nextTrackParam, nextTrackParam->GetClusterPtr()->GetZ()); |
b709ac13 | 220 | |
221 | // save them | |
222 | nextTrackParam->SetSmoothParameters(nextTrackParam->GetParameters()); | |
223 | nextTrackParam->SetSmoothCovariances(nextTrackParam->GetCovariances()); | |
224 | ||
225 | } | |
226 | ||
227 | } | |
228 | ||
229 | } | |
230 | ||
208f139e | 231 | // Printout for debuging |
232 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
96ebe67e | 233 | cout<<endl<<"Track parameter covariances at first cluster:"<<endl; |
234 | ((AliMUONTrackParam*) track->GetTrackParamAtCluster()->First())->GetCovariances().Print(); | |
208f139e | 235 | } |
ea94c18b | 236 | |
96ebe67e | 237 | // Look for compatible cluster(s) in station(0..) "station" |
238 | clusterFound = FollowTrackInStation(*track, clusterStore, station); | |
ea94c18b | 239 | |
240 | // Try to recover track if required | |
96ebe67e | 241 | if (!clusterFound && AliMUONReconstructor::GetRecoParam()->RecoverTracks()) |
242 | clusterFound = RecoverTrack(*track, clusterStore, station); | |
ea94c18b | 243 | |
96ebe67e | 244 | // remove track if no cluster found |
245 | if (!clusterFound) { | |
ea94c18b | 246 | fRecTracksPtr->Remove(track); |
247 | fNRecTracks--; | |
248 | } | |
249 | ||
208f139e | 250 | } |
ea94c18b | 251 | |
208f139e | 252 | // Compress fRecTracksPtr for the next step |
253 | fRecTracksPtr->Compress(); | |
ea94c18b | 254 | |
208f139e | 255 | // Keep only the best tracks if required |
3304fa09 | 256 | if (!AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks(); |
ea94c18b | 257 | |
208f139e | 258 | } |
259 | ||
96ebe67e | 260 | // Last fit of track candidates with all stations |
208f139e | 261 | // Take into account the multiple scattering and remove bad tracks |
262 | Int_t trackIndex = -1; | |
04b5ea16 | 263 | track = (AliMUONTrack*) fRecTracksPtr->First(); |
04b5ea16 | 264 | while (track) { |
ea94c18b | 265 | |
04b5ea16 | 266 | trackIndex++; |
267 | nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); // prepare next track | |
ea94c18b | 268 | |
96ebe67e | 269 | Fit(*track, kTRUE, kFALSE, kTRUE); |
ea94c18b | 270 | |
208f139e | 271 | // Printout for debuging |
272 | if (AliLog::GetGlobalDebugLevel() >= 3) { | |
273 | cout << "FollowTracks: track candidate(0..) " << trackIndex << " after final fit" << endl; | |
a9e2aefa | 274 | track->RecursiveDump(); |
208f139e | 275 | } |
ea94c18b | 276 | |
208f139e | 277 | // Remove the track if the normalized chi2 is too high |
3304fa09 | 278 | if (track->GetNormalizedChi2() > sigmaCut2) { |
208f139e | 279 | fRecTracksPtr->Remove(track); |
280 | fNRecTracks--; | |
6d9a2d45 | 281 | track = nextTrack; |
282 | continue; | |
a9e2aefa | 283 | } |
ea94c18b | 284 | |
b709ac13 | 285 | // save parameters from fit into smoothed parameters to complete track afterward |
3304fa09 | 286 | if (AliMUONReconstructor::GetRecoParam()->ComplementTracks()) { |
b709ac13 | 287 | |
288 | // save parameters from fit | |
96ebe67e | 289 | trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First(); |
b709ac13 | 290 | trackParam->SetSmoothParameters(trackParam->GetParameters()); |
291 | trackParam->SetSmoothCovariances(trackParam->GetCovariances()); | |
292 | ||
293 | // save parameters extrapolated to the second chamber of the same station if it has been hit | |
96ebe67e | 294 | nextTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam); |
295 | if (nextTrackParam->GetClusterPtr()->GetChamberId() < 2) { | |
b709ac13 | 296 | |
297 | // reset parameters and covariances | |
298 | nextTrackParam->SetParameters(trackParam->GetParameters()); | |
299 | nextTrackParam->SetZ(trackParam->GetZ()); | |
300 | nextTrackParam->SetCovariances(trackParam->GetCovariances()); | |
301 | ||
302 | // extrapolate them to the z of the corresponding cluster | |
96ebe67e | 303 | AliMUONTrackExtrap::ExtrapToZCov(nextTrackParam, nextTrackParam->GetClusterPtr()->GetZ()); |
b709ac13 | 304 | |
305 | // save them | |
306 | nextTrackParam->SetSmoothParameters(nextTrackParam->GetParameters()); | |
307 | nextTrackParam->SetSmoothCovariances(nextTrackParam->GetCovariances()); | |
308 | ||
309 | } | |
310 | ||
311 | } | |
312 | ||
208f139e | 313 | track = nextTrack; |
ea94c18b | 314 | |
208f139e | 315 | } |
ea94c18b | 316 | |
208f139e | 317 | fRecTracksPtr->Compress(); |
318 | ||
319 | } | |
1a38e749 | 320 | |
208f139e | 321 | //__________________________________________________________________________ |
1fef78c8 | 322 | Bool_t AliMUONTrackReconstructor::FollowTrackInStation(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
208f139e | 323 | { |
96ebe67e | 324 | /// Follow trackCandidate in station(0..) nextStation and search for compatible cluster(s) |
208f139e | 325 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: |
326 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
327 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
328 | /// Remove the obsolete "trackCandidate" at the end. | |
96ebe67e | 329 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. |
208f139e | 330 | AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1)); |
331 | ||
ea94c18b | 332 | // Order the chamber according to the propagation direction (tracking starts with chamber 2): |
333 | // - nextStation == station(1...) 5 => forward propagation | |
334 | // - nextStation < station(1...) 5 => backward propagation | |
335 | Int_t ch1, ch2; | |
336 | if (nextStation==4) { | |
337 | ch1 = 2*nextStation+1; | |
338 | ch2 = 2*nextStation; | |
339 | } else { | |
340 | ch1 = 2*nextStation; | |
341 | ch2 = 2*nextStation+1; | |
342 | } | |
343 | ||
96ebe67e | 344 | Double_t chi2WithOneCluster = 1.e10; |
345 | Double_t chi2WithTwoClusters = 1.e10; | |
346 | Double_t maxChi2WithOneCluster = 2. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * | |
347 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
348 | Double_t maxChi2WithTwoClusters = 4. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * | |
349 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 4 because 4 quantities in chi2 | |
350 | Double_t bestChi2WithOneCluster = maxChi2WithOneCluster; | |
351 | Double_t bestChi2WithTwoClusters = maxChi2WithTwoClusters; | |
352 | Bool_t foundOneCluster = kFALSE; | |
353 | Bool_t foundTwoClusters = kFALSE; | |
208f139e | 354 | AliMUONTrack *newTrack = 0x0; |
96ebe67e | 355 | AliMUONVCluster *clusterCh1, *clusterCh2; |
019df241 | 356 | AliMUONTrackParam extrapTrackParam; |
7332f213 | 357 | AliMUONTrackParam extrapTrackParamAtCh; |
96ebe67e | 358 | AliMUONTrackParam extrapTrackParamAtCluster1; |
359 | AliMUONTrackParam extrapTrackParamAtCluster2; | |
360 | AliMUONTrackParam bestTrackParamAtCluster1; | |
361 | AliMUONTrackParam bestTrackParamAtCluster2; | |
362 | ||
363 | Int_t nClusters = clusterStore.GetSize(); | |
364 | Bool_t *clusterCh1Used = new Bool_t[nClusters]; | |
365 | for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE; | |
366 | Int_t iCluster1; | |
ea94c18b | 367 | |
7332f213 | 368 | // Get track parameters according to the propagation direction |
369 | if (nextStation==4) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last(); | |
370 | else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First(); | |
ea94c18b | 371 | |
372 | // Add MCS effect | |
019df241 | 373 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 374 | |
375 | // Add MCS in the missing chamber if any (only 1 chamber can be missing according to tracking criteria) | |
96ebe67e | 376 | if (ch1 < ch2 && extrapTrackParamAtCh.GetClusterPtr()->GetChamberId() > ch2 + 1) { |
ea94c18b | 377 | // extrapolation to the missing chamber |
019df241 | 378 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2 + 1)); |
ea94c18b | 379 | // add MCS effect |
019df241 | 380 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 381 | } |
382 | ||
383 | //Extrapolate trackCandidate to chamber "ch2" | |
019df241 | 384 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2)); |
ea94c18b | 385 | |
208f139e | 386 | // Printout for debuging |
387 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
96ebe67e | 388 | cout<<endl<<"Track parameter covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl; |
019df241 | 389 | extrapTrackParamAtCh.GetCovariances().Print(); |
208f139e | 390 | } |
ea94c18b | 391 | |
208f139e | 392 | // Printout for debuging |
393 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 394 | cout << "FollowTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl; |
208f139e | 395 | } |
ea94c18b | 396 | |
1fef78c8 | 397 | // Ask the clustering to reconstruct new clusters around the track position in the current station |
398 | // except for station 4 and 5 that are already entirely clusterized | |
399 | if (AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco()) { | |
400 | if (nextStation < 3) AskForNewClustersInStation(extrapTrackParamAtCh, clusterStore, nextStation); | |
401 | } | |
402 | ||
96ebe67e | 403 | // Create iterators to loop over clusters in both chambers |
404 | TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1)); | |
405 | TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2)); | |
406 | ||
407 | // look for candidates in chamber 2 | |
408 | while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) { | |
ea94c18b | 409 | |
96ebe67e | 410 | // try to add the current cluster fast |
411 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh2)) continue; | |
019df241 | 412 | |
96ebe67e | 413 | // try to add the current cluster accuratly |
414 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh2, extrapTrackParamAtCluster2); | |
ea94c18b | 415 | |
96ebe67e | 416 | // if good chi2 then try to attach a cluster in the other chamber too |
417 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
418 | Bool_t foundSecondCluster = kFALSE; | |
ea94c18b | 419 | |
208f139e | 420 | // Printout for debuging |
421 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 422 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch2+1 |
423 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
424 | cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl; | |
a9e2aefa | 425 | } |
ea94c18b | 426 | |
427 | // add MCS effect for next step | |
96ebe67e | 428 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCluster2,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 429 | |
019df241 | 430 | // copy new track parameters for next step |
96ebe67e | 431 | extrapTrackParam = extrapTrackParamAtCluster2; |
019df241 | 432 | |
433 | //Extrapolate track parameters to chamber "ch1" | |
434 | AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1)); | |
435 | ||
96ebe67e | 436 | // reset cluster iterator of chamber 1 |
437 | nextInCh1.Reset(); | |
438 | iCluster1 = -1; | |
439 | ||
440 | // look for second candidates in chamber 1 | |
441 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
442 | iCluster1++; | |
ea94c18b | 443 | |
96ebe67e | 444 | // try to add the current cluster fast |
445 | if (!TryOneClusterFast(extrapTrackParam, clusterCh1)) continue; | |
019df241 | 446 | |
96ebe67e | 447 | // try to add the current cluster accuratly |
448 | chi2WithTwoClusters = TryTwoClusters(extrapTrackParamAtCluster2, clusterCh1, extrapTrackParamAtCluster1); | |
ea94c18b | 449 | |
96ebe67e | 450 | // if good chi2 then create a new track by adding the 2 clusters to the "trackCandidate" |
451 | if (chi2WithTwoClusters < maxChi2WithTwoClusters) { | |
452 | foundSecondCluster = kTRUE; | |
453 | foundTwoClusters = kTRUE; | |
ea94c18b | 454 | |
455 | // Printout for debuging | |
456 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 457 | cout << "FollowTrackInStation: found second cluster in chamber(1..): " << ch1+1 |
458 | << " (Global Chi2 = " << chi2WithTwoClusters << ")" << endl; | |
ea94c18b | 459 | } |
460 | ||
3304fa09 | 461 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 462 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters |
ea94c18b | 463 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 464 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1,extrapTrackParamAtCluster2); |
208f139e | 465 | fNRecTracks++; |
ea94c18b | 466 | |
96ebe67e | 467 | // Tag clusterCh1 as used |
468 | clusterCh1Used[iCluster1] = kTRUE; | |
ea94c18b | 469 | |
208f139e | 470 | // Printout for debuging |
471 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 472 | cout << "FollowTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl; |
208f139e | 473 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
a9e2aefa | 474 | } |
ea94c18b | 475 | |
96ebe67e | 476 | } else if (chi2WithTwoClusters < bestChi2WithTwoClusters) { |
477 | // keep track of the best couple of clusters | |
478 | bestChi2WithTwoClusters = chi2WithTwoClusters; | |
479 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
480 | bestTrackParamAtCluster2 = extrapTrackParamAtCluster2; | |
208f139e | 481 | } |
ea94c18b | 482 | |
a9e2aefa | 483 | } |
ea94c18b | 484 | |
d0bfce8d | 485 | } |
ea94c18b | 486 | |
96ebe67e | 487 | // if no clusterCh1 found then consider to add clusterCh2 only |
488 | if (!foundSecondCluster) { | |
489 | foundOneCluster = kTRUE; | |
ea94c18b | 490 | |
3304fa09 | 491 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 492 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 493 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 494 | UpdateTrack(*newTrack,extrapTrackParamAtCluster2); |
208f139e | 495 | fNRecTracks++; |
ea94c18b | 496 | |
208f139e | 497 | // Printout for debuging |
498 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 499 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl; |
208f139e | 500 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
501 | } | |
ea94c18b | 502 | |
96ebe67e | 503 | } else if (!foundTwoClusters && chi2WithOneCluster < bestChi2WithOneCluster) { |
504 | // keep track of the best single cluster except if a couple of clusters has already been found | |
505 | bestChi2WithOneCluster = chi2WithOneCluster; | |
506 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster2; | |
208f139e | 507 | } |
ea94c18b | 508 | |
d0bfce8d | 509 | } |
ea94c18b | 510 | |
208f139e | 511 | } |
ea94c18b | 512 | |
208f139e | 513 | } |
ea94c18b | 514 | |
208f139e | 515 | // look for candidates in chamber 1 not already attached to a track |
96ebe67e | 516 | // if we want to keep all possible tracks or if no good couple of clusters has been found |
517 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks() || !foundTwoClusters) { | |
ea94c18b | 518 | |
519 | // Printout for debuging | |
208f139e | 520 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { |
96ebe67e | 521 | cout << "FollowTrackInStation: look for single clusters in chamber(1..): " << ch1+1 << endl; |
208f139e | 522 | } |
ea94c18b | 523 | |
524 | // add MCS effect for next step | |
019df241 | 525 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
526 | ||
527 | //Extrapolate trackCandidate to chamber "ch1" | |
528 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1)); | |
529 | ||
96ebe67e | 530 | // reset cluster iterator of chamber 1 |
531 | nextInCh1.Reset(); | |
532 | iCluster1 = -1; | |
533 | ||
534 | // look for second candidates in chamber 1 | |
535 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
536 | iCluster1++; | |
ea94c18b | 537 | |
96ebe67e | 538 | if (clusterCh1Used[iCluster1]) continue; // Skip cluster already used |
ea94c18b | 539 | |
96ebe67e | 540 | // try to add the current cluster fast |
541 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh1)) continue; | |
019df241 | 542 | |
96ebe67e | 543 | // try to add the current cluster accuratly |
544 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh1, extrapTrackParamAtCluster1); | |
ea94c18b | 545 | |
96ebe67e | 546 | // if good chi2 then consider to add clusterCh1 |
547 | // We do not try to attach a cluster in the other chamber too since it has already been done above | |
548 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
549 | foundOneCluster = kTRUE; | |
ea94c18b | 550 | |
551 | // Printout for debuging | |
552 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 553 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1 |
554 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
ea94c18b | 555 | } |
556 | ||
3304fa09 | 557 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 558 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 559 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 560 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1); |
208f139e | 561 | fNRecTracks++; |
ea94c18b | 562 | |
563 | // Printout for debuging | |
208f139e | 564 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { |
96ebe67e | 565 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl; |
208f139e | 566 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
567 | } | |
ea94c18b | 568 | |
96ebe67e | 569 | } else if (chi2WithOneCluster < bestChi2WithOneCluster) { |
570 | // keep track of the best single cluster except if a couple of clusters has already been found | |
571 | bestChi2WithOneCluster = chi2WithOneCluster; | |
572 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
208f139e | 573 | } |
ea94c18b | 574 | |
d0bfce8d | 575 | } |
ea94c18b | 576 | |
208f139e | 577 | } |
ea94c18b | 578 | |
208f139e | 579 | } |
ea94c18b | 580 | |
208f139e | 581 | // fill out the best track if required else clean up the fRecTracksPtr array |
3304fa09 | 582 | if (!AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 583 | if (foundTwoClusters) { |
584 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestTrackParamAtCluster2); | |
ea94c18b | 585 | |
208f139e | 586 | // Printout for debuging |
587 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 588 | cout << "FollowTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl; |
208f139e | 589 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
a9e2aefa | 590 | } |
ea94c18b | 591 | |
96ebe67e | 592 | } else if (foundOneCluster) { |
593 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1); | |
ea94c18b | 594 | |
208f139e | 595 | // Printout for debuging |
596 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 597 | cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl; |
208f139e | 598 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
04b5ea16 | 599 | } |
ea94c18b | 600 | |
dd230855 | 601 | } else { |
96ebe67e | 602 | delete [] clusterCh1Used; |
dd230855 | 603 | return kFALSE; |
604 | } | |
ea94c18b | 605 | |
96ebe67e | 606 | } else if (foundOneCluster || foundTwoClusters) { |
ea94c18b | 607 | |
608 | // remove obsolete track | |
609 | fRecTracksPtr->Remove(&trackCandidate); | |
610 | fNRecTracks--; | |
611 | ||
dd230855 | 612 | } else { |
96ebe67e | 613 | delete [] clusterCh1Used; |
dd230855 | 614 | return kFALSE; |
615 | } | |
ea94c18b | 616 | |
96ebe67e | 617 | delete [] clusterCh1Used; |
ea94c18b | 618 | return kTRUE; |
619 | ||
620 | } | |
621 | ||
622 | //__________________________________________________________________________ | |
96ebe67e | 623 | Double_t AliMUONTrackReconstructor::TryTwoClusters(const AliMUONTrackParam &trackParamAtCluster1, AliMUONVCluster* cluster2, |
624 | AliMUONTrackParam &trackParamAtCluster2) | |
ea94c18b | 625 | { |
96ebe67e | 626 | /// Test the compatibility between the track and the 2 clusters together (using trackParam's covariance matrix): |
627 | /// return the corresponding Chi2 accounting for covariances between the 2 clusters | |
628 | /// return trackParamAtCluster1 & 2 | |
ea94c18b | 629 | |
96ebe67e | 630 | // extrapolate track parameters at the z position of the second cluster (no need to extrapolate the covariances) |
631 | trackParamAtCluster2.SetParameters(trackParamAtCluster1.GetParameters()); | |
632 | trackParamAtCluster2.SetZ(trackParamAtCluster1.GetZ()); | |
633 | AliMUONTrackExtrap::ExtrapToZ(&trackParamAtCluster2, cluster2->GetZ()); | |
ea94c18b | 634 | |
96ebe67e | 635 | // set pointer to cluster2 into trackParamAtCluster2 |
636 | trackParamAtCluster2.SetClusterPtr(cluster2); | |
ea94c18b | 637 | |
96ebe67e | 638 | // Set differences between track and the 2 clusters in the bending and non bending directions |
639 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
ea94c18b | 640 | TMatrixD dPos(4,1); |
96ebe67e | 641 | dPos(0,0) = cluster1->GetX() - trackParamAtCluster1.GetNonBendingCoor(); |
642 | dPos(1,0) = cluster1->GetY() - trackParamAtCluster1.GetBendingCoor(); | |
643 | dPos(2,0) = cluster2->GetX() - trackParamAtCluster2.GetNonBendingCoor(); | |
644 | dPos(3,0) = cluster2->GetY() - trackParamAtCluster2.GetBendingCoor(); | |
ea94c18b | 645 | |
96ebe67e | 646 | // Calculate the error matrix from the track parameter covariances at first cluster |
ea94c18b | 647 | TMatrixD error(4,4); |
648 | error.Zero(); | |
96ebe67e | 649 | if (trackParamAtCluster1.CovariancesExist()) { |
650 | // Save track parameters at first cluster | |
651 | TMatrixD paramAtCluster1Save(trackParamAtCluster1.GetParameters()); | |
652 | ||
653 | // Save track coordinates at second cluster | |
654 | Double_t nonBendingCoor2 = trackParamAtCluster2.GetNonBendingCoor(); | |
655 | Double_t bendingCoor2 = trackParamAtCluster2.GetBendingCoor(); | |
ea94c18b | 656 | |
96ebe67e | 657 | // copy track parameters at first cluster for jacobian calculation |
658 | AliMUONTrackParam trackParam(trackParamAtCluster1); | |
ea94c18b | 659 | |
96ebe67e | 660 | // add MCS effect to the covariance matrix at first cluster |
661 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
ea94c18b | 662 | |
96ebe67e | 663 | // Get the pointer to the parameter covariance matrix at first cluster |
664 | const TMatrixD& kParamCov = trackParam.GetCovariances(); | |
ea94c18b | 665 | |
666 | // Calculate the jacobian related to the transformation between track parameters | |
96ebe67e | 667 | // at first cluster and track coordinates at the 2 cluster z-positions |
ea94c18b | 668 | TMatrixD jacob(4,5); |
669 | jacob.Zero(); | |
96ebe67e | 670 | // first derivative at the first cluster: |
ea94c18b | 671 | jacob(0,0) = 1.; // dx1/dx |
672 | jacob(1,2) = 1.; // dy1/dy | |
96ebe67e | 673 | // first derivative at the second cluster: |
ea94c18b | 674 | TMatrixD dParam(5,1); |
675 | for (Int_t i=0; i<5; i++) { | |
676 | // Skip jacobian calculation for parameters with no associated error | |
677 | if (kParamCov(i,i) == 0.) continue; | |
678 | // Small variation of parameter i only | |
679 | for (Int_t j=0; j<5; j++) { | |
680 | if (j==i) { | |
681 | dParam(j,0) = TMath::Sqrt(kParamCov(i,i)); | |
96ebe67e | 682 | if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramAtCluster1Save(4,0)); // variation always in the same direction |
ea94c18b | 683 | } else dParam(j,0) = 0.; |
684 | } | |
685 | ||
96ebe67e | 686 | // Set new track parameters at first cluster |
687 | trackParam.SetParameters(paramAtCluster1Save); | |
688 | trackParam.AddParameters(dParam); | |
689 | trackParam.SetZ(cluster1->GetZ()); | |
ea94c18b | 690 | |
96ebe67e | 691 | // Extrapolate new track parameters to the z position of the second cluster |
692 | AliMUONTrackExtrap::ExtrapToZ(&trackParam,cluster2->GetZ()); | |
ea94c18b | 693 | |
694 | // Calculate the jacobian | |
96ebe67e | 695 | jacob(2,i) = (trackParam.GetNonBendingCoor() - nonBendingCoor2) / dParam(i,0); // dx2/dParami |
696 | jacob(3,i) = (trackParam.GetBendingCoor() - bendingCoor2 ) / dParam(i,0); // dy2/dParami | |
208f139e | 697 | } |
ea94c18b | 698 | |
699 | // Calculate the error matrix | |
700 | TMatrixD tmp(jacob,TMatrixD::kMult,kParamCov); | |
701 | error = TMatrixD(tmp,TMatrixD::kMultTranspose,jacob); | |
702 | } | |
703 | ||
96ebe67e | 704 | // Add cluster resolution to the error matrix |
705 | error(0,0) += cluster1->GetErrX2(); | |
706 | error(1,1) += cluster1->GetErrY2(); | |
707 | error(2,2) += cluster2->GetErrX2(); | |
708 | error(3,3) += cluster2->GetErrY2(); | |
ea94c18b | 709 | |
710 | // invert the error matrix for Chi2 calculation | |
711 | if (error.Determinant() != 0) { | |
712 | error.Invert(); | |
208f139e | 713 | } else { |
ea94c18b | 714 | AliWarning(" Determinant error=0"); |
715 | return 1.e10; | |
208f139e | 716 | } |
717 | ||
ea94c18b | 718 | // Compute the Chi2 value |
719 | TMatrixD tmp2(dPos,TMatrixD::kTransposeMult,error); | |
720 | TMatrixD result(tmp2,TMatrixD::kMult,dPos); | |
721 | ||
722 | return result(0,0); | |
723 | ||
724 | } | |
725 | ||
726 | //__________________________________________________________________________ | |
96ebe67e | 727 | void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster) |
ea94c18b | 728 | { |
96ebe67e | 729 | /// Add 1 cluster to the track candidate |
ea94c18b | 730 | /// Update chi2 of the track |
731 | ||
732 | // Compute local chi2 | |
96ebe67e | 733 | AliMUONVCluster* cluster = trackParamAtCluster.GetClusterPtr(); |
734 | Double_t deltaX = trackParamAtCluster.GetNonBendingCoor() - cluster->GetX(); | |
735 | Double_t deltaY = trackParamAtCluster.GetBendingCoor() - cluster->GetY(); | |
736 | Double_t localChi2 = deltaX*deltaX / cluster->GetErrX2() + | |
737 | deltaY*deltaY / cluster->GetErrY2(); | |
ea94c18b | 738 | |
96ebe67e | 739 | // Flag cluster as being not removable |
740 | trackParamAtCluster.SetRemovable(kFALSE); | |
741 | trackParamAtCluster.SetLocalChi2(0.); // --> Local chi2 not used | |
5f4ceff2 | 742 | |
ea94c18b | 743 | // Update the chi2 of the new track |
96ebe67e | 744 | track.SetGlobalChi2(track.GetGlobalChi2() + localChi2); |
ea94c18b | 745 | |
96ebe67e | 746 | // Update TrackParamAtCluster |
747 | track.AddTrackParamAtCluster(trackParamAtCluster,*cluster); | |
ea94c18b | 748 | |
04b5ea16 | 749 | } |
750 | ||
de2cd600 | 751 | //__________________________________________________________________________ |
96ebe67e | 752 | void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster1, AliMUONTrackParam &trackParamAtCluster2) |
ea94c18b | 753 | { |
96ebe67e | 754 | /// Add 2 clusters to the track candidate |
ea94c18b | 755 | /// Update track and local chi2 |
756 | ||
96ebe67e | 757 | // Update local chi2 at first cluster |
758 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
759 | Double_t deltaX = trackParamAtCluster1.GetNonBendingCoor() - cluster1->GetX(); | |
760 | Double_t deltaY = trackParamAtCluster1.GetBendingCoor() - cluster1->GetY(); | |
761 | Double_t localChi2AtCluster1 = deltaX*deltaX / cluster1->GetErrX2() + | |
762 | deltaY*deltaY / cluster1->GetErrY2(); | |
763 | trackParamAtCluster1.SetLocalChi2(localChi2AtCluster1); | |
ea94c18b | 764 | |
96ebe67e | 765 | // Flag first cluster as being removable |
766 | trackParamAtCluster1.SetRemovable(kTRUE); | |
ea94c18b | 767 | |
96ebe67e | 768 | // Update local chi2 at second cluster |
769 | AliMUONVCluster* cluster2 = trackParamAtCluster2.GetClusterPtr(); | |
770 | deltaX = trackParamAtCluster2.GetNonBendingCoor() - cluster2->GetX(); | |
771 | deltaY = trackParamAtCluster2.GetBendingCoor() - cluster2->GetY(); | |
772 | Double_t localChi2AtCluster2 = deltaX*deltaX / cluster2->GetErrX2() + | |
773 | deltaY*deltaY / cluster2->GetErrY2(); | |
774 | trackParamAtCluster2.SetLocalChi2(localChi2AtCluster2); | |
ea94c18b | 775 | |
96ebe67e | 776 | // Flag first cluster as being removable |
777 | trackParamAtCluster2.SetRemovable(kTRUE); | |
ea94c18b | 778 | |
779 | // Update the chi2 of the new track | |
96ebe67e | 780 | track.SetGlobalChi2(track.GetGlobalChi2() + localChi2AtCluster1 + localChi2AtCluster2); |
ea94c18b | 781 | |
96ebe67e | 782 | // Update TrackParamAtCluster |
783 | track.AddTrackParamAtCluster(trackParamAtCluster1,*cluster1); | |
784 | track.AddTrackParamAtCluster(trackParamAtCluster2,*cluster2); | |
ea94c18b | 785 | |
786 | } | |
787 | ||
788 | //__________________________________________________________________________ | |
1fef78c8 | 789 | Bool_t AliMUONTrackReconstructor::RecoverTrack(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
ea94c18b | 790 | { |
791 | /// Try to recover the track candidate in the next station | |
96ebe67e | 792 | /// by removing the worst of the two clusters attached in the current station |
ea94c18b | 793 | /// Return kTRUE if recovering succeeds |
794 | AliDebug(1,"Enter RecoverTrack"); | |
795 | ||
96ebe67e | 796 | // Do not try to recover track until we have attached cluster(s) on station(1..) 3 |
ea94c18b | 797 | if (nextStation > 1) return kFALSE; |
798 | ||
96ebe67e | 799 | Int_t worstClusterNumber = -1; |
ea94c18b | 800 | Double_t localChi2, worstLocalChi2 = 0.; |
801 | ||
96ebe67e | 802 | // Look for the cluster to remove |
803 | for (Int_t clusterNumber = 0; clusterNumber < 2; clusterNumber++) { | |
804 | AliMUONTrackParam *trackParamAtCluster = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(clusterNumber); | |
ea94c18b | 805 | |
96ebe67e | 806 | // check if current cluster is removable |
807 | if (!trackParamAtCluster->IsRemovable()) return kFALSE; | |
ea94c18b | 808 | |
96ebe67e | 809 | // Pick up cluster with the worst chi2 |
810 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
ea94c18b | 811 | if (localChi2 > worstLocalChi2) { |
812 | worstLocalChi2 = localChi2; | |
96ebe67e | 813 | worstClusterNumber = clusterNumber; |
ea94c18b | 814 | } |
815 | } | |
816 | ||
96ebe67e | 817 | // Reset best cluster as being NOT removable |
818 | ((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt((worstClusterNumber+1)%2))->SetRemovable(kFALSE); | |
ea94c18b | 819 | |
96ebe67e | 820 | // Remove the worst cluster |
821 | trackCandidate.RemoveTrackParamAtCluster((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(worstClusterNumber)); | |
ea94c18b | 822 | |
823 | // Re-fit the track: | |
824 | // Do not take into account the multiple scattering to speed up the fit | |
825 | // Calculate the track parameter covariance matrix | |
96ebe67e | 826 | Fit(trackCandidate, kFALSE, kFALSE, kTRUE); |
ea94c18b | 827 | |
96ebe67e | 828 | // Look for new cluster(s) in next station |
829 | return FollowTrackInStation(trackCandidate,clusterStore,nextStation); | |
ea94c18b | 830 | |
831 | } | |
832 | ||
833 | //__________________________________________________________________________ | |
96ebe67e | 834 | void AliMUONTrackReconstructor::SetVertexErrXY2ForFit(AliMUONTrack &trackCandidate) |
de2cd600 | 835 | { |
96ebe67e | 836 | /// Compute the vertex resolution square from natural vertex dispersion and |
208f139e | 837 | /// multiple scattering effets according to trackCandidate path in absorber |
838 | /// It is necessary to account for multiple scattering effects here instead of during the fit of | |
839 | /// the "trackCandidate" to do not influence the result by changing track resolution at vertex | |
840 | AliDebug(1,"Enter SetVertexForFit"); | |
de2cd600 | 841 | |
3304fa09 | 842 | Double_t nonBendingReso2 = AliMUONReconstructor::GetRecoParam()->GetNonBendingVertexDispersion() * |
843 | AliMUONReconstructor::GetRecoParam()->GetNonBendingVertexDispersion(); | |
844 | Double_t bendingReso2 = AliMUONReconstructor::GetRecoParam()->GetBendingVertexDispersion() * | |
845 | AliMUONReconstructor::GetRecoParam()->GetBendingVertexDispersion(); | |
96ebe67e | 846 | |
208f139e | 847 | // add multiple scattering effets |
96ebe67e | 848 | AliMUONTrackParam paramAtVertex(*((AliMUONTrackParam*)(trackCandidate.GetTrackParamAtCluster()->First()))); |
208f139e | 849 | paramAtVertex.DeleteCovariances(); // to be sure to account only for multiple scattering |
850 | AliMUONTrackExtrap::ExtrapToVertexUncorrected(¶mAtVertex,0.); | |
ea94c18b | 851 | const TMatrixD& kParamCov = paramAtVertex.GetCovariances(); |
852 | nonBendingReso2 += kParamCov(0,0); | |
853 | bendingReso2 += kParamCov(2,2); | |
96ebe67e | 854 | |
855 | // Set the vertex resolution square | |
856 | trackCandidate.SetVertexErrXY2(nonBendingReso2,bendingReso2); | |
208f139e | 857 | } |
858 | ||
859 | //__________________________________________________________________________ | |
96ebe67e | 860 | void AliMUONTrackReconstructor::Fit(AliMUONTrack &track, Bool_t includeMCS, Bool_t fitWithVertex, Bool_t calcCov) |
208f139e | 861 | { |
96ebe67e | 862 | /// Fit the track |
863 | /// w/wo multiple Coulomb scattering according to "includeMCS". | |
864 | /// w/wo constraining the vertex according to "fitWithVertex". | |
865 | /// calculating or not the covariance matrix according to "calcCov". | |
7332f213 | 866 | AliDebug(1,"Enter Fit"); |
de2cd600 | 867 | |
208f139e | 868 | Double_t benC, errorParam, invBenP, nonBenC, x, y; |
de2cd600 | 869 | AliMUONTrackParam *trackParam; |
96ebe67e | 870 | Double_t arg[1], fedm, errdef, globalChi2; |
208f139e | 871 | Int_t npari, nparx; |
872 | Int_t status, covStatus; | |
873 | ||
8cde4af5 | 874 | // Instantiate gMinuit if not already done |
875 | if (!gMinuit) gMinuit = new TMinuit(6); | |
208f139e | 876 | // Clear MINUIT parameters |
877 | gMinuit->mncler(); | |
878 | // Give the fitted track to MINUIT | |
ea94c18b | 879 | gMinuit->SetObjectFit(&track); |
208f139e | 880 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { |
881 | // Define print level | |
882 | arg[0] = 1; | |
883 | gMinuit->mnexcm("SET PRI", arg, 1, status); | |
884 | // Print covariance matrix | |
885 | gMinuit->mnexcm("SHO COV", arg, 0, status); | |
886 | } else { | |
887 | arg[0] = -1; | |
888 | gMinuit->mnexcm("SET PRI", arg, 1, status); | |
889 | } | |
de2cd600 | 890 | // No warnings |
208f139e | 891 | gMinuit->mnexcm("SET NOW", arg, 0, status); |
892 | // Define strategy | |
893 | //arg[0] = 2; | |
894 | //gMinuit->mnexcm("SET STR", arg, 1, status); | |
895 | ||
ea94c18b | 896 | // set flag w/wo multiple scattering according to "includeMCS" |
96ebe67e | 897 | track.FitWithMCS(includeMCS); |
ea94c18b | 898 | if (includeMCS) { |
96ebe67e | 899 | // compute cluster weights only once |
900 | if (!track.ComputeClusterWeights()) { | |
ea94c18b | 901 | AliWarning("cannot take into account the multiple scattering effects"); |
96ebe67e | 902 | track.FitWithMCS(kFALSE); |
ea94c18b | 903 | } |
904 | } | |
905 | ||
96ebe67e | 906 | track.FitWithVertex(fitWithVertex); |
907 | if (fitWithVertex) SetVertexErrXY2ForFit(track); | |
908 | ||
ea94c18b | 909 | // Set fitting function |
910 | gMinuit->SetFCN(TrackChi2); | |
208f139e | 911 | |
912 | // Set fitted parameters (!! The order is very important for the covariance matrix !!) | |
96ebe67e | 913 | trackParam = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->First()); |
de2cd600 | 914 | // could be tried with no limits for the search (min=max=0) ???? |
208f139e | 915 | // mandatory limits in non Bending to avoid NaN values of parameters |
916 | gMinuit->mnparm(0, "X", trackParam->GetNonBendingCoor(), 0.03, -500.0, 500.0, status); | |
917 | gMinuit->mnparm(1, "NonBenS", trackParam->GetNonBendingSlope(), 0.001, -0.5, 0.5, status); | |
918 | // mandatory limits in Bending to avoid NaN values of parameters | |
919 | gMinuit->mnparm(2, "Y", trackParam->GetBendingCoor(), 0.10, -500.0, 500.0, status); | |
920 | gMinuit->mnparm(3, "BenS", trackParam->GetBendingSlope(), 0.001, -0.5, 0.5, status); | |
7332f213 | 921 | gMinuit->mnparm(4, "InvBenP", trackParam->GetInverseBendingMomentum(), 0.003, -0.5, 0.5, status); |
208f139e | 922 | |
de2cd600 | 923 | // minimization |
208f139e | 924 | gMinuit->mnexcm("MIGRAD", arg, 0, status); |
925 | ||
926 | // Calculate the covariance matrix more accurately if required | |
927 | if (calcCov) gMinuit->mnexcm("HESSE", arg, 0, status); | |
8cde4af5 | 928 | |
de2cd600 | 929 | // get results into "invBenP", "benC", "nonBenC" ("x", "y") |
208f139e | 930 | gMinuit->GetParameter(0, x, errorParam); |
931 | trackParam->SetNonBendingCoor(x); | |
932 | gMinuit->GetParameter(1, nonBenC, errorParam); | |
de2cd600 | 933 | trackParam->SetNonBendingSlope(nonBenC); |
208f139e | 934 | gMinuit->GetParameter(2, y, errorParam); |
935 | trackParam->SetBendingCoor(y); | |
936 | gMinuit->GetParameter(3, benC, errorParam); | |
937 | trackParam->SetBendingSlope(benC); | |
938 | gMinuit->GetParameter(4, invBenP, errorParam); | |
939 | trackParam->SetInverseBendingMomentum(invBenP); | |
940 | ||
de2cd600 | 941 | // global result of the fit |
96ebe67e | 942 | gMinuit->mnstat(globalChi2, fedm, errdef, npari, nparx, covStatus); |
943 | track.SetGlobalChi2(globalChi2); | |
208f139e | 944 | |
945 | // Get the covariance matrix if required | |
946 | if (calcCov) { | |
947 | // Covariance matrix according to HESSE status | |
948 | // If problem then keep only the diagonal terms (variances) | |
949 | Double_t matrix[5][5]; | |
950 | gMinuit->mnemat(&matrix[0][0],5); | |
951 | if (covStatus == 3) trackParam->SetCovariances(matrix); | |
952 | else trackParam->SetVariances(matrix); | |
ea94c18b | 953 | } else trackParam->DeleteCovariances(); |
208f139e | 954 | |
de2cd600 | 955 | } |
956 | ||
957 | //__________________________________________________________________________ | |
ea94c18b | 958 | void TrackChi2(Int_t & /*nParam*/, Double_t * /*gradient*/, Double_t &chi2, Double_t *param, Int_t /*flag*/) |
de2cd600 | 959 | { |
ea94c18b | 960 | /// Return the "Chi2" to be minimized with Minuit for track fitting. |
96ebe67e | 961 | /// Assumes that the trackParamAtCluster are sorted according to increasing Z. |
962 | /// Track parameters at each cluster are updated accordingly. | |
ea94c18b | 963 | /// Vertex is used according to the flag "trackBeingFitted->GetFitWithVertex()". |
964 | /// Multiple Coulomb scattering is taken into account according to the flag "trackBeingFitted->GetFitWithMCS()". | |
208f139e | 965 | |
966 | AliMUONTrack *trackBeingFitted = (AliMUONTrack*) gMinuit->GetObjectFit(); | |
96ebe67e | 967 | AliMUONTrackParam* trackParamAtCluster = (AliMUONTrackParam*) trackBeingFitted->GetTrackParamAtCluster()->First(); |
208f139e | 968 | Double_t dX, dY; |
ea94c18b | 969 | chi2 = 0.; // initialize chi2 |
208f139e | 970 | |
ea94c18b | 971 | // update track parameters |
96ebe67e | 972 | trackParamAtCluster->SetNonBendingCoor(param[0]); |
973 | trackParamAtCluster->SetNonBendingSlope(param[1]); | |
974 | trackParamAtCluster->SetBendingCoor(param[2]); | |
975 | trackParamAtCluster->SetBendingSlope(param[3]); | |
976 | trackParamAtCluster->SetInverseBendingMomentum(param[4]); | |
977 | trackBeingFitted->UpdateTrackParamAtCluster(); | |
208f139e | 978 | |
979 | // Take the vertex into account in the fit if required | |
96ebe67e | 980 | if (trackBeingFitted->FitWithVertex()) { |
981 | Double_t nonBendingReso2,bendingReso2; | |
982 | trackBeingFitted->GetVertexErrXY2(nonBendingReso2,bendingReso2); | |
983 | if (nonBendingReso2 == 0. || bendingReso2 == 0.) chi2 += 1.e10; | |
984 | else { | |
985 | AliMUONTrackParam paramAtVertex(*trackParamAtCluster); | |
986 | AliMUONTrackExtrap::ExtrapToZ(¶mAtVertex, 0.); // vextex position = (0,0,0) | |
987 | dX = paramAtVertex.GetNonBendingCoor(); | |
988 | dY = paramAtVertex.GetBendingCoor(); | |
989 | chi2 += dX * dX / nonBendingReso2 + dY * dY / bendingReso2; | |
208f139e | 990 | } |
de2cd600 | 991 | } |
208f139e | 992 | |
ea94c18b | 993 | // compute chi2 w/wo multiple scattering |
96ebe67e | 994 | chi2 += trackBeingFitted->ComputeGlobalChi2(trackBeingFitted->FitWithMCS()); |
b709ac13 | 995 | |
996 | } | |
997 | ||
998 | //__________________________________________________________________________ | |
96ebe67e | 999 | void AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clusterStore) |
b709ac13 | 1000 | { |
1001 | /// Complete tracks by adding missing clusters (if there is an overlap between | |
1002 | /// two detection elements, the track may have two clusters in the same chamber) | |
1003 | /// Re-fit track parameters and covariances | |
1004 | AliDebug(1,"Enter ComplementTracks"); | |
1005 | ||
1006 | Int_t chamberId, detElemId; | |
96ebe67e | 1007 | Double_t chi2OfCluster, bestChi2OfCluster; |
3304fa09 | 1008 | Double_t sigmaCut2 = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * |
1009 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); | |
96ebe67e | 1010 | Bool_t foundOneCluster, trackModified; |
1011 | AliMUONVCluster* cluster; | |
1012 | AliMUONTrackParam *trackParam, *nextTrackParam, copyOfTrackParam, trackParamAtCluster, bestTrackParamAtCluster; | |
b709ac13 | 1013 | |
1014 | // Remove double track to complete only "good" tracks | |
1015 | RemoveDoubleTracks(); | |
1016 | ||
1017 | AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First(); | |
1018 | while (track) { | |
1019 | trackModified = kFALSE; | |
1020 | ||
96ebe67e | 1021 | trackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->First(); |
b709ac13 | 1022 | while (trackParam) { |
96ebe67e | 1023 | foundOneCluster = kFALSE; |
1024 | bestChi2OfCluster = 2. * sigmaCut2; // 2 because 2 quantities in chi2 | |
1025 | chamberId = trackParam->GetClusterPtr()->GetChamberId(); | |
1026 | detElemId = trackParam->GetClusterPtr()->GetDetElemId(); | |
b709ac13 | 1027 | |
1028 | // prepare nextTrackParam before adding new cluster because of the sorting | |
96ebe67e | 1029 | nextTrackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->After(trackParam); |
b709ac13 | 1030 | |
1031 | // recover track parameters from local fit and put them into a copy of trackParam | |
1032 | copyOfTrackParam.SetZ(trackParam->GetZ()); | |
1033 | copyOfTrackParam.SetParameters(trackParam->GetSmoothParameters()); | |
1034 | copyOfTrackParam.SetCovariances(trackParam->GetSmoothCovariances()); | |
1035 | ||
96ebe67e | 1036 | // Create iterators to loop over clusters in current chamber |
1037 | TIter nextInCh(clusterStore.CreateChamberIterator(chamberId,chamberId)); | |
1038 | ||
b709ac13 | 1039 | // look for one second candidate in the same chamber |
96ebe67e | 1040 | while ( ( cluster = static_cast<AliMUONVCluster*>(nextInCh()) ) ) { |
b709ac13 | 1041 | |
1042 | // look for a cluster in another detection element | |
96ebe67e | 1043 | if (cluster->GetDetElemId() == detElemId) continue; |
b709ac13 | 1044 | |
96ebe67e | 1045 | // try to add the current cluster fast |
1046 | if (!TryOneClusterFast(copyOfTrackParam, cluster)) continue; | |
b709ac13 | 1047 | |
96ebe67e | 1048 | // try to add the current cluster accurately |
1049 | chi2OfCluster = TryOneCluster(copyOfTrackParam, cluster, trackParamAtCluster); | |
b709ac13 | 1050 | |
1051 | // if better chi2 then prepare to add this cluster to the track | |
96ebe67e | 1052 | if (chi2OfCluster < bestChi2OfCluster) { |
1053 | bestChi2OfCluster = chi2OfCluster; | |
1054 | bestTrackParamAtCluster = trackParamAtCluster; | |
1055 | foundOneCluster = kTRUE; | |
b709ac13 | 1056 | } |
1057 | ||
1058 | } | |
1059 | ||
1060 | // add new cluster if any | |
96ebe67e | 1061 | if (foundOneCluster) { |
7332f213 | 1062 | trackParam->SetRemovable(kTRUE); |
1063 | bestTrackParamAtCluster.SetRemovable(kTRUE); | |
1064 | track->AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr())); | |
b709ac13 | 1065 | trackModified = kTRUE; |
1066 | } | |
1067 | ||
1068 | trackParam = nextTrackParam; | |
1069 | } | |
1070 | ||
1071 | // re-fit track parameters if needed | |
96ebe67e | 1072 | if (trackModified) Fit(*track, kTRUE, kFALSE, kTRUE); |
b709ac13 | 1073 | |
1074 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1075 | } | |
ea94c18b | 1076 | |
de2cd600 | 1077 | } |
1078 | ||
1079 | //__________________________________________________________________________ | |
7332f213 | 1080 | void AliMUONTrackReconstructor::ImproveTrack(AliMUONTrack &track) |
de2cd600 | 1081 | { |
7332f213 | 1082 | /// Improve the given track by removing clusters with local chi2 highter than the defined cut |
ea94c18b | 1083 | /// Recompute track parameters and covariances at the remaining clusters |
7332f213 | 1084 | AliDebug(1,"Enter ImproveTrack"); |
208f139e | 1085 | |
ea94c18b | 1086 | Double_t localChi2, worstLocalChi2; |
7332f213 | 1087 | AliMUONTrackParam *trackParamAtCluster, *worstTrackParamAtCluster; |
3304fa09 | 1088 | Double_t sigmaCut2 = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForImprovement() * |
1089 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForImprovement(); | |
208f139e | 1090 | |
7332f213 | 1091 | while (!track.IsImproved()) { |
ea94c18b | 1092 | |
7332f213 | 1093 | // identify removable clusters |
1094 | track.TagRemovableClusters(); | |
b709ac13 | 1095 | |
7332f213 | 1096 | // Update track parameters and covariances |
1097 | track.UpdateCovTrackParamAtCluster(); | |
1098 | ||
1099 | // Compute local chi2 of each clusters | |
1100 | track.ComputeLocalChi2(kTRUE); | |
1101 | ||
1102 | // Look for the cluster to remove | |
1103 | worstTrackParamAtCluster = NULL; | |
1104 | worstLocalChi2 = 0.; | |
1105 | trackParamAtCluster = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First(); | |
1106 | while (trackParamAtCluster) { | |
ea94c18b | 1107 | |
7332f213 | 1108 | // Pick up cluster with the worst chi2 |
1109 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
1110 | if (localChi2 > worstLocalChi2) { | |
1111 | worstLocalChi2 = localChi2; | |
1112 | worstTrackParamAtCluster = trackParamAtCluster; | |
ea94c18b | 1113 | } |
1114 | ||
7332f213 | 1115 | trackParamAtCluster = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(trackParamAtCluster); |
1116 | } | |
1117 | ||
1118 | // Check if worst cluster found | |
1119 | if (!worstTrackParamAtCluster) { | |
1120 | AliWarning("Bad local chi2 values?"); | |
1121 | break; | |
1122 | } | |
1123 | ||
1124 | // Check whether the worst chi2 is under requirement or not | |
1125 | if (worstLocalChi2 < 2. * sigmaCut2) { // 2 because 2 quantities in chi2 | |
1126 | track.SetImproved(kTRUE); | |
1127 | break; | |
1128 | } | |
1129 | ||
1130 | // if the worst cluster is not removable then stop improvement | |
1131 | if (!worstTrackParamAtCluster->IsRemovable()) break; | |
1132 | ||
1133 | // Remove the worst cluster | |
1134 | track.RemoveTrackParamAtCluster(worstTrackParamAtCluster); | |
1135 | ||
1136 | // Re-fit the track: | |
1137 | // Take into account the multiple scattering | |
1138 | // Calculate the track parameter covariance matrix | |
1139 | Fit(track, kTRUE, kFALSE, kTRUE); | |
1140 | ||
1141 | // Printout for debuging | |
1142 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
1143 | cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(&track)+1 << " improved " << endl; | |
de2cd600 | 1144 | } |
ea94c18b | 1145 | |
de2cd600 | 1146 | } |
1147 | ||
de2cd600 | 1148 | } |
1149 | ||
208f139e | 1150 | //__________________________________________________________________________ |
7332f213 | 1151 | void AliMUONTrackReconstructor::FinalizeTrack(AliMUONTrack &track) |
b8dc484b | 1152 | { |
7332f213 | 1153 | /// Recompute track parameters and covariances at each attached cluster |
1154 | /// from those at the first one, if not already done | |
1155 | AliDebug(1,"Enter FinalizeTrack"); | |
1156 | if (!track.IsImproved()) track.UpdateCovTrackParamAtCluster(); | |
a9e2aefa | 1157 | } |
1158 | ||
7deb8eb0 | 1159 | //__________________________________________________________________________ |
1160 | Bool_t AliMUONTrackReconstructor::RefitTrack(AliMUONTrack &track) | |
1161 | { | |
1162 | /// re-fit the given track | |
1163 | ||
1164 | // check validity of the track | |
1165 | if (!track.IsValid()) { | |
1166 | AliWarning("the track does not contain enough clusters --> unable to refit"); | |
1167 | return kFALSE; | |
1168 | } | |
1169 | ||
1170 | // reset the seed (i.e. parameters at first cluster) before fitting | |
1171 | AliMUONTrackParam* firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First(); | |
1172 | if (firstTrackParam->GetInverseBendingMomentum() == 0.) { | |
1173 | AliWarning("track parameters at first chamber are not initialized --> unable to refit"); | |
1174 | return kFALSE; | |
1175 | } | |
1176 | ||
1177 | // compute track parameters at each cluster from parameters at the first one | |
1178 | // necessary to compute multiple scattering effect during refitting | |
1179 | track.UpdateTrackParamAtCluster(); | |
1180 | ||
1181 | // Re-fit the track: | |
1182 | // Take into account the multiple scattering | |
1183 | // Calculate the track parameter covariance matrix | |
1184 | Fit(track, kTRUE, kFALSE, kTRUE); | |
1185 | ||
1186 | // Improve the reconstructed tracks if required | |
1187 | if (AliMUONReconstructor::GetRecoParam()->ImproveTracks()) ImproveTrack(track); | |
1188 | ||
1189 | // Fill AliMUONTrack data members | |
1190 | FinalizeTrack(track); | |
1191 | ||
1192 | return kTRUE; | |
1193 | ||
1194 | } | |
1195 |