]>
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--; | |
a9e2aefa | 281 | } |
ea94c18b | 282 | |
b709ac13 | 283 | // save parameters from fit into smoothed parameters to complete track afterward |
3304fa09 | 284 | if (AliMUONReconstructor::GetRecoParam()->ComplementTracks()) { |
b709ac13 | 285 | |
286 | // save parameters from fit | |
96ebe67e | 287 | trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First(); |
b709ac13 | 288 | trackParam->SetSmoothParameters(trackParam->GetParameters()); |
289 | trackParam->SetSmoothCovariances(trackParam->GetCovariances()); | |
290 | ||
291 | // save parameters extrapolated to the second chamber of the same station if it has been hit | |
96ebe67e | 292 | nextTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam); |
293 | if (nextTrackParam->GetClusterPtr()->GetChamberId() < 2) { | |
b709ac13 | 294 | |
295 | // reset parameters and covariances | |
296 | nextTrackParam->SetParameters(trackParam->GetParameters()); | |
297 | nextTrackParam->SetZ(trackParam->GetZ()); | |
298 | nextTrackParam->SetCovariances(trackParam->GetCovariances()); | |
299 | ||
300 | // extrapolate them to the z of the corresponding cluster | |
96ebe67e | 301 | AliMUONTrackExtrap::ExtrapToZCov(nextTrackParam, nextTrackParam->GetClusterPtr()->GetZ()); |
b709ac13 | 302 | |
303 | // save them | |
304 | nextTrackParam->SetSmoothParameters(nextTrackParam->GetParameters()); | |
305 | nextTrackParam->SetSmoothCovariances(nextTrackParam->GetCovariances()); | |
306 | ||
307 | } | |
308 | ||
309 | } | |
310 | ||
208f139e | 311 | track = nextTrack; |
ea94c18b | 312 | |
208f139e | 313 | } |
ea94c18b | 314 | |
208f139e | 315 | fRecTracksPtr->Compress(); |
316 | ||
317 | } | |
1a38e749 | 318 | |
208f139e | 319 | //__________________________________________________________________________ |
1fef78c8 | 320 | Bool_t AliMUONTrackReconstructor::FollowTrackInStation(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
208f139e | 321 | { |
96ebe67e | 322 | /// Follow trackCandidate in station(0..) nextStation and search for compatible cluster(s) |
208f139e | 323 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: |
324 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
325 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
326 | /// Remove the obsolete "trackCandidate" at the end. | |
96ebe67e | 327 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. |
208f139e | 328 | AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1)); |
329 | ||
ea94c18b | 330 | // Order the chamber according to the propagation direction (tracking starts with chamber 2): |
331 | // - nextStation == station(1...) 5 => forward propagation | |
332 | // - nextStation < station(1...) 5 => backward propagation | |
333 | Int_t ch1, ch2; | |
334 | if (nextStation==4) { | |
335 | ch1 = 2*nextStation+1; | |
336 | ch2 = 2*nextStation; | |
337 | } else { | |
338 | ch1 = 2*nextStation; | |
339 | ch2 = 2*nextStation+1; | |
340 | } | |
341 | ||
96ebe67e | 342 | Double_t chi2WithOneCluster = 1.e10; |
343 | Double_t chi2WithTwoClusters = 1.e10; | |
344 | Double_t maxChi2WithOneCluster = 2. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * | |
345 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
346 | Double_t maxChi2WithTwoClusters = 4. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * | |
347 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 4 because 4 quantities in chi2 | |
348 | Double_t bestChi2WithOneCluster = maxChi2WithOneCluster; | |
349 | Double_t bestChi2WithTwoClusters = maxChi2WithTwoClusters; | |
350 | Bool_t foundOneCluster = kFALSE; | |
351 | Bool_t foundTwoClusters = kFALSE; | |
208f139e | 352 | AliMUONTrack *newTrack = 0x0; |
96ebe67e | 353 | AliMUONVCluster *clusterCh1, *clusterCh2; |
019df241 | 354 | AliMUONTrackParam extrapTrackParam; |
96ebe67e | 355 | AliMUONTrackParam extrapTrackParamAtCluster1; |
356 | AliMUONTrackParam extrapTrackParamAtCluster2; | |
357 | AliMUONTrackParam bestTrackParamAtCluster1; | |
358 | AliMUONTrackParam bestTrackParamAtCluster2; | |
359 | ||
360 | Int_t nClusters = clusterStore.GetSize(); | |
361 | Bool_t *clusterCh1Used = new Bool_t[nClusters]; | |
362 | for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE; | |
363 | Int_t iCluster1; | |
ea94c18b | 364 | |
019df241 | 365 | // Get track parameters |
96ebe67e | 366 | AliMUONTrackParam extrapTrackParamAtCh(*(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First()); |
ea94c18b | 367 | |
368 | // Add MCS effect | |
019df241 | 369 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 370 | |
371 | // Add MCS in the missing chamber if any (only 1 chamber can be missing according to tracking criteria) | |
96ebe67e | 372 | if (ch1 < ch2 && extrapTrackParamAtCh.GetClusterPtr()->GetChamberId() > ch2 + 1) { |
ea94c18b | 373 | // extrapolation to the missing chamber |
019df241 | 374 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2 + 1)); |
ea94c18b | 375 | // add MCS effect |
019df241 | 376 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 377 | } |
378 | ||
379 | //Extrapolate trackCandidate to chamber "ch2" | |
019df241 | 380 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2)); |
ea94c18b | 381 | |
208f139e | 382 | // Printout for debuging |
383 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
96ebe67e | 384 | cout<<endl<<"Track parameter covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl; |
019df241 | 385 | extrapTrackParamAtCh.GetCovariances().Print(); |
208f139e | 386 | } |
ea94c18b | 387 | |
208f139e | 388 | // Printout for debuging |
389 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 390 | cout << "FollowTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl; |
208f139e | 391 | } |
ea94c18b | 392 | |
1fef78c8 | 393 | // Ask the clustering to reconstruct new clusters around the track position in the current station |
394 | // except for station 4 and 5 that are already entirely clusterized | |
395 | if (AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco()) { | |
396 | if (nextStation < 3) AskForNewClustersInStation(extrapTrackParamAtCh, clusterStore, nextStation); | |
397 | } | |
398 | ||
96ebe67e | 399 | // Create iterators to loop over clusters in both chambers |
400 | TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1)); | |
401 | TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2)); | |
402 | ||
403 | // look for candidates in chamber 2 | |
404 | while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) { | |
ea94c18b | 405 | |
96ebe67e | 406 | // try to add the current cluster fast |
407 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh2)) continue; | |
019df241 | 408 | |
96ebe67e | 409 | // try to add the current cluster accuratly |
410 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh2, extrapTrackParamAtCluster2); | |
ea94c18b | 411 | |
96ebe67e | 412 | // if good chi2 then try to attach a cluster in the other chamber too |
413 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
414 | Bool_t foundSecondCluster = kFALSE; | |
ea94c18b | 415 | |
208f139e | 416 | // Printout for debuging |
417 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 418 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch2+1 |
419 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
420 | cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl; | |
a9e2aefa | 421 | } |
ea94c18b | 422 | |
423 | // add MCS effect for next step | |
96ebe67e | 424 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCluster2,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 425 | |
019df241 | 426 | // copy new track parameters for next step |
96ebe67e | 427 | extrapTrackParam = extrapTrackParamAtCluster2; |
019df241 | 428 | |
429 | //Extrapolate track parameters to chamber "ch1" | |
430 | AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1)); | |
431 | ||
96ebe67e | 432 | // reset cluster iterator of chamber 1 |
433 | nextInCh1.Reset(); | |
434 | iCluster1 = -1; | |
435 | ||
436 | // look for second candidates in chamber 1 | |
437 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
438 | iCluster1++; | |
ea94c18b | 439 | |
96ebe67e | 440 | // try to add the current cluster fast |
441 | if (!TryOneClusterFast(extrapTrackParam, clusterCh1)) continue; | |
019df241 | 442 | |
96ebe67e | 443 | // try to add the current cluster accuratly |
444 | chi2WithTwoClusters = TryTwoClusters(extrapTrackParamAtCluster2, clusterCh1, extrapTrackParamAtCluster1); | |
ea94c18b | 445 | |
96ebe67e | 446 | // if good chi2 then create a new track by adding the 2 clusters to the "trackCandidate" |
447 | if (chi2WithTwoClusters < maxChi2WithTwoClusters) { | |
448 | foundSecondCluster = kTRUE; | |
449 | foundTwoClusters = kTRUE; | |
ea94c18b | 450 | |
451 | // Printout for debuging | |
452 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 453 | cout << "FollowTrackInStation: found second cluster in chamber(1..): " << ch1+1 |
454 | << " (Global Chi2 = " << chi2WithTwoClusters << ")" << endl; | |
ea94c18b | 455 | } |
456 | ||
3304fa09 | 457 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 458 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters |
ea94c18b | 459 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 460 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1,extrapTrackParamAtCluster2); |
208f139e | 461 | fNRecTracks++; |
ea94c18b | 462 | |
96ebe67e | 463 | // Tag clusterCh1 as used |
464 | clusterCh1Used[iCluster1] = kTRUE; | |
ea94c18b | 465 | |
208f139e | 466 | // Printout for debuging |
467 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 468 | cout << "FollowTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl; |
208f139e | 469 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
a9e2aefa | 470 | } |
ea94c18b | 471 | |
96ebe67e | 472 | } else if (chi2WithTwoClusters < bestChi2WithTwoClusters) { |
473 | // keep track of the best couple of clusters | |
474 | bestChi2WithTwoClusters = chi2WithTwoClusters; | |
475 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
476 | bestTrackParamAtCluster2 = extrapTrackParamAtCluster2; | |
208f139e | 477 | } |
ea94c18b | 478 | |
a9e2aefa | 479 | } |
ea94c18b | 480 | |
d0bfce8d | 481 | } |
ea94c18b | 482 | |
96ebe67e | 483 | // if no clusterCh1 found then consider to add clusterCh2 only |
484 | if (!foundSecondCluster) { | |
485 | foundOneCluster = kTRUE; | |
ea94c18b | 486 | |
3304fa09 | 487 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 488 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 489 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 490 | UpdateTrack(*newTrack,extrapTrackParamAtCluster2); |
208f139e | 491 | fNRecTracks++; |
ea94c18b | 492 | |
208f139e | 493 | // Printout for debuging |
494 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 495 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl; |
208f139e | 496 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
497 | } | |
ea94c18b | 498 | |
96ebe67e | 499 | } else if (!foundTwoClusters && chi2WithOneCluster < bestChi2WithOneCluster) { |
500 | // keep track of the best single cluster except if a couple of clusters has already been found | |
501 | bestChi2WithOneCluster = chi2WithOneCluster; | |
502 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster2; | |
208f139e | 503 | } |
ea94c18b | 504 | |
d0bfce8d | 505 | } |
ea94c18b | 506 | |
208f139e | 507 | } |
ea94c18b | 508 | |
208f139e | 509 | } |
ea94c18b | 510 | |
208f139e | 511 | // look for candidates in chamber 1 not already attached to a track |
96ebe67e | 512 | // if we want to keep all possible tracks or if no good couple of clusters has been found |
513 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks() || !foundTwoClusters) { | |
ea94c18b | 514 | |
515 | // Printout for debuging | |
208f139e | 516 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { |
96ebe67e | 517 | cout << "FollowTrackInStation: look for single clusters in chamber(1..): " << ch1+1 << endl; |
208f139e | 518 | } |
ea94c18b | 519 | |
520 | // add MCS effect for next step | |
019df241 | 521 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
522 | ||
523 | //Extrapolate trackCandidate to chamber "ch1" | |
524 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1)); | |
525 | ||
96ebe67e | 526 | // reset cluster iterator of chamber 1 |
527 | nextInCh1.Reset(); | |
528 | iCluster1 = -1; | |
529 | ||
530 | // look for second candidates in chamber 1 | |
531 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
532 | iCluster1++; | |
ea94c18b | 533 | |
96ebe67e | 534 | if (clusterCh1Used[iCluster1]) continue; // Skip cluster already used |
ea94c18b | 535 | |
96ebe67e | 536 | // try to add the current cluster fast |
537 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh1)) continue; | |
019df241 | 538 | |
96ebe67e | 539 | // try to add the current cluster accuratly |
540 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh1, extrapTrackParamAtCluster1); | |
ea94c18b | 541 | |
96ebe67e | 542 | // if good chi2 then consider to add clusterCh1 |
543 | // We do not try to attach a cluster in the other chamber too since it has already been done above | |
544 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
545 | foundOneCluster = kTRUE; | |
ea94c18b | 546 | |
547 | // Printout for debuging | |
548 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 549 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1 |
550 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
ea94c18b | 551 | } |
552 | ||
3304fa09 | 553 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 554 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 555 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 556 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1); |
208f139e | 557 | fNRecTracks++; |
ea94c18b | 558 | |
559 | // Printout for debuging | |
208f139e | 560 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { |
96ebe67e | 561 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl; |
208f139e | 562 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
563 | } | |
ea94c18b | 564 | |
96ebe67e | 565 | } else if (chi2WithOneCluster < bestChi2WithOneCluster) { |
566 | // keep track of the best single cluster except if a couple of clusters has already been found | |
567 | bestChi2WithOneCluster = chi2WithOneCluster; | |
568 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
208f139e | 569 | } |
ea94c18b | 570 | |
d0bfce8d | 571 | } |
ea94c18b | 572 | |
208f139e | 573 | } |
ea94c18b | 574 | |
208f139e | 575 | } |
ea94c18b | 576 | |
208f139e | 577 | // fill out the best track if required else clean up the fRecTracksPtr array |
3304fa09 | 578 | if (!AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 579 | if (foundTwoClusters) { |
580 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestTrackParamAtCluster2); | |
ea94c18b | 581 | |
208f139e | 582 | // Printout for debuging |
583 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 584 | cout << "FollowTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl; |
208f139e | 585 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
a9e2aefa | 586 | } |
ea94c18b | 587 | |
96ebe67e | 588 | } else if (foundOneCluster) { |
589 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1); | |
ea94c18b | 590 | |
208f139e | 591 | // Printout for debuging |
592 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 593 | cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl; |
208f139e | 594 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
04b5ea16 | 595 | } |
ea94c18b | 596 | |
dd230855 | 597 | } else { |
96ebe67e | 598 | delete [] clusterCh1Used; |
dd230855 | 599 | return kFALSE; |
600 | } | |
ea94c18b | 601 | |
96ebe67e | 602 | } else if (foundOneCluster || foundTwoClusters) { |
ea94c18b | 603 | |
604 | // remove obsolete track | |
605 | fRecTracksPtr->Remove(&trackCandidate); | |
606 | fNRecTracks--; | |
607 | ||
dd230855 | 608 | } else { |
96ebe67e | 609 | delete [] clusterCh1Used; |
dd230855 | 610 | return kFALSE; |
611 | } | |
ea94c18b | 612 | |
96ebe67e | 613 | delete [] clusterCh1Used; |
ea94c18b | 614 | return kTRUE; |
615 | ||
616 | } | |
617 | ||
618 | //__________________________________________________________________________ | |
96ebe67e | 619 | Double_t AliMUONTrackReconstructor::TryTwoClusters(const AliMUONTrackParam &trackParamAtCluster1, AliMUONVCluster* cluster2, |
620 | AliMUONTrackParam &trackParamAtCluster2) | |
ea94c18b | 621 | { |
96ebe67e | 622 | /// Test the compatibility between the track and the 2 clusters together (using trackParam's covariance matrix): |
623 | /// return the corresponding Chi2 accounting for covariances between the 2 clusters | |
624 | /// return trackParamAtCluster1 & 2 | |
ea94c18b | 625 | |
96ebe67e | 626 | // extrapolate track parameters at the z position of the second cluster (no need to extrapolate the covariances) |
627 | trackParamAtCluster2.SetParameters(trackParamAtCluster1.GetParameters()); | |
628 | trackParamAtCluster2.SetZ(trackParamAtCluster1.GetZ()); | |
629 | AliMUONTrackExtrap::ExtrapToZ(&trackParamAtCluster2, cluster2->GetZ()); | |
ea94c18b | 630 | |
96ebe67e | 631 | // set pointer to cluster2 into trackParamAtCluster2 |
632 | trackParamAtCluster2.SetClusterPtr(cluster2); | |
ea94c18b | 633 | |
96ebe67e | 634 | // Set differences between track and the 2 clusters in the bending and non bending directions |
635 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
ea94c18b | 636 | TMatrixD dPos(4,1); |
96ebe67e | 637 | dPos(0,0) = cluster1->GetX() - trackParamAtCluster1.GetNonBendingCoor(); |
638 | dPos(1,0) = cluster1->GetY() - trackParamAtCluster1.GetBendingCoor(); | |
639 | dPos(2,0) = cluster2->GetX() - trackParamAtCluster2.GetNonBendingCoor(); | |
640 | dPos(3,0) = cluster2->GetY() - trackParamAtCluster2.GetBendingCoor(); | |
ea94c18b | 641 | |
96ebe67e | 642 | // Calculate the error matrix from the track parameter covariances at first cluster |
ea94c18b | 643 | TMatrixD error(4,4); |
644 | error.Zero(); | |
96ebe67e | 645 | if (trackParamAtCluster1.CovariancesExist()) { |
646 | // Save track parameters at first cluster | |
647 | TMatrixD paramAtCluster1Save(trackParamAtCluster1.GetParameters()); | |
648 | ||
649 | // Save track coordinates at second cluster | |
650 | Double_t nonBendingCoor2 = trackParamAtCluster2.GetNonBendingCoor(); | |
651 | Double_t bendingCoor2 = trackParamAtCluster2.GetBendingCoor(); | |
ea94c18b | 652 | |
96ebe67e | 653 | // copy track parameters at first cluster for jacobian calculation |
654 | AliMUONTrackParam trackParam(trackParamAtCluster1); | |
ea94c18b | 655 | |
96ebe67e | 656 | // add MCS effect to the covariance matrix at first cluster |
657 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
ea94c18b | 658 | |
96ebe67e | 659 | // Get the pointer to the parameter covariance matrix at first cluster |
660 | const TMatrixD& kParamCov = trackParam.GetCovariances(); | |
ea94c18b | 661 | |
662 | // Calculate the jacobian related to the transformation between track parameters | |
96ebe67e | 663 | // at first cluster and track coordinates at the 2 cluster z-positions |
ea94c18b | 664 | TMatrixD jacob(4,5); |
665 | jacob.Zero(); | |
96ebe67e | 666 | // first derivative at the first cluster: |
ea94c18b | 667 | jacob(0,0) = 1.; // dx1/dx |
668 | jacob(1,2) = 1.; // dy1/dy | |
96ebe67e | 669 | // first derivative at the second cluster: |
ea94c18b | 670 | TMatrixD dParam(5,1); |
671 | for (Int_t i=0; i<5; i++) { | |
672 | // Skip jacobian calculation for parameters with no associated error | |
673 | if (kParamCov(i,i) == 0.) continue; | |
674 | // Small variation of parameter i only | |
675 | for (Int_t j=0; j<5; j++) { | |
676 | if (j==i) { | |
677 | dParam(j,0) = TMath::Sqrt(kParamCov(i,i)); | |
96ebe67e | 678 | if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramAtCluster1Save(4,0)); // variation always in the same direction |
ea94c18b | 679 | } else dParam(j,0) = 0.; |
680 | } | |
681 | ||
96ebe67e | 682 | // Set new track parameters at first cluster |
683 | trackParam.SetParameters(paramAtCluster1Save); | |
684 | trackParam.AddParameters(dParam); | |
685 | trackParam.SetZ(cluster1->GetZ()); | |
ea94c18b | 686 | |
96ebe67e | 687 | // Extrapolate new track parameters to the z position of the second cluster |
688 | AliMUONTrackExtrap::ExtrapToZ(&trackParam,cluster2->GetZ()); | |
ea94c18b | 689 | |
690 | // Calculate the jacobian | |
96ebe67e | 691 | jacob(2,i) = (trackParam.GetNonBendingCoor() - nonBendingCoor2) / dParam(i,0); // dx2/dParami |
692 | jacob(3,i) = (trackParam.GetBendingCoor() - bendingCoor2 ) / dParam(i,0); // dy2/dParami | |
208f139e | 693 | } |
ea94c18b | 694 | |
695 | // Calculate the error matrix | |
696 | TMatrixD tmp(jacob,TMatrixD::kMult,kParamCov); | |
697 | error = TMatrixD(tmp,TMatrixD::kMultTranspose,jacob); | |
698 | } | |
699 | ||
96ebe67e | 700 | // Add cluster resolution to the error matrix |
701 | error(0,0) += cluster1->GetErrX2(); | |
702 | error(1,1) += cluster1->GetErrY2(); | |
703 | error(2,2) += cluster2->GetErrX2(); | |
704 | error(3,3) += cluster2->GetErrY2(); | |
ea94c18b | 705 | |
706 | // invert the error matrix for Chi2 calculation | |
707 | if (error.Determinant() != 0) { | |
708 | error.Invert(); | |
208f139e | 709 | } else { |
ea94c18b | 710 | AliWarning(" Determinant error=0"); |
711 | return 1.e10; | |
208f139e | 712 | } |
713 | ||
ea94c18b | 714 | // Compute the Chi2 value |
715 | TMatrixD tmp2(dPos,TMatrixD::kTransposeMult,error); | |
716 | TMatrixD result(tmp2,TMatrixD::kMult,dPos); | |
717 | ||
718 | return result(0,0); | |
719 | ||
720 | } | |
721 | ||
722 | //__________________________________________________________________________ | |
96ebe67e | 723 | void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster) |
ea94c18b | 724 | { |
96ebe67e | 725 | /// Add 1 cluster to the track candidate |
ea94c18b | 726 | /// Update chi2 of the track |
727 | ||
728 | // Compute local chi2 | |
96ebe67e | 729 | AliMUONVCluster* cluster = trackParamAtCluster.GetClusterPtr(); |
730 | Double_t deltaX = trackParamAtCluster.GetNonBendingCoor() - cluster->GetX(); | |
731 | Double_t deltaY = trackParamAtCluster.GetBendingCoor() - cluster->GetY(); | |
732 | Double_t localChi2 = deltaX*deltaX / cluster->GetErrX2() + | |
733 | deltaY*deltaY / cluster->GetErrY2(); | |
ea94c18b | 734 | |
96ebe67e | 735 | // Flag cluster as being not removable |
736 | trackParamAtCluster.SetRemovable(kFALSE); | |
737 | trackParamAtCluster.SetLocalChi2(0.); // --> Local chi2 not used | |
5f4ceff2 | 738 | |
ea94c18b | 739 | // Update the chi2 of the new track |
96ebe67e | 740 | track.SetGlobalChi2(track.GetGlobalChi2() + localChi2); |
ea94c18b | 741 | |
96ebe67e | 742 | // Update TrackParamAtCluster |
743 | track.AddTrackParamAtCluster(trackParamAtCluster,*cluster); | |
744 | track.GetTrackParamAtCluster()->Sort(); | |
ea94c18b | 745 | |
04b5ea16 | 746 | } |
747 | ||
de2cd600 | 748 | //__________________________________________________________________________ |
96ebe67e | 749 | void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster1, AliMUONTrackParam &trackParamAtCluster2) |
ea94c18b | 750 | { |
96ebe67e | 751 | /// Add 2 clusters to the track candidate |
ea94c18b | 752 | /// Update track and local chi2 |
753 | ||
96ebe67e | 754 | // Update local chi2 at first cluster |
755 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
756 | Double_t deltaX = trackParamAtCluster1.GetNonBendingCoor() - cluster1->GetX(); | |
757 | Double_t deltaY = trackParamAtCluster1.GetBendingCoor() - cluster1->GetY(); | |
758 | Double_t localChi2AtCluster1 = deltaX*deltaX / cluster1->GetErrX2() + | |
759 | deltaY*deltaY / cluster1->GetErrY2(); | |
760 | trackParamAtCluster1.SetLocalChi2(localChi2AtCluster1); | |
ea94c18b | 761 | |
96ebe67e | 762 | // Flag first cluster as being removable |
763 | trackParamAtCluster1.SetRemovable(kTRUE); | |
ea94c18b | 764 | |
96ebe67e | 765 | // Update local chi2 at second cluster |
766 | AliMUONVCluster* cluster2 = trackParamAtCluster2.GetClusterPtr(); | |
767 | deltaX = trackParamAtCluster2.GetNonBendingCoor() - cluster2->GetX(); | |
768 | deltaY = trackParamAtCluster2.GetBendingCoor() - cluster2->GetY(); | |
769 | Double_t localChi2AtCluster2 = deltaX*deltaX / cluster2->GetErrX2() + | |
770 | deltaY*deltaY / cluster2->GetErrY2(); | |
771 | trackParamAtCluster2.SetLocalChi2(localChi2AtCluster2); | |
ea94c18b | 772 | |
96ebe67e | 773 | // Flag first cluster as being removable |
774 | trackParamAtCluster2.SetRemovable(kTRUE); | |
ea94c18b | 775 | |
776 | // Update the chi2 of the new track | |
96ebe67e | 777 | track.SetGlobalChi2(track.GetGlobalChi2() + localChi2AtCluster1 + localChi2AtCluster2); |
ea94c18b | 778 | |
96ebe67e | 779 | // Update TrackParamAtCluster |
780 | track.AddTrackParamAtCluster(trackParamAtCluster1,*cluster1); | |
781 | track.AddTrackParamAtCluster(trackParamAtCluster2,*cluster2); | |
782 | track.GetTrackParamAtCluster()->Sort(); | |
ea94c18b | 783 | |
784 | } | |
785 | ||
786 | //__________________________________________________________________________ | |
1fef78c8 | 787 | Bool_t AliMUONTrackReconstructor::RecoverTrack(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
ea94c18b | 788 | { |
789 | /// Try to recover the track candidate in the next station | |
96ebe67e | 790 | /// by removing the worst of the two clusters attached in the current station |
ea94c18b | 791 | /// Return kTRUE if recovering succeeds |
792 | AliDebug(1,"Enter RecoverTrack"); | |
793 | ||
96ebe67e | 794 | // Do not try to recover track until we have attached cluster(s) on station(1..) 3 |
ea94c18b | 795 | if (nextStation > 1) return kFALSE; |
796 | ||
96ebe67e | 797 | Int_t worstClusterNumber = -1; |
ea94c18b | 798 | Double_t localChi2, worstLocalChi2 = 0.; |
799 | ||
96ebe67e | 800 | // Look for the cluster to remove |
801 | for (Int_t clusterNumber = 0; clusterNumber < 2; clusterNumber++) { | |
802 | AliMUONTrackParam *trackParamAtCluster = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(clusterNumber); | |
ea94c18b | 803 | |
96ebe67e | 804 | // check if current cluster is removable |
805 | if (!trackParamAtCluster->IsRemovable()) return kFALSE; | |
ea94c18b | 806 | |
96ebe67e | 807 | // Pick up cluster with the worst chi2 |
808 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
ea94c18b | 809 | if (localChi2 > worstLocalChi2) { |
810 | worstLocalChi2 = localChi2; | |
96ebe67e | 811 | worstClusterNumber = clusterNumber; |
ea94c18b | 812 | } |
813 | } | |
814 | ||
96ebe67e | 815 | // Reset best cluster as being NOT removable |
816 | ((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt((worstClusterNumber+1)%2))->SetRemovable(kFALSE); | |
ea94c18b | 817 | |
96ebe67e | 818 | // Remove the worst cluster |
819 | trackCandidate.RemoveTrackParamAtCluster((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(worstClusterNumber)); | |
ea94c18b | 820 | |
821 | // Re-fit the track: | |
822 | // Do not take into account the multiple scattering to speed up the fit | |
823 | // Calculate the track parameter covariance matrix | |
96ebe67e | 824 | Fit(trackCandidate, kFALSE, kFALSE, kTRUE); |
ea94c18b | 825 | |
96ebe67e | 826 | // Look for new cluster(s) in next station |
827 | return FollowTrackInStation(trackCandidate,clusterStore,nextStation); | |
ea94c18b | 828 | |
829 | } | |
830 | ||
831 | //__________________________________________________________________________ | |
96ebe67e | 832 | void AliMUONTrackReconstructor::SetVertexErrXY2ForFit(AliMUONTrack &trackCandidate) |
de2cd600 | 833 | { |
96ebe67e | 834 | /// Compute the vertex resolution square from natural vertex dispersion and |
208f139e | 835 | /// multiple scattering effets according to trackCandidate path in absorber |
836 | /// It is necessary to account for multiple scattering effects here instead of during the fit of | |
837 | /// the "trackCandidate" to do not influence the result by changing track resolution at vertex | |
838 | AliDebug(1,"Enter SetVertexForFit"); | |
de2cd600 | 839 | |
3304fa09 | 840 | Double_t nonBendingReso2 = AliMUONReconstructor::GetRecoParam()->GetNonBendingVertexDispersion() * |
841 | AliMUONReconstructor::GetRecoParam()->GetNonBendingVertexDispersion(); | |
842 | Double_t bendingReso2 = AliMUONReconstructor::GetRecoParam()->GetBendingVertexDispersion() * | |
843 | AliMUONReconstructor::GetRecoParam()->GetBendingVertexDispersion(); | |
96ebe67e | 844 | |
208f139e | 845 | // add multiple scattering effets |
96ebe67e | 846 | AliMUONTrackParam paramAtVertex(*((AliMUONTrackParam*)(trackCandidate.GetTrackParamAtCluster()->First()))); |
208f139e | 847 | paramAtVertex.DeleteCovariances(); // to be sure to account only for multiple scattering |
848 | AliMUONTrackExtrap::ExtrapToVertexUncorrected(¶mAtVertex,0.); | |
ea94c18b | 849 | const TMatrixD& kParamCov = paramAtVertex.GetCovariances(); |
850 | nonBendingReso2 += kParamCov(0,0); | |
851 | bendingReso2 += kParamCov(2,2); | |
96ebe67e | 852 | |
853 | // Set the vertex resolution square | |
854 | trackCandidate.SetVertexErrXY2(nonBendingReso2,bendingReso2); | |
208f139e | 855 | } |
856 | ||
857 | //__________________________________________________________________________ | |
96ebe67e | 858 | void AliMUONTrackReconstructor::Fit(AliMUONTrack &track, Bool_t includeMCS, Bool_t fitWithVertex, Bool_t calcCov) |
208f139e | 859 | { |
96ebe67e | 860 | /// Fit the track |
861 | /// w/wo multiple Coulomb scattering according to "includeMCS". | |
862 | /// w/wo constraining the vertex according to "fitWithVertex". | |
863 | /// calculating or not the covariance matrix according to "calcCov". | |
de2cd600 | 864 | |
208f139e | 865 | Double_t benC, errorParam, invBenP, nonBenC, x, y; |
de2cd600 | 866 | AliMUONTrackParam *trackParam; |
96ebe67e | 867 | Double_t arg[1], fedm, errdef, globalChi2; |
208f139e | 868 | Int_t npari, nparx; |
869 | Int_t status, covStatus; | |
870 | ||
8cde4af5 | 871 | // Instantiate gMinuit if not already done |
872 | if (!gMinuit) gMinuit = new TMinuit(6); | |
208f139e | 873 | // Clear MINUIT parameters |
874 | gMinuit->mncler(); | |
875 | // Give the fitted track to MINUIT | |
ea94c18b | 876 | gMinuit->SetObjectFit(&track); |
208f139e | 877 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { |
878 | // Define print level | |
879 | arg[0] = 1; | |
880 | gMinuit->mnexcm("SET PRI", arg, 1, status); | |
881 | // Print covariance matrix | |
882 | gMinuit->mnexcm("SHO COV", arg, 0, status); | |
883 | } else { | |
884 | arg[0] = -1; | |
885 | gMinuit->mnexcm("SET PRI", arg, 1, status); | |
886 | } | |
de2cd600 | 887 | // No warnings |
208f139e | 888 | gMinuit->mnexcm("SET NOW", arg, 0, status); |
889 | // Define strategy | |
890 | //arg[0] = 2; | |
891 | //gMinuit->mnexcm("SET STR", arg, 1, status); | |
892 | ||
ea94c18b | 893 | // set flag w/wo multiple scattering according to "includeMCS" |
96ebe67e | 894 | track.FitWithMCS(includeMCS); |
ea94c18b | 895 | if (includeMCS) { |
96ebe67e | 896 | // compute cluster weights only once |
897 | if (!track.ComputeClusterWeights()) { | |
ea94c18b | 898 | AliWarning("cannot take into account the multiple scattering effects"); |
96ebe67e | 899 | track.FitWithMCS(kFALSE); |
ea94c18b | 900 | } |
901 | } | |
902 | ||
96ebe67e | 903 | track.FitWithVertex(fitWithVertex); |
904 | if (fitWithVertex) SetVertexErrXY2ForFit(track); | |
905 | ||
ea94c18b | 906 | // Set fitting function |
907 | gMinuit->SetFCN(TrackChi2); | |
208f139e | 908 | |
909 | // Set fitted parameters (!! The order is very important for the covariance matrix !!) | |
96ebe67e | 910 | trackParam = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->First()); |
de2cd600 | 911 | // could be tried with no limits for the search (min=max=0) ???? |
208f139e | 912 | // mandatory limits in non Bending to avoid NaN values of parameters |
913 | gMinuit->mnparm(0, "X", trackParam->GetNonBendingCoor(), 0.03, -500.0, 500.0, status); | |
914 | gMinuit->mnparm(1, "NonBenS", trackParam->GetNonBendingSlope(), 0.001, -0.5, 0.5, status); | |
915 | // mandatory limits in Bending to avoid NaN values of parameters | |
916 | gMinuit->mnparm(2, "Y", trackParam->GetBendingCoor(), 0.10, -500.0, 500.0, status); | |
917 | gMinuit->mnparm(3, "BenS", trackParam->GetBendingSlope(), 0.001, -0.5, 0.5, status); | |
918 | gMinuit->mnparm(4, "InvBenP", trackParam->GetInverseBendingMomentum(), 0.003, -0.4, 0.4, status); | |
919 | ||
de2cd600 | 920 | // minimization |
208f139e | 921 | gMinuit->mnexcm("MIGRAD", arg, 0, status); |
922 | ||
923 | // Calculate the covariance matrix more accurately if required | |
924 | if (calcCov) gMinuit->mnexcm("HESSE", arg, 0, status); | |
8cde4af5 | 925 | |
de2cd600 | 926 | // get results into "invBenP", "benC", "nonBenC" ("x", "y") |
208f139e | 927 | gMinuit->GetParameter(0, x, errorParam); |
928 | trackParam->SetNonBendingCoor(x); | |
929 | gMinuit->GetParameter(1, nonBenC, errorParam); | |
de2cd600 | 930 | trackParam->SetNonBendingSlope(nonBenC); |
208f139e | 931 | gMinuit->GetParameter(2, y, errorParam); |
932 | trackParam->SetBendingCoor(y); | |
933 | gMinuit->GetParameter(3, benC, errorParam); | |
934 | trackParam->SetBendingSlope(benC); | |
935 | gMinuit->GetParameter(4, invBenP, errorParam); | |
936 | trackParam->SetInverseBendingMomentum(invBenP); | |
937 | ||
de2cd600 | 938 | // global result of the fit |
96ebe67e | 939 | gMinuit->mnstat(globalChi2, fedm, errdef, npari, nparx, covStatus); |
940 | track.SetGlobalChi2(globalChi2); | |
208f139e | 941 | |
942 | // Get the covariance matrix if required | |
943 | if (calcCov) { | |
944 | // Covariance matrix according to HESSE status | |
945 | // If problem then keep only the diagonal terms (variances) | |
946 | Double_t matrix[5][5]; | |
947 | gMinuit->mnemat(&matrix[0][0],5); | |
948 | if (covStatus == 3) trackParam->SetCovariances(matrix); | |
949 | else trackParam->SetVariances(matrix); | |
ea94c18b | 950 | } else trackParam->DeleteCovariances(); |
208f139e | 951 | |
de2cd600 | 952 | } |
953 | ||
954 | //__________________________________________________________________________ | |
ea94c18b | 955 | void TrackChi2(Int_t & /*nParam*/, Double_t * /*gradient*/, Double_t &chi2, Double_t *param, Int_t /*flag*/) |
de2cd600 | 956 | { |
ea94c18b | 957 | /// Return the "Chi2" to be minimized with Minuit for track fitting. |
96ebe67e | 958 | /// Assumes that the trackParamAtCluster are sorted according to increasing Z. |
959 | /// Track parameters at each cluster are updated accordingly. | |
ea94c18b | 960 | /// Vertex is used according to the flag "trackBeingFitted->GetFitWithVertex()". |
961 | /// Multiple Coulomb scattering is taken into account according to the flag "trackBeingFitted->GetFitWithMCS()". | |
208f139e | 962 | |
963 | AliMUONTrack *trackBeingFitted = (AliMUONTrack*) gMinuit->GetObjectFit(); | |
96ebe67e | 964 | AliMUONTrackParam* trackParamAtCluster = (AliMUONTrackParam*) trackBeingFitted->GetTrackParamAtCluster()->First(); |
208f139e | 965 | Double_t dX, dY; |
ea94c18b | 966 | chi2 = 0.; // initialize chi2 |
208f139e | 967 | |
ea94c18b | 968 | // update track parameters |
96ebe67e | 969 | trackParamAtCluster->SetNonBendingCoor(param[0]); |
970 | trackParamAtCluster->SetNonBendingSlope(param[1]); | |
971 | trackParamAtCluster->SetBendingCoor(param[2]); | |
972 | trackParamAtCluster->SetBendingSlope(param[3]); | |
973 | trackParamAtCluster->SetInverseBendingMomentum(param[4]); | |
974 | trackBeingFitted->UpdateTrackParamAtCluster(); | |
208f139e | 975 | |
976 | // Take the vertex into account in the fit if required | |
96ebe67e | 977 | if (trackBeingFitted->FitWithVertex()) { |
978 | Double_t nonBendingReso2,bendingReso2; | |
979 | trackBeingFitted->GetVertexErrXY2(nonBendingReso2,bendingReso2); | |
980 | if (nonBendingReso2 == 0. || bendingReso2 == 0.) chi2 += 1.e10; | |
981 | else { | |
982 | AliMUONTrackParam paramAtVertex(*trackParamAtCluster); | |
983 | AliMUONTrackExtrap::ExtrapToZ(¶mAtVertex, 0.); // vextex position = (0,0,0) | |
984 | dX = paramAtVertex.GetNonBendingCoor(); | |
985 | dY = paramAtVertex.GetBendingCoor(); | |
986 | chi2 += dX * dX / nonBendingReso2 + dY * dY / bendingReso2; | |
208f139e | 987 | } |
de2cd600 | 988 | } |
208f139e | 989 | |
ea94c18b | 990 | // compute chi2 w/wo multiple scattering |
96ebe67e | 991 | chi2 += trackBeingFitted->ComputeGlobalChi2(trackBeingFitted->FitWithMCS()); |
b709ac13 | 992 | |
993 | } | |
994 | ||
995 | //__________________________________________________________________________ | |
96ebe67e | 996 | void AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clusterStore) |
b709ac13 | 997 | { |
998 | /// Complete tracks by adding missing clusters (if there is an overlap between | |
999 | /// two detection elements, the track may have two clusters in the same chamber) | |
1000 | /// Re-fit track parameters and covariances | |
1001 | AliDebug(1,"Enter ComplementTracks"); | |
1002 | ||
1003 | Int_t chamberId, detElemId; | |
96ebe67e | 1004 | Double_t chi2OfCluster, bestChi2OfCluster; |
3304fa09 | 1005 | Double_t sigmaCut2 = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * |
1006 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); | |
96ebe67e | 1007 | Bool_t foundOneCluster, trackModified; |
1008 | AliMUONVCluster* cluster; | |
1009 | AliMUONTrackParam *trackParam, *nextTrackParam, copyOfTrackParam, trackParamAtCluster, bestTrackParamAtCluster; | |
b709ac13 | 1010 | |
1011 | // Remove double track to complete only "good" tracks | |
1012 | RemoveDoubleTracks(); | |
1013 | ||
1014 | AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First(); | |
1015 | while (track) { | |
1016 | trackModified = kFALSE; | |
1017 | ||
96ebe67e | 1018 | trackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->First(); |
b709ac13 | 1019 | while (trackParam) { |
96ebe67e | 1020 | foundOneCluster = kFALSE; |
1021 | bestChi2OfCluster = 2. * sigmaCut2; // 2 because 2 quantities in chi2 | |
1022 | chamberId = trackParam->GetClusterPtr()->GetChamberId(); | |
1023 | detElemId = trackParam->GetClusterPtr()->GetDetElemId(); | |
b709ac13 | 1024 | |
1025 | // prepare nextTrackParam before adding new cluster because of the sorting | |
96ebe67e | 1026 | nextTrackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->After(trackParam); |
b709ac13 | 1027 | |
1028 | // recover track parameters from local fit and put them into a copy of trackParam | |
1029 | copyOfTrackParam.SetZ(trackParam->GetZ()); | |
1030 | copyOfTrackParam.SetParameters(trackParam->GetSmoothParameters()); | |
1031 | copyOfTrackParam.SetCovariances(trackParam->GetSmoothCovariances()); | |
1032 | ||
96ebe67e | 1033 | // Create iterators to loop over clusters in current chamber |
1034 | TIter nextInCh(clusterStore.CreateChamberIterator(chamberId,chamberId)); | |
1035 | ||
b709ac13 | 1036 | // look for one second candidate in the same chamber |
96ebe67e | 1037 | while ( ( cluster = static_cast<AliMUONVCluster*>(nextInCh()) ) ) { |
b709ac13 | 1038 | |
1039 | // look for a cluster in another detection element | |
96ebe67e | 1040 | if (cluster->GetDetElemId() == detElemId) continue; |
b709ac13 | 1041 | |
96ebe67e | 1042 | // try to add the current cluster fast |
1043 | if (!TryOneClusterFast(copyOfTrackParam, cluster)) continue; | |
b709ac13 | 1044 | |
96ebe67e | 1045 | // try to add the current cluster accurately |
1046 | chi2OfCluster = TryOneCluster(copyOfTrackParam, cluster, trackParamAtCluster); | |
b709ac13 | 1047 | |
1048 | // if better chi2 then prepare to add this cluster to the track | |
96ebe67e | 1049 | if (chi2OfCluster < bestChi2OfCluster) { |
1050 | bestChi2OfCluster = chi2OfCluster; | |
1051 | bestTrackParamAtCluster = trackParamAtCluster; | |
1052 | foundOneCluster = kTRUE; | |
b709ac13 | 1053 | } |
1054 | ||
1055 | } | |
1056 | ||
1057 | // add new cluster if any | |
96ebe67e | 1058 | if (foundOneCluster) { |
1059 | UpdateTrack(*track,bestTrackParamAtCluster); | |
1060 | bestTrackParamAtCluster.SetAloneInChamber(kFALSE); | |
b709ac13 | 1061 | trackParam->SetAloneInChamber(kFALSE); |
1062 | trackModified = kTRUE; | |
1063 | } | |
1064 | ||
1065 | trackParam = nextTrackParam; | |
1066 | } | |
1067 | ||
1068 | // re-fit track parameters if needed | |
96ebe67e | 1069 | if (trackModified) Fit(*track, kTRUE, kFALSE, kTRUE); |
b709ac13 | 1070 | |
1071 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1072 | } | |
ea94c18b | 1073 | |
de2cd600 | 1074 | } |
1075 | ||
1076 | //__________________________________________________________________________ | |
ea94c18b | 1077 | void AliMUONTrackReconstructor::ImproveTracks() |
de2cd600 | 1078 | { |
ea94c18b | 1079 | /// Improve tracks by removing clusters with local chi2 highter than the defined cut |
1080 | /// Recompute track parameters and covariances at the remaining clusters | |
1081 | AliDebug(1,"Enter ImproveTracks"); | |
208f139e | 1082 | |
ea94c18b | 1083 | Double_t localChi2, worstLocalChi2; |
b709ac13 | 1084 | Int_t worstChamber, previousChamber; |
1085 | AliMUONTrack *track, *nextTrack; | |
96ebe67e | 1086 | AliMUONTrackParam *trackParamAtCluster, *worstTrackParamAtCluster, *previousTrackParam, *nextTrackParam; |
3304fa09 | 1087 | Double_t sigmaCut2 = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForImprovement() * |
1088 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForImprovement(); | |
208f139e | 1089 | |
ea94c18b | 1090 | // Remove double track to improve only "good" tracks |
1091 | RemoveDoubleTracks(); | |
1092 | ||
b709ac13 | 1093 | track = (AliMUONTrack*) fRecTracksPtr->First(); |
ea94c18b | 1094 | while (track) { |
1095 | ||
b709ac13 | 1096 | // prepare next track in case the actual track is suppressed |
1097 | nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1098 | ||
ea94c18b | 1099 | while (!track->IsImproved()) { |
1100 | ||
1101 | // Update track parameters and covariances | |
96ebe67e | 1102 | track->UpdateCovTrackParamAtCluster(); |
ea94c18b | 1103 | |
96ebe67e | 1104 | // Compute local chi2 of each clusters |
ea94c18b | 1105 | track->ComputeLocalChi2(kTRUE); |
1106 | ||
96ebe67e | 1107 | // Look for the cluster to remove |
1108 | worstTrackParamAtCluster = NULL; | |
ea94c18b | 1109 | worstLocalChi2 = 0.; |
96ebe67e | 1110 | trackParamAtCluster = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First(); |
1111 | while (trackParamAtCluster) { | |
ea94c18b | 1112 | |
96ebe67e | 1113 | // Pick up cluster with the worst chi2 |
1114 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
ea94c18b | 1115 | if (localChi2 > worstLocalChi2) { |
1116 | worstLocalChi2 = localChi2; | |
96ebe67e | 1117 | worstTrackParamAtCluster = trackParamAtCluster; |
ea94c18b | 1118 | } |
1119 | ||
96ebe67e | 1120 | trackParamAtCluster = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParamAtCluster); |
de2cd600 | 1121 | } |
ea94c18b | 1122 | |
96ebe67e | 1123 | // Check if bad cluster found |
1124 | if (!worstTrackParamAtCluster) { | |
ea94c18b | 1125 | track->SetImproved(kTRUE); |
1126 | break; | |
de2cd600 | 1127 | } |
ea94c18b | 1128 | |
b709ac13 | 1129 | // Check whether the worst chi2 is under requirement or not |
3304fa09 | 1130 | if (worstLocalChi2 < 2. * sigmaCut2) { // 2 because 2 quantities in chi2 |
ea94c18b | 1131 | track->SetImproved(kTRUE); |
1132 | break; | |
de2cd600 | 1133 | } |
ea94c18b | 1134 | |
96ebe67e | 1135 | // if the worst cluster is not removable then remove the entire track |
1136 | if (!worstTrackParamAtCluster->IsRemovable() && worstTrackParamAtCluster->IsAloneInChamber()) { | |
b709ac13 | 1137 | fRecTracksPtr->Remove(track); |
1138 | fNRecTracks--; | |
ea94c18b | 1139 | break; |
1140 | } | |
1141 | ||
96ebe67e | 1142 | // Reset the second cluster in the same station as being not removable |
1143 | // or reset the second cluster in the same chamber as being alone | |
1144 | worstChamber = worstTrackParamAtCluster->GetClusterPtr()->GetChamberId(); | |
1145 | previousTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->Before(worstTrackParamAtCluster); | |
1146 | nextTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(worstTrackParamAtCluster); | |
1147 | if (worstTrackParamAtCluster->IsAloneInChamber()) { // Worst cluster removable and alone in chamber | |
b709ac13 | 1148 | |
1149 | if (worstChamber%2 == 0) { // Modify flags in next chamber | |
1150 | ||
1151 | nextTrackParam->SetRemovable(kFALSE); | |
96ebe67e | 1152 | if (!nextTrackParam->IsAloneInChamber()) // Make sure both clusters in second chamber are not removable anymore |
1153 | ((AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(nextTrackParam))->SetRemovable(kFALSE); | |
b709ac13 | 1154 | |
1155 | } else { // Modify flags in previous chamber | |
1156 | ||
1157 | previousTrackParam->SetRemovable(kFALSE); | |
96ebe67e | 1158 | if (!previousTrackParam->IsAloneInChamber()) // Make sure both clusters in second chamber are not removable anymore |
1159 | ((AliMUONTrackParam*) track->GetTrackParamAtCluster()->Before(previousTrackParam))->SetRemovable(kFALSE); | |
b709ac13 | 1160 | |
1161 | } | |
1162 | ||
96ebe67e | 1163 | } else { // Worst cluster not alone in its chamber |
b709ac13 | 1164 | |
96ebe67e | 1165 | if (previousTrackParam) previousChamber = previousTrackParam->GetClusterPtr()->GetChamberId(); |
b709ac13 | 1166 | else previousChamber = -1; |
1167 | ||
96ebe67e | 1168 | if (previousChamber == worstChamber) { // the second cluster on the same chamber is the previous one |
b709ac13 | 1169 | |
1170 | previousTrackParam->SetAloneInChamber(kTRUE); | |
96ebe67e | 1171 | // transfert the removability to the second cluster |
1172 | if (worstTrackParamAtCluster->IsRemovable()) previousTrackParam->SetRemovable(kTRUE); | |
b709ac13 | 1173 | |
96ebe67e | 1174 | } else { // the second cluster on the same chamber is the next one |
b709ac13 | 1175 | |
1176 | nextTrackParam->SetAloneInChamber(kTRUE); | |
96ebe67e | 1177 | // transfert the removability to the second cluster |
1178 | if (worstTrackParamAtCluster->IsRemovable()) nextTrackParam->SetRemovable(kTRUE); | |
b709ac13 | 1179 | |
1180 | } | |
1181 | ||
1182 | } | |
ea94c18b | 1183 | |
96ebe67e | 1184 | // Remove the worst cluster |
1185 | track->RemoveTrackParamAtCluster(worstTrackParamAtCluster); | |
ea94c18b | 1186 | |
1187 | // Re-fit the track: | |
1188 | // Take into account the multiple scattering | |
1189 | // Calculate the track parameter covariance matrix | |
96ebe67e | 1190 | Fit(*track, kTRUE, kFALSE, kTRUE); |
ea94c18b | 1191 | |
1192 | // Printout for debuging | |
1193 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
1194 | cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(track)+1 << " improved " << endl; | |
1195 | } | |
1196 | ||
de2cd600 | 1197 | } |
ea94c18b | 1198 | |
b709ac13 | 1199 | track = nextTrack; |
de2cd600 | 1200 | } |
1201 | ||
b709ac13 | 1202 | // compress the array in case of some tracks have been removed |
1203 | fRecTracksPtr->Compress(); | |
1204 | ||
de2cd600 | 1205 | } |
1206 | ||
208f139e | 1207 | //__________________________________________________________________________ |
ea94c18b | 1208 | void AliMUONTrackReconstructor::Finalize() |
b8dc484b | 1209 | { |
b58638a9 | 1210 | /// Recompute track parameters and covariances at each attached cluster from those at the first one |
b709ac13 | 1211 | |
b8dc484b | 1212 | AliMUONTrack *track; |
b58638a9 | 1213 | |
b8dc484b | 1214 | track = (AliMUONTrack*) fRecTracksPtr->First(); |
1215 | while (track) { | |
ea94c18b | 1216 | |
1217 | // update track parameters if not already done | |
96ebe67e | 1218 | if (!track->IsImproved()) track->UpdateCovTrackParamAtCluster(); |
ea94c18b | 1219 | |
b8dc484b | 1220 | track = (AliMUONTrack*) fRecTracksPtr->After(track); |
ea94c18b | 1221 | |
de2cd600 | 1222 | } |
96ebe67e | 1223 | |
a9e2aefa | 1224 | } |
1225 |