1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONVTrackReconstructor
20 /// Virtual MUON track reconstructor in ALICE (class renamed from AliMUONEventReconstructor)
22 /// This class contains as data a pointer to the array of reconstructed tracks
24 /// It contains as methods, among others:
25 /// * EventReconstruct to build the muon tracks
26 /// * EventReconstructTrigger to build the trigger tracks
27 /// * ValidateTracksWithTrigger to match tracker/trigger tracks
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);
35 /// Main parameters and options are:
36 /// - *fgkSigmaToCutForTracking* : quality cut used to select new clusters to be
37 /// attached to the track candidate and to select good tracks.
38 /// - *fgkMakeTrackCandidatesFast* : if this flag is set to 'true', the track candidates
39 /// are made assuming linear propagation between stations 4 and 5.
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
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
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).
53 /// - *fgkSigmaToCutForImprovement* : quality cut used when we try to improve the
54 /// quality of the tracks.
56 /// \author Philippe Pillot
57 //-----------------------------------------------------------------------------
59 #include "AliMUONVTrackReconstructor.h"
61 #include "AliMUONConstants.h"
62 #include "AliMUONObjectPair.h"
63 #include "AliMUONTriggerTrack.h"
64 #include "AliMUONTriggerCircuit.h"
65 #include "AliMUONLocalTrigger.h"
66 #include "AliMUONGlobalTrigger.h"
67 #include "AliMUONTrack.h"
68 #include "AliMUONTrackParam.h"
69 #include "AliMUONTrackExtrap.h"
70 #include "AliMUONTrackHitPattern.h"
71 #include "AliMUONVTrackStore.h"
72 #include "AliMUONVClusterStore.h"
73 #include "AliMUONVCluster.h"
74 #include "AliMUONVClusterServer.h"
75 #include "AliMUONVTriggerStore.h"
76 #include "AliMUONVTriggerTrackStore.h"
77 #include "AliMpDEManager.h"
78 #include "AliMpArea.h"
81 #include "AliCodeTimer.h"
82 #include "AliTracker.h"
84 #include <TClonesArray.h>
89 #include <Riostream.h>
92 ClassImp(AliMUONVTrackReconstructor) // Class implementation in ROOT context
95 //__________________________________________________________________________
96 AliMUONVTrackReconstructor::AliMUONVTrackReconstructor(const AliMUONRecoParam* recoParam,
97 AliMUONVClusterServer* clusterServer)
101 fClusterServer(clusterServer),
102 fRecoParam(recoParam)
104 /// Constructor for class AliMUONVTrackReconstructor
105 /// WARNING: if clusterServer=0x0, no clusterization will be possible at this level
107 // Memory allocation for the TClonesArray of reconstructed tracks
108 fRecTracksPtr = new TClonesArray("AliMUONTrack", 100);
110 // set the magnetic field for track extrapolations
111 const AliMagF* kField = AliTracker::GetFieldMap();
112 if (!kField) AliFatal("No field available");
113 AliMUONTrackExtrap::SetField(kField);
116 //__________________________________________________________________________
117 AliMUONVTrackReconstructor::~AliMUONVTrackReconstructor()
119 /// Destructor for class AliMUONVTrackReconstructor
120 delete fRecTracksPtr;
123 //__________________________________________________________________________
124 void AliMUONVTrackReconstructor::ResetTracks()
126 /// To reset the TClonesArray of reconstructed tracks
127 if (fRecTracksPtr) fRecTracksPtr->Clear("C");
132 //__________________________________________________________________________
133 void AliMUONVTrackReconstructor::EventReconstruct(AliMUONVClusterStore& clusterStore, AliMUONVTrackStore& trackStore)
135 /// To reconstruct one event
137 AliCodeTimerAuto("");
139 // Reset array of tracks
142 // Look for candidates from clusters in stations(1..) 4 and 5
143 MakeTrackCandidates(clusterStore);
145 // Look for extra candidates from clusters in stations(1..) 4 and 5
146 if (GetRecoParam()->MakeMoreTrackCandidates()) MakeMoreTrackCandidates(clusterStore);
148 // Stop tracking if no candidate found
149 if (fRecTracksPtr->GetEntriesFast() == 0) return;
151 // Follow tracks in stations(1..) 3, 2 and 1
152 FollowTracks(clusterStore);
154 // Complement the reconstructed tracks
155 if (GetRecoParam()->ComplementTracks()) ComplementTracks(clusterStore);
157 // Improve the reconstructed tracks
158 if (GetRecoParam()->ImproveTracks()) ImproveTracks();
160 // Remove double tracks
161 RemoveDoubleTracks();
163 // Fill AliMUONTrack data members
166 // Add tracks to MUON data container
167 for (Int_t i=0; i<fNRecTracks; ++i)
169 AliMUONTrack * track = (AliMUONTrack*) fRecTracksPtr->At(i);
170 track->SetUniqueID(i+1);
171 trackStore.Add(*track);
175 //__________________________________________________________________________
176 TClonesArray* AliMUONVTrackReconstructor::MakeSegmentsBetweenChambers(const AliMUONVClusterStore& clusterStore, Int_t ch1, Int_t ch2)
178 /// To make the list of segments from the list of clusters in the 2 given chambers.
179 /// Return a new TClonesArray of segments.
180 /// It is the responsibility of the user to delete it afterward.
181 AliDebug(1,Form("Enter MakeSegmentsBetweenChambers (1..) %d-%d", ch1+1, ch2+1));
183 AliMUONVCluster *cluster1, *cluster2;
184 AliMUONObjectPair *segment;
185 Double_t nonBendingSlope = 0, bendingSlope = 0, impactParam = 0., bendingMomentum = 0.; // to avoid compilation warning
187 // Create iterators to loop over clusters in both chambers
188 TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1));
189 TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
192 TClonesArray *segments = new TClonesArray("AliMUONObjectPair", 100);
194 // Loop over clusters in the first chamber of the station
195 while ( ( cluster1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
197 // reset cluster iterator of chamber 2
200 // Loop over clusters in the second chamber of the station
201 while ( ( cluster2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) {
204 nonBendingSlope = (cluster1->GetX() - cluster2->GetX()) / (cluster1->GetZ() - cluster2->GetZ());
206 // check if non bending slope is within tolerances
207 if (TMath::Abs(nonBendingSlope) > GetRecoParam()->GetMaxNonBendingSlope()) continue;
210 bendingSlope = (cluster1->GetY() - cluster2->GetY()) / (cluster1->GetZ() - cluster2->GetZ());
212 // check the bending momentum of the bending slope depending if the field is ON or OFF
213 if (AliMUONTrackExtrap::IsFieldON()) {
216 impactParam = cluster1->GetY() - cluster1->GetZ() * bendingSlope;
218 // absolute value of bending momentum
219 bendingMomentum = TMath::Abs(AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(impactParam));
221 // check if bending momentum is within tolerances
222 if (bendingMomentum < GetRecoParam()->GetMinBendingMomentum() ||
223 bendingMomentum > GetRecoParam()->GetMaxBendingMomentum()) continue;
227 // check if non bending slope is within tolerances
228 if (TMath::Abs(bendingSlope) > GetRecoParam()->GetMaxBendingSlope()) continue;
232 segment = new ((*segments)[segments->GetLast()+1]) AliMUONObjectPair(cluster1, cluster2, kFALSE, kFALSE);
234 // Printout for debug
235 if (AliLog::GetGlobalDebugLevel() > 1) {
236 cout << "segmentIndex(0...): " << segments->GetLast() << endl;
238 cout << "Cluster in first chamber" << endl;
240 cout << "Cluster in second chamber" << endl;
248 // Printout for debug
249 AliDebug(1,Form("chambers%d-%d: NSegments = %d ", ch1+1, ch2+1, segments->GetEntriesFast()));
254 //__________________________________________________________________________
255 void AliMUONVTrackReconstructor::RemoveIdenticalTracks()
257 /// To remove identical tracks:
258 /// Tracks are considered identical if they have all their clusters in common.
259 /// One keeps the track with the larger number of clusters if need be
260 AliMUONTrack *track1, *track2, *trackToRemove;
261 Int_t clustersInCommon, nClusters1, nClusters2;
262 Bool_t removedTrack1;
263 // Loop over first track of the pair
264 track1 = (AliMUONTrack*) fRecTracksPtr->First();
266 removedTrack1 = kFALSE;
267 nClusters1 = track1->GetNClusters();
268 // Loop over second track of the pair
269 track2 = (AliMUONTrack*) fRecTracksPtr->After(track1);
271 nClusters2 = track2->GetNClusters();
272 // number of clusters in common between two tracks
273 clustersInCommon = track1->ClustersInCommon(track2);
274 // check for identical tracks
275 if ((clustersInCommon == nClusters1) || (clustersInCommon == nClusters2)) {
276 // decide which track to remove
277 if (nClusters2 > nClusters1) {
278 // remove track1 and continue the first loop with the track next to track1
279 trackToRemove = track1;
280 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
281 fRecTracksPtr->Remove(trackToRemove);
282 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
284 removedTrack1 = kTRUE;
287 // remove track2 and continue the second loop with the track next to track2
288 trackToRemove = track2;
289 track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
290 fRecTracksPtr->Remove(trackToRemove);
291 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
294 } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
296 if (removedTrack1) continue;
297 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
302 //__________________________________________________________________________
303 void AliMUONVTrackReconstructor::RemoveDoubleTracks()
305 /// To remove double tracks:
306 /// Tracks are considered identical if more than half of the clusters of the track
307 /// which has the smaller number of clusters are in common with the other track.
308 /// Among two identical tracks, one keeps the track with the larger number of clusters
309 /// or, if these numbers are equal, the track with the minimum chi2.
310 AliMUONTrack *track1, *track2, *trackToRemove;
311 Int_t clustersInCommon, nClusters1, nClusters2;
312 Bool_t removedTrack1;
313 // Loop over first track of the pair
314 track1 = (AliMUONTrack*) fRecTracksPtr->First();
316 removedTrack1 = kFALSE;
317 nClusters1 = track1->GetNClusters();
318 // Loop over second track of the pair
319 track2 = (AliMUONTrack*) fRecTracksPtr->After(track1);
321 nClusters2 = track2->GetNClusters();
322 // number of clusters in common between two tracks
323 clustersInCommon = track1->ClustersInCommon(track2);
324 // check for identical tracks
325 if (((nClusters1 < nClusters2) && (2 * clustersInCommon > nClusters1)) || (2 * clustersInCommon > nClusters2)) {
326 // decide which track to remove
327 if ((nClusters1 > nClusters2) || ((nClusters1 == nClusters2) && (track1->GetGlobalChi2() <= track2->GetGlobalChi2()))) {
328 // remove track2 and continue the second loop with the track next to track2
329 trackToRemove = track2;
330 track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
331 fRecTracksPtr->Remove(trackToRemove);
332 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
335 // else remove track1 and continue the first loop with the track next to track1
336 trackToRemove = track1;
337 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
338 fRecTracksPtr->Remove(trackToRemove);
339 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
341 removedTrack1 = kTRUE;
344 } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
346 if (removedTrack1) continue;
347 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
352 //__________________________________________________________________________
353 void AliMUONVTrackReconstructor::AskForNewClustersInChamber(const AliMUONTrackParam &trackParam,
354 AliMUONVClusterStore& clusterStore, Int_t chamber)
356 /// Ask the clustering to reconstruct new clusters around the track candidate position
358 // check if the current chamber is useable
359 if (!fClusterServer || !GetRecoParam()->UseChamber(chamber)) return;
361 // maximum distance between the center of the chamber and a detection element
362 // (accounting for the inclination of the chamber)
363 static const Double_t kMaxDZ = 15.; // 15 cm
365 // extrapolate track parameters to the chamber
366 AliMUONTrackParam extrapTrackParam(trackParam);
367 AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(chamber));
369 // build the searching area using the track resolution and the maximum-distance-to-track value
370 const TMatrixD& kParamCov = extrapTrackParam.GetCovariances();
371 Double_t errX2 = kParamCov(0,0) + kMaxDZ * kMaxDZ * kParamCov(1,1) + 2. * kMaxDZ * TMath::Abs(kParamCov(0,1));
372 Double_t errY2 = kParamCov(2,2) + kMaxDZ * kMaxDZ * kParamCov(3,3) + 2. * kMaxDZ * TMath::Abs(kParamCov(2,3));
373 Double_t dX = TMath::Abs(trackParam.GetNonBendingSlope()) * kMaxDZ +
374 GetRecoParam()->GetMaxNonBendingDistanceToTrack() +
375 GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errX2);
376 Double_t dY = TMath::Abs(trackParam.GetBendingSlope()) * kMaxDZ +
377 GetRecoParam()->GetMaxBendingDistanceToTrack() +
378 GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errY2);
379 TVector2 dimensions(dX, dY);
380 TVector2 position(extrapTrackParam.GetNonBendingCoor(), extrapTrackParam.GetBendingCoor());
381 AliMpArea area(position, dimensions);
383 // ask to cluterize in the given area of the given chamber
384 fClusterServer->Clusterize(chamber, clusterStore, area);
388 //__________________________________________________________________________
389 void AliMUONVTrackReconstructor::AskForNewClustersInStation(const AliMUONTrackParam &trackParam,
390 AliMUONVClusterStore& clusterStore, Int_t station)
392 /// Ask the clustering to reconstruct new clusters around the track candidate position
393 /// in the 2 chambers of the given station
394 AskForNewClustersInChamber(trackParam, clusterStore, 2*station+1);
395 AskForNewClustersInChamber(trackParam, clusterStore, 2*station);
398 //__________________________________________________________________________
399 Double_t AliMUONVTrackReconstructor::TryOneCluster(const AliMUONTrackParam &trackParam, AliMUONVCluster* cluster,
400 AliMUONTrackParam &trackParamAtCluster, Bool_t updatePropagator)
402 /// Test the compatibility between the track and the cluster (using trackParam's covariance matrix):
403 /// return the corresponding Chi2
404 /// return trackParamAtCluster
406 // extrapolate track parameters and covariances at the z position of the tested cluster
407 trackParamAtCluster = trackParam;
408 AliMUONTrackExtrap::ExtrapToZCov(&trackParamAtCluster, cluster->GetZ(), updatePropagator);
410 // set pointer to cluster into trackParamAtCluster
411 trackParamAtCluster.SetClusterPtr(cluster);
413 // Set differences between trackParam and cluster in the bending and non bending directions
414 Double_t dX = cluster->GetX() - trackParamAtCluster.GetNonBendingCoor();
415 Double_t dY = cluster->GetY() - trackParamAtCluster.GetBendingCoor();
417 // Calculate errors and covariances
418 const TMatrixD& kParamCov = trackParamAtCluster.GetCovariances();
419 Double_t sigmaX2 = kParamCov(0,0) + cluster->GetErrX2();
420 Double_t sigmaY2 = kParamCov(2,2) + cluster->GetErrY2();
423 return dX * dX / sigmaX2 + dY * dY / sigmaY2;
427 //__________________________________________________________________________
428 Bool_t AliMUONVTrackReconstructor::TryOneClusterFast(const AliMUONTrackParam &trackParam, AliMUONVCluster* cluster)
430 /// Test the compatibility between the track and the cluster
431 /// given the track resolution + the maximum-distance-to-track value
432 /// and assuming linear propagation of the track:
433 /// return kTRUE if they are compatibles
435 Double_t dZ = cluster->GetZ() - trackParam.GetZ();
436 Double_t dX = cluster->GetX() - (trackParam.GetNonBendingCoor() + trackParam.GetNonBendingSlope() * dZ);
437 Double_t dY = cluster->GetY() - (trackParam.GetBendingCoor() + trackParam.GetBendingSlope() * dZ);
438 const TMatrixD& kParamCov = trackParam.GetCovariances();
439 Double_t errX2 = kParamCov(0,0) + dZ * dZ * kParamCov(1,1) + 2. * dZ * kParamCov(0,1);
440 Double_t errY2 = kParamCov(2,2) + dZ * dZ * kParamCov(3,3) + 2. * dZ * kParamCov(2,3);
442 Double_t dXmax = GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errX2) +
443 GetRecoParam()->GetMaxNonBendingDistanceToTrack();
444 Double_t dYmax = GetRecoParam()->GetSigmaCutForTracking() * TMath::Sqrt(errY2) +
445 GetRecoParam()->GetMaxBendingDistanceToTrack();
447 if (TMath::Abs(dX) > dXmax || TMath::Abs(dY) > dYmax) return kFALSE;
453 //__________________________________________________________________________
454 Double_t AliMUONVTrackReconstructor::TryTwoClustersFast(const AliMUONTrackParam &trackParamAtCluster1, AliMUONVCluster* cluster2,
455 AliMUONTrackParam &trackParamAtCluster2)
457 /// Test the compatibility between the track and the 2 clusters together (using trackParam's covariance matrix)
458 /// assuming linear propagation between the two clusters:
459 /// return the corresponding Chi2 accounting for covariances between the 2 clusters
460 /// return trackParamAtCluster2
462 // extrapolate linearly track parameters and covariances at the z position of the second cluster
463 trackParamAtCluster2 = trackParamAtCluster1;
464 AliMUONTrackExtrap::LinearExtrapToZ(&trackParamAtCluster2, cluster2->GetZ());
466 // set pointer to cluster2 into trackParamAtCluster2
467 trackParamAtCluster2.SetClusterPtr(cluster2);
469 // Set differences between track and clusters in the bending and non bending directions
470 AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr();
471 Double_t dX1 = cluster1->GetX() - trackParamAtCluster1.GetNonBendingCoor();
472 Double_t dX2 = cluster2->GetX() - trackParamAtCluster2.GetNonBendingCoor();
473 Double_t dY1 = cluster1->GetY() - trackParamAtCluster1.GetBendingCoor();
474 Double_t dY2 = cluster2->GetY() - trackParamAtCluster2.GetBendingCoor();
476 // Calculate errors and covariances
477 const TMatrixD& kParamCov1 = trackParamAtCluster1.GetCovariances();
478 const TMatrixD& kParamCov2 = trackParamAtCluster2.GetCovariances();
479 Double_t dZ = trackParamAtCluster2.GetZ() - trackParamAtCluster1.GetZ();
480 Double_t sigma2X1 = kParamCov1(0,0) + cluster1->GetErrX2();
481 Double_t sigma2X2 = kParamCov2(0,0) + cluster2->GetErrX2();
482 Double_t covX1X2 = kParamCov1(0,0) + dZ * kParamCov1(0,1);
483 Double_t sigma2Y1 = kParamCov1(2,2) + cluster1->GetErrY2();
484 Double_t sigma2Y2 = kParamCov2(2,2) + cluster2->GetErrY2();
485 Double_t covY1Y2 = kParamCov1(2,2) + dZ * kParamCov1(2,3);
488 Double_t detX = sigma2X1 * sigma2X2 - covX1X2 * covX1X2;
489 Double_t detY = sigma2Y1 * sigma2Y2 - covY1Y2 * covY1Y2;
490 if (detX == 0. || detY == 0.) return 1.e10;
491 return (dX1 * dX1 * sigma2X2 + dX2 * dX2 * sigma2X1 - 2. * dX1 * dX2 * covX1X2) / detX
492 + (dY1 * dY1 * sigma2Y2 + dY2 * dY2 * sigma2Y1 - 2. * dY1 * dY2 * covY1Y2) / detY;
496 //__________________________________________________________________________
497 Bool_t AliMUONVTrackReconstructor::FollowLinearTrackInChamber(AliMUONTrack &trackCandidate, const AliMUONVClusterStore& clusterStore,
500 /// Follow trackCandidate in chamber(0..) nextChamber assuming linear propagation, and search for compatible cluster(s)
501 /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks:
502 /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of
503 /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure.
504 /// Remove the obsolete "trackCandidate" at the end.
505 /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority.
506 /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE)
507 AliDebug(1,Form("Enter FollowLinearTrackInChamber(1..) %d", nextChamber+1));
509 Double_t chi2WithOneCluster = 1.e10;
510 Double_t maxChi2WithOneCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
511 GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
512 Double_t bestChi2WithOneCluster = maxChi2WithOneCluster;
513 Bool_t foundOneCluster = kFALSE;
514 AliMUONTrack *newTrack = 0x0;
515 AliMUONVCluster *cluster;
516 AliMUONTrackParam trackParam;
517 AliMUONTrackParam extrapTrackParamAtCluster;
518 AliMUONTrackParam bestTrackParamAtCluster;
520 // Get track parameters according to the propagation direction
521 if (nextChamber > 7) trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last();
522 else trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First();
524 // Printout for debuging
525 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
526 cout<<endl<<"Track parameters and covariances at first cluster:"<<endl;
527 trackParam.GetParameters().Print();
528 trackParam.GetCovariances().Print();
532 AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.);
534 // Printout for debuging
535 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
536 cout << "FollowLinearTrackInChamber: look for cluster in chamber(1..): " << nextChamber+1 << endl;
539 // Create iterators to loop over clusters in chamber
540 TIter next(clusterStore.CreateChamberIterator(nextChamber,nextChamber));
542 // look for candidates in chamber
543 while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
545 // try to add the current cluster fast
546 if (!TryOneClusterFast(trackParam, cluster)) continue;
548 // try to add the current cluster accuratly
549 extrapTrackParamAtCluster = trackParam;
550 AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster, cluster->GetZ());
551 chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster, cluster, extrapTrackParamAtCluster);
553 // if good chi2 then consider to add cluster
554 if (chi2WithOneCluster < maxChi2WithOneCluster) {
555 foundOneCluster = kTRUE;
557 // Printout for debuging
558 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
559 cout << "FollowLinearTrackInChamber: found one cluster in chamber(1..): " << nextChamber+1
560 << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
564 if (GetRecoParam()->TrackAllTracks()) {
565 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
566 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
567 if (GetRecoParam()->RequestStation(nextChamber/2))
568 extrapTrackParamAtCluster.SetRemovable(kFALSE);
569 else extrapTrackParamAtCluster.SetRemovable(kTRUE);
570 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster,*cluster);
573 // Printout for debuging
574 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
575 cout << "FollowLinearTrackInChamber: added one cluster in chamber(1..): " << nextChamber+1 << endl;
576 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
579 } else if (chi2WithOneCluster < bestChi2WithOneCluster) {
580 // keep track of the best cluster
581 bestChi2WithOneCluster = chi2WithOneCluster;
582 bestTrackParamAtCluster = extrapTrackParamAtCluster;
589 // fill out the best track if required else clean up the fRecTracksPtr array
590 if (!GetRecoParam()->TrackAllTracks()) {
591 if (foundOneCluster) {
592 if (GetRecoParam()->RequestStation(nextChamber/2))
593 bestTrackParamAtCluster.SetRemovable(kFALSE);
594 else bestTrackParamAtCluster.SetRemovable(kTRUE);
595 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr()));
597 // Printout for debuging
598 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
599 cout << "FollowLinearTrackInChamber: added the best cluster in chamber(1..): " << bestTrackParamAtCluster.GetClusterPtr()->GetChamberId()+1 << endl;
600 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
603 } else return kFALSE;
605 } else if (foundOneCluster) {
607 // remove obsolete track
608 fRecTracksPtr->Remove(&trackCandidate);
611 } else return kFALSE;
617 //__________________________________________________________________________
618 Bool_t AliMUONVTrackReconstructor::FollowLinearTrackInStation(AliMUONTrack &trackCandidate, const AliMUONVClusterStore& clusterStore,
621 /// Follow trackCandidate in station(0..) nextStation assuming linear propagation, and search for compatible cluster(s)
622 /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks:
623 /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of
624 /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure.
625 /// Remove the obsolete "trackCandidate" at the end.
626 /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority.
627 /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE)
628 AliDebug(1,Form("Enter FollowLinearTrackInStation(1..) %d", nextStation+1));
630 // Order the chamber according to the propagation direction (tracking starts with chamber 2):
631 // - nextStation == station(1...) 5 => forward propagation
632 // - nextStation < station(1...) 5 => backward propagation
634 if (nextStation==4) {
635 ch1 = 2*nextStation+1;
639 ch2 = 2*nextStation+1;
642 Double_t chi2WithOneCluster = 1.e10;
643 Double_t chi2WithTwoClusters = 1.e10;
644 Double_t maxChi2WithOneCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
645 GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
646 Double_t maxChi2WithTwoClusters = 4. * GetRecoParam()->GetSigmaCutForTracking() *
647 GetRecoParam()->GetSigmaCutForTracking(); // 4 because 4 quantities in chi2
648 Double_t bestChi2WithOneCluster = maxChi2WithOneCluster;
649 Double_t bestChi2WithTwoClusters = maxChi2WithTwoClusters;
650 Bool_t foundOneCluster = kFALSE;
651 Bool_t foundTwoClusters = kFALSE;
652 AliMUONTrack *newTrack = 0x0;
653 AliMUONVCluster *clusterCh1, *clusterCh2;
654 AliMUONTrackParam trackParam;
655 AliMUONTrackParam extrapTrackParamAtCluster1;
656 AliMUONTrackParam extrapTrackParamAtCluster2;
657 AliMUONTrackParam bestTrackParamAtCluster1;
658 AliMUONTrackParam bestTrackParamAtCluster2;
660 Int_t nClusters = clusterStore.GetSize();
661 Bool_t *clusterCh1Used = new Bool_t[nClusters];
662 for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE;
665 // Get track parameters according to the propagation direction
666 if (nextStation==4) trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last();
667 else trackParam = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First();
669 // Printout for debuging
670 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
671 cout<<endl<<"Track parameters and covariances at first cluster:"<<endl;
672 trackParam.GetParameters().Print();
673 trackParam.GetCovariances().Print();
677 AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.);
679 // Printout for debuging
680 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
681 cout << "FollowLinearTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl;
684 // Create iterators to loop over clusters in both chambers
685 TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1));
686 TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
688 // look for candidates in chamber 2
689 while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) {
691 // try to add the current cluster fast
692 if (!TryOneClusterFast(trackParam, clusterCh2)) continue;
694 // try to add the current cluster accuratly
695 extrapTrackParamAtCluster2 = trackParam;
696 AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster2, clusterCh2->GetZ());
697 chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster2, clusterCh2, extrapTrackParamAtCluster2);
699 // if good chi2 then try to attach a cluster in the other chamber too
700 if (chi2WithOneCluster < maxChi2WithOneCluster) {
701 Bool_t foundSecondCluster = kFALSE;
703 // Printout for debuging
704 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
705 cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch2+1
706 << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
708 cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl;
712 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCluster2,AliMUONConstants::ChamberThicknessInX0(),1.);
714 // reset cluster iterator of chamber 1
718 // look for second candidates in chamber 1
719 while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
722 // try to add the current cluster fast
723 if (!TryOneClusterFast(extrapTrackParamAtCluster2, clusterCh1)) continue;
725 // try to add the current cluster in addition to the one found in the previous chamber
726 chi2WithTwoClusters = TryTwoClustersFast(extrapTrackParamAtCluster2, clusterCh1, extrapTrackParamAtCluster1);
728 // if good chi2 then consider to add the 2 clusters to the "trackCandidate"
729 if (chi2WithTwoClusters < maxChi2WithTwoClusters) {
730 foundSecondCluster = kTRUE;
731 foundTwoClusters = kTRUE;
733 // Printout for debuging
734 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
735 cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch1+1
736 << " (Chi2 = " << chi2WithTwoClusters << ")" << endl;
740 if (GetRecoParam()->TrackAllTracks()) {
741 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters
742 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
743 extrapTrackParamAtCluster1.SetRemovable(kTRUE);
744 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster1,*clusterCh1);
745 extrapTrackParamAtCluster2.SetRemovable(kTRUE);
746 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster2,*clusterCh2);
749 // Tag clusterCh1 as used
750 clusterCh1Used[iCluster1] = kTRUE;
752 // Printout for debuging
753 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
754 cout << "FollowLinearTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl;
755 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
758 } else if (chi2WithTwoClusters < bestChi2WithTwoClusters) {
759 // keep track of the best couple of clusters
760 bestChi2WithTwoClusters = chi2WithTwoClusters;
761 bestTrackParamAtCluster1 = extrapTrackParamAtCluster1;
762 bestTrackParamAtCluster2 = extrapTrackParamAtCluster2;
769 // if no cluster found in chamber1 then consider to add clusterCh2 only
770 if (!foundSecondCluster) {
771 foundOneCluster = kTRUE;
773 if (GetRecoParam()->TrackAllTracks()) {
774 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
775 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
776 if (GetRecoParam()->RequestStation(nextStation))
777 extrapTrackParamAtCluster2.SetRemovable(kFALSE);
778 else extrapTrackParamAtCluster2.SetRemovable(kTRUE);
779 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster2,*clusterCh2);
782 // Printout for debuging
783 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
784 cout << "FollowLinearTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl;
785 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
788 } else if (!foundTwoClusters && chi2WithOneCluster < bestChi2WithOneCluster) {
789 // keep track of the best cluster except if a couple of clusters has already been found
790 bestChi2WithOneCluster = chi2WithOneCluster;
791 bestTrackParamAtCluster1 = extrapTrackParamAtCluster2;
800 // look for candidates in chamber 1 not already attached to a track
801 // if we want to keep all possible tracks or if no good couple of clusters has been found
802 if (GetRecoParam()->TrackAllTracks() || !foundTwoClusters) {
804 // Printout for debuging
805 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
806 cout << "FollowLinearTrackInStation: look for single cluster in chamber(1..): " << ch1+1 << endl;
809 //Extrapolate trackCandidate to chamber "ch2"
810 AliMUONTrackExtrap::LinearExtrapToZ(&trackParam, AliMUONConstants::DefaultChamberZ(ch2));
812 // add MCS effect for next step
813 AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.);
815 // reset cluster iterator of chamber 1
819 // look for second candidates in chamber 1
820 while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
823 if (clusterCh1Used[iCluster1]) continue; // Skip clusters already used
825 // try to add the current cluster fast
826 if (!TryOneClusterFast(trackParam, clusterCh1)) continue;
828 // try to add the current cluster accuratly
829 extrapTrackParamAtCluster1 = trackParam;
830 AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster1, clusterCh1->GetZ());
831 chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster1, clusterCh1, extrapTrackParamAtCluster1);
833 // if good chi2 then consider to add clusterCh1
834 // We do not try to attach a cluster in the other chamber too since it has already been done above
835 if (chi2WithOneCluster < maxChi2WithOneCluster) {
836 foundOneCluster = kTRUE;
838 // Printout for debuging
839 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
840 cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch1+1
841 << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
845 if (GetRecoParam()->TrackAllTracks()) {
846 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
847 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
848 if (GetRecoParam()->RequestStation(nextStation))
849 extrapTrackParamAtCluster1.SetRemovable(kFALSE);
850 else extrapTrackParamAtCluster1.SetRemovable(kTRUE);
851 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster1,*clusterCh1);
854 // Printout for debuging
855 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
856 cout << "FollowLinearTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl;
857 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
860 } else if (chi2WithOneCluster < bestChi2WithOneCluster) {
861 // keep track of the best cluster except if a couple of clusters has already been found
862 bestChi2WithOneCluster = chi2WithOneCluster;
863 bestTrackParamAtCluster1 = extrapTrackParamAtCluster1;
872 // fill out the best track if required else clean up the fRecTracksPtr array
873 if (!GetRecoParam()->TrackAllTracks()) {
874 if (foundTwoClusters) {
875 bestTrackParamAtCluster1.SetRemovable(kTRUE);
876 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster1,*(bestTrackParamAtCluster1.GetClusterPtr()));
877 bestTrackParamAtCluster2.SetRemovable(kTRUE);
878 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster2,*(bestTrackParamAtCluster2.GetClusterPtr()));
880 // Printout for debuging
881 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
882 cout << "FollowLinearTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl;
883 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
886 } else if (foundOneCluster) {
887 if (GetRecoParam()->RequestStation(nextStation))
888 bestTrackParamAtCluster1.SetRemovable(kFALSE);
889 else bestTrackParamAtCluster1.SetRemovable(kTRUE);
890 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster1,*(bestTrackParamAtCluster1.GetClusterPtr()));
892 // Printout for debuging
893 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
894 cout << "FollowLinearTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl;
895 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
899 delete [] clusterCh1Used;
903 } else if (foundOneCluster || foundTwoClusters) {
905 // remove obsolete track
906 fRecTracksPtr->Remove(&trackCandidate);
910 delete [] clusterCh1Used;
914 delete [] clusterCh1Used;
919 //__________________________________________________________________________
920 void AliMUONVTrackReconstructor::ImproveTracks()
922 /// Improve tracks by removing clusters with local chi2 highter than the defined cut
923 /// Recompute track parameters and covariances at the remaining clusters
924 AliDebug(1,"Enter ImproveTracks");
926 AliMUONTrack *track, *nextTrack;
928 track = (AliMUONTrack*) fRecTracksPtr->First();
931 // prepare next track in case the actual track is suppressed
932 nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track);
934 ImproveTrack(*track);
936 // remove track if improvement failed
937 if (!track->IsImproved()) {
938 fRecTracksPtr->Remove(track);
945 // compress the array in case of some tracks have been removed
946 fRecTracksPtr->Compress();
950 //__________________________________________________________________________
951 void AliMUONVTrackReconstructor::Finalize()
953 /// Recompute track parameters and covariances at each attached cluster from those at the first one
957 track = (AliMUONTrack*) fRecTracksPtr->First();
960 FinalizeTrack(*track);
962 track = (AliMUONTrack*) fRecTracksPtr->After(track);
968 //__________________________________________________________________________
969 void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(AliMUONVTrackStore& trackStore,
970 const AliMUONVTriggerTrackStore& triggerTrackStore,
971 const AliMUONVTriggerStore& triggerStore,
972 const AliMUONTrackHitPattern& trackHitPattern)
974 /// Try to match track from tracking system with trigger track
975 AliCodeTimerAuto("");
977 trackHitPattern.ExecuteValidation(trackStore, triggerTrackStore, triggerStore);
980 //__________________________________________________________________________
981 void AliMUONVTrackReconstructor::EventReconstructTrigger(const AliMUONTriggerCircuit& circuit,
982 const AliMUONVTriggerStore& triggerStore,
983 AliMUONVTriggerTrackStore& triggerTrackStore)
985 /// To make the trigger tracks from Local Trigger
987 AliCodeTimerAuto("");
989 AliMUONGlobalTrigger* globalTrigger = triggerStore.Global();
991 UChar_t gloTrigPat = 0;
995 gloTrigPat = globalTrigger->GetGlobalResponse();
998 TIter next(triggerStore.CreateIterator());
999 AliMUONLocalTrigger* locTrg(0x0);
1001 Float_t z11 = AliMUONConstants::DefaultChamberZ(10);
1002 Float_t z21 = AliMUONConstants::DefaultChamberZ(12);
1004 AliMUONTriggerTrack triggerTrack;
1006 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
1008 Bool_t xTrig=locTrg->IsTrigX();
1009 Bool_t yTrig=locTrg->IsTrigY();
1011 Int_t localBoardId = locTrg->LoCircuit();
1014 { // make Trigger Track if trigger in X and Y
1016 Float_t y11 = circuit.GetY11Pos(localBoardId, locTrg->LoStripX());
1017 // need first to convert deviation to [0-30]
1018 // (see AliMUONLocalTriggerBoard::LocalTrigger)
1019 Int_t deviation = locTrg->GetDeviation();
1020 Int_t stripX21 = locTrg->LoStripX()+deviation+1;
1021 Float_t y21 = circuit.GetY21Pos(localBoardId, stripX21);
1022 Float_t x11 = circuit.GetX11Pos(localBoardId, locTrg->LoStripY());
1024 AliDebug(1, Form(" MakeTriggerTrack %d %d %d %d %f %f %f \n",locTrg->LoCircuit(),
1025 locTrg->LoStripX(),locTrg->LoStripX()+locTrg->LoDev()+1,locTrg->LoStripY(),y11, y21, x11));
1027 Float_t thetax = TMath::ATan2( x11 , z11 );
1028 Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) );
1030 triggerTrack.SetX11(x11);
1031 triggerTrack.SetY11(y11);
1032 triggerTrack.SetThetax(thetax);
1033 triggerTrack.SetThetay(thetay);
1034 triggerTrack.SetGTPattern(gloTrigPat);
1035 triggerTrack.SetLoTrgNum(localBoardId);
1037 triggerTrackStore.Add(triggerTrack);
1039 } // end of loop on Local Trigger