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