]>
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 | ||
18 | //////////////////////////////////// | |
06ca6d7b | 19 | /// |
c4ee792d | 20 | /// \class AliMUONVTrackReconstructor |
06ca6d7b | 21 | /// Virtual MUON track reconstructor in ALICE (class renamed from AliMUONEventReconstructor) |
22 | /// | |
23 | /// This class contains as data: | |
24 | /// * a pointer to the array of hits to be reconstructed (the event) | |
06ca6d7b | 25 | /// * a pointer to the array of reconstructed tracks |
26 | /// | |
27 | /// It contains as methods, among others: | |
28 | /// * EventReconstruct to build the muon tracks | |
29 | /// * EventReconstructTrigger to build the trigger tracks | |
30 | /// | |
dfb547bf | 31 | /// Several options and adjustable parameters are available for both Kalman and Original |
32 | /// tracking algorithms (hard coded for the moment in AliMUONVTrackReconstructor.cxx): | |
33 | /// - *fgkSigmaToCutForTracking* : quality cut used to select new clusters to be | |
34 | /// attached to the track candidate and to select good tracks. | |
019df241 | 35 | /// - *fgkMakeTrackCandidatesFast* : if this flag is set to 'true', the track candidates |
36 | /// are made assuming linear propagation between stations 4 and 5. | |
dfb547bf | 37 | /// - *fgkTrackAllTracks* : according to the value of this flag, in case that several |
38 | /// new clusters pass the quality cut, either we consider all the possibilities | |
39 | /// (duplicating tracks) or we attach only the best cluster. | |
40 | /// - *fgkRecoverTracks* : if this flag is set to 'true', we try to recover the tracks | |
41 | /// lost during the tracking by removing the worst of the 2 clusters attached in the | |
42 | /// previous station. | |
43 | /// - *fgkImproveTracks* : if this flag is set to 'true', we try to improve the quality | |
44 | /// of the tracks at the end of the tracking by removing clusters that do not pass | |
45 | /// new quality cut (within the limit that we must keep at least one cluster per | |
46 | /// the station). | |
47 | /// - *fgkSigmaToCutForImprovement* : quality cut used when we try to improve the | |
48 | /// quality of the tracks. | |
49 | /// | |
c4ee792d | 50 | /// \author Philippe Pillot |
51 | /// | |
8d0843c6 | 52 | //////////////////////////////////// |
53 | ||
8d0843c6 | 54 | #include "AliMUONVTrackReconstructor.h" |
7ec3b9cf | 55 | |
8d0843c6 | 56 | #include "AliMUONConstants.h" |
ea94c18b | 57 | #include "AliMUONRawCluster.h" |
8d0843c6 | 58 | #include "AliMUONHitForRec.h" |
208f139e | 59 | #include "AliMUONObjectPair.h" |
8d0843c6 | 60 | #include "AliMUONTriggerTrack.h" |
e1a10d41 | 61 | #include "AliMUONTriggerCircuit.h" |
8d0843c6 | 62 | #include "AliMUONLocalTrigger.h" |
63 | #include "AliMUONGlobalTrigger.h" | |
8d0843c6 | 64 | #include "AliMUONTrack.h" |
37827b29 | 65 | #include "AliMUONTrackParam.h" |
66 | #include "AliMUONTrackExtrap.h" | |
7771752e | 67 | #include "AliMUONTrackHitPattern.h" |
7ec3b9cf | 68 | #include "AliMUONVTrackStore.h" |
69 | #include "AliMUONVClusterStore.h" | |
70 | #include "AliMUONRawCluster.h" | |
7ec3b9cf | 71 | #include "AliMUONVTriggerStore.h" |
72 | #include "AliMUONVTriggerTrackStore.h" | |
ea94c18b | 73 | #include "AliMpDEManager.h" |
74 | ||
75 | #include "AliLog.h" | |
76 | #include "AliTracker.h" | |
8d0843c6 | 77 | |
4889d34c | 78 | #include <TClonesArray.h> |
79 | #include <TMath.h> | |
ea94c18b | 80 | #include <TMatrixD.h> |
81 | ||
82 | #include <Riostream.h> | |
4889d34c | 83 | |
78649106 | 84 | /// \cond CLASSIMP |
8d0843c6 | 85 | ClassImp(AliMUONVTrackReconstructor) // Class implementation in ROOT context |
78649106 | 86 | /// \endcond |
8d0843c6 | 87 | |
019df241 | 88 | |
8d0843c6 | 89 | //************* Defaults parameters for reconstruction |
90 | const Double_t AliMUONVTrackReconstructor::fgkDefaultMinBendingMomentum = 3.0; | |
91 | const Double_t AliMUONVTrackReconstructor::fgkDefaultMaxBendingMomentum = 3000.0; | |
208f139e | 92 | const Double_t AliMUONVTrackReconstructor::fgkDefaultMaxNormChi2MatchTrigger = 16.0; |
019df241 | 93 | const Double_t AliMUONVTrackReconstructor::fgkMaxTrackingDistanceBending = 2.; |
94 | const Double_t AliMUONVTrackReconstructor::fgkMaxTrackingDistanceNonBending = 2.; | |
8d0843c6 | 95 | |
ea94c18b | 96 | const Double_t AliMUONVTrackReconstructor::fgkSigmaToCutForTracking = 6.0; |
019df241 | 97 | const Bool_t AliMUONVTrackReconstructor::fgkMakeTrackCandidatesFast = kFALSE; |
ea94c18b | 98 | const Bool_t AliMUONVTrackReconstructor::fgkTrackAllTracks = kTRUE; |
ea94c18b | 99 | const Bool_t AliMUONVTrackReconstructor::fgkRecoverTracks = kTRUE; |
100 | const Bool_t AliMUONVTrackReconstructor::fgkImproveTracks = kTRUE; | |
019df241 | 101 | const Double_t AliMUONVTrackReconstructor::fgkSigmaToCutForImprovement = 4.0; |
ea94c18b | 102 | |
103 | ||
104 | //__________________________________________________________________________ | |
7ec3b9cf | 105 | AliMUONVTrackReconstructor::AliMUONVTrackReconstructor() |
8d0843c6 | 106 | : TObject(), |
107 | fMinBendingMomentum(fgkDefaultMinBendingMomentum), | |
108 | fMaxBendingMomentum(fgkDefaultMaxBendingMomentum), | |
208f139e | 109 | fMaxNormChi2MatchTrigger(fgkDefaultMaxNormChi2MatchTrigger), |
8d0843c6 | 110 | fHitsForRecPtr(0x0), |
111 | fNHitsForRec(0), | |
112 | fNHitsForRecPerChamber(0x0), | |
113 | fIndexOfFirstHitForRecPerChamber(0x0), | |
8d0843c6 | 114 | fRecTracksPtr(0x0), |
7ec3b9cf | 115 | fNRecTracks(0) |
8d0843c6 | 116 | { |
117 | /// Constructor for class AliMUONVTrackReconstructor | |
8d0843c6 | 118 | fNHitsForRecPerChamber = new Int_t[AliMUONConstants::NTrackingCh()]; |
119 | fIndexOfFirstHitForRecPerChamber = new Int_t[AliMUONConstants::NTrackingCh()]; | |
120 | ||
8d0843c6 | 121 | // Memory allocation for the TClonesArray of hits for reconstruction |
122 | // Is 10000 the right size ???? | |
123 | fHitsForRecPtr = new TClonesArray("AliMUONHitForRec", 10000); | |
ea94c18b | 124 | |
125 | // Memory allocation for the TClonesArray of reconstructed tracks | |
126 | fRecTracksPtr = new TClonesArray("AliMUONTrack", 10); | |
7ec3b9cf | 127 | |
208f139e | 128 | // set the magnetic field for track extrapolations |
8d0843c6 | 129 | const AliMagF* kField = AliTracker::GetFieldMap(); |
130 | if (!kField) AliFatal("No field available"); | |
37827b29 | 131 | AliMUONTrackExtrap::SetField(kField); |
8d0843c6 | 132 | } |
133 | ||
134 | //__________________________________________________________________________ | |
ea94c18b | 135 | AliMUONVTrackReconstructor::~AliMUONVTrackReconstructor() |
8d0843c6 | 136 | { |
137 | /// Destructor for class AliMUONVTrackReconstructor | |
8d0843c6 | 138 | delete [] fNHitsForRecPerChamber; |
139 | delete [] fIndexOfFirstHitForRecPerChamber; | |
8d0843c6 | 140 | delete fHitsForRecPtr; |
ea94c18b | 141 | delete fRecTracksPtr; |
8d0843c6 | 142 | } |
143 | ||
ea94c18b | 144 | //__________________________________________________________________________ |
145 | void AliMUONVTrackReconstructor::ResetHitsForRec() | |
146 | { | |
147 | /// To reset the TClonesArray of HitsForRec, | |
148 | /// and the number of HitForRec and the index of the first HitForRec per chamber | |
149 | if (fHitsForRecPtr) fHitsForRecPtr->Clear("C"); | |
150 | fNHitsForRec = 0; | |
151 | for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) { | |
152 | fNHitsForRecPerChamber[ch] = 0; | |
153 | fIndexOfFirstHitForRecPerChamber[ch] = 0; | |
154 | } | |
155 | } | |
156 | ||
157 | //__________________________________________________________________________ | |
158 | void AliMUONVTrackReconstructor::ResetTracks() | |
159 | { | |
160 | /// To reset the TClonesArray of reconstructed tracks | |
161 | if (fRecTracksPtr) fRecTracksPtr->Clear("C"); | |
162 | fNRecTracks = 0; | |
163 | return; | |
164 | } | |
165 | ||
166 | //__________________________________________________________________________ | |
167 | void AliMUONVTrackReconstructor::EventReconstruct(const AliMUONVClusterStore& clusterStore, AliMUONVTrackStore& trackStore) | |
168 | { | |
169 | /// To reconstruct one event | |
170 | AliDebug(1,""); | |
171 | ||
172 | ResetTracks(); | |
173 | ResetHitsForRec(); | |
174 | AddHitsForRecFromRawClusters(clusterStore); | |
175 | MakeTracks(); | |
176 | ||
177 | // Add tracks to MUON data container | |
178 | for (Int_t i=0; i<fNRecTracks; ++i) | |
179 | { | |
180 | AliMUONTrack * track = (AliMUONTrack*) fRecTracksPtr->At(i); | |
181 | trackStore.Add(*track); | |
182 | } | |
183 | } | |
184 | ||
185 | //__________________________________________________________________________ | |
186 | void AliMUONVTrackReconstructor::AddHitsForRecFromRawClusters(const AliMUONVClusterStore& clusterStore) | |
7ec3b9cf | 187 | { |
188 | /// Build internal array of hit for rec from clusterStore | |
189 | ||
190 | TIter next(clusterStore.CreateIterator()); | |
191 | AliMUONRawCluster* clus(0x0); | |
192 | Int_t iclus(0); | |
193 | ||
194 | while ( ( clus = static_cast<AliMUONRawCluster*>(next()) ) ) | |
195 | { | |
196 | // new AliMUONHitForRec from raw cluster | |
197 | // and increment number of AliMUONHitForRec's (total and in chamber) | |
198 | AliMUONHitForRec* hitForRec = new ((*fHitsForRecPtr)[fNHitsForRec]) AliMUONHitForRec(clus); | |
199 | fNHitsForRec++; | |
200 | // more information into HitForRec | |
201 | hitForRec->SetBendingReso2(clus->GetErrY() * clus->GetErrY()); | |
202 | hitForRec->SetNonBendingReso2(clus->GetErrX() * clus->GetErrX()); | |
203 | // original raw cluster | |
204 | Int_t ch = AliMpDEManager::GetChamberId(clus->GetDetElemId()); | |
205 | hitForRec->SetChamberNumber(ch); | |
206 | hitForRec->SetHitNumber(iclus); | |
207 | // Z coordinate of the raw cluster (cm) | |
208 | hitForRec->SetZ(clus->GetZ(0)); | |
209 | if (AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 3) { | |
210 | cout << "Chamber " << ch <<" raw cluster " << iclus << " : " << endl; | |
211 | clus->Print("full"); | |
212 | cout << "AliMUONHitForRec number (1...): " << fNHitsForRec << endl; | |
213 | hitForRec->Print("full"); | |
214 | } | |
215 | ++iclus; | |
216 | } // end of chamber loop | |
217 | ||
218 | SortHitsForRecWithIncreasingChamber(); | |
219 | ||
220 | AliDebug(1,"End of AddHitsForRecFromRawClusters"); | |
221 | ||
222 | if (AliLog::GetGlobalDebugLevel() > 0) | |
223 | { | |
224 | AliDebug(1, Form("NHitsForRec: %d",fNHitsForRec)); | |
225 | for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) | |
226 | { | |
227 | AliDebug(1, Form("Chamber(0...): %d",ch)); | |
228 | AliDebug(1, Form("NHitsForRec: %d", fNHitsForRecPerChamber[ch])); | |
229 | AliDebug(1, Form("Index(first HitForRec): %d", fIndexOfFirstHitForRecPerChamber[ch])); | |
230 | for (Int_t hit = fIndexOfFirstHitForRecPerChamber[ch]; | |
231 | hit < fIndexOfFirstHitForRecPerChamber[ch] + fNHitsForRecPerChamber[ch]; | |
232 | hit++) { | |
233 | AliDebug(1, Form("HitForRec index(0...): %d",hit)); | |
234 | ((*fHitsForRecPtr)[hit])->Dump(); | |
235 | } | |
236 | } | |
237 | } | |
238 | } | |
239 | ||
8d0843c6 | 240 | //__________________________________________________________________________ |
241 | void AliMUONVTrackReconstructor::SortHitsForRecWithIncreasingChamber() | |
242 | { | |
243 | /// Sort HitsForRec's in increasing order with respect to chamber number. | |
244 | /// Uses the function "Compare". | |
245 | /// Update the information for HitsForRec per chamber too. | |
246 | Int_t ch, nhits, prevch; | |
247 | fHitsForRecPtr->Sort(); | |
248 | for (ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) { | |
249 | fNHitsForRecPerChamber[ch] = 0; | |
250 | fIndexOfFirstHitForRecPerChamber[ch] = 0; | |
251 | } | |
252 | prevch = 0; // previous chamber | |
253 | nhits = 0; // number of hits in current chamber | |
254 | // Loop over HitsForRec | |
255 | for (Int_t hit = 0; hit < fNHitsForRec; hit++) { | |
256 | // chamber number (0...) | |
257 | ch = ((AliMUONHitForRec*) ((*fHitsForRecPtr)[hit]))->GetChamberNumber(); | |
258 | // increment number of hits in current chamber | |
259 | (fNHitsForRecPerChamber[ch])++; | |
260 | // update index of first HitForRec in current chamber | |
261 | // if chamber number different from previous one | |
262 | if (ch != prevch) { | |
263 | fIndexOfFirstHitForRecPerChamber[ch] = hit; | |
264 | prevch = ch; | |
265 | } | |
266 | } | |
267 | return; | |
268 | } | |
269 | ||
ea94c18b | 270 | //__________________________________________________________________________ |
271 | void AliMUONVTrackReconstructor::MakeTracks() | |
272 | { | |
273 | /// To make the tracks from the list of segments and points in all stations | |
274 | AliDebug(1,"Enter MakeTracks"); | |
275 | // Look for candidates from at least 3 aligned points in stations(1..) 4 and 5 | |
276 | MakeTrackCandidates(); | |
277 | if (fRecTracksPtr->GetEntriesFast() == 0) return; | |
278 | // Follow tracks in stations(1..) 3, 2 and 1 | |
279 | FollowTracks(); | |
280 | // Improve the reconstructed tracks | |
281 | if (fgkImproveTracks) ImproveTracks(); | |
282 | // Remove double tracks | |
283 | RemoveDoubleTracks(); | |
284 | // Fill AliMUONTrack data members | |
285 | Finalize(); | |
286 | } | |
287 | ||
8d0843c6 | 288 | //__________________________________________________________________________ |
208f139e | 289 | TClonesArray* AliMUONVTrackReconstructor::MakeSegmentsInStation(Int_t station) |
8d0843c6 | 290 | { |
208f139e | 291 | /// To make the list of segments in station(0..) "Station" from the list of hits to be reconstructed. |
292 | /// Return a new TClonesArray of segments. | |
293 | /// It is the responsibility of the user to delete it afterward. | |
294 | AliDebug(1,Form("Enter MakeSegmentsPerStation (0...) %d",station)); | |
295 | ||
8d0843c6 | 296 | AliMUONHitForRec *hit1Ptr, *hit2Ptr; |
208f139e | 297 | AliMUONObjectPair *segment; |
22ccc301 | 298 | Double_t bendingSlope = 0, impactParam = 0., bendingMomentum = 0.; // to avoid compilation warning |
7ec3b9cf | 299 | // first and second chambers (0...) in the station |
208f139e | 300 | Int_t ch1 = 2 * station; |
8d0843c6 | 301 | Int_t ch2 = ch1 + 1; |
7ec3b9cf | 302 | |
208f139e | 303 | // list of segments |
304 | TClonesArray *segments = new TClonesArray("AliMUONObjectPair", fNHitsForRecPerChamber[ch2]); | |
7ec3b9cf | 305 | segments->SetOwner(kTRUE); |
306 | ||
208f139e | 307 | // Loop over HitForRec's in the first chamber of the station |
8d0843c6 | 308 | for (Int_t hit1 = fIndexOfFirstHitForRecPerChamber[ch1]; |
309 | hit1 < fIndexOfFirstHitForRecPerChamber[ch1] + fNHitsForRecPerChamber[ch1]; | |
7ec3b9cf | 310 | hit1++) |
311 | { | |
8d0843c6 | 312 | // pointer to the HitForRec |
313 | hit1Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit1]); | |
208f139e | 314 | // Loop over HitsForRec's in the second chamber of the station |
8d0843c6 | 315 | for (Int_t hit2 = fIndexOfFirstHitForRecPerChamber[ch2]; |
7ec3b9cf | 316 | hit2 < fIndexOfFirstHitForRecPerChamber[ch2] + fNHitsForRecPerChamber[ch2]; |
317 | hit2++) | |
318 | { | |
8d0843c6 | 319 | // pointer to the HitForRec |
320 | hit2Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit2]); | |
7ec3b9cf | 321 | if ( hit1Ptr->GetZ() - hit2Ptr->GetZ() != 0. ) |
322 | { | |
22ccc301 | 323 | // bending slope |
208f139e | 324 | bendingSlope = (hit1Ptr->GetBendingCoor() - hit2Ptr->GetBendingCoor()) / (hit1Ptr->GetZ() - hit2Ptr->GetZ()); |
325 | // impact parameter | |
326 | impactParam = hit1Ptr->GetBendingCoor() - hit1Ptr->GetZ() * bendingSlope; | |
327 | // absolute value of bending momentum | |
7ec3b9cf | 328 | bendingMomentum = TMath::Abs(AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(impactParam)); |
329 | } else | |
330 | { | |
208f139e | 331 | AliWarning("hit1Ptr->GetZ() = hit2Ptr->GetZ(): no segment created"); |
332 | continue; | |
333 | } | |
22ccc301 | 334 | // check for bending momentum within tolerances |
7ec3b9cf | 335 | if ((bendingMomentum < fMaxBendingMomentum) && (bendingMomentum > fMinBendingMomentum)) |
336 | { | |
337 | // make new segment | |
338 | segment = new ((*segments)[segments->GetLast()+1]) AliMUONObjectPair(hit1Ptr, hit2Ptr, kFALSE, kFALSE); | |
339 | if (AliLog::GetGlobalDebugLevel() > 1) { | |
340 | cout << "segmentIndex(0...): " << segments->GetLast() << endl; | |
341 | segment->Dump(); | |
342 | cout << "HitForRec in first chamber" << endl; | |
343 | hit1Ptr->Dump(); | |
344 | cout << "HitForRec in second chamber" << endl; | |
345 | hit2Ptr->Dump(); | |
346 | } | |
8d0843c6 | 347 | } |
348 | } //for (Int_t hit2 | |
349 | } // for (Int_t hit1... | |
208f139e | 350 | AliDebug(1,Form("Station: %d NSegments: %d ", station, segments->GetEntriesFast())); |
351 | return segments; | |
8d0843c6 | 352 | } |
353 | ||
ea94c18b | 354 | //__________________________________________________________________________ |
355 | void AliMUONVTrackReconstructor::RemoveIdenticalTracks() | |
356 | { | |
357 | /// To remove identical tracks: | |
358 | /// Tracks are considered identical if they have all their hits in common. | |
359 | /// One keeps the track with the larger number of hits if need be | |
360 | AliMUONTrack *track1, *track2, *trackToRemove; | |
361 | Int_t hitsInCommon, nHits1, nHits2; | |
362 | Bool_t removedTrack1; | |
363 | // Loop over first track of the pair | |
364 | track1 = (AliMUONTrack*) fRecTracksPtr->First(); | |
365 | while (track1) { | |
366 | removedTrack1 = kFALSE; | |
367 | nHits1 = track1->GetNTrackHits(); | |
368 | // Loop over second track of the pair | |
369 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
370 | while (track2) { | |
371 | nHits2 = track2->GetNTrackHits(); | |
372 | // number of hits in common between two tracks | |
373 | hitsInCommon = track1->HitsInCommon(track2); | |
374 | // check for identical tracks | |
375 | if ((hitsInCommon == nHits1) || (hitsInCommon == nHits2)) { | |
376 | // decide which track to remove | |
377 | if (nHits2 > nHits1) { | |
378 | // remove track1 and continue the first loop with the track next to track1 | |
379 | trackToRemove = track1; | |
380 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
381 | fRecTracksPtr->Remove(trackToRemove); | |
382 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
383 | fNRecTracks--; | |
384 | removedTrack1 = kTRUE; | |
385 | break; | |
386 | } else { | |
387 | // remove track2 and continue the second loop with the track next to track2 | |
388 | trackToRemove = track2; | |
389 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
390 | fRecTracksPtr->Remove(trackToRemove); | |
391 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
392 | fNRecTracks--; | |
393 | } | |
394 | } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
395 | } // track2 | |
396 | if (removedTrack1) continue; | |
397 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
398 | } // track1 | |
399 | return; | |
400 | } | |
401 | ||
402 | //__________________________________________________________________________ | |
403 | void AliMUONVTrackReconstructor::RemoveDoubleTracks() | |
404 | { | |
405 | /// To remove double tracks: | |
406 | /// Tracks are considered identical if more than half of the hits of the track | |
407 | /// which has the smaller number of hits are in common with the other track. | |
408 | /// Among two identical tracks, one keeps the track with the larger number of hits | |
409 | /// or, if these numbers are equal, the track with the minimum chi2. | |
410 | AliMUONTrack *track1, *track2, *trackToRemove; | |
411 | Int_t hitsInCommon, nHits1, nHits2; | |
412 | Bool_t removedTrack1; | |
413 | // Loop over first track of the pair | |
414 | track1 = (AliMUONTrack*) fRecTracksPtr->First(); | |
415 | while (track1) { | |
416 | removedTrack1 = kFALSE; | |
417 | nHits1 = track1->GetNTrackHits(); | |
418 | // Loop over second track of the pair | |
419 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
420 | while (track2) { | |
421 | nHits2 = track2->GetNTrackHits(); | |
422 | // number of hits in common between two tracks | |
423 | hitsInCommon = track1->HitsInCommon(track2); | |
424 | // check for identical tracks | |
425 | if (((nHits1 < nHits2) && (2 * hitsInCommon > nHits1)) || (2 * hitsInCommon > nHits2)) { | |
426 | // decide which track to remove | |
427 | if ((nHits1 > nHits2) || ((nHits1 == nHits2) && (track1->GetFitFMin() <= track2->GetFitFMin()))) { | |
428 | // remove track2 and continue the second loop with the track next to track2 | |
429 | trackToRemove = track2; | |
430 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
431 | fRecTracksPtr->Remove(trackToRemove); | |
432 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
433 | fNRecTracks--; | |
434 | } else { | |
435 | // else remove track1 and continue the first loop with the track next to track1 | |
436 | trackToRemove = track1; | |
437 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
438 | fRecTracksPtr->Remove(trackToRemove); | |
439 | fRecTracksPtr->Compress(); // this is essential to retrieve the TClonesArray afterwards | |
440 | fNRecTracks--; | |
441 | removedTrack1 = kTRUE; | |
442 | break; | |
443 | } | |
444 | } else track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
445 | } // track2 | |
446 | if (removedTrack1) continue; | |
447 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
448 | } // track1 | |
449 | return; | |
450 | } | |
451 | ||
452 | //__________________________________________________________________________ | |
453 | Double_t AliMUONVTrackReconstructor::TryOneHitForRec(const AliMUONTrackParam &trackParam, AliMUONHitForRec* hitForRec, | |
454 | AliMUONTrackParam &trackParamAtHit, Bool_t updatePropagator) | |
455 | { | |
456 | /// Test the compatibility between the track and the hitForRec (using trackParam's covariance matrix): | |
457 | /// return the corresponding Chi2 | |
458 | /// return trackParamAtHit | |
459 | ||
ea94c18b | 460 | // extrapolate track parameters and covariances at the z position of the tested hit |
019df241 | 461 | trackParamAtHit = trackParam; |
462 | AliMUONTrackExtrap::ExtrapToZCov(&trackParamAtHit, hitForRec->GetZ(), updatePropagator); | |
ea94c18b | 463 | |
464 | // set pointer to hit into trackParamAtHit | |
465 | trackParamAtHit.SetHitForRecPtr(hitForRec); | |
466 | ||
467 | // Set differences between trackParam and hitForRec in the bending and non bending directions | |
019df241 | 468 | Double_t dX = hitForRec->GetNonBendingCoor() - trackParamAtHit.GetNonBendingCoor(); |
469 | Double_t dY = hitForRec->GetBendingCoor() - trackParamAtHit.GetBendingCoor(); | |
ea94c18b | 470 | |
019df241 | 471 | // Calculate errors and covariances |
ea94c18b | 472 | const TMatrixD& kParamCov = trackParamAtHit.GetCovariances(); |
019df241 | 473 | Double_t sigma2X = kParamCov(0,0) + hitForRec->GetNonBendingReso2(); |
474 | Double_t sigma2Y = kParamCov(2,2) + hitForRec->GetBendingReso2(); | |
475 | ||
476 | // Compute chi2 | |
477 | return dX * dX / sigma2X + dY * dY / sigma2Y; | |
478 | ||
479 | } | |
480 | ||
481 | //__________________________________________________________________________ | |
482 | Bool_t AliMUONVTrackReconstructor::TryOneHitForRecFast(const AliMUONTrackParam &trackParam, AliMUONHitForRec* hitForRec) | |
483 | { | |
484 | /// Test the compatibility between the track and the hitForRec within a wide fix window | |
485 | /// assuming linear propagation of the track: | |
486 | /// return kTRUE if they are compatibles | |
487 | ||
488 | Double_t dZ = hitForRec->GetZ() - trackParam.GetZ(); | |
489 | Double_t dX = hitForRec->GetNonBendingCoor() - (trackParam.GetNonBendingCoor() + trackParam.GetNonBendingSlope() * dZ); | |
490 | Double_t dY = hitForRec->GetBendingCoor() - (trackParam.GetBendingCoor() + trackParam.GetBendingSlope() * dZ); | |
491 | ||
492 | if (TMath::Abs(dX) > fgkMaxTrackingDistanceNonBending || TMath::Abs(dY) > fgkMaxTrackingDistanceBending) return kFALSE; | |
493 | ||
494 | return kTRUE; | |
495 | ||
496 | } | |
497 | ||
498 | //__________________________________________________________________________ | |
499 | Double_t AliMUONVTrackReconstructor::TryTwoHitForRecFast(const AliMUONTrackParam &trackParamAtHit1, AliMUONHitForRec* hitForRec2, | |
500 | AliMUONTrackParam &trackParamAtHit2) | |
501 | { | |
502 | /// Test the compatibility between the track and the 2 hitForRec together (using trackParam's covariance matrix) | |
503 | /// assuming linear propagation between the two hits: | |
504 | /// return the corresponding Chi2 accounting for covariances between the 2 hitForRec | |
505 | /// return trackParamAtHit1 & 2 | |
506 | ||
507 | // extrapolate linearly track parameters at the z position of the second hit | |
508 | trackParamAtHit2 = trackParamAtHit1; | |
509 | AliMUONTrackExtrap::LinearExtrapToZ(&trackParamAtHit2, hitForRec2->GetZ()); | |
510 | ||
511 | // set pointer to hit2 into trackParamAtHit2 | |
512 | trackParamAtHit2.SetHitForRecPtr(hitForRec2); | |
513 | ||
514 | // Set differences between track and hitForRec in the bending and non bending directions | |
515 | AliMUONHitForRec* hitForRec1 = trackParamAtHit1.GetHitForRecPtr(); | |
516 | Double_t dX1 = hitForRec1->GetNonBendingCoor() - trackParamAtHit1.GetNonBendingCoor(); | |
517 | Double_t dX2 = hitForRec2->GetNonBendingCoor() - trackParamAtHit2.GetNonBendingCoor(); | |
518 | Double_t dY1 = hitForRec1->GetBendingCoor() - trackParamAtHit1.GetBendingCoor(); | |
519 | Double_t dY2 = hitForRec2->GetBendingCoor() - trackParamAtHit2.GetBendingCoor(); | |
520 | ||
521 | // Calculate errors and covariances | |
522 | const TMatrixD& kParamCov1 = trackParamAtHit1.GetCovariances(); | |
523 | const TMatrixD& kParamCov2 = trackParamAtHit2.GetCovariances(); | |
524 | Double_t dZ = trackParamAtHit2.GetZ() - trackParamAtHit1.GetZ(); | |
525 | Double_t sigma2X1 = kParamCov1(0,0) + hitForRec1->GetNonBendingReso2(); | |
526 | Double_t sigma2X2 = kParamCov2(0,0) + hitForRec2->GetNonBendingReso2(); | |
527 | Double_t covX1X2 = kParamCov1(0,0) + dZ * kParamCov1(0,1); | |
528 | Double_t sigma2Y1 = kParamCov1(2,2) + hitForRec1->GetBendingReso2(); | |
529 | Double_t sigma2Y2 = kParamCov2(2,2) + hitForRec2->GetBendingReso2(); | |
530 | Double_t covY1Y2 = kParamCov1(2,2) + dZ * kParamCov1(2,3); | |
531 | ||
532 | // Compute chi2 | |
533 | Double_t detX = sigma2X1 * sigma2X2 - covX1X2 * covX1X2; | |
534 | Double_t detY = sigma2Y1 * sigma2Y2 - covY1Y2 * covY1Y2; | |
535 | if (detX == 0. || detY == 0.) return 1.e10; | |
536 | return (dX1 * dX1 * sigma2X2 + dX2 * dX2 * sigma2X1 - 2. * dX1 * dX2 * covX1X2) / detX | |
537 | + (dY1 * dY1 * sigma2Y2 + dY2 * dY2 * sigma2Y1 - 2. * dY1 * dY2 * covY1Y2) / detY; | |
538 | ||
539 | } | |
540 | ||
541 | //__________________________________________________________________________ | |
542 | Bool_t AliMUONVTrackReconstructor::FollowLinearTrackInStation(AliMUONTrack &trackCandidate, Int_t nextStation) | |
543 | { | |
544 | /// Follow trackCandidate in station(0..) nextStation assuming linear propagation, and search for compatible HitForRec(s) | |
545 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: | |
546 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
547 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
548 | /// Remove the obsolete "trackCandidate" at the end. | |
549 | /// kFALSE: add only the best hit(s) to the "trackCandidate". Try to add a couple of hits in priority. | |
550 | /// return kTRUE if new hits have been found (otherwise return kFALSE) | |
551 | AliDebug(1,Form("Enter FollowLinearTrackInStation(1..) %d", nextStation+1)); | |
552 | ||
553 | // Order the chamber according to the propagation direction (tracking starts with chamber 2): | |
554 | // - nextStation == station(1...) 5 => forward propagation | |
555 | // - nextStation < station(1...) 5 => backward propagation | |
556 | Int_t ch1, ch2; | |
557 | if (nextStation==4) { | |
558 | ch1 = 2*nextStation+1; | |
559 | ch2 = 2*nextStation; | |
ea94c18b | 560 | } else { |
019df241 | 561 | ch1 = 2*nextStation; |
562 | ch2 = 2*nextStation+1; | |
ea94c18b | 563 | } |
564 | ||
019df241 | 565 | Double_t chi2WithOneHitForRec = 1.e10; |
566 | Double_t chi2WithTwoHitForRec = 1.e10; | |
567 | Double_t maxChi2WithOneHitForRec = 2. * fgkSigmaToCutForTracking * fgkSigmaToCutForTracking; // 2 because 2 quantities in chi2 | |
568 | Double_t maxChi2WithTwoHitForRec = 4. * fgkSigmaToCutForTracking * fgkSigmaToCutForTracking; // 4 because 4 quantities in chi2 | |
569 | Double_t bestChi2WithOneHitForRec = maxChi2WithOneHitForRec; | |
570 | Double_t bestChi2WithTwoHitForRec = maxChi2WithTwoHitForRec; | |
571 | Bool_t foundOneHit = kFALSE; | |
572 | Bool_t foundTwoHits = kFALSE; | |
573 | AliMUONTrack *newTrack = 0x0; | |
574 | AliMUONHitForRec *hitForRecCh1, *hitForRecCh2; | |
575 | AliMUONTrackParam extrapTrackParamAtHit1; | |
576 | AliMUONTrackParam extrapTrackParamAtHit2; | |
577 | AliMUONTrackParam bestTrackParamAtHit1; | |
578 | AliMUONTrackParam bestTrackParamAtHit2; | |
579 | Bool_t *hitForRecCh1Used = new Bool_t[fNHitsForRecPerChamber[ch1]]; | |
580 | for (Int_t hit1 = 0; hit1 < fNHitsForRecPerChamber[ch1]; hit1++) hitForRecCh1Used[hit1] = kFALSE; | |
581 | ||
582 | // Get track parameters | |
583 | AliMUONTrackParam trackParam(*(AliMUONTrackParam*)trackCandidate.GetTrackParamAtHit()->First()); | |
584 | ||
585 | // Add MCS effect | |
586 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
587 | ||
588 | // Printout for debuging | |
589 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
590 | cout << "FollowLinearTrackInStation: look for hits in chamber(1..): " << ch2+1 << endl; | |
591 | } | |
592 | ||
593 | // look for candidates in chamber 2 | |
594 | for (Int_t hit2 = 0; hit2 < fNHitsForRecPerChamber[ch2]; hit2++) { | |
595 | ||
596 | hitForRecCh2 = (AliMUONHitForRec*) fHitsForRecPtr->UncheckedAt(fIndexOfFirstHitForRecPerChamber[ch2]+hit2); | |
597 | ||
598 | // try to add the current hit fast | |
599 | if (!TryOneHitForRecFast(trackParam, hitForRecCh2)) continue; | |
600 | ||
601 | // try to add the current hit accuratly | |
602 | extrapTrackParamAtHit2 = trackParam; | |
603 | AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtHit2, hitForRecCh2->GetZ()); | |
604 | chi2WithOneHitForRec = TryOneHitForRec(extrapTrackParamAtHit2, hitForRecCh2, extrapTrackParamAtHit2); | |
605 | ||
606 | // if good chi2 then try to attach a hitForRec in the other chamber too | |
607 | if (chi2WithOneHitForRec < maxChi2WithOneHitForRec) { | |
608 | Bool_t foundSecondHit = kFALSE; | |
609 | ||
610 | // Printout for debuging | |
611 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
612 | cout << "FollowLinearTrackInStation: found one hit in chamber(1..): " << ch2+1 | |
613 | << " (Chi2 = " << chi2WithOneHitForRec << ")" << endl; | |
614 | cout << " look for second hits in chamber(1..): " << ch1+1 << " ..." << endl; | |
615 | } | |
616 | ||
617 | // add MCS effect | |
618 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtHit2,AliMUONConstants::ChamberThicknessInX0(),1.); | |
619 | ||
620 | for (Int_t hit1 = 0; hit1 < fNHitsForRecPerChamber[ch1]; hit1++) { | |
621 | ||
622 | hitForRecCh1 = (AliMUONHitForRec*) fHitsForRecPtr->UncheckedAt(fIndexOfFirstHitForRecPerChamber[ch1]+hit1); | |
623 | ||
624 | // try to add the current hit fast | |
625 | if (!TryOneHitForRecFast(extrapTrackParamAtHit2, hitForRecCh1)) continue; | |
626 | ||
627 | // try to add the current hit in addition to the one found on the previous chamber | |
628 | chi2WithTwoHitForRec = TryTwoHitForRecFast(extrapTrackParamAtHit2, hitForRecCh1, extrapTrackParamAtHit1); | |
629 | ||
630 | // if good chi2 then consider to add the 2 hitForRec to the "trackCandidate" | |
631 | if (chi2WithTwoHitForRec < maxChi2WithTwoHitForRec) { | |
632 | foundSecondHit = kTRUE; | |
633 | foundTwoHits = kTRUE; | |
634 | ||
635 | // Printout for debuging | |
636 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
637 | cout << "FollowLinearTrackInStation: found one hit in chamber(1..): " << ch1+1 | |
638 | << " (Chi2 = " << chi2WithTwoHitForRec << ")" << endl; | |
639 | } | |
640 | ||
641 | if (fgkTrackAllTracks) { | |
642 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new hitForRec's | |
643 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); | |
644 | extrapTrackParamAtHit1.SetRemovable(kTRUE); | |
645 | newTrack->AddTrackParamAtHit(&extrapTrackParamAtHit1,hitForRecCh1); | |
646 | extrapTrackParamAtHit2.SetRemovable(kTRUE); | |
647 | newTrack->AddTrackParamAtHit(&extrapTrackParamAtHit2,hitForRecCh2); | |
648 | newTrack->GetTrackParamAtHit()->Sort(); | |
649 | fNRecTracks++; | |
650 | ||
651 | // Tag hitForRecCh1 as used | |
652 | hitForRecCh1Used[hit1] = kTRUE; | |
653 | ||
654 | // Printout for debuging | |
655 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
656 | cout << "FollowLinearTrackInStation: added two hits in station(1..): " << nextStation+1 << endl; | |
657 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
658 | } | |
659 | ||
660 | } else if (chi2WithTwoHitForRec < bestChi2WithTwoHitForRec) { | |
661 | // keep track of the best couple of hits | |
662 | bestChi2WithTwoHitForRec = chi2WithTwoHitForRec; | |
663 | bestTrackParamAtHit1 = extrapTrackParamAtHit1; | |
664 | bestTrackParamAtHit2 = extrapTrackParamAtHit2; | |
665 | } | |
666 | ||
667 | } | |
668 | ||
669 | } | |
670 | ||
671 | // if no hitForRecCh1 found then consider to add hitForRecCh2 only | |
672 | if (!foundSecondHit) { | |
673 | foundOneHit = kTRUE; | |
674 | ||
675 | if (fgkTrackAllTracks) { | |
676 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new hitForRec's | |
677 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); | |
678 | extrapTrackParamAtHit2.SetRemovable(kFALSE); | |
679 | newTrack->AddTrackParamAtHit(&extrapTrackParamAtHit2,hitForRecCh2); | |
680 | newTrack->GetTrackParamAtHit()->Sort(); | |
681 | fNRecTracks++; | |
682 | ||
683 | // Printout for debuging | |
684 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
685 | cout << "FollowLinearTrackInStation: added one hit in chamber(1..): " << ch2+1 << endl; | |
686 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
687 | } | |
688 | ||
689 | } else if (!foundTwoHits && chi2WithOneHitForRec < bestChi2WithOneHitForRec) { | |
690 | // keep track of the best single hitForRec except if a couple of hits has already been found | |
691 | bestChi2WithOneHitForRec = chi2WithOneHitForRec; | |
692 | bestTrackParamAtHit1 = extrapTrackParamAtHit2; | |
693 | } | |
694 | ||
695 | } | |
696 | ||
697 | } | |
698 | ||
699 | } | |
700 | ||
701 | // look for candidates in chamber 1 not already attached to a track | |
702 | // if we want to keep all possible tracks or if no good couple of hitForRec has been found | |
703 | if (fgkTrackAllTracks || !foundTwoHits) { | |
704 | ||
705 | // Printout for debuging | |
706 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
707 | cout << "FollowLinearTrackInStation: look for single hits in chamber(1..): " << ch1+1 << endl; | |
708 | } | |
709 | ||
710 | //Extrapolate trackCandidate to chamber "ch2" | |
711 | AliMUONTrackExtrap::LinearExtrapToZ(&trackParam, AliMUONConstants::DefaultChamberZ(ch2)); | |
712 | ||
713 | // add MCS effect for next step | |
714 | AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
715 | ||
716 | for (Int_t hit1 = 0; hit1 < fNHitsForRecPerChamber[ch1]; hit1++) { | |
717 | ||
718 | hitForRecCh1 = (AliMUONHitForRec*) fHitsForRecPtr->UncheckedAt(fIndexOfFirstHitForRecPerChamber[ch1]+hit1); | |
719 | ||
720 | if (hitForRecCh1Used[hit1]) continue; // Skip hitForRec already used | |
721 | ||
722 | // try to add the current hit fast | |
723 | if (!TryOneHitForRecFast(trackParam, hitForRecCh1)) continue; | |
724 | ||
725 | // try to add the current hit accuratly | |
726 | extrapTrackParamAtHit1 = trackParam; | |
727 | AliMUONTrackExtrap::LinearExtrapToZ(&extrapTrackParamAtHit1, hitForRecCh1->GetZ()); | |
728 | chi2WithOneHitForRec = TryOneHitForRec(extrapTrackParamAtHit1, hitForRecCh1, extrapTrackParamAtHit1); | |
729 | ||
730 | // if good chi2 then consider to add hitForRecCh1 | |
731 | // We do not try to attach a hitForRec in the other chamber too since it has already been done above | |
732 | if (chi2WithOneHitForRec < maxChi2WithOneHitForRec) { | |
733 | foundOneHit = kTRUE; | |
734 | ||
735 | // Printout for debuging | |
736 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
737 | cout << "FollowLinearTrackInStation: found one hit in chamber(1..): " << ch1+1 | |
738 | << " (Chi2 = " << chi2WithOneHitForRec << ")" << endl; | |
739 | } | |
740 | ||
741 | if (fgkTrackAllTracks) { | |
742 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new hitForRec's | |
743 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); | |
744 | extrapTrackParamAtHit1.SetRemovable(kFALSE); | |
745 | newTrack->AddTrackParamAtHit(&extrapTrackParamAtHit1,hitForRecCh1); | |
746 | newTrack->GetTrackParamAtHit()->Sort(); | |
747 | fNRecTracks++; | |
748 | ||
749 | // Printout for debuging | |
750 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
751 | cout << "FollowLinearTrackInStation: added one hit in chamber(1..): " << ch1+1 << endl; | |
752 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
753 | } | |
754 | ||
755 | } else if (chi2WithOneHitForRec < bestChi2WithOneHitForRec) { | |
756 | // keep track of the best single hitForRec except if a couple of hits has already been found | |
757 | bestChi2WithOneHitForRec = chi2WithOneHitForRec; | |
758 | bestTrackParamAtHit1 = extrapTrackParamAtHit1; | |
759 | } | |
760 | ||
761 | } | |
762 | ||
763 | } | |
764 | ||
765 | } | |
766 | ||
767 | // fill out the best track if required else clean up the fRecTracksPtr array | |
768 | if (!fgkTrackAllTracks) { | |
769 | if (foundTwoHits) { | |
770 | bestTrackParamAtHit1.SetRemovable(kTRUE); | |
771 | trackCandidate.AddTrackParamAtHit(&bestTrackParamAtHit1,bestTrackParamAtHit1.GetHitForRecPtr()); | |
772 | bestTrackParamAtHit2.SetRemovable(kTRUE); | |
773 | trackCandidate.AddTrackParamAtHit(&bestTrackParamAtHit2,bestTrackParamAtHit2.GetHitForRecPtr()); | |
774 | trackCandidate.GetTrackParamAtHit()->Sort(); | |
775 | ||
776 | // Printout for debuging | |
777 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
778 | cout << "FollowLinearTrackInStation: added the two best hits in station(1..): " << nextStation+1 << endl; | |
779 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
780 | } | |
781 | ||
782 | } else if (foundOneHit) { | |
783 | bestTrackParamAtHit1.SetRemovable(kFALSE); | |
784 | trackCandidate.AddTrackParamAtHit(&bestTrackParamAtHit1,bestTrackParamAtHit1.GetHitForRecPtr()); | |
785 | trackCandidate.GetTrackParamAtHit()->Sort(); | |
786 | ||
787 | // Printout for debuging | |
788 | if ((AliLog::GetDebugLevel("MUON","AliMUONVTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
789 | cout << "FollowLinearTrackInStation: added the best hit in chamber(1..): " << bestTrackParamAtHit1.GetHitForRecPtr()->GetChamberNumber()+1 << endl; | |
790 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
791 | } | |
792 | ||
793 | } else return kFALSE; | |
794 | ||
795 | } else if (foundOneHit || foundTwoHits) { | |
796 | ||
797 | // remove obsolete track | |
798 | fRecTracksPtr->Remove(&trackCandidate); | |
799 | fNRecTracks--; | |
800 | ||
801 | } else return kFALSE; | |
ea94c18b | 802 | |
019df241 | 803 | return kTRUE; |
ea94c18b | 804 | |
805 | } | |
806 | ||
807 | //__________________________________________________________________________ | |
7ec3b9cf | 808 | void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(AliMUONVTrackStore& trackStore, |
809 | const AliMUONVTriggerTrackStore& triggerTrackStore, | |
810 | const AliMUONVTriggerStore& triggerStore, | |
811 | const AliMUONTrackHitPattern& trackHitPattern) | |
8d0843c6 | 812 | { |
813 | /// Try to match track from tracking system with trigger track | |
06ca6d7b | 814 | static const Double_t kDistSigma[3]={1,1,0.02}; // sigma of distributions (trigger-track) X,Y,slopeY |
208f139e | 815 | |
7771752e | 816 | Int_t matchTrigger; |
7ec3b9cf | 817 | Int_t loTrgNum(-1); |
8d0843c6 | 818 | Double_t distTriggerTrack[3]; |
208f139e | 819 | Double_t xTrack, yTrack, ySlopeTrack, chi2MatchTrigger, minChi2MatchTrigger, chi2; |
7ec3b9cf | 820 | |
821 | TIter itTrack(trackStore.CreateIterator()); | |
822 | AliMUONTrack* track; | |
8d0843c6 | 823 | |
7ec3b9cf | 824 | while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) |
825 | { | |
423b32ca | 826 | matchTrigger = 0; |
8d0843c6 | 827 | chi2MatchTrigger = 0.; |
c6ba19f7 | 828 | loTrgNum = -1; |
7771752e | 829 | Int_t doubleMatch=-1; // Check if track matches 2 trigger tracks |
830 | Double_t doubleChi2 = -1.; | |
7ec3b9cf | 831 | |
832 | AliMUONTrackParam trackParam(*((AliMUONTrackParam*) (track->GetTrackParamAtHit()->Last()))); | |
37827b29 | 833 | AliMUONTrackExtrap::ExtrapToZ(&trackParam, AliMUONConstants::DefaultChamberZ(10)); // extrap to 1st trigger chamber |
8d0843c6 | 834 | |
835 | xTrack = trackParam.GetNonBendingCoor(); | |
836 | yTrack = trackParam.GetBendingCoor(); | |
837 | ySlopeTrack = trackParam.GetBendingSlope(); | |
208f139e | 838 | minChi2MatchTrigger = 999.; |
7ec3b9cf | 839 | |
840 | AliMUONTriggerTrack *triggerTrack; | |
841 | TIter itTriggerTrack(triggerTrackStore.CreateIterator()); | |
842 | while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack() ) ) ) | |
843 | { | |
06ca6d7b | 844 | distTriggerTrack[0] = (triggerTrack->GetX11()-xTrack)/kDistSigma[0]; |
845 | distTriggerTrack[1] = (triggerTrack->GetY11()-yTrack)/kDistSigma[1]; | |
846 | distTriggerTrack[2] = (TMath::Tan(triggerTrack->GetThetay())-ySlopeTrack)/kDistSigma[2]; | |
208f139e | 847 | chi2 = 0.; |
848 | for (Int_t iVar = 0; iVar < 3; iVar++) chi2 += distTriggerTrack[iVar]*distTriggerTrack[iVar]; | |
849 | chi2 /= 3.; // Normalized Chi2: 3 degrees of freedom (X,Y,slopeY) | |
7ec3b9cf | 850 | if (chi2 < fMaxNormChi2MatchTrigger) |
851 | { | |
852 | Bool_t isDoubleTrack = (TMath::Abs(chi2 - minChi2MatchTrigger)<1.); | |
853 | if (chi2 < minChi2MatchTrigger && chi2 < fMaxNormChi2MatchTrigger) | |
854 | { | |
855 | if(isDoubleTrack) | |
856 | { | |
857 | doubleMatch = loTrgNum; | |
858 | doubleChi2 = chi2MatchTrigger; | |
859 | } | |
860 | minChi2MatchTrigger = chi2; | |
861 | chi2MatchTrigger = chi2; | |
862 | loTrgNum = triggerTrack->GetLoTrgNum(); | |
863 | AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(loTrgNum); | |
864 | matchTrigger=1; | |
865 | if(locTrg->LoLpt()>0)matchTrigger=2; | |
866 | if(locTrg->LoHpt()>0)matchTrigger=3; | |
867 | } | |
868 | else if(isDoubleTrack) | |
869 | { | |
870 | doubleMatch = triggerTrack->GetLoTrgNum(); | |
871 | doubleChi2 = chi2; | |
872 | } | |
8d0843c6 | 873 | } |
8d0843c6 | 874 | } |
7ec3b9cf | 875 | if(doubleMatch>=0) |
876 | { // If two trigger tracks match, select the one passing more trigger cuts | |
877 | AliDebug(1, Form("Two candidates found: %i and %i",loTrgNum,doubleMatch)); | |
878 | AliMUONLocalTrigger* locTrg1 = triggerStore.FindLocal(doubleMatch); | |
879 | if((locTrg1->LoLpt()>0 && matchTrigger<2) || (locTrg1->LoHpt() && matchTrigger<3)) | |
880 | { | |
881 | if(locTrg1->LoHpt()>0)matchTrigger=3; | |
882 | else matchTrigger=2; | |
883 | loTrgNum = doubleMatch; | |
884 | chi2MatchTrigger=doubleChi2; | |
885 | } | |
7771752e | 886 | } |
8d0843c6 | 887 | |
888 | track->SetMatchTrigger(matchTrigger); | |
c6ba19f7 | 889 | track->SetLoTrgNum(loTrgNum); |
8d0843c6 | 890 | track->SetChi2MatchTrigger(chi2MatchTrigger); |
7ec3b9cf | 891 | |
892 | AliMUONLocalTrigger* locTrg = static_cast<AliMUONLocalTrigger*>(triggerStore.FindLocal(loTrgNum)); | |
893 | ||
894 | if (locTrg) | |
895 | { | |
896 | track->SetLocalTrigger(locTrg->LoCircuit(), | |
897 | locTrg->LoStripX(), | |
898 | locTrg->LoStripY(), | |
899 | locTrg->LoDev(), | |
900 | locTrg->LoLpt(), | |
901 | locTrg->LoHpt()); | |
902 | } | |
903 | } | |
904 | ||
905 | trackHitPattern.GetHitPattern(trackStore,triggerStore); | |
8d0843c6 | 906 | } |
907 | ||
ea94c18b | 908 | //__________________________________________________________________________ |
909 | void AliMUONVTrackReconstructor::EventReconstructTrigger(const AliMUONTriggerCircuit& circuit, | |
910 | const AliMUONVTriggerStore& triggerStore, | |
911 | AliMUONVTriggerTrackStore& triggerTrackStore) | |
8d0843c6 | 912 | { |
71a2d3aa | 913 | /// To make the trigger tracks from Local Trigger |
7ec3b9cf | 914 | AliDebug(1, ""); |
915 | ||
916 | AliMUONGlobalTrigger* globalTrigger = triggerStore.Global(); | |
e6b25a6e | 917 | |
7ec3b9cf | 918 | UChar_t gloTrigPat = 0; |
e6b25a6e | 919 | |
7ec3b9cf | 920 | if (globalTrigger) |
921 | { | |
922 | gloTrigPat = globalTrigger->GetGlobalResponse(); | |
e6b25a6e | 923 | } |
924 | ||
7ec3b9cf | 925 | TIter next(triggerStore.CreateIterator()); |
926 | AliMUONLocalTrigger* locTrg(0x0); | |
8d0843c6 | 927 | |
e6b25a6e | 928 | Float_t z11 = AliMUONConstants::DefaultChamberZ(10); |
929 | Float_t z21 = AliMUONConstants::DefaultChamberZ(12); | |
7cf63da6 | 930 | |
7ec3b9cf | 931 | AliMUONTriggerTrack triggerTrack; |
932 | ||
933 | while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) ) | |
934 | { | |
935 | Bool_t xTrig=kFALSE; | |
936 | Bool_t yTrig=kFALSE; | |
937 | ||
32ab62c9 | 938 | Int_t localBoardId = locTrg->LoCircuit(); |
7ec3b9cf | 939 | if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 && |
940 | locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X | |
941 | else xTrig=kTRUE; // trigger in X | |
942 | if (locTrg->LoTrigY()==1 && | |
943 | locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y | |
944 | else yTrig = kTRUE; // trigger in Y | |
945 | ||
946 | if (xTrig && yTrig) | |
947 | { // make Trigger Track if trigger in X and Y | |
8b0baca4 | 948 | |
32ab62c9 | 949 | Float_t y11 = circuit.GetY11Pos(localBoardId, locTrg->LoStripX()); |
7ec3b9cf | 950 | // need first to convert deviation to [0-30] |
951 | // (see AliMUONLocalTriggerBoard::LocalTrigger) | |
952 | Int_t deviation = locTrg->LoDev(); | |
953 | Int_t sign = 0; | |
954 | if ( !locTrg->LoSdev() && deviation ) sign=-1; | |
955 | if ( !locTrg->LoSdev() && !deviation ) sign= 0; | |
956 | if ( locTrg->LoSdev() == 1 ) sign=+1; | |
957 | deviation *= sign; | |
958 | deviation += 15; | |
959 | Int_t stripX21 = locTrg->LoStripX()+deviation+1; | |
32ab62c9 | 960 | Float_t y21 = circuit.GetY21Pos(localBoardId, stripX21); |
961 | Float_t x11 = circuit.GetX11Pos(localBoardId, locTrg->LoStripY()); | |
7ec3b9cf | 962 | |
963 | AliDebug(1, Form(" MakeTriggerTrack %d %d %d %d %f %f %f \n",locTrg->LoCircuit(), | |
964 | locTrg->LoStripX(),locTrg->LoStripX()+locTrg->LoDev()+1,locTrg->LoStripY(),y11, y21, x11)); | |
965 | ||
966 | Float_t thetax = TMath::ATan2( x11 , z11 ); | |
967 | Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) ); | |
968 | ||
969 | triggerTrack.SetX11(x11); | |
970 | triggerTrack.SetY11(y11); | |
971 | triggerTrack.SetThetax(thetax); | |
972 | triggerTrack.SetThetay(thetay); | |
973 | triggerTrack.SetGTPattern(gloTrigPat); | |
32ab62c9 | 974 | triggerTrack.SetLoTrgNum(localBoardId); |
7ec3b9cf | 975 | |
976 | triggerTrackStore.Add(triggerTrack); | |
977 | } // board is fired | |
e6b25a6e | 978 | } // end of loop on Local Trigger |
8d0843c6 | 979 | } |
ea94c18b | 980 |