]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONVTrackReconstructor.cxx
Removing clustering from here as it is now driven by the tracking, whatever the track...
[u/mrichter/AliRoot.git] / MUON / AliMUONVTrackReconstructor.cxx
CommitLineData
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"
7ec3b9cf 74#include "AliMUONVTriggerStore.h"
75#include "AliMUONVTriggerTrackStore.h"
ea94c18b 76#include "AliMpDEManager.h"
77
78#include "AliLog.h"
b709ac13 79#include "AliCodeTimer.h"
ea94c18b 80#include "AliTracker.h"
8d0843c6 81
4889d34c 82#include <TClonesArray.h>
83#include <TMath.h>
ea94c18b 84#include <TMatrixD.h>
85
86#include <Riostream.h>
4889d34c 87
78649106 88/// \cond CLASSIMP
8d0843c6 89ClassImp(AliMUONVTrackReconstructor) // Class implementation in ROOT context
78649106 90/// \endcond
8d0843c6 91
ea94c18b 92 //__________________________________________________________________________
7ec3b9cf 93AliMUONVTrackReconstructor::AliMUONVTrackReconstructor()
8d0843c6 94 : TObject(),
8d0843c6 95 fRecTracksPtr(0x0),
7ec3b9cf 96 fNRecTracks(0)
8d0843c6 97{
98 /// Constructor for class AliMUONVTrackReconstructor
ea94c18b 99
100 // Memory allocation for the TClonesArray of reconstructed tracks
96ebe67e 101 fRecTracksPtr = new TClonesArray("AliMUONTrack", 100);
7ec3b9cf 102
208f139e 103 // set the magnetic field for track extrapolations
8d0843c6 104 const AliMagF* kField = AliTracker::GetFieldMap();
105 if (!kField) AliFatal("No field available");
37827b29 106 AliMUONTrackExtrap::SetField(kField);
8d0843c6 107}
108
109 //__________________________________________________________________________
ea94c18b 110AliMUONVTrackReconstructor::~AliMUONVTrackReconstructor()
8d0843c6 111{
112 /// Destructor for class AliMUONVTrackReconstructor
ea94c18b 113 delete fRecTracksPtr;
8d0843c6 114}
115
ea94c18b 116 //__________________________________________________________________________
117void AliMUONVTrackReconstructor::ResetTracks()
118{
119 /// To reset the TClonesArray of reconstructed tracks
120 if (fRecTracksPtr) fRecTracksPtr->Clear("C");
121 fNRecTracks = 0;
122 return;
123}
124
125 //__________________________________________________________________________
126void AliMUONVTrackReconstructor::EventReconstruct(const AliMUONVClusterStore& clusterStore, AliMUONVTrackStore& trackStore)
127{
128 /// To reconstruct one event
129 AliDebug(1,"");
b709ac13 130 AliCodeTimerAuto("");
ea94c18b 131
96ebe67e 132 // Reset array of tracks
ea94c18b 133 ResetTracks();
2060b217 134
ea94c18b 135 // Look for candidates from at least 3 aligned points in stations(1..) 4 and 5
96ebe67e 136 MakeTrackCandidates(clusterStore);
137
138 // Stop tracking if no candidate found
ea94c18b 139 if (fRecTracksPtr->GetEntriesFast() == 0) return;
96ebe67e 140
ea94c18b 141 // Follow tracks in stations(1..) 3, 2 and 1
96ebe67e 142 FollowTracks(clusterStore);
143
b709ac13 144 // Complement the reconstructed tracks
96ebe67e 145 if (AliMUONReconstructor::GetRecoParam()->ComplementTracks()) ComplementTracks(clusterStore);
146
ea94c18b 147 // Improve the reconstructed tracks
3304fa09 148 if (AliMUONReconstructor::GetRecoParam()->ImproveTracks()) ImproveTracks();
96ebe67e 149
ea94c18b 150 // Remove double tracks
151 RemoveDoubleTracks();
96ebe67e 152
ea94c18b 153 // Fill AliMUONTrack data members
154 Finalize();
96ebe67e 155
156 // Add tracks to MUON data container
157 for (Int_t i=0; i<fNRecTracks; ++i)
158 {
159 AliMUONTrack * track = (AliMUONTrack*) fRecTracksPtr->At(i);
160 trackStore.Add(*track);
161 }
ea94c18b 162}
163
8d0843c6 164 //__________________________________________________________________________
96ebe67e 165TClonesArray* AliMUONVTrackReconstructor::MakeSegmentsInStation(const AliMUONVClusterStore& clusterStore, Int_t station)
8d0843c6 166{
96ebe67e 167 /// To make the list of segments in station(0..) "Station" from the list of clusters to be reconstructed.
208f139e 168 /// Return a new TClonesArray of segments.
169 /// It is the responsibility of the user to delete it afterward.
96ebe67e 170 AliDebug(1,Form("Enter MakeSegmentsPerStation (1..) %d",station+1));
208f139e 171
96ebe67e 172 AliMUONVCluster *cluster1, *cluster2;
208f139e 173 AliMUONObjectPair *segment;
22ccc301 174 Double_t bendingSlope = 0, impactParam = 0., bendingMomentum = 0.; // to avoid compilation warning
208f139e 175 Int_t ch1 = 2 * station;
8d0843c6 176 Int_t ch2 = ch1 + 1;
7ec3b9cf 177
96ebe67e 178 // Create iterators to loop over clusters in both chambers
179 TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1));
180 TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
181
208f139e 182 // list of segments
96ebe67e 183 TClonesArray *segments = new TClonesArray("AliMUONObjectPair", 100);
7ec3b9cf 184 segments->SetOwner(kTRUE);
185
96ebe67e 186 // Loop over clusters in the first chamber of the station
187 while ( ( cluster1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
188
189 // reset cluster iterator of chamber 2
190 nextInCh2.Reset();
191
192 // Loop over clusters in the second chamber of the station
193 while ( ( cluster2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) {
194
195 // bending slope
196 bendingSlope = (cluster1->GetY() - cluster2->GetY()) / (cluster1->GetZ() - cluster2->GetZ());
197
198 // impact parameter
199 impactParam = cluster1->GetY() - cluster1->GetZ() * bendingSlope;
200
201 // absolute value of bending momentum
202 bendingMomentum = TMath::Abs(AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(impactParam));
203
22ccc301 204 // check for bending momentum within tolerances
3304fa09 205 if ((bendingMomentum < AliMUONReconstructor::GetRecoParam()->GetMaxBendingMomentum()) &&
96ebe67e 206 (bendingMomentum > AliMUONReconstructor::GetRecoParam()->GetMinBendingMomentum())) {
207
208 // make new segment
209 segment = new ((*segments)[segments->GetLast()+1]) AliMUONObjectPair(cluster1, cluster2, kFALSE, kFALSE);
210
211 // Printout for debug
212 if (AliLog::GetGlobalDebugLevel() > 1) {
7ec3b9cf 213 cout << "segmentIndex(0...): " << segments->GetLast() << endl;
214 segment->Dump();
96ebe67e 215 cout << "Cluster in first chamber" << endl;
216 cluster1->Print();
217 cout << "Cluster in second chamber" << endl;
218 cluster2->Print();
7ec3b9cf 219 }
96ebe67e 220
8d0843c6 221 }
96ebe67e 222
223 }
224
225 }
226
227 // Printout for debug
228 AliDebug(1,Form("Station: %d NSegments: %d ", station+1, segments->GetEntriesFast()));
229
208f139e 230 return segments;
8d0843c6 231}
232
ea94c18b 233 //__________________________________________________________________________
234void AliMUONVTrackReconstructor::RemoveIdenticalTracks()
235{
236 /// To remove identical tracks:
96ebe67e 237 /// Tracks are considered identical if they have all their clusters in common.
238 /// One keeps the track with the larger number of clusters if need be
ea94c18b 239 AliMUONTrack *track1, *track2, *trackToRemove;
96ebe67e 240 Int_t clustersInCommon, nClusters1, nClusters2;
ea94c18b 241 Bool_t removedTrack1;
242 // Loop over first track of the pair
243 track1 = (AliMUONTrack*) fRecTracksPtr->First();
244 while (track1) {
245 removedTrack1 = kFALSE;
96ebe67e 246 nClusters1 = track1->GetNClusters();
ea94c18b 247 // Loop over second track of the pair
248 track2 = (AliMUONTrack*) fRecTracksPtr->After(track1);
249 while (track2) {
96ebe67e 250 nClusters2 = track2->GetNClusters();
251 // number of clusters in common between two tracks
252 clustersInCommon = track1->ClustersInCommon(track2);
ea94c18b 253 // check for identical tracks
96ebe67e 254 if ((clustersInCommon == nClusters1) || (clustersInCommon == nClusters2)) {
ea94c18b 255 // decide which track to remove
96ebe67e 256 if (nClusters2 > nClusters1) {
ea94c18b 257 // remove track1 and continue the first loop with the track next to track1
258 trackToRemove = track1;
259 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
260 fRecTracksPtr->Remove(trackToRemove);
261 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
262 fNRecTracks--;
263 removedTrack1 = kTRUE;
264 break;
265 } else {
266 // remove track2 and continue the second loop with the track next to track2
267 trackToRemove = track2;
268 track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
269 fRecTracksPtr->Remove(trackToRemove);
270 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
271 fNRecTracks--;
272 }
273 } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
274 } // track2
275 if (removedTrack1) continue;
276 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
277 } // track1
278 return;
279}
280
281 //__________________________________________________________________________
282void AliMUONVTrackReconstructor::RemoveDoubleTracks()
283{
284 /// To remove double tracks:
96ebe67e 285 /// Tracks are considered identical if more than half of the clusters of the track
286 /// which has the smaller number of clusters are in common with the other track.
287 /// Among two identical tracks, one keeps the track with the larger number of clusters
ea94c18b 288 /// or, if these numbers are equal, the track with the minimum chi2.
289 AliMUONTrack *track1, *track2, *trackToRemove;
96ebe67e 290 Int_t clustersInCommon, nClusters1, nClusters2;
ea94c18b 291 Bool_t removedTrack1;
292 // Loop over first track of the pair
293 track1 = (AliMUONTrack*) fRecTracksPtr->First();
294 while (track1) {
295 removedTrack1 = kFALSE;
96ebe67e 296 nClusters1 = track1->GetNClusters();
ea94c18b 297 // Loop over second track of the pair
298 track2 = (AliMUONTrack*) fRecTracksPtr->After(track1);
299 while (track2) {
96ebe67e 300 nClusters2 = track2->GetNClusters();
301 // number of clusters in common between two tracks
302 clustersInCommon = track1->ClustersInCommon(track2);
ea94c18b 303 // check for identical tracks
96ebe67e 304 if (((nClusters1 < nClusters2) && (2 * clustersInCommon > nClusters1)) || (2 * clustersInCommon > nClusters2)) {
ea94c18b 305 // decide which track to remove
96ebe67e 306 if ((nClusters1 > nClusters2) || ((nClusters1 == nClusters2) && (track1->GetGlobalChi2() <= track2->GetGlobalChi2()))) {
ea94c18b 307 // remove track2 and continue the second loop with the track next to track2
308 trackToRemove = track2;
309 track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
310 fRecTracksPtr->Remove(trackToRemove);
311 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
312 fNRecTracks--;
313 } else {
314 // else remove track1 and continue the first loop with the track next to track1
315 trackToRemove = track1;
316 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
317 fRecTracksPtr->Remove(trackToRemove);
318 fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards
319 fNRecTracks--;
320 removedTrack1 = kTRUE;
321 break;
322 }
323 } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
324 } // track2
325 if (removedTrack1) continue;
326 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
327 } // track1
328 return;
329}
330
331 //__________________________________________________________________________
96ebe67e 332Double_t AliMUONVTrackReconstructor::TryOneCluster(const AliMUONTrackParam &trackParam, AliMUONVCluster* cluster,
333 AliMUONTrackParam &trackParamAtCluster, Bool_t updatePropagator)
ea94c18b 334{
96ebe67e 335/// Test the compatibility between the track and the cluster (using trackParam's covariance matrix):
ea94c18b 336/// return the corresponding Chi2
96ebe67e 337/// return trackParamAtCluster
ea94c18b 338
96ebe67e 339 // extrapolate track parameters and covariances at the z position of the tested cluster
340 trackParamAtCluster = trackParam;
341 AliMUONTrackExtrap::ExtrapToZCov(&trackParamAtCluster, cluster->GetZ(), updatePropagator);
ea94c18b 342
96ebe67e 343 // set pointer to cluster into trackParamAtCluster
344 trackParamAtCluster.SetClusterPtr(cluster);
ea94c18b 345
96ebe67e 346 // Set differences between trackParam and cluster in the bending and non bending directions
347 Double_t dX = cluster->GetX() - trackParamAtCluster.GetNonBendingCoor();
348 Double_t dY = cluster->GetY() - trackParamAtCluster.GetBendingCoor();
ea94c18b 349
019df241 350 // Calculate errors and covariances
96ebe67e 351 const TMatrixD& kParamCov = trackParamAtCluster.GetCovariances();
352 Double_t sigmaX2 = kParamCov(0,0) + cluster->GetErrX2();
353 Double_t sigmaY2 = kParamCov(2,2) + cluster->GetErrY2();
019df241 354
355 // Compute chi2
96ebe67e 356 return dX * dX / sigmaX2 + dY * dY / sigmaY2;
019df241 357
358}
359
360 //__________________________________________________________________________
96ebe67e 361Bool_t AliMUONVTrackReconstructor::TryOneClusterFast(const AliMUONTrackParam &trackParam, AliMUONVCluster* cluster)
019df241 362{
96ebe67e 363/// Test the compatibility between the track and the cluster within a wide fix window
019df241 364/// assuming linear propagation of the track:
365/// return kTRUE if they are compatibles
366
96ebe67e 367 Double_t dZ = cluster->GetZ() - trackParam.GetZ();
368 Double_t dX = cluster->GetX() - (trackParam.GetNonBendingCoor() + trackParam.GetNonBendingSlope() * dZ);
369 Double_t dY = cluster->GetY() - (trackParam.GetBendingCoor() + trackParam.GetBendingSlope() * dZ);
019df241 370
3304fa09 371 if (TMath::Abs(dX) > AliMUONReconstructor::GetRecoParam()->GetMaxNonBendingDistanceToTrack() ||
372 TMath::Abs(dY) > AliMUONReconstructor::GetRecoParam()->GetMaxBendingDistanceToTrack()) return kFALSE;
019df241 373
374 return kTRUE;
375
376}
377
378 //__________________________________________________________________________
96ebe67e 379Double_t AliMUONVTrackReconstructor::TryTwoClustersFast(const AliMUONTrackParam &trackParamAtCluster1, AliMUONVCluster* cluster2,
380 AliMUONTrackParam &trackParamAtCluster2)
019df241 381{
96ebe67e 382/// Test the compatibility between the track and the 2 clusters together (using trackParam's covariance matrix)
383/// assuming linear propagation between the two clusters:
384/// return the corresponding Chi2 accounting for covariances between the 2 clusters
385/// return trackParamAtCluster2
019df241 386
96ebe67e 387 // extrapolate linearly track parameters and covariances at the z position of the second cluster
388 trackParamAtCluster2 = trackParamAtCluster1;
389 AliMUONTrackExtrap::LinearExtrapToZ(&trackParamAtCluster2, cluster2->GetZ());
019df241 390
96ebe67e 391 // set pointer to cluster2 into trackParamAtCluster2
392 trackParamAtCluster2.SetClusterPtr(cluster2);
019df241 393
96ebe67e 394 // Set differences between track and clusters in the bending and non bending directions
395 AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr();
396 Double_t dX1 = cluster1->GetX() - trackParamAtCluster1.GetNonBendingCoor();
397 Double_t dX2 = cluster2->GetX() - trackParamAtCluster2.GetNonBendingCoor();
398 Double_t dY1 = cluster1->GetY() - trackParamAtCluster1.GetBendingCoor();
399 Double_t dY2 = cluster2->GetY() - trackParamAtCluster2.GetBendingCoor();
019df241 400
401 // Calculate errors and covariances
96ebe67e 402 const TMatrixD& kParamCov1 = trackParamAtCluster1.GetCovariances();
403 const TMatrixD& kParamCov2 = trackParamAtCluster2.GetCovariances();
404 Double_t dZ = trackParamAtCluster2.GetZ() - trackParamAtCluster1.GetZ();
405 Double_t sigma2X1 = kParamCov1(0,0) + cluster1->GetErrX2();
406 Double_t sigma2X2 = kParamCov2(0,0) + cluster2->GetErrX2();
019df241 407 Double_t covX1X2 = kParamCov1(0,0) + dZ * kParamCov1(0,1);
96ebe67e 408 Double_t sigma2Y1 = kParamCov1(2,2) + cluster1->GetErrY2();
409 Double_t sigma2Y2 = kParamCov2(2,2) + cluster2->GetErrY2();
019df241 410 Double_t covY1Y2 = kParamCov1(2,2) + dZ * kParamCov1(2,3);
411
412 // Compute chi2
413 Double_t detX = sigma2X1 * sigma2X2 - covX1X2 * covX1X2;
414 Double_t detY = sigma2Y1 * sigma2Y2 - covY1Y2 * covY1Y2;
415 if (detX == 0. || detY == 0.) return 1.e10;
416 return (dX1 * dX1 * sigma2X2 + dX2 * dX2 * sigma2X1 - 2. * dX1 * dX2 * covX1X2) / detX
417 + (dY1 * dY1 * sigma2Y2 + dY2 * dY2 * sigma2Y1 - 2. * dY1 * dY2 * covY1Y2) / detY;
418
419}
420
421 //__________________________________________________________________________
96ebe67e 422Bool_t AliMUONVTrackReconstructor::FollowLinearTrackInStation(AliMUONTrack &trackCandidate, const AliMUONVClusterStore& clusterStore,
423 Int_t nextStation)
019df241 424{
96ebe67e 425 /// Follow trackCandidate in station(0..) nextStation assuming linear propagation, and search for compatible cluster(s)
019df241 426 /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks:
427 /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of
428 /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure.
429 /// Remove the obsolete "trackCandidate" at the end.
96ebe67e 430 /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority.
431 /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE)
019df241 432 AliDebug(1,Form("Enter FollowLinearTrackInStation(1..) %d", nextStation+1));
433
434 // Order the chamber according to the propagation direction (tracking starts with chamber 2):
435 // - nextStation == station(1...) 5 => forward propagation
436 // - nextStation < station(1...) 5 => backward propagation
437 Int_t ch1, ch2;
438 if (nextStation==4) {
439 ch1 = 2*nextStation+1;
440 ch2 = 2*nextStation;
ea94c18b 441 } else {
019df241 442 ch1 = 2*nextStation;
443 ch2 = 2*nextStation+1;
ea94c18b 444 }
445
96ebe67e 446 Double_t chi2WithOneCluster = 1.e10;
447 Double_t chi2WithTwoClusters = 1.e10;
448 Double_t maxChi2WithOneCluster = 2. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() *
449 AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
450 Double_t maxChi2WithTwoClusters = 4. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() *
451 AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 4 because 4 quantities in chi2
452 Double_t bestChi2WithOneCluster = maxChi2WithOneCluster;
453 Double_t bestChi2WithTwoClusters = maxChi2WithTwoClusters;
454 Bool_t foundOneCluster = kFALSE;
455 Bool_t foundTwoClusters = kFALSE;
019df241 456 AliMUONTrack *newTrack = 0x0;
96ebe67e 457 AliMUONVCluster *clusterCh1, *clusterCh2;
458 AliMUONTrackParam extrapTrackParamAtCluster1;
459 AliMUONTrackParam extrapTrackParamAtCluster2;
460 AliMUONTrackParam bestTrackParamAtCluster1;
461 AliMUONTrackParam bestTrackParamAtCluster2;
462
463 Int_t nClusters = clusterStore.GetSize();
464 Bool_t *clusterCh1Used = new Bool_t[nClusters];
465 for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE;
466 Int_t iCluster1;
019df241 467
468 // Get track parameters
96ebe67e 469 AliMUONTrackParam trackParam(*(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First());
019df241 470
471 // Add MCS effect
472 AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.);
473
474 // Printout for debuging
475 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 476 cout << "FollowLinearTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl;
019df241 477 }
478
96ebe67e 479 // Create iterators to loop over clusters in both chambers
480 TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1));
481 TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
482
483 // look for candidates in chamber 2
484 while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) {
019df241 485
96ebe67e 486 // try to add the current cluster fast
487 if (!TryOneClusterFast(trackParam, clusterCh2)) continue;
019df241 488
96ebe67e 489 // try to add the current cluster accuratly
490 extrapTrackParamAtCluster2 = trackParam;
491 AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster2, clusterCh2->GetZ());
492 chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster2, clusterCh2, extrapTrackParamAtCluster2);
019df241 493
96ebe67e 494 // if good chi2 then try to attach a cluster in the other chamber too
495 if (chi2WithOneCluster < maxChi2WithOneCluster) {
496 Bool_t foundSecondCluster = kFALSE;
019df241 497
498 // Printout for debuging
499 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 500 cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch2+1
501 << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
502 cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl;
019df241 503 }
504
505 // add MCS effect
96ebe67e 506 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCluster2,AliMUONConstants::ChamberThicknessInX0(),1.);
019df241 507
96ebe67e 508 // reset cluster iterator of chamber 1
509 nextInCh1.Reset();
510 iCluster1 = -1;
511
512 // look for second candidates in chamber 1
513 while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
514 iCluster1++;
019df241 515
96ebe67e 516 // try to add the current cluster fast
517 if (!TryOneClusterFast(extrapTrackParamAtCluster2, clusterCh1)) continue;
019df241 518
96ebe67e 519 // try to add the current cluster in addition to the one found in the previous chamber
520 chi2WithTwoClusters = TryTwoClustersFast(extrapTrackParamAtCluster2, clusterCh1, extrapTrackParamAtCluster1);
019df241 521
96ebe67e 522 // if good chi2 then consider to add the 2 clusters to the "trackCandidate"
523 if (chi2WithTwoClusters < maxChi2WithTwoClusters) {
524 foundSecondCluster = kTRUE;
525 foundTwoClusters = kTRUE;
019df241 526
527 // Printout for debuging
528 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 529 cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch1+1
530 << " (Chi2 = " << chi2WithTwoClusters << ")" << endl;
019df241 531 }
532
3304fa09 533 if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) {
96ebe67e 534 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters
019df241 535 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
96ebe67e 536 extrapTrackParamAtCluster1.SetRemovable(kTRUE);
537 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster1,*clusterCh1);
538 extrapTrackParamAtCluster2.SetRemovable(kTRUE);
539 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster2,*clusterCh2);
540 newTrack->GetTrackParamAtCluster()->Sort();
019df241 541 fNRecTracks++;
542
96ebe67e 543 // Tag clusterCh1 as used
544 clusterCh1Used[iCluster1] = kTRUE;
019df241 545
546 // Printout for debuging
547 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 548 cout << "FollowLinearTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl;
019df241 549 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
550 }
551
96ebe67e 552 } else if (chi2WithTwoClusters < bestChi2WithTwoClusters) {
553 // keep track of the best couple of clusters
554 bestChi2WithTwoClusters = chi2WithTwoClusters;
555 bestTrackParamAtCluster1 = extrapTrackParamAtCluster1;
556 bestTrackParamAtCluster2 = extrapTrackParamAtCluster2;
019df241 557 }
558
559 }
560
561 }
562
96ebe67e 563 // if no cluster found in chamber1 then consider to add clusterCh2 only
564 if (!foundSecondCluster) {
565 foundOneCluster = kTRUE;
019df241 566
3304fa09 567 if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) {
96ebe67e 568 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
019df241 569 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
96ebe67e 570 extrapTrackParamAtCluster2.SetRemovable(kFALSE);
571 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster2,*clusterCh2);
572 newTrack->GetTrackParamAtCluster()->Sort();
019df241 573 fNRecTracks++;
574
575 // Printout for debuging
576 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 577 cout << "FollowLinearTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl;
019df241 578 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
579 }
580
96ebe67e 581 } else if (!foundTwoClusters && chi2WithOneCluster < bestChi2WithOneCluster) {
582 // keep track of the best cluster except if a couple of clusters has already been found
583 bestChi2WithOneCluster = chi2WithOneCluster;
584 bestTrackParamAtCluster1 = extrapTrackParamAtCluster2;
019df241 585 }
586
587 }
588
589 }
590
591 }
592
593 // look for candidates in chamber 1 not already attached to a track
96ebe67e 594 // if we want to keep all possible tracks or if no good couple of clusters has been found
595 if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks() || !foundTwoClusters) {
019df241 596
597 // Printout for debuging
598 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 599 cout << "FollowLinearTrackInStation: look for single cluster in chamber(1..): " << ch1+1 << endl;
019df241 600 }
601
602 //Extrapolate trackCandidate to chamber "ch2"
603 AliMUONTrackExtrap::LinearExtrapToZ(&trackParam, AliMUONConstants::DefaultChamberZ(ch2));
604
605 // add MCS effect for next step
606 AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.);
607
96ebe67e 608 // reset cluster iterator of chamber 1
609 nextInCh1.Reset();
610 iCluster1 = -1;
611
612 // look for second candidates in chamber 1
613 while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
614 iCluster1++;
019df241 615
96ebe67e 616 if (clusterCh1Used[iCluster1]) continue; // Skip clusters already used
019df241 617
96ebe67e 618 // try to add the current cluster fast
619 if (!TryOneClusterFast(trackParam, clusterCh1)) continue;
019df241 620
96ebe67e 621 // try to add the current cluster accuratly
622 extrapTrackParamAtCluster1 = trackParam;
623 AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtCluster1, clusterCh1->GetZ());
624 chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCluster1, clusterCh1, extrapTrackParamAtCluster1);
019df241 625
96ebe67e 626 // if good chi2 then consider to add clusterCh1
627 // We do not try to attach a cluster in the other chamber too since it has already been done above
628 if (chi2WithOneCluster < maxChi2WithOneCluster) {
629 foundOneCluster = kTRUE;
019df241 630
631 // Printout for debuging
632 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 633 cout << "FollowLinearTrackInStation: found one cluster in chamber(1..): " << ch1+1
634 << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
019df241 635 }
636
3304fa09 637 if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) {
96ebe67e 638 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
019df241 639 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
96ebe67e 640 extrapTrackParamAtCluster1.SetRemovable(kFALSE);
641 newTrack->AddTrackParamAtCluster(extrapTrackParamAtCluster1,*clusterCh1);
642 newTrack->GetTrackParamAtCluster()->Sort();
019df241 643 fNRecTracks++;
644
645 // Printout for debuging
646 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 647 cout << "FollowLinearTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl;
019df241 648 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
649 }
650
96ebe67e 651 } else if (chi2WithOneCluster < bestChi2WithOneCluster) {
652 // keep track of the best cluster except if a couple of clusters has already been found
653 bestChi2WithOneCluster = chi2WithOneCluster;
654 bestTrackParamAtCluster1 = extrapTrackParamAtCluster1;
019df241 655 }
656
657 }
658
659 }
660
661 }
662
663 // fill out the best track if required else clean up the fRecTracksPtr array
3304fa09 664 if (!AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) {
96ebe67e 665 if (foundTwoClusters) {
666 bestTrackParamAtCluster1.SetRemovable(kTRUE);
667 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster1,*(bestTrackParamAtCluster1.GetClusterPtr()));
668 bestTrackParamAtCluster2.SetRemovable(kTRUE);
669 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster2,*(bestTrackParamAtCluster2.GetClusterPtr()));
670 trackCandidate.GetTrackParamAtCluster()->Sort();
019df241 671
672 // Printout for debuging
673 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 674 cout << "FollowLinearTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl;
019df241 675 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
676 }
677
96ebe67e 678 } else if (foundOneCluster) {
679 bestTrackParamAtCluster1.SetRemovable(kFALSE);
680 trackCandidate.AddTrackParamAtCluster(bestTrackParamAtCluster1,*(bestTrackParamAtCluster1.GetClusterPtr()));
681 trackCandidate.GetTrackParamAtCluster()->Sort();
019df241 682
683 // Printout for debuging
684 if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
96ebe67e 685 cout << "FollowLinearTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl;
019df241 686 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
687 }
688
dd230855 689 } else {
96ebe67e 690 delete [] clusterCh1Used;
dd230855 691 return kFALSE;
692 }
019df241 693
96ebe67e 694 } else if (foundOneCluster || foundTwoClusters) {
019df241 695
696 // remove obsolete track
697 fRecTracksPtr->Remove(&trackCandidate);
698 fNRecTracks--;
699
dd230855 700 } else {
96ebe67e 701 delete [] clusterCh1Used;
dd230855 702 return kFALSE;
703 }
ea94c18b 704
96ebe67e 705 delete [] clusterCh1Used;
019df241 706 return kTRUE;
ea94c18b 707
708}
709
710 //__________________________________________________________________________
7ec3b9cf 711void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(AliMUONVTrackStore& trackStore,
712 const AliMUONVTriggerTrackStore& triggerTrackStore,
713 const AliMUONVTriggerStore& triggerStore,
714 const AliMUONTrackHitPattern& trackHitPattern)
8d0843c6 715{
716 /// Try to match track from tracking system with trigger track
b709ac13 717 AliCodeTimerAuto("");
fda59e58 718
719 const Double_t kDeltaZ = TMath::Abs(AliMUONConstants::DefaultChamberZ(12) - AliMUONConstants::DefaultChamberZ(10));
720
721 //static const Double_t kDistSigma[3]={1,1,0.02}; // sigma of distributions (trigger-track) X,Y,slopeY
722 // sigma of distributions (trigger-track) X,Y,slopeY
723 const Double_t kDistSigma[3]={AliMUONConstants::TriggerNonBendingReso(),
724 AliMUONConstants::TriggerBendingReso(),
725 1.414 * AliMUONConstants::TriggerBendingReso()/kDeltaZ};
726
727 const Double_t kTrigNonBendReso = AliMUONConstants::TriggerNonBendingReso();
728 const Double_t kTrigBendReso = AliMUONConstants::TriggerBendingReso();
729 const Double_t kTrigSlopeBendReso = 1.414 * AliMUONConstants::TriggerBendingReso()/kDeltaZ;
730 const Double_t kTrigCovSlopeBend = - kTrigBendReso * kTrigBendReso / kDeltaZ;
731
732 // Covariance matrix 3x3 (X,Y,slopeY) for trigger tracks
733 TMatrixD trigCov(3,3);
734 trigCov.Zero();
735 trigCov(0,0) = kTrigNonBendReso * kTrigNonBendReso;
736 trigCov(1,1) = kTrigBendReso * kTrigBendReso;
737 trigCov(2,2) = kTrigSlopeBendReso * kTrigSlopeBendReso;
738 trigCov(1,2) = trigCov(2,1) = kTrigCovSlopeBend;
739
7771752e 740 Int_t matchTrigger;
7ec3b9cf 741 Int_t loTrgNum(-1);
fda59e58 742 Double_t distTriggerTrack[3], sigma2[3];
208f139e 743 Double_t xTrack, yTrack, ySlopeTrack, chi2MatchTrigger, minChi2MatchTrigger, chi2;
7ec3b9cf 744
745 TIter itTrack(trackStore.CreateIterator());
746 AliMUONTrack* track;
fda59e58 747
748 const Float_t kZFilterOut = AliMUONConstants::MuonFilterZEnd();
749 const Float_t kFilterThickness = TMath::Abs(kZFilterOut-AliMUONConstants::MuonFilterZBeg()); // cm
750 const Int_t kFirstTrigCh = AliMUONConstants::NTrackingCh();
8d0843c6 751
7ec3b9cf 752 while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) )
753 {
423b32ca 754 matchTrigger = 0;
8d0843c6 755 chi2MatchTrigger = 0.;
c6ba19f7 756 loTrgNum = -1;
7771752e 757 Int_t doubleMatch=-1; // Check if track matches 2 trigger tracks
758 Double_t doubleChi2 = -1.;
7ec3b9cf 759
96ebe67e 760 AliMUONTrackParam trackParam(*((AliMUONTrackParam*) (track->GetTrackParamAtCluster()->Last())));
fda59e58 761
762 AliMUONTrackExtrap::ExtrapToZCov(&trackParam, kZFilterOut); // Extrap to muon filter end
763 AliMUONTrackExtrap::AddMCSEffect(&trackParam, kFilterThickness, AliMUONConstants::MuonFilterX0()); // Add MCS effects
764 AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(kFirstTrigCh)); // extrap to 1st trigger chamber
765
766 const TMatrixD& kParamCov = trackParam.GetCovariances();
8d0843c6 767
768 xTrack = trackParam.GetNonBendingCoor();
769 yTrack = trackParam.GetBendingCoor();
770 ySlopeTrack = trackParam.GetBendingSlope();
fda59e58 771
772 // Covariance matrix 3x3 (X,Y,slopeY) for tracker tracks
773 TMatrixD trackCov(3,3);
774 trackCov.Zero();
775 trackCov(0,0) = kParamCov(0,0);
776 trackCov(1,1) = kParamCov(2,2);
777 trackCov(2,2) = kParamCov(3,3);
778 trackCov(1,2) = kParamCov(2,3);
779 trackCov(2,1) = kParamCov(3,2);
780
781 TMatrixD sumCov(trackCov,TMatrixD::kPlus,trigCov);
782
783 Bool_t isCovOK = kTRUE;
784
785 if (sumCov.Determinant() != 0) {
786 sumCov.Invert();
787 } else {
788 AliWarning(" Determinant = 0");
789 isCovOK = kFALSE;
790 sigma2[0] = kParamCov(0,0);
791 sigma2[1] = kParamCov(2,2);
792 sigma2[2] = kParamCov(3,3);
793 for (Int_t iVar = 0; iVar < 3; iVar++) sigma2[iVar] += kDistSigma[iVar] * kDistSigma[iVar];
794 }
795
208f139e 796 minChi2MatchTrigger = 999.;
fda59e58 797
7ec3b9cf 798 AliMUONTriggerTrack *triggerTrack;
799 TIter itTriggerTrack(triggerTrackStore.CreateIterator());
800 while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack() ) ) )
801 {
fda59e58 802 distTriggerTrack[0] = triggerTrack->GetX11()-xTrack;
803 distTriggerTrack[1] = triggerTrack->GetY11()-yTrack;
804 distTriggerTrack[2] = TMath::Tan(triggerTrack->GetThetay())-ySlopeTrack;
805
806 if(isCovOK){
807 TMatrixD paramDiff(3,1);
808 for(Int_t iVar = 0; iVar < 3; iVar++)
809 paramDiff(iVar,0) = distTriggerTrack[iVar];
810
811 TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff);
812 TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp);
813 chi2 = chi2M(0,0);
814 }
815 else {
816 chi2 = 0.;
817 for (Int_t iVar = 0; iVar < 3; iVar++) chi2 += distTriggerTrack[iVar]*distTriggerTrack[iVar]/sigma2[iVar];
818 }
819
208f139e 820 chi2 /= 3.; // Normalized Chi2: 3 degrees of freedom (X,Y,slopeY)
3304fa09 821 if (chi2 < AliMUONReconstructor::GetRecoParam()->GetMaxNormChi2MatchTrigger())
7ec3b9cf 822 {
823 Bool_t isDoubleTrack = (TMath::Abs(chi2 - minChi2MatchTrigger)<1.);
3304fa09 824 if (chi2 < minChi2MatchTrigger && chi2 < AliMUONReconstructor::GetRecoParam()->GetMaxNormChi2MatchTrigger())
7ec3b9cf 825 {
826 if(isDoubleTrack)
827 {
828 doubleMatch = loTrgNum;
829 doubleChi2 = chi2MatchTrigger;
830 }
831 minChi2MatchTrigger = chi2;
832 chi2MatchTrigger = chi2;
833 loTrgNum = triggerTrack->GetLoTrgNum();
834 AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(loTrgNum);
835 matchTrigger=1;
836 if(locTrg->LoLpt()>0)matchTrigger=2;
837 if(locTrg->LoHpt()>0)matchTrigger=3;
838 }
839 else if(isDoubleTrack)
840 {
841 doubleMatch = triggerTrack->GetLoTrgNum();
842 doubleChi2 = chi2;
843 }
8d0843c6 844 }
8d0843c6 845 }
7ec3b9cf 846 if(doubleMatch>=0)
847 { // If two trigger tracks match, select the one passing more trigger cuts
848 AliDebug(1, Form("Two candidates found: %i and %i",loTrgNum,doubleMatch));
849 AliMUONLocalTrigger* locTrg1 = triggerStore.FindLocal(doubleMatch);
850 if((locTrg1->LoLpt()>0 && matchTrigger<2) || (locTrg1->LoHpt() && matchTrigger<3))
851 {
852 if(locTrg1->LoHpt()>0)matchTrigger=3;
853 else matchTrigger=2;
854 loTrgNum = doubleMatch;
855 chi2MatchTrigger=doubleChi2;
856 }
7771752e 857 }
8d0843c6 858
859 track->SetMatchTrigger(matchTrigger);
c6ba19f7 860 track->SetLoTrgNum(loTrgNum);
8d0843c6 861 track->SetChi2MatchTrigger(chi2MatchTrigger);
7ec3b9cf 862
863 AliMUONLocalTrigger* locTrg = static_cast<AliMUONLocalTrigger*>(triggerStore.FindLocal(loTrgNum));
864
865 if (locTrg)
866 {
867 track->SetLocalTrigger(locTrg->LoCircuit(),
868 locTrg->LoStripX(),
869 locTrg->LoStripY(),
870 locTrg->LoDev(),
871 locTrg->LoLpt(),
872 locTrg->LoHpt());
873 }
874 }
875
876 trackHitPattern.GetHitPattern(trackStore,triggerStore);
8d0843c6 877}
878
ea94c18b 879 //__________________________________________________________________________
880void AliMUONVTrackReconstructor::EventReconstructTrigger(const AliMUONTriggerCircuit& circuit,
881 const AliMUONVTriggerStore& triggerStore,
882 AliMUONVTriggerTrackStore& triggerTrackStore)
8d0843c6 883{
71a2d3aa 884 /// To make the trigger tracks from Local Trigger
7ec3b9cf 885 AliDebug(1, "");
b709ac13 886 AliCodeTimerAuto("");
7ec3b9cf 887
888 AliMUONGlobalTrigger* globalTrigger = triggerStore.Global();
e6b25a6e 889
7ec3b9cf 890 UChar_t gloTrigPat = 0;
e6b25a6e 891
7ec3b9cf 892 if (globalTrigger)
893 {
894 gloTrigPat = globalTrigger->GetGlobalResponse();
e6b25a6e 895 }
896
7ec3b9cf 897 TIter next(triggerStore.CreateIterator());
898 AliMUONLocalTrigger* locTrg(0x0);
8d0843c6 899
e6b25a6e 900 Float_t z11 = AliMUONConstants::DefaultChamberZ(10);
901 Float_t z21 = AliMUONConstants::DefaultChamberZ(12);
7cf63da6 902
7ec3b9cf 903 AliMUONTriggerTrack triggerTrack;
904
905 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
906 {
907 Bool_t xTrig=kFALSE;
908 Bool_t yTrig=kFALSE;
909
32ab62c9 910 Int_t localBoardId = locTrg->LoCircuit();
7ec3b9cf 911 if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 &&
912 locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X
913 else xTrig=kTRUE; // trigger in X
914 if (locTrg->LoTrigY()==1 &&
915 locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
916 else yTrig = kTRUE; // trigger in Y
917
918 if (xTrig && yTrig)
919 { // make Trigger Track if trigger in X and Y
8b0baca4 920
32ab62c9 921 Float_t y11 = circuit.GetY11Pos(localBoardId, locTrg->LoStripX());
7ec3b9cf 922 // need first to convert deviation to [0-30]
923 // (see AliMUONLocalTriggerBoard::LocalTrigger)
924 Int_t deviation = locTrg->LoDev();
925 Int_t sign = 0;
926 if ( !locTrg->LoSdev() && deviation ) sign=-1;
927 if ( !locTrg->LoSdev() && !deviation ) sign= 0;
928 if ( locTrg->LoSdev() == 1 ) sign=+1;
929 deviation *= sign;
930 deviation += 15;
931 Int_t stripX21 = locTrg->LoStripX()+deviation+1;
32ab62c9 932 Float_t y21 = circuit.GetY21Pos(localBoardId, stripX21);
933 Float_t x11 = circuit.GetX11Pos(localBoardId, locTrg->LoStripY());
7ec3b9cf 934
935 AliDebug(1, Form(" MakeTriggerTrack %d %d %d %d %f %f %f \n",locTrg->LoCircuit(),
936 locTrg->LoStripX(),locTrg->LoStripX()+locTrg->LoDev()+1,locTrg->LoStripY(),y11, y21, x11));
937
938 Float_t thetax = TMath::ATan2( x11 , z11 );
939 Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) );
940
941 triggerTrack.SetX11(x11);
942 triggerTrack.SetY11(y11);
943 triggerTrack.SetThetax(thetax);
944 triggerTrack.SetThetay(thetay);
945 triggerTrack.SetGTPattern(gloTrigPat);
32ab62c9 946 triggerTrack.SetLoTrgNum(localBoardId);
7ec3b9cf 947
948 triggerTrackStore.Add(triggerTrack);
949 } // board is fired
e6b25a6e 950 } // end of loop on Local Trigger
8d0843c6 951}
ea94c18b 952