]>
Commit | Line | Data |
---|---|---|
8d0843c6 | 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 | ||
16 | /* $Id$ */ | |
17 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
c4ee792d | 19 | /// \class AliMUONVTrackReconstructor |
06ca6d7b | 20 | /// Virtual MUON track reconstructor in ALICE (class renamed from AliMUONEventReconstructor) |
21 | /// | |
96ebe67e | 22 | /// This class contains as data a pointer to the array of reconstructed tracks |
06ca6d7b | 23 | /// |
24 | /// It contains as methods, among others: | |
25 | /// * EventReconstruct to build the muon tracks | |
26 | /// * EventReconstructTrigger to build the trigger tracks | |
96ebe67e | 27 | /// * ValidateTracksWithTrigger to match tracker/trigger tracks |
06ca6d7b | 28 | /// |
96ebe67e | 29 | /// Several options and adjustable parameters are available for both KALMAN and ORIGINAL |
ad3c6eda | 30 | /// tracking algorithms. They can be changed through the AliMUONRecoParam object |
31 | /// set in the reconstruction macro or read from the CDB | |
32 | /// (see methods in AliMUONRecoParam.h file for details) | |
96ebe67e | 33 | /// |
34 | /// Main parameters and options are: | |
dfb547bf | 35 | /// - *fgkSigmaToCutForTracking* : quality cut used to select new clusters to be |
36 | /// attached to the track candidate and to select good tracks. | |
019df241 | 37 | /// - *fgkMakeTrackCandidatesFast* : if this flag is set to 'true', the track candidates |
38 | /// are made assuming linear propagation between stations 4 and 5. | |
dfb547bf | 39 | /// - *fgkTrackAllTracks* : according to the value of this flag, in case that several |
40 | /// new clusters pass the quality cut, either we consider all the possibilities | |
41 | /// (duplicating tracks) or we attach only the best cluster. | |
42 | /// - *fgkRecoverTracks* : if this flag is set to 'true', we try to recover the tracks | |
43 | /// lost during the tracking by removing the worst of the 2 clusters attached in the | |
44 | /// previous station. | |
45 | /// - *fgkImproveTracks* : if this flag is set to 'true', we try to improve the quality | |
46 | /// of the tracks at the end of the tracking by removing clusters that do not pass | |
3304fa09 | 47 | /// new quality cut (the track is removed is it does not contain enough cluster anymore). |
48 | /// - *fgkComplementTracks* : if this flag is set to 'true', we try to improve the quality | |
49 | /// of the tracks at the end of the tracking by adding potentially missing clusters | |
50 | /// (we may have 2 clusters in the same chamber because of the overlapping of detection | |
51 | /// elements, which is not handle by the tracking algorithm). | |
dfb547bf | 52 | /// - *fgkSigmaToCutForImprovement* : quality cut used when we try to improve the |
53 | /// quality of the tracks. | |
54 | /// | |
c4ee792d | 55 | /// \author Philippe Pillot |
3d1463c8 | 56 | //----------------------------------------------------------------------------- |
8d0843c6 | 57 | |
8d0843c6 | 58 | #include "AliMUONVTrackReconstructor.h" |
7ec3b9cf | 59 | |
8d0843c6 | 60 | #include "AliMUONConstants.h" |
208f139e | 61 | #include "AliMUONObjectPair.h" |
8d0843c6 | 62 | #include "AliMUONTriggerTrack.h" |
e1a10d41 | 63 | #include "AliMUONTriggerCircuit.h" |
8d0843c6 | 64 | #include "AliMUONLocalTrigger.h" |
65 | #include "AliMUONGlobalTrigger.h" | |
8d0843c6 | 66 | #include "AliMUONTrack.h" |
37827b29 | 67 | #include "AliMUONTrackParam.h" |
68 | #include "AliMUONTrackExtrap.h" | |
7771752e | 69 | #include "AliMUONTrackHitPattern.h" |
7ec3b9cf | 70 | #include "AliMUONVTrackStore.h" |
71 | #include "AliMUONVClusterStore.h" | |
2060b217 | 72 | #include "AliMUONVCluster.h" |
1fef78c8 | 73 | #include "AliMUONVClusterServer.h" |
7ec3b9cf | 74 | #include "AliMUONVTriggerStore.h" |
75 | #include "AliMUONVTriggerTrackStore.h" | |
ea94c18b | 76 | #include "AliMpDEManager.h" |
1fef78c8 | 77 | #include "AliMpArea.h" |
ea94c18b | 78 | |
79 | #include "AliLog.h" | |
b709ac13 | 80 | #include "AliCodeTimer.h" |
ea94c18b | 81 | #include "AliTracker.h" |
8d0843c6 | 82 | |
4889d34c | 83 | #include <TClonesArray.h> |
84 | #include <TMath.h> | |
ea94c18b | 85 | #include <TMatrixD.h> |
1fef78c8 | 86 | #include <TVector2.h> |
ea94c18b | 87 | |
88 | #include <Riostream.h> | |
4889d34c | 89 | |
78649106 | 90 | /// \cond CLASSIMP |
8d0843c6 | 91 | ClassImp(AliMUONVTrackReconstructor) // Class implementation in ROOT context |
78649106 | 92 | /// \endcond |
8d0843c6 | 93 | |
ea94c18b | 94 | //__________________________________________________________________________ |
a0dc65b4 | 95 | AliMUONVTrackReconstructor::AliMUONVTrackReconstructor(const AliMUONRecoParam* recoParam, |
96 | AliMUONVClusterServer* clusterServer) | |
97 | : TObject(), | |
98 | fRecTracksPtr(0x0), | |
99 | fNRecTracks(0), | |
100 | fClusterServer(clusterServer), | |
101 | fRecoParam(recoParam) | |
8d0843c6 | 102 | { |
103 | /// Constructor for class AliMUONVTrackReconstructor | |
b1fea02e | 104 | /// WARNING: if clusterServer=0x0, no clusterization will be possible at this level |
ea94c18b | 105 | |
106 | // Memory allocation for the TClonesArray of reconstructed tracks | |
96ebe67e | 107 | fRecTracksPtr = new TClonesArray("AliMUONTrack", 100); |
7ec3b9cf | 108 | |
208f139e | 109 | // set the magnetic field for track extrapolations |
f7a1cc68 | 110 | AliMUONTrackExtrap::SetField(); |
8d0843c6 | 111 | } |
112 | ||
113 | //__________________________________________________________________________ | |
ea94c18b | 114 | AliMUONVTrackReconstructor::~AliMUONVTrackReconstructor() |
8d0843c6 | 115 | { |
116 | /// Destructor for class AliMUONVTrackReconstructor | |
ea94c18b | 117 | delete fRecTracksPtr; |
8d0843c6 | 118 | } |
119 | ||
ea94c18b | 120 | //__________________________________________________________________________ |
121 | void AliMUONVTrackReconstructor::ResetTracks() | |
122 | { | |
123 | /// To reset the TClonesArray of reconstructed tracks | |
124 | if (fRecTracksPtr) fRecTracksPtr->Clear("C"); | |
125 | fNRecTracks = 0; | |
126 | return; | |
127 | } | |
128 | ||
129 | //__________________________________________________________________________ | |
1fef78c8 | 130 | void AliMUONVTrackReconstructor::EventReconstruct(AliMUONVClusterStore& clusterStore, AliMUONVTrackStore& trackStore) |
ea94c18b | 131 | { |
132 | /// To reconstruct one event | |
133 | AliDebug(1,""); | |
b709ac13 | 134 | AliCodeTimerAuto(""); |
ea94c18b | 135 | |
96ebe67e | 136 | // Reset array of tracks |
ea94c18b | 137 | ResetTracks(); |
2060b217 | 138 | |
9bf6860b | 139 | // Look for candidates from clusters in stations(1..) 4 and 5 |
96ebe67e | 140 | MakeTrackCandidates(clusterStore); |
141 | ||
9bf6860b | 142 | // Look for extra candidates from clusters in stations(1..) 4 and 5 |
a0dc65b4 | 143 | if (GetRecoParam()->MakeMoreTrackCandidates()) MakeMoreTrackCandidates(clusterStore); |
9bf6860b | 144 | |
96ebe67e | 145 | // Stop tracking if no candidate found |
ea94c18b | 146 | if (fRecTracksPtr->GetEntriesFast() == 0) return; |
96ebe67e | 147 | |
ea94c18b | 148 | // Follow tracks in stations(1..) 3, 2 and 1 |
96ebe67e | 149 | FollowTracks(clusterStore); |
150 | ||
b709ac13 | 151 | // Complement the reconstructed tracks |
a0dc65b4 | 152 | if (GetRecoParam()->ComplementTracks()) ComplementTracks(clusterStore); |
96ebe67e | 153 | |
ea94c18b | 154 | // Improve the reconstructed tracks |
a0dc65b4 | 155 | if (GetRecoParam()->ImproveTracks()) ImproveTracks(); |
96ebe67e | 156 | |
c59f70b9 | 157 | // Remove connected tracks |
158 | if (GetRecoParam()->RemoveConnectedTracksInSt12()) RemoveConnectedTracks(kFALSE); | |
159 | else RemoveConnectedTracks(kTRUE); | |
96ebe67e | 160 | |
ea94c18b | 161 | // Fill AliMUONTrack data members |
162 | Finalize(); | |
96ebe67e | 163 | |
164 | // Add tracks to MUON data container | |
165 | for (Int_t i=0; i<fNRecTracks; ++i) | |
166 | { | |
167 | AliMUONTrack * track = (AliMUONTrack*) fRecTracksPtr->At(i); | |
7332f213 | 168 | track->SetUniqueID(i+1); |
96ebe67e | 169 | trackStore.Add(*track); |
170 | } | |
ea94c18b | 171 | } |
172 | ||
8d0843c6 | 173 | //__________________________________________________________________________ |
9bf6860b | 174 | TClonesArray* AliMUONVTrackReconstructor::MakeSegmentsBetweenChambers(const AliMUONVClusterStore& clusterStore, Int_t ch1, Int_t ch2) |
8d0843c6 | 175 | { |
9bf6860b | 176 | /// To make the list of segments from the list of clusters in the 2 given chambers. |
208f139e | 177 | /// Return a new TClonesArray of segments. |
178 | /// It is the responsibility of the user to delete it afterward. | |
9bf6860b | 179 | AliDebug(1,Form("Enter MakeSegmentsBetweenChambers (1..) %d-%d", ch1+1, ch2+1)); |
208f139e | 180 | |
96ebe67e | 181 | AliMUONVCluster *cluster1, *cluster2; |
208f139e | 182 | AliMUONObjectPair *segment; |
9bf6860b | 183 | Double_t nonBendingSlope = 0, bendingSlope = 0, impactParam = 0., bendingMomentum = 0.; // to avoid compilation warning |
7ec3b9cf | 184 | |
96ebe67e | 185 | // Create iterators to loop over clusters in both chambers |
186 | TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1)); | |
187 | TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2)); | |
188 | ||
208f139e | 189 | // list of segments |
96ebe67e | 190 | TClonesArray *segments = new TClonesArray("AliMUONObjectPair", 100); |
7ec3b9cf | 191 | |
96ebe67e | 192 | // Loop over clusters in the first chamber of the station |
193 | while ( ( cluster1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
194 | ||
195 | // reset cluster iterator of chamber 2 | |
196 | nextInCh2.Reset(); | |
197 | ||
198 | // Loop over clusters in the second chamber of the station | |
199 | while ( ( cluster2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) { | |
200 | ||
9bf6860b | 201 | // non bending slope |
202 | nonBendingSlope = (cluster1->GetX() - cluster2->GetX()) / (cluster1->GetZ() - cluster2->GetZ()); | |
203 | ||
9f093251 | 204 | // check if non bending slope is within tolerances |
a0dc65b4 | 205 | if (TMath::Abs(nonBendingSlope) > GetRecoParam()->GetMaxNonBendingSlope()) continue; |
9f093251 | 206 | |
96ebe67e | 207 | // bending slope |
208 | bendingSlope = (cluster1->GetY() - cluster2->GetY()) / (cluster1->GetZ() - cluster2->GetZ()); | |
209 | ||
9f093251 | 210 | // check the bending momentum of the bending slope depending if the field is ON or OFF |
211 | if (AliMUONTrackExtrap::IsFieldON()) { | |
212 | ||
213 | // impact parameter | |
214 | impactParam = cluster1->GetY() - cluster1->GetZ() * bendingSlope; | |
215 | ||
216 | // absolute value of bending momentum | |
217 | bendingMomentum = TMath::Abs(AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(impactParam)); | |
218 | ||
219 | // check if bending momentum is within tolerances | |
a0dc65b4 | 220 | if (bendingMomentum < GetRecoParam()->GetMinBendingMomentum() || |
221 | bendingMomentum > GetRecoParam()->GetMaxBendingMomentum()) continue; | |
96ebe67e | 222 | |
9f093251 | 223 | } else { |
224 | ||
225 | // check if non bending slope is within tolerances | |
a0dc65b4 | 226 | if (TMath::Abs(bendingSlope) > GetRecoParam()->GetMaxBendingSlope()) continue; |
9f093251 | 227 | |
228 | } | |
229 | // make new segment | |
230 | segment = new ((*segments)[segments->GetLast()+1]) AliMUONObjectPair(cluster1, cluster2, kFALSE, kFALSE); | |
231 | ||
232 | // Printout for debug | |
233 | if (AliLog::GetGlobalDebugLevel() > 1) { | |
234 | cout << "segmentIndex(0...): " << segments->GetLast() << endl; | |
235 | segment->Dump(); | |
236 | cout << "Cluster in first chamber" << endl; | |
237 | cluster1->Print(); | |
238 | cout << "Cluster in second chamber" << endl; | |
239 | cluster2->Print(); | |
8d0843c6 | 240 | } |
96ebe67e | 241 | |
242 | } | |
243 | ||
244 | } | |
245 | ||
246 | // Printout for debug | |
9bf6860b | 247 | AliDebug(1,Form("chambers%d-%d: NSegments = %d ", ch1+1, ch2+1, segments->GetEntriesFast())); |
96ebe67e | 248 | |
208f139e | 249 | return segments; |
8d0843c6 | 250 | } |
251 | ||
ea94c18b | 252 | //__________________________________________________________________________ |
253 | void AliMUONVTrackReconstructor::RemoveIdenticalTracks() | |
254 | { | |
255 | /// To remove identical tracks: | |
96ebe67e | 256 | /// Tracks are considered identical if they have all their clusters in common. |
257 | /// One keeps the track with the larger number of clusters if need be | |
ea94c18b | 258 | AliMUONTrack *track1, *track2, *trackToRemove; |
96ebe67e | 259 | Int_t clustersInCommon, nClusters1, nClusters2; |
ea94c18b | 260 | Bool_t removedTrack1; |
261 | // Loop over first track of the pair | |
262 | track1 = (AliMUONTrack*) fRecTracksPtr->First(); | |
263 | while (track1) { | |
264 | removedTrack1 = kFALSE; | |
96ebe67e | 265 | nClusters1 = track1->GetNClusters(); |
ea94c18b | 266 | // Loop over second track of the pair |
267 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
268 | while (track2) { | |
96ebe67e | 269 | nClusters2 = track2->GetNClusters(); |
270 | // number of clusters in common between two tracks | |
271 | clustersInCommon = track1->ClustersInCommon(track2); | |
ea94c18b | 272 | // check for identical tracks |
96ebe67e | 273 | if ((clustersInCommon == nClusters1) || (clustersInCommon == nClusters2)) { |
ea94c18b | 274 | // decide which track to remove |
96ebe67e | 275 | if (nClusters2 > nClusters1) { |
ea94c18b | 276 | // remove track1 and continue the first loop with the track next to track1 |
277 | trackToRemove = track1; | |
278 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
279 | fRecTracksPtr->Remove(trackToRemove); | |
280 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
281 | fNRecTracks--; | |
282 | removedTrack1 = kTRUE; | |
283 | break; | |
284 | } else { | |
285 | // remove track2 and continue the second loop with the track next to track2 | |
286 | trackToRemove = track2; | |
287 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
288 | fRecTracksPtr->Remove(trackToRemove); | |
289 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
290 | fNRecTracks--; | |
291 | } | |
292 | } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
293 | } // track2 | |
294 | if (removedTrack1) continue; | |
295 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
296 | } // track1 | |
297 | return; | |
298 | } | |
299 | ||
300 | //__________________________________________________________________________ | |
301 | void AliMUONVTrackReconstructor::RemoveDoubleTracks() | |
302 | { | |
303 | /// To remove double tracks: | |
96ebe67e | 304 | /// Tracks are considered identical if more than half of the clusters of the track |
305 | /// which has the smaller number of clusters are in common with the other track. | |
306 | /// Among two identical tracks, one keeps the track with the larger number of clusters | |
ea94c18b | 307 | /// or, if these numbers are equal, the track with the minimum chi2. |
308 | AliMUONTrack *track1, *track2, *trackToRemove; | |
96ebe67e | 309 | Int_t clustersInCommon, nClusters1, nClusters2; |
ea94c18b | 310 | Bool_t removedTrack1; |
311 | // Loop over first track of the pair | |
312 | track1 = (AliMUONTrack*) fRecTracksPtr->First(); | |
313 | while (track1) { | |
314 | removedTrack1 = kFALSE; | |
96ebe67e | 315 | nClusters1 = track1->GetNClusters(); |
ea94c18b | 316 | // Loop over second track of the pair |
317 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
318 | while (track2) { | |
96ebe67e | 319 | nClusters2 = track2->GetNClusters(); |
320 | // number of clusters in common between two tracks | |
321 | clustersInCommon = track1->ClustersInCommon(track2); | |
ea94c18b | 322 | // check for identical tracks |
96ebe67e | 323 | if (((nClusters1 < nClusters2) && (2 * clustersInCommon > nClusters1)) || (2 * clustersInCommon > nClusters2)) { |
ea94c18b | 324 | // decide which track to remove |
96ebe67e | 325 | if ((nClusters1 > nClusters2) || ((nClusters1 == nClusters2) && (track1->GetGlobalChi2() <= track2->GetGlobalChi2()))) { |
ea94c18b | 326 | // remove track2 and continue the second loop with the track next to track2 |
327 | trackToRemove = track2; | |
328 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
329 | fRecTracksPtr->Remove(trackToRemove); | |
c59f70b9 | 330 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards |
331 | fNRecTracks--; | |
332 | } else { | |
333 | // else remove track1 and continue the first loop with the track next to track1 | |
334 | trackToRemove = track1; | |
335 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
336 | fRecTracksPtr->Remove(trackToRemove); | |
337 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
338 | fNRecTracks--; | |
339 | removedTrack1 = kTRUE; | |
340 | break; | |
341 | } | |
342 | } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
343 | } // track2 | |
344 | if (removedTrack1) continue; | |
345 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
346 | } // track1 | |
347 | return; | |
348 | } | |
349 | ||
350 | //__________________________________________________________________________ | |
351 | void AliMUONVTrackReconstructor::RemoveConnectedTracks(Bool_t inSt345) | |
352 | { | |
353 | /// To remove double tracks: | |
354 | /// Tracks are considered identical if they share 1 cluster or more. | |
355 | /// If inSt345=kTRUE only stations 3, 4 and 5 are considered. | |
356 | /// Among two identical tracks, one keeps the track with the larger number of clusters | |
357 | /// or, if these numbers are equal, the track with the minimum chi2. | |
358 | AliMUONTrack *track1, *track2, *trackToRemove; | |
359 | Int_t clustersInCommon, nClusters1, nClusters2; | |
360 | Bool_t removedTrack1; | |
361 | // Loop over first track of the pair | |
362 | track1 = (AliMUONTrack*) fRecTracksPtr->First(); | |
363 | while (track1) { | |
364 | removedTrack1 = kFALSE; | |
365 | nClusters1 = track1->GetNClusters(); | |
366 | // Loop over second track of the pair | |
367 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
368 | while (track2) { | |
369 | nClusters2 = track2->GetNClusters(); | |
370 | // number of clusters in common between two tracks | |
371 | clustersInCommon = track1->ClustersInCommon(track2, inSt345); | |
372 | // check for identical tracks | |
373 | if (clustersInCommon > 0) { | |
374 | // decide which track to remove | |
375 | if ((nClusters1 > nClusters2) || ((nClusters1 == nClusters2) && (track1->GetGlobalChi2() <= track2->GetGlobalChi2()))) { | |
376 | // remove track2 and continue the second loop with the track next to track2 | |
377 | trackToRemove = track2; | |
378 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
379 | fRecTracksPtr->Remove(trackToRemove); | |
ea94c18b | 380 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards |
381 | fNRecTracks--; | |
382 | } else { | |
383 | // else remove track1 and continue the first loop with the track next to track1 | |
384 | trackToRemove = track1; | |
385 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
386 | fRecTracksPtr->Remove(trackToRemove); | |
387 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
388 | fNRecTracks--; | |
389 | removedTrack1 = kTRUE; | |
390 | break; | |
391 | } | |
392 | } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
393 | } // track2 | |
394 | if (removedTrack1) continue; | |
395 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
396 | } // track1 | |
397 | return; | |
398 | } | |
399 | ||
1fef78c8 | 400 | //__________________________________________________________________________ |
9bf6860b | 401 | void AliMUONVTrackReconstructor::AskForNewClustersInChamber(const AliMUONTrackParam &trackParam, |
402 | AliMUONVClusterStore& clusterStore, Int_t chamber) | |
1fef78c8 | 403 | { |
404 | /// Ask the clustering to reconstruct new clusters around the track candidate position | |
1fef78c8 | 405 | |
9bf6860b | 406 | // check if the current chamber is useable |
a0dc65b4 | 407 | if (!fClusterServer || !GetRecoParam()->UseChamber(chamber)) return; |
1fef78c8 | 408 | |
9bf6860b | 409 | // maximum distance between the center of the chamber and a detection element |
410 | // (accounting for the inclination of the chamber) | |
b89ac3d6 | 411 | static const Double_t kMaxDZ = 15.; // 15 cm |
1fef78c8 | 412 | |
9bf6860b | 413 | // extrapolate track parameters to the chamber |
414 | AliMUONTrackParam extrapTrackParam(trackParam); | |
415 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(chamber)); | |
416 | ||
417 | // build the searching area using the track resolution and the maximum-distance-to-track value | |
418 | const TMatrixD& kParamCov = extrapTrackParam.GetCovariances(); | |
b89ac3d6 | 419 | Double_t errX2 = kParamCov(0,0) + kMaxDZ * kMaxDZ * kParamCov(1,1) + 2. * kMaxDZ * TMath::Abs(kParamCov(0,1)); |
420 | Double_t errY2 = kParamCov(2,2) + kMaxDZ * kMaxDZ * kParamCov(3,3) + 2. * kMaxDZ * TMath::Abs(kParamCov(2,3)); | |
421 | Double_t dX = TMath::Abs(trackParam.GetNonBendingSlope()) * kMaxDZ + | |
a0dc65b4 | 422 | GetRecoParam()->GetMaxNonBendingDistanceToTrack() + |
423 | GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errX2); | |
b89ac3d6 | 424 | Double_t dY = TMath::Abs(trackParam.GetBendingSlope()) * kMaxDZ + |
a0dc65b4 | 425 | GetRecoParam()->GetMaxBendingDistanceToTrack() + |
426 | GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errY2); | |
9bf6860b | 427 | TVector2 dimensions(dX, dY); |
1fef78c8 | 428 | TVector2 position(extrapTrackParam.GetNonBendingCoor(), extrapTrackParam.GetBendingCoor()); |
9bf6860b | 429 | AliMpArea area(position, dimensions); |
1fef78c8 | 430 | |
431 | // ask to cluterize in the given area of the given chamber | |
35be7ed7 | 432 | fClusterServer->Clusterize(chamber, clusterStore, area, GetRecoParam()); |
1fef78c8 | 433 | |
9bf6860b | 434 | } |
435 | ||
436 | //__________________________________________________________________________ | |
437 | void AliMUONVTrackReconstructor::AskForNewClustersInStation(const AliMUONTrackParam &trackParam, | |
438 | AliMUONVClusterStore& clusterStore, Int_t station) | |
439 | { | |
440 | /// Ask the clustering to reconstruct new clusters around the track candidate position | |
441 | /// in the 2 chambers of the given station | |
442 | AskForNewClustersInChamber(trackParam, clusterStore, 2*station+1); | |
443 | AskForNewClustersInChamber(trackParam, clusterStore, 2*station); | |
1fef78c8 | 444 | } |
445 | ||
ea94c18b | 446 | //__________________________________________________________________________ |
96ebe67e | 447 | Double_t AliMUONVTrackReconstructor::TryOneCluster(const AliMUONTrackParam &trackParam, AliMUONVCluster* cluster, |
1fef78c8 | 448 | AliMUONTrackParam &trackParamAtCluster, Bool_t updatePropagator) |
ea94c18b | 449 | { |
96ebe67e | 450 | /// Test the compatibility between the track and the cluster (using trackParam's covariance matrix): |
ea94c18b | 451 | /// return the corresponding Chi2 |
96ebe67e | 452 | /// return trackParamAtCluster |
ea94c18b | 453 | |
96ebe67e | 454 | // extrapolate track parameters and covariances at the z position of the tested cluster |
455 | trackParamAtCluster = trackParam; | |
456 | AliMUONTrackExtrap::ExtrapToZCov(&trackParamAtCluster, cluster->GetZ(), updatePropagator); | |
ea94c18b | 457 | |
96ebe67e | 458 | // set pointer to cluster into trackParamAtCluster |
459 | trackParamAtCluster.SetClusterPtr(cluster); | |
ea94c18b | 460 | |
96ebe67e | 461 | // Set differences between trackParam and cluster in the bending and non bending directions |
462 | Double_t dX = cluster->GetX() - trackParamAtCluster.GetNonBendingCoor(); | |
463 | Double_t dY = cluster->GetY() - trackParamAtCluster.GetBendingCoor(); | |
ea94c18b | 464 | |
019df241 | 465 | // Calculate errors and covariances |
96ebe67e | 466 | const TMatrixD& kParamCov = trackParamAtCluster.GetCovariances(); |
467 | Double_t sigmaX2 = kParamCov(0,0) + cluster->GetErrX2(); | |
468 | Double_t sigmaY2 = kParamCov(2,2) + cluster->GetErrY2(); | |
019df241 | 469 | |
470 | // Compute chi2 | |
96ebe67e | 471 | return dX * dX / sigmaX2 + dY * dY / sigmaY2; |
019df241 | 472 | |
473 | } | |
474 | ||
475 | //__________________________________________________________________________ | |
96ebe67e | 476 | Bool_t AliMUONVTrackReconstructor::TryOneClusterFast(const AliMUONTrackParam &trackParam, AliMUONVCluster* cluster) |
019df241 | 477 | { |
9bf6860b | 478 | /// Test the compatibility between the track and the cluster |
479 | /// given the track resolution + the maximum-distance-to-track value | |
480 | /// and assuming linear propagation of the track: | |
019df241 | 481 | /// return kTRUE if they are compatibles |
482 | ||
96ebe67e | 483 | Double_t dZ = cluster->GetZ() - trackParam.GetZ(); |
484 | Double_t dX = cluster->GetX() - (trackParam.GetNonBendingCoor() + trackParam.GetNonBendingSlope() * dZ); | |
485 | Double_t dY = cluster->GetY() - (trackParam.GetBendingCoor() + trackParam.GetBendingSlope() * dZ); | |
9bf6860b | 486 | const TMatrixD& kParamCov = trackParam.GetCovariances(); |
487 | Double_t errX2 = kParamCov(0,0) + dZ * dZ * kParamCov(1,1) + 2. * dZ * kParamCov(0,1); | |
488 | Double_t errY2 = kParamCov(2,2) + dZ * dZ * kParamCov(3,3) + 2. * dZ * kParamCov(2,3); | |
489 | ||
a0dc65b4 | 490 | Double_t dXmax = GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errX2) + |
491 | GetRecoParam()->GetMaxNonBendingDistanceToTrack(); | |
492 | Double_t dYmax = GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errY2) + | |
493 | GetRecoParam()->GetMaxBendingDistanceToTrack(); | |
019df241 | 494 | |
9bf6860b | 495 | if (TMath::Abs(dX) > dXmax || TMath::Abs(dY) > dYmax) return kFALSE; |
019df241 | 496 | |
497 | return kTRUE; | |
498 | ||
499 | } | |
500 | ||
501 | //__________________________________________________________________________ | |
96ebe67e | 502 | Double_t AliMUONVTrackReconstructor::TryTwoClustersFast(const AliMUONTrackParam &trackParamAtCluster1, AliMUONVCluster* cluster2, |
503 | AliMUONTrackParam &trackParamAtCluster2) | |
019df241 | 504 | { |
96ebe67e | 505 | /// Test the compatibility between the track and the 2 clusters together (using trackParam's covariance matrix) |
506 | /// assuming linear propagation between the two clusters: | |
507 | /// return the corresponding Chi2 accounting for covariances between the 2 clusters | |
508 | /// return trackParamAtCluster2 | |
019df241 | 509 | |
96ebe67e | 510 | // extrapolate linearly track parameters and covariances at the z position of the second cluster |
511 | trackParamAtCluster2 = trackParamAtCluster1; | |
512 | AliMUONTrackExtrap::LinearExtrapToZ(&trackParamAtCluster2, cluster2->GetZ()); | |
019df241 | 513 | |
96ebe67e | 514 | // set pointer to cluster2 into trackParamAtCluster2 |
515 | trackParamAtCluster2.SetClusterPtr(cluster2); | |
019df241 | 516 | |
96ebe67e | 517 | // Set differences between track and clusters in the bending and non bending directions |
518 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
519 | Double_t dX1 = cluster1->GetX() - trackParamAtCluster1.GetNonBendingCoor(); | |
520 | Double_t dX2 = cluster2->GetX() - trackParamAtCluster2.GetNonBendingCoor(); | |
521 | Double_t dY1 = cluster1->GetY() - trackParamAtCluster1.GetBendingCoor(); | |
522 | Double_t dY2 = cluster2->GetY() - trackParamAtCluster2.GetBendingCoor(); | |
019df241 | 523 | |
524 | // Calculate errors and covariances | |
96ebe67e | 525 | const TMatrixD& kParamCov1 = trackParamAtCluster1.GetCovariances(); |
526 | const TMatrixD& kParamCov2 = trackParamAtCluster2.GetCovariances(); | |
527 | Double_t dZ = trackParamAtCluster2.GetZ() - trackParamAtCluster1.GetZ(); | |
528 | Double_t sigma2X1 = kParamCov1(0,0) + cluster1->GetErrX2(); | |
529 | Double_t sigma2X2 = kParamCov2(0,0) + cluster2->GetErrX2(); | |
019df241 | 530 | Double_t covX1X2 = kParamCov1(0,0) + dZ * kParamCov1(0,1); |
96ebe67e | 531 | Double_t sigma2Y1 = kParamCov1(2,2) + cluster1->GetErrY2(); |
532 | Double_t sigma2Y2 = kParamCov2(2,2) + cluster2->GetErrY2(); | |
019df241 | 533 | Double_t covY1Y2 = kParamCov1(2,2) + dZ * kParamCov1(2,3); |
534 | ||
535 | // Compute chi2 | |
536 | Double_t detX = sigma2X1 * sigma2X2 - covX1X2 * covX1X2; | |
537 | Double_t detY = sigma2Y1 * sigma2Y2 - covY1Y2 * covY1Y2; | |
538 | if (detX == 0. || detY == 0.) return 1.e10; | |
539 | return (dX1 * dX1 * sigma2X2 + dX2 * dX2 * sigma2X1 - 2. * dX1 * dX2 * covX1X2) / detX | |
540 | + (dY1 * dY1 * sigma2Y2 + dY2 * dY2 * sigma2Y1 - 2. * dY1 * dY2 * covY1Y2) / detY; | |
541 | ||
542 | } | |
543 | ||
544 | //__________________________________________________________________________ | |
9bf6860b | 545 | Bool_t AliMUONVTrackReconstructor::FollowLinearTrackInChamber(AliMUONTrack &trackCandidate, const AliMUONVClusterStore& clusterStore, |
546 | Int_t nextChamber) | |
547 | { | |
548 | /// Follow trackCandidate in chamber(0..) nextChamber assuming linear propagation, and search for compatible cluster(s) | |
549 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: | |
550 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
551 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
552 | /// Remove the obsolete "trackCandidate" at the end. | |
553 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. | |
554 | /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE) | |
555 | AliDebug(1,Form("Enter FollowLinearTrackInChamber(1..) %d", nextChamber+1)); | |
556 | ||
557 | Double_t chi2WithOneCluster = 1.e10; | |
a0dc65b4 | 558 | Double_t maxChi2WithOneCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() * |
559 | GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
9bf6860b | 560 | Double_t bestChi2WithOneCluster = maxChi2WithOneCluster; |
561 | Bool_t foundOneCluster = kFALSE; | |
562 | AliMUONTrack *newTrack = 0x0; | |
563 | AliMUONVCluster *cluster; | |
564 | AliMUONTrackParam trackParam; | |
565 | AliMUONTrackParam extrapTrackParamAtCluster; | |
566 | AliMUONTrackParam bestTrackParamAtCluster; | |
567 | ||
568 | // Get track parameters according to the propagation direction | |
569 | if (nextChamber > 7) trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last(); | |
570 | else trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First(); | |
571 | ||
572 | // Printout for debuging | |
573 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
574 | cout<<endl<<"Track parameters and covariances at first cluster:"<<endl; | |
575 | trackParam.GetParameters().Print(); | |
576 | trackParam.GetCovariances().Print(); | |
577 | } | |
578 | ||
579 | // Add MCS effect | |
580 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
581 | ||
582 | // Printout for debuging | |
583 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
584 | cout << "FollowLinearTrackInChamber: look for cluster in chamber(1..): " << nextChamber+1 << endl; | |
585 | } | |
586 | ||
587 | // Create iterators to loop over clusters in chamber | |
588 | TIter next(clusterStore.CreateChamberIterator(nextChamber,nextChamber)); | |
589 | ||
590 | // look for candidates in chamber | |
591 | while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) { | |
592 | ||
593 | // try to add the current cluster fast | |
594 | if (!TryOneClusterFast(trackParam, cluster)) continue; | |
595 | ||
596 | // try to add the current cluster accuratly | |
597 | extrapTrackParamAtCluster = trackParam; | |
598 | AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster, cluster->GetZ()); | |
599 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster, cluster, extrapTrackParamAtCluster); | |
600 | ||
601 | // if good chi2 then consider to add cluster | |
602 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
603 | foundOneCluster = kTRUE; | |
604 | ||
605 | // Printout for debuging | |
606 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
607 | cout << "FollowLinearTrackInChamber: found one cluster in chamber(1..): " << nextChamber+1 | |
608 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
609 | cluster->Print(); | |
610 | } | |
611 | ||
a0dc65b4 | 612 | if (GetRecoParam()->TrackAllTracks()) { |
9bf6860b | 613 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
614 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); | |
a0dc65b4 | 615 | if (GetRecoParam()->RequestStation(nextChamber/2)) |
9bf6860b | 616 | extrapTrackParamAtCluster.SetRemovable(kFALSE); |
617 | else extrapTrackParamAtCluster.SetRemovable(kTRUE); | |
618 | newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster,*cluster); | |
619 | fNRecTracks++; | |
620 | ||
621 | // Printout for debuging | |
622 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
623 | cout << "FollowLinearTrackInChamber: added one cluster in chamber(1..): " << nextChamber+1 << endl; | |
624 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
625 | } | |
626 | ||
627 | } else if (chi2WithOneCluster < bestChi2WithOneCluster) { | |
628 | // keep track of the best cluster | |
629 | bestChi2WithOneCluster = chi2WithOneCluster; | |
630 | bestTrackParamAtCluster = extrapTrackParamAtCluster; | |
631 | } | |
632 | ||
633 | } | |
634 | ||
635 | } | |
636 | ||
637 | // fill out the best track if required else clean up the fRecTracksPtr array | |
a0dc65b4 | 638 | if (!GetRecoParam()->TrackAllTracks()) { |
9bf6860b | 639 | if (foundOneCluster) { |
a0dc65b4 | 640 | if (GetRecoParam()->RequestStation(nextChamber/2)) |
9bf6860b | 641 | bestTrackParamAtCluster.SetRemovable(kFALSE); |
642 | else bestTrackParamAtCluster.SetRemovable(kTRUE); | |
643 | trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr())); | |
644 | ||
645 | // Printout for debuging | |
646 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
647 | cout << "FollowLinearTrackInChamber: added the best cluster in chamber(1..): " << bestTrackParamAtCluster.GetClusterPtr()->GetChamberId()+1 << endl; | |
648 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
649 | } | |
650 | ||
651 | } else return kFALSE; | |
652 | ||
653 | } else if (foundOneCluster) { | |
654 | ||
655 | // remove obsolete track | |
656 | fRecTracksPtr->Remove(&trackCandidate); | |
657 | fNRecTracks--; | |
658 | ||
659 | } else return kFALSE; | |
660 | ||
661 | return kTRUE; | |
662 | ||
663 | } | |
664 | ||
665 | //__________________________________________________________________________ | |
96ebe67e | 666 | Bool_t AliMUONVTrackReconstructor::FollowLinearTrackInStation(AliMUONTrack &trackCandidate, const AliMUONVClusterStore& clusterStore, |
667 | Int_t nextStation) | |
019df241 | 668 | { |
96ebe67e | 669 | /// Follow trackCandidate in station(0..) nextStation assuming linear propagation, and search for compatible cluster(s) |
019df241 | 670 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: |
671 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
672 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
673 | /// Remove the obsolete "trackCandidate" at the end. | |
96ebe67e | 674 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. |
675 | /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE) | |
019df241 | 676 | AliDebug(1,Form("Enter FollowLinearTrackInStation(1..) %d", nextStation+1)); |
677 | ||
678 | // Order the chamber according to the propagation direction (tracking starts with chamber 2): | |
679 | // - nextStation == station(1...) 5 => forward propagation | |
680 | // - nextStation < station(1...) 5 => backward propagation | |
681 | Int_t ch1, ch2; | |
682 | if (nextStation==4) { | |
683 | ch1 = 2*nextStation+1; | |
684 | ch2 = 2*nextStation; | |
ea94c18b | 685 | } else { |
019df241 | 686 | ch1 = 2*nextStation; |
687 | ch2 = 2*nextStation+1; | |
ea94c18b | 688 | } |
689 | ||
96ebe67e | 690 | Double_t chi2WithOneCluster = 1.e10; |
691 | Double_t chi2WithTwoClusters = 1.e10; | |
a0dc65b4 | 692 | Double_t maxChi2WithOneCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() * |
693 | GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
694 | Double_t maxChi2WithTwoClusters = 4. * GetRecoParam()->GetSigmaCutForTracking() * | |
695 | GetRecoParam()->GetSigmaCutForTracking(); // 4 because 4 quantities in chi2 | |
96ebe67e | 696 | Double_t bestChi2WithOneCluster = maxChi2WithOneCluster; |
697 | Double_t bestChi2WithTwoClusters = maxChi2WithTwoClusters; | |
698 | Bool_t foundOneCluster = kFALSE; | |
699 | Bool_t foundTwoClusters = kFALSE; | |
019df241 | 700 | AliMUONTrack *newTrack = 0x0; |
96ebe67e | 701 | AliMUONVCluster *clusterCh1, *clusterCh2; |
7332f213 | 702 | AliMUONTrackParam trackParam; |
96ebe67e | 703 | AliMUONTrackParam extrapTrackParamAtCluster1; |
704 | AliMUONTrackParam extrapTrackParamAtCluster2; | |
705 | AliMUONTrackParam bestTrackParamAtCluster1; | |
706 | AliMUONTrackParam bestTrackParamAtCluster2; | |
707 | ||
708 | Int_t nClusters = clusterStore.GetSize(); | |
709 | Bool_t *clusterCh1Used = new Bool_t[nClusters]; | |
710 | for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE; | |
711 | Int_t iCluster1; | |
019df241 | 712 | |
7332f213 | 713 | // Get track parameters according to the propagation direction |
714 | if (nextStation==4) trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last(); | |
715 | else trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First(); | |
019df241 | 716 | |
9bf6860b | 717 | // Printout for debuging |
718 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
719 | cout<<endl<<"Track parameters and covariances at first cluster:"<<endl; | |
720 | trackParam.GetParameters().Print(); | |
721 | trackParam.GetCovariances().Print(); | |
722 | } | |
723 | ||
019df241 | 724 | // Add MCS effect |
725 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
726 | ||
727 | // Printout for debuging | |
728 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 729 | cout << "FollowLinearTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl; |
019df241 | 730 | } |
731 | ||
96ebe67e | 732 | // Create iterators to loop over clusters in both chambers |
733 | TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1)); | |
734 | TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2)); | |
735 | ||
736 | // look for candidates in chamber 2 | |
737 | while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) { | |
019df241 | 738 | |
96ebe67e | 739 | // try to add the current cluster fast |
740 | if (!TryOneClusterFast(trackParam, clusterCh2)) continue; | |
019df241 | 741 | |
96ebe67e | 742 | // try to add the current cluster accuratly |
743 | extrapTrackParamAtCluster2 = trackParam; | |
744 | AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster2, clusterCh2->GetZ()); | |
745 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster2, clusterCh2, extrapTrackParamAtCluster2); | |
019df241 | 746 | |
96ebe67e | 747 | // if good chi2 then try to attach a cluster in the other chamber too |
748 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
749 | Bool_t foundSecondCluster = kFALSE; | |
019df241 | 750 | |
751 | // Printout for debuging | |
752 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 753 | cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch2+1 |
754 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
9bf6860b | 755 | clusterCh2->Print(); |
96ebe67e | 756 | cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl; |
019df241 | 757 | } |
758 | ||
759 | // add MCS effect | |
96ebe67e | 760 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCluster2,AliMUONConstants::ChamberThicknessInX0(),1.); |
019df241 | 761 | |
96ebe67e | 762 | // reset cluster iterator of chamber 1 |
763 | nextInCh1.Reset(); | |
764 | iCluster1 = -1; | |
765 | ||
766 | // look for second candidates in chamber 1 | |
767 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
768 | iCluster1++; | |
019df241 | 769 | |
96ebe67e | 770 | // try to add the current cluster fast |
771 | if (!TryOneClusterFast(extrapTrackParamAtCluster2, clusterCh1)) continue; | |
019df241 | 772 | |
96ebe67e | 773 | // try to add the current cluster in addition to the one found in the previous chamber |
774 | chi2WithTwoClusters = TryTwoClustersFast(extrapTrackParamAtCluster2, clusterCh1, extrapTrackParamAtCluster1); | |
019df241 | 775 | |
96ebe67e | 776 | // if good chi2 then consider to add the 2 clusters to the "trackCandidate" |
777 | if (chi2WithTwoClusters < maxChi2WithTwoClusters) { | |
778 | foundSecondCluster = kTRUE; | |
779 | foundTwoClusters = kTRUE; | |
019df241 | 780 | |
781 | // Printout for debuging | |
782 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 783 | cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch1+1 |
9bf6860b | 784 | << " (Chi2 = " << chi2WithTwoClusters << ")" << endl; |
785 | clusterCh1->Print(); | |
019df241 | 786 | } |
787 | ||
a0dc65b4 | 788 | if (GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 789 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters |
019df241 | 790 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 791 | extrapTrackParamAtCluster1.SetRemovable(kTRUE); |
792 | newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster1,*clusterCh1); | |
793 | extrapTrackParamAtCluster2.SetRemovable(kTRUE); | |
794 | newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster2,*clusterCh2); | |
019df241 | 795 | fNRecTracks++; |
796 | ||
96ebe67e | 797 | // Tag clusterCh1 as used |
798 | clusterCh1Used[iCluster1] = kTRUE; | |
019df241 | 799 | |
800 | // Printout for debuging | |
801 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 802 | cout << "FollowLinearTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl; |
019df241 | 803 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
804 | } | |
805 | ||
96ebe67e | 806 | } else if (chi2WithTwoClusters < bestChi2WithTwoClusters) { |
807 | // keep track of the best couple of clusters | |
808 | bestChi2WithTwoClusters = chi2WithTwoClusters; | |
809 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
810 | bestTrackParamAtCluster2 = extrapTrackParamAtCluster2; | |
019df241 | 811 | } |
812 | ||
813 | } | |
814 | ||
815 | } | |
816 | ||
96ebe67e | 817 | // if no cluster found in chamber1 then consider to add clusterCh2 only |
818 | if (!foundSecondCluster) { | |
819 | foundOneCluster = kTRUE; | |
019df241 | 820 | |
a0dc65b4 | 821 | if (GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 822 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
019df241 | 823 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
a0dc65b4 | 824 | if (GetRecoParam()->RequestStation(nextStation)) |
9bf6860b | 825 | extrapTrackParamAtCluster2.SetRemovable(kFALSE); |
826 | else extrapTrackParamAtCluster2.SetRemovable(kTRUE); | |
96ebe67e | 827 | newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster2,*clusterCh2); |
019df241 | 828 | fNRecTracks++; |
829 | ||
830 | // Printout for debuging | |
831 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 832 | cout << "FollowLinearTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl; |
019df241 | 833 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
834 | } | |
835 | ||
96ebe67e | 836 | } else if (!foundTwoClusters && chi2WithOneCluster < bestChi2WithOneCluster) { |
837 | // keep track of the best cluster except if a couple of clusters has already been found | |
838 | bestChi2WithOneCluster = chi2WithOneCluster; | |
839 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster2; | |
019df241 | 840 | } |
841 | ||
842 | } | |
843 | ||
844 | } | |
845 | ||
846 | } | |
847 | ||
848 | // look for candidates in chamber 1 not already attached to a track | |
96ebe67e | 849 | // if we want to keep all possible tracks or if no good couple of clusters has been found |
a0dc65b4 | 850 | if (GetRecoParam()->TrackAllTracks() || !foundTwoClusters) { |
019df241 | 851 | |
852 | // Printout for debuging | |
853 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 854 | cout << "FollowLinearTrackInStation: look for single cluster in chamber(1..): " << ch1+1 << endl; |
019df241 | 855 | } |
856 | ||
857 | //Extrapolate trackCandidate to chamber "ch2" | |
858 | AliMUONTrackExtrap::LinearExtrapToZ(&trackParam, AliMUONConstants::DefaultChamberZ(ch2)); | |
859 | ||
860 | // add MCS effect for next step | |
861 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
9bf6860b | 862 | |
96ebe67e | 863 | // reset cluster iterator of chamber 1 |
864 | nextInCh1.Reset(); | |
865 | iCluster1 = -1; | |
866 | ||
867 | // look for second candidates in chamber 1 | |
868 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
869 | iCluster1++; | |
019df241 | 870 | |
96ebe67e | 871 | if (clusterCh1Used[iCluster1]) continue; // Skip clusters already used |
019df241 | 872 | |
96ebe67e | 873 | // try to add the current cluster fast |
874 | if (!TryOneClusterFast(trackParam, clusterCh1)) continue; | |
9bf6860b | 875 | |
96ebe67e | 876 | // try to add the current cluster accuratly |
877 | extrapTrackParamAtCluster1 = trackParam; | |
878 | AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster1, clusterCh1->GetZ()); | |
879 | chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster1, clusterCh1, extrapTrackParamAtCluster1); | |
9bf6860b | 880 | |
96ebe67e | 881 | // if good chi2 then consider to add clusterCh1 |
882 | // We do not try to attach a cluster in the other chamber too since it has already been done above | |
883 | if (chi2WithOneCluster < maxChi2WithOneCluster) { | |
884 | foundOneCluster = kTRUE; | |
019df241 | 885 | |
886 | // Printout for debuging | |
887 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 888 | cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch1+1 |
889 | << " (Chi2 = " << chi2WithOneCluster << ")" << endl; | |
9bf6860b | 890 | clusterCh1->Print(); |
019df241 | 891 | } |
892 | ||
a0dc65b4 | 893 | if (GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 894 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
019df241 | 895 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
a0dc65b4 | 896 | if (GetRecoParam()->RequestStation(nextStation)) |
9bf6860b | 897 | extrapTrackParamAtCluster1.SetRemovable(kFALSE); |
898 | else extrapTrackParamAtCluster1.SetRemovable(kTRUE); | |
96ebe67e | 899 | newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster1,*clusterCh1); |
019df241 | 900 | fNRecTracks++; |
901 | ||
902 | // Printout for debuging | |
903 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 904 | cout << "FollowLinearTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl; |
019df241 | 905 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
906 | } | |
907 | ||
96ebe67e | 908 | } else if (chi2WithOneCluster < bestChi2WithOneCluster) { |
909 | // keep track of the best cluster except if a couple of clusters has already been found | |
910 | bestChi2WithOneCluster = chi2WithOneCluster; | |
911 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
019df241 | 912 | } |
913 | ||
914 | } | |
915 | ||
916 | } | |
917 | ||
918 | } | |
919 | ||
920 | // fill out the best track if required else clean up the fRecTracksPtr array | |
a0dc65b4 | 921 | if (!GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 922 | if (foundTwoClusters) { |
923 | bestTrackParamAtCluster1.SetRemovable(kTRUE); | |
924 | trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster1,*(bestTrackParamAtCluster1.GetClusterPtr())); | |
925 | bestTrackParamAtCluster2.SetRemovable(kTRUE); | |
926 | trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster2,*(bestTrackParamAtCluster2.GetClusterPtr())); | |
019df241 | 927 | |
928 | // Printout for debuging | |
929 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 930 | cout << "FollowLinearTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl; |
019df241 | 931 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
932 | } | |
933 | ||
96ebe67e | 934 | } else if (foundOneCluster) { |
a0dc65b4 | 935 | if (GetRecoParam()->RequestStation(nextStation)) |
9bf6860b | 936 | bestTrackParamAtCluster1.SetRemovable(kFALSE); |
937 | else bestTrackParamAtCluster1.SetRemovable(kTRUE); | |
96ebe67e | 938 | trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster1,*(bestTrackParamAtCluster1.GetClusterPtr())); |
019df241 | 939 | |
940 | // Printout for debuging | |
941 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 942 | cout << "FollowLinearTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl; |
019df241 | 943 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
944 | } | |
945 | ||
dd230855 | 946 | } else { |
96ebe67e | 947 | delete [] clusterCh1Used; |
dd230855 | 948 | return kFALSE; |
949 | } | |
019df241 | 950 | |
96ebe67e | 951 | } else if (foundOneCluster || foundTwoClusters) { |
019df241 | 952 | |
953 | // remove obsolete track | |
954 | fRecTracksPtr->Remove(&trackCandidate); | |
955 | fNRecTracks--; | |
956 | ||
dd230855 | 957 | } else { |
96ebe67e | 958 | delete [] clusterCh1Used; |
dd230855 | 959 | return kFALSE; |
960 | } | |
ea94c18b | 961 | |
96ebe67e | 962 | delete [] clusterCh1Used; |
019df241 | 963 | return kTRUE; |
ea94c18b | 964 | |
965 | } | |
966 | ||
7332f213 | 967 | //__________________________________________________________________________ |
968 | void AliMUONVTrackReconstructor::ImproveTracks() | |
969 | { | |
970 | /// Improve tracks by removing clusters with local chi2 highter than the defined cut | |
971 | /// Recompute track parameters and covariances at the remaining clusters | |
972 | AliDebug(1,"Enter ImproveTracks"); | |
973 | ||
974 | AliMUONTrack *track, *nextTrack; | |
975 | ||
7332f213 | 976 | track = (AliMUONTrack*) fRecTracksPtr->First(); |
977 | while (track) { | |
978 | ||
979 | // prepare next track in case the actual track is suppressed | |
980 | nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); | |
981 | ||
982 | ImproveTrack(*track); | |
983 | ||
984 | // remove track if improvement failed | |
985 | if (!track->IsImproved()) { | |
986 | fRecTracksPtr->Remove(track); | |
987 | fNRecTracks--; | |
988 | } | |
989 | ||
990 | track = nextTrack; | |
991 | } | |
992 | ||
993 | // compress the array in case of some tracks have been removed | |
994 | fRecTracksPtr->Compress(); | |
995 | ||
996 | } | |
997 | ||
998 | //__________________________________________________________________________ | |
999 | void AliMUONVTrackReconstructor::Finalize() | |
1000 | { | |
1001 | /// Recompute track parameters and covariances at each attached cluster from those at the first one | |
1002 | ||
1003 | AliMUONTrack *track; | |
1004 | ||
1005 | track = (AliMUONTrack*) fRecTracksPtr->First(); | |
1006 | while (track) { | |
1007 | ||
1008 | FinalizeTrack(*track); | |
1009 | ||
1010 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1011 | ||
1012 | } | |
1013 | ||
1014 | } | |
1015 | ||
1016 | //__________________________________________________________________________ | |
7ec3b9cf | 1017 | void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(AliMUONVTrackStore& trackStore, |
1018 | const AliMUONVTriggerTrackStore& triggerTrackStore, | |
1019 | const AliMUONVTriggerStore& triggerStore, | |
1020 | const AliMUONTrackHitPattern& trackHitPattern) | |
8d0843c6 | 1021 | { |
1022 | /// Try to match track from tracking system with trigger track | |
b709ac13 | 1023 | AliCodeTimerAuto(""); |
fda59e58 | 1024 | |
683cb6c5 | 1025 | trackHitPattern.ExecuteValidation(trackStore, triggerTrackStore, triggerStore); |
8d0843c6 | 1026 | } |
1027 | ||
ea94c18b | 1028 | //__________________________________________________________________________ |
1029 | void AliMUONVTrackReconstructor::EventReconstructTrigger(const AliMUONTriggerCircuit& circuit, | |
1030 | const AliMUONVTriggerStore& triggerStore, | |
1031 | AliMUONVTriggerTrackStore& triggerTrackStore) | |
8d0843c6 | 1032 | { |
71a2d3aa | 1033 | /// To make the trigger tracks from Local Trigger |
7ec3b9cf | 1034 | AliDebug(1, ""); |
b709ac13 | 1035 | AliCodeTimerAuto(""); |
7ec3b9cf | 1036 | |
1037 | AliMUONGlobalTrigger* globalTrigger = triggerStore.Global(); | |
e6b25a6e | 1038 | |
7ec3b9cf | 1039 | UChar_t gloTrigPat = 0; |
e6b25a6e | 1040 | |
7ec3b9cf | 1041 | if (globalTrigger) |
1042 | { | |
1043 | gloTrigPat = globalTrigger->GetGlobalResponse(); | |
e6b25a6e | 1044 | } |
1045 | ||
7ec3b9cf | 1046 | TIter next(triggerStore.CreateIterator()); |
1047 | AliMUONLocalTrigger* locTrg(0x0); | |
8d0843c6 | 1048 | |
e6b25a6e | 1049 | Float_t z11 = AliMUONConstants::DefaultChamberZ(10); |
1050 | Float_t z21 = AliMUONConstants::DefaultChamberZ(12); | |
7cf63da6 | 1051 | |
7ec3b9cf | 1052 | AliMUONTriggerTrack triggerTrack; |
1053 | ||
1054 | while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) ) | |
1055 | { | |
d72d7b9e | 1056 | Bool_t xTrig=locTrg->IsTrigX(); |
1057 | Bool_t yTrig=locTrg->IsTrigY(); | |
7ec3b9cf | 1058 | |
32ab62c9 | 1059 | Int_t localBoardId = locTrg->LoCircuit(); |
7ec3b9cf | 1060 | |
1061 | if (xTrig && yTrig) | |
1062 | { // make Trigger Track if trigger in X and Y | |
8b0baca4 | 1063 | |
32ab62c9 | 1064 | Float_t y11 = circuit.GetY11Pos(localBoardId, locTrg->LoStripX()); |
7ec3b9cf | 1065 | // need first to convert deviation to [0-30] |
1066 | // (see AliMUONLocalTriggerBoard::LocalTrigger) | |
d72d7b9e | 1067 | Int_t deviation = locTrg->GetDeviation(); |
7ec3b9cf | 1068 | Int_t stripX21 = locTrg->LoStripX()+deviation+1; |
32ab62c9 | 1069 | Float_t y21 = circuit.GetY21Pos(localBoardId, stripX21); |
1070 | Float_t x11 = circuit.GetX11Pos(localBoardId, locTrg->LoStripY()); | |
7ec3b9cf | 1071 | |
1072 | AliDebug(1, Form(" MakeTriggerTrack %d %d %d %d %f %f %f \n",locTrg->LoCircuit(), | |
1073 | locTrg->LoStripX(),locTrg->LoStripX()+locTrg->LoDev()+1,locTrg->LoStripY(),y11, y21, x11)); | |
1074 | ||
1075 | Float_t thetax = TMath::ATan2( x11 , z11 ); | |
1076 | Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) ); | |
1077 | ||
1078 | triggerTrack.SetX11(x11); | |
1079 | triggerTrack.SetY11(y11); | |
1080 | triggerTrack.SetThetax(thetax); | |
1081 | triggerTrack.SetThetay(thetay); | |
1082 | triggerTrack.SetGTPattern(gloTrigPat); | |
32ab62c9 | 1083 | triggerTrack.SetLoTrgNum(localBoardId); |
7ec3b9cf | 1084 | |
1085 | triggerTrackStore.Add(triggerTrack); | |
1086 | } // board is fired | |
e6b25a6e | 1087 | } // end of loop on Local Trigger |
8d0843c6 | 1088 | } |
ea94c18b | 1089 |