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