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