]>
Commit | Line | Data |
---|---|---|
7771752e | 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 | ||
ea94c18b | 16 | /* $Id$ */ |
17 | ||
18 | ||
3d1463c8 | 19 | //----------------------------------------------------------------------------- |
7771752e | 20 | /// \class AliMUONTrackHitPattern |
21 | /// | |
22 | /// This class propagates tracks to trigger chambers | |
683cb6c5 | 23 | /// searching for matching trigger tracks and fired strips. |
7771752e | 24 | /// |
25 | /// To each track, a hit pattern for trigger chambers is set. | |
26 | /// The hit pattern is a UShort_t with 8 bits used: | |
fda59e58 | 27 | /// <pre> |
7771752e | 28 | /// 1 1 0 1 1 1 0 1 |
29 | /// | | | | |
30 | /// ----------- ------------ | |
31 | /// chamber: 11 12 13 14 | 11 12 13 14 | |
32 | /// cathode: bending | non-bending | |
fda59e58 | 33 | /// </pre> |
7771752e | 34 | /// The main method is: |
683cb6c5 | 35 | /// * ExecuteValidation |
7771752e | 36 | /// |
37 | /// \author Diego Stocco | |
3d1463c8 | 38 | //----------------------------------------------------------------------------- |
7771752e | 39 | |
40 | ||
41 | #include "AliMUONTrackHitPattern.h" | |
7ec3b9cf | 42 | |
7771752e | 43 | #include "AliMUONConstants.h" |
7ec3b9cf | 44 | #include "AliMUONVDigit.h" |
45 | #include "AliMUONDigitMaker.h" | |
46 | #include "AliMUONDigitStoreV1.h" | |
7771752e | 47 | #include "AliMUONGeometryTransformer.h" |
7771752e | 48 | #include "AliMUONLocalTrigger.h" |
7771752e | 49 | #include "AliMUONLocalTriggerBoard.h" |
7ec3b9cf | 50 | #include "AliMUONTrack.h" |
51 | #include "AliMUONTrackExtrap.h" | |
52 | #include "AliMUONTrackParam.h" | |
53 | #include "AliMUONVTrackStore.h" | |
54 | #include "AliMUONVTriggerStore.h" | |
7771752e | 55 | #include "AliMpPad.h" |
7771752e | 56 | #include "AliMpSegmentation.h" |
7ec3b9cf | 57 | #include "AliMpVSegmentation.h" |
fda59e58 | 58 | #include "AliMpDEManager.h" |
59 | #include "AliMUONReconstructor.h" | |
60 | #include "AliMUONRecoParam.h" | |
683cb6c5 | 61 | #include "AliMUONTriggerTrack.h" |
62 | #include "AliMUONVTriggerTrackStore.h" | |
63 | ||
64 | #include "AliMpConstants.h" | |
ea94c18b | 65 | |
66 | #include "AliMagF.h" | |
67 | #include "AliLog.h" | |
7771752e | 68 | #include "AliTracker.h" |
ea94c18b | 69 | |
7771752e | 70 | #include <Riostream.h> |
7ec3b9cf | 71 | #include <TArrayS.h> |
7771752e | 72 | #include <TClonesArray.h> |
73 | #include <TMath.h> | |
74 | #include <TMatrixD.h> | |
683cb6c5 | 75 | #include <TROOT.h> |
76 | #include <TDirectory.h> | |
77 | #include <TFile.h> | |
78 | #include <TSystem.h> | |
79 | ||
80 | #include <cassert> | |
7771752e | 81 | |
82 | /// \cond CLASSIMP | |
83 | ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context | |
84 | /// \endcond | |
85 | ||
86 | ||
87 | //______________________________________________________________________________ | |
7ec3b9cf | 88 | AliMUONTrackHitPattern::AliMUONTrackHitPattern(const AliMUONGeometryTransformer& transformer, |
89 | const AliMUONDigitMaker& digitMaker) | |
7771752e | 90 | : TObject(), |
7ec3b9cf | 91 | fTransformer(transformer), |
683cb6c5 | 92 | fDigitMaker(digitMaker), |
4a3224ff | 93 | fDeltaZ(0.0), |
94 | fTrigCovariance(0x0), | |
683cb6c5 | 95 | fkMaxDistance(99999.) |
7771752e | 96 | { |
97 | /// Default constructor | |
683cb6c5 | 98 | InitMembers(); |
7771752e | 99 | |
100 | // Set magnetic field | |
101 | const AliMagF* kField = AliTracker::GetFieldMap(); | |
102 | if (!kField) AliFatal("No field available"); | |
103 | AliMUONTrackExtrap::SetField(kField); | |
7771752e | 104 | } |
105 | ||
106 | ||
107 | //______________________________________________________________________________ | |
108 | AliMUONTrackHitPattern::~AliMUONTrackHitPattern(void) | |
109 | { | |
7ec3b9cf | 110 | /// Destructor |
683cb6c5 | 111 | delete fTrigCovariance; |
7771752e | 112 | } |
113 | ||
114 | ||
115 | //______________________________________________________________________________ | |
683cb6c5 | 116 | void AliMUONTrackHitPattern::InitMembers() |
7771752e | 117 | { |
683cb6c5 | 118 | // |
119 | /// Initialize data members | |
120 | // | |
121 | fDeltaZ = TMath::Abs(AliMUONConstants::DefaultChamberZ(12) - AliMUONConstants::DefaultChamberZ(10)); | |
122 | ||
123 | const Double_t kTrigNonBendReso = AliMUONConstants::TriggerNonBendingReso(); | |
124 | const Double_t kTrigBendReso = AliMUONConstants::TriggerBendingReso(); | |
125 | const Double_t kTrigSlopeBendReso = 1.414 * AliMUONConstants::TriggerBendingReso()/fDeltaZ; | |
126 | const Double_t kTrigCovSlopeBend = - kTrigBendReso * kTrigBendReso / fDeltaZ; | |
127 | ||
128 | // Covariance matrix 3x3 (X,Y,slopeY) for trigger tracks | |
129 | fTrigCovariance = new TMatrixD(3,3); | |
130 | fTrigCovariance->Zero(); | |
131 | (*fTrigCovariance)(0,0) = kTrigNonBendReso * kTrigNonBendReso; | |
132 | (*fTrigCovariance)(1,1) = kTrigBendReso * kTrigBendReso; | |
133 | (*fTrigCovariance)(2,2) = kTrigSlopeBendReso * kTrigSlopeBendReso; | |
134 | (*fTrigCovariance)(1,2) = (*fTrigCovariance)(2,1) = kTrigCovSlopeBend; | |
683cb6c5 | 135 | } |
fda59e58 | 136 | |
7ec3b9cf | 137 | |
683cb6c5 | 138 | //_____________________________________________________________________________ |
139 | void AliMUONTrackHitPattern::CheckConstants() const | |
140 | { | |
141 | /// Check consistence of redefined constants | |
142 | ||
143 | assert(fgkNcathodes == AliMpConstants::NofCathodes()); | |
144 | assert(fgkNchambers == AliMpConstants::NofTriggerChambers()); | |
145 | assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes); | |
146 | } | |
147 | ||
148 | ||
149 | //______________________________________________________________________________ | |
150 | void AliMUONTrackHitPattern::ExecuteValidation(AliMUONVTrackStore& trackStore, | |
151 | const AliMUONVTriggerTrackStore& triggerTrackStore, | |
152 | const AliMUONVTriggerStore& triggerStore) const | |
153 | { | |
154 | // | |
155 | /// Main method: | |
156 | /// Loops on reco tracks, extrapolates them to trigger chambers | |
157 | /// and searches for matching trigger tracks and digits | |
158 | // | |
159 | ||
160 | AliMUONDigitStoreV1 digitStore; | |
161 | TriggerDigits(triggerStore,digitStore); | |
162 | ||
163 | ||
164 | TIter itTrack(trackStore.CreateIterator()); | |
165 | AliMUONTrack* track; | |
166 | ||
167 | const Int_t kFirstTrigCh = AliMUONConstants::NTrackingCh(); | |
168 | ||
169 | while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) ) | |
170 | { | |
171 | AliMUONTrackParam trackParam(*((AliMUONTrackParam*) (track->GetTrackParamAtCluster()->Last()))); | |
172 | ||
173 | ApplyMCSCorrections(trackParam); | |
174 | AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(kFirstTrigCh)); // extrap to 1st trigger chamber | |
175 | ||
176 | AliMUONTriggerTrack *matchedTriggerTrack = MatchTriggerTrack(track, trackParam, triggerTrackStore, triggerStore); | |
177 | ||
178 | UShort_t pattern = GetHitPattern(trackParam, matchedTriggerTrack, digitStore); | |
179 | track->SetHitsPatternInTrigCh(pattern); | |
180 | } | |
181 | } | |
182 | ||
183 | ||
184 | //______________________________________________________________________________ | |
185 | AliMUONTriggerTrack * | |
186 | AliMUONTrackHitPattern::MatchTriggerTrack(AliMUONTrack* track, | |
187 | AliMUONTrackParam& trackParam, | |
188 | const AliMUONVTriggerTrackStore& triggerTrackStore, | |
189 | const AliMUONVTriggerStore& triggerStore) const | |
190 | { | |
191 | // | |
192 | /// Match track with trigger track | |
193 | // | |
194 | ||
195 | Int_t matchTrigger = 0; | |
196 | Int_t loTrgNum(-1); | |
197 | Double_t distTriggerTrack[3], sigma2[3]; | |
198 | Double_t chi2; | |
199 | Double_t chi2MatchTrigger = 0., minChi2MatchTrigger = 999.; | |
200 | Int_t doubleMatch = -1; // Check if track matches 2 trigger tracks | |
201 | Double_t doubleChi2 = -1.; | |
202 | AliMUONTriggerTrack* doubleTriggerTrack = 0x0; | |
203 | AliMUONTriggerTrack* matchedTriggerTrack = 0x0; | |
7ec3b9cf | 204 | |
683cb6c5 | 205 | const TMatrixD& kParamCov = trackParam.GetCovariances(); |
7ec3b9cf | 206 | |
683cb6c5 | 207 | Double_t xTrack = trackParam.GetNonBendingCoor(); |
208 | Double_t yTrack = trackParam.GetBendingCoor(); | |
209 | Double_t ySlopeTrack = trackParam.GetBendingSlope(); | |
210 | ||
211 | // Covariance matrix 3x3 (X,Y,slopeY) for tracker tracks | |
212 | TMatrixD trackCov(3,3); | |
213 | trackCov.Zero(); | |
214 | trackCov(0,0) = kParamCov(0,0); | |
215 | trackCov(1,1) = kParamCov(2,2); | |
216 | trackCov(2,2) = kParamCov(3,3); | |
217 | trackCov(1,2) = kParamCov(2,3); | |
218 | trackCov(2,1) = kParamCov(3,2); | |
219 | ||
220 | TMatrixD sumCov(trackCov,TMatrixD::kPlus,*fTrigCovariance); | |
221 | ||
222 | Bool_t isCovOK = kTRUE; | |
223 | ||
224 | if (sumCov.Determinant() != 0) { | |
225 | sumCov.Invert(); | |
226 | } else { | |
227 | AliWarning(" Determinant = 0"); | |
228 | isCovOK = kFALSE; | |
229 | sigma2[0] = kParamCov(0,0); | |
230 | sigma2[1] = kParamCov(2,2); | |
231 | sigma2[2] = kParamCov(3,3); | |
232 | // sigma of distributions (trigger-track) X,Y,slopeY | |
233 | const Double_t kDistSigma[3]={AliMUONConstants::TriggerNonBendingReso(), | |
234 | AliMUONConstants::TriggerBendingReso(), | |
235 | 1.414 * AliMUONConstants::TriggerBendingReso()/fDeltaZ}; | |
236 | for (Int_t iVar = 0; iVar < 3; iVar++) sigma2[iVar] += kDistSigma[iVar] * kDistSigma[iVar]; | |
237 | } | |
fda59e58 | 238 | |
683cb6c5 | 239 | AliMUONTriggerTrack *triggerTrack; |
240 | TIter itTriggerTrack(triggerTrackStore.CreateIterator()); | |
241 | while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack() ) ) ) | |
242 | { | |
243 | distTriggerTrack[0] = triggerTrack->GetX11() - xTrack; | |
244 | distTriggerTrack[1] = triggerTrack->GetY11() - yTrack; | |
245 | distTriggerTrack[2] = TMath::Tan(triggerTrack->GetThetay()) - ySlopeTrack; | |
246 | ||
247 | if(isCovOK){ | |
248 | TMatrixD paramDiff(3,1); | |
249 | for(Int_t iVar = 0; iVar < 3; iVar++) | |
250 | paramDiff(iVar,0) = distTriggerTrack[iVar]; | |
251 | ||
252 | TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff); | |
253 | TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp); | |
254 | chi2 = chi2M(0,0); | |
255 | } | |
256 | else { | |
257 | chi2 = 0.; | |
258 | for (Int_t iVar = 0; iVar < 3; iVar++) chi2 += distTriggerTrack[iVar]*distTriggerTrack[iVar]/sigma2[iVar]; | |
259 | } | |
fda59e58 | 260 | |
683cb6c5 | 261 | chi2 /= 3.; // Normalized Chi2: 3 degrees of freedom (X,Y,slopeY) |
262 | if (chi2 < AliMUONReconstructor::GetRecoParam()->GetMaxNormChi2MatchTrigger()) | |
7ec3b9cf | 263 | { |
683cb6c5 | 264 | Bool_t isDoubleTrack = (TMath::Abs(chi2 - minChi2MatchTrigger)<1.); |
265 | if (chi2 < minChi2MatchTrigger && chi2 < AliMUONReconstructor::GetRecoParam()->GetMaxNormChi2MatchTrigger()) | |
7ec3b9cf | 266 | { |
683cb6c5 | 267 | if(isDoubleTrack) |
268 | { | |
269 | doubleMatch = loTrgNum; | |
270 | doubleChi2 = chi2MatchTrigger; | |
271 | doubleTriggerTrack = matchedTriggerTrack; | |
fda59e58 | 272 | } |
683cb6c5 | 273 | minChi2MatchTrigger = chi2; |
274 | chi2MatchTrigger = chi2; | |
275 | loTrgNum = triggerTrack->GetLoTrgNum(); | |
276 | matchedTriggerTrack = triggerTrack; | |
277 | AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(loTrgNum); | |
278 | matchTrigger = 1; | |
279 | if(locTrg->LoLpt()>0) matchTrigger = 2; | |
280 | if(locTrg->LoHpt()>0) matchTrigger = 3; | |
281 | } | |
282 | else if(isDoubleTrack) | |
283 | { | |
284 | doubleMatch = triggerTrack->GetLoTrgNum(); | |
285 | doubleChi2 = chi2; | |
7ec3b9cf | 286 | } |
7771752e | 287 | } |
683cb6c5 | 288 | } |
289 | if(doubleMatch>=0) | |
290 | { // If two trigger tracks match, select the one passing more trigger cuts | |
291 | AliDebug(1, Form("Two candidates found: %i and %i",loTrgNum,doubleMatch)); | |
292 | AliMUONLocalTrigger* locTrg1 = triggerStore.FindLocal(doubleMatch); | |
293 | if((locTrg1->LoLpt()>0 && matchTrigger<2) || (locTrg1->LoHpt() && matchTrigger<3)) | |
294 | { | |
295 | if(locTrg1->LoHpt()>0) matchTrigger=3; | |
296 | else matchTrigger = 2; | |
297 | loTrgNum = doubleMatch; | |
298 | chi2MatchTrigger = doubleChi2; | |
299 | matchedTriggerTrack = doubleTriggerTrack; | |
300 | } | |
301 | } | |
302 | ||
303 | track->SetMatchTrigger(matchTrigger); | |
304 | track->SetLoTrgNum(loTrgNum); | |
305 | track->SetChi2MatchTrigger(chi2MatchTrigger); | |
306 | ||
307 | AliMUONLocalTrigger* locTrg = static_cast<AliMUONLocalTrigger*>(triggerStore.FindLocal(loTrgNum)); | |
308 | ||
309 | if (locTrg) | |
310 | { | |
c79ae710 | 311 | Int_t deviation = locTrg->LoDev(); |
312 | Int_t sign = 0; | |
313 | if ( !locTrg->LoSdev() && deviation ) sign=-1; | |
314 | if ( !locTrg->LoSdev() && !deviation ) sign= 0; | |
315 | if ( locTrg->LoSdev() == 1 ) sign=+1; | |
316 | deviation *= sign; | |
317 | deviation += 15; | |
683cb6c5 | 318 | track->SetLocalTrigger(locTrg->LoCircuit(), |
319 | locTrg->LoStripX(), | |
320 | locTrg->LoStripY(), | |
c79ae710 | 321 | deviation, |
683cb6c5 | 322 | locTrg->LoLpt(), |
323 | locTrg->LoHpt()); | |
324 | } | |
325 | ||
326 | return matchedTriggerTrack; | |
327 | } | |
328 | ||
329 | ||
330 | //______________________________________________________________________________ | |
331 | UShort_t AliMUONTrackHitPattern::GetHitPattern(AliMUONTrackParam &trackParam, | |
332 | AliMUONTriggerTrack* matchedTriggerTrack, | |
333 | AliMUONVDigitStore& digitStore) const | |
334 | { | |
335 | // | |
336 | /// Get hit pattern on trigger chambers for the current track | |
337 | // | |
338 | UShort_t pattern = 0; | |
339 | Bool_t isMatch[2]; | |
340 | const Int_t kNTrackingCh = AliMUONConstants::NTrackingCh(); | |
341 | ||
342 | Bool_t patternFromTrigTrack = kFALSE; | |
343 | ||
344 | ||
345 | // Calculate hit pattern from trigger track | |
346 | if(matchedTriggerTrack){ | |
347 | patternFromTrigTrack = PerformTrigTrackMatch(pattern, matchedTriggerTrack, digitStore); | |
348 | } | |
349 | ||
350 | if(patternFromTrigTrack) return pattern; | |
351 | ||
352 | ||
353 | // Calculate hit pattern from tracker track propagation | |
354 | // if hit pattern from trigger track failed | |
355 | ||
356 | for(Int_t ch=0; ch<4; ++ch) | |
357 | { | |
358 | Int_t iChamber = kNTrackingCh+ch; | |
359 | AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(iChamber)); | |
360 | FindPadMatchingTrack(digitStore, trackParam, isMatch, iChamber); | |
361 | for(Int_t cath=0; cath<2; ++cath) | |
362 | { | |
363 | if(isMatch[cath]) SetBit(pattern, cath, ch); | |
364 | } | |
365 | } | |
366 | return pattern; | |
367 | } | |
368 | ||
369 | ||
370 | //______________________________________________________________________________ | |
371 | void AliMUONTrackHitPattern::SetBit(UShort_t& pattern, Int_t cathode, Int_t chamber) const | |
372 | { | |
373 | // | |
374 | /// Set hits pattern | |
375 | // | |
376 | const Int_t kMask[2][4]= {{0x80, 0x40, 0x20, 0x10}, | |
377 | {0x08, 0x04, 0x02, 0x01}}; | |
378 | pattern |= kMask[cathode][chamber]; | |
379 | } | |
380 | ||
381 | ||
382 | //______________________________________________________________________________ | |
383 | void AliMUONTrackHitPattern::AddEffInfo(UShort_t& pattern, Int_t slat, Int_t effType) const | |
384 | { | |
385 | // | |
386 | /// Set info on efficiency calculation | |
387 | // | |
388 | pattern += effType << 8; | |
389 | pattern += slat << 10; | |
390 | } | |
391 | ||
392 | ||
393 | //______________________________________________________________________________ | |
394 | void | |
395 | AliMUONTrackHitPattern::ApplyMCSCorrections(AliMUONTrackParam& trackParam) const | |
396 | { | |
397 | // | |
398 | /// Returns uncertainties on extrapolated position. | |
399 | /// Takes into account Branson plane corrections in the iron wall. | |
400 | // | |
401 | ||
402 | const Float_t kZFilterOut = AliMUONConstants::MuonFilterZEnd(); | |
403 | const Float_t kFilterThickness = TMath::Abs(kZFilterOut-AliMUONConstants::MuonFilterZBeg()); // cm | |
404 | ||
405 | AliMUONTrackExtrap::ExtrapToZCov(&trackParam, kZFilterOut); // Extrap to muon filter end | |
406 | AliMUONTrackExtrap::AddMCSEffect(&trackParam, kFilterThickness, AliMUONConstants::MuonFilterX0()); // Add MCS effects | |
407 | return; | |
408 | } | |
409 | ||
410 | ||
411 | //______________________________________________________________________________ | |
412 | Bool_t | |
413 | AliMUONTrackHitPattern::TriggerDigits(const AliMUONVTriggerStore& triggerStore, | |
414 | AliMUONVDigitStore& digitStore) const | |
415 | { | |
416 | // | |
417 | /// make (S)Digit for trigger | |
418 | // | |
419 | ||
420 | digitStore.Clear(); | |
421 | ||
422 | AliMUONLocalTrigger* locTrg; | |
423 | TIter next(triggerStore.CreateLocalIterator()); | |
424 | ||
425 | while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) ) | |
426 | { | |
427 | if (locTrg->IsNull()) continue; | |
428 | ||
429 | TArrayS xyPattern[2]; | |
430 | locTrg->GetXPattern(xyPattern[0]); | |
431 | locTrg->GetYPattern(xyPattern[1]); | |
432 | ||
433 | // do we need this ? (Ch.F.) | |
434 | // for(Int_t cath=0; cath<2; ++cath) | |
435 | // { | |
436 | // for(Int_t ch=0; ch<4; ++ch) | |
437 | // { | |
438 | // if(xyPattern[cath][ch]==0) continue; | |
439 | // } | |
440 | // } | |
441 | ||
442 | Int_t nBoard = locTrg->LoCircuit(); | |
443 | fDigitMaker.TriggerDigits(nBoard, xyPattern, digitStore); | |
444 | } | |
445 | return kTRUE; | |
7771752e | 446 | } |
447 | ||
448 | ||
449 | //______________________________________________________________________________ | |
7ec3b9cf | 450 | void |
451 | AliMUONTrackHitPattern::FindPadMatchingTrack(AliMUONVDigitStore& digitStore, | |
452 | const AliMUONTrackParam& trackParam, | |
fda59e58 | 453 | Bool_t isMatch[2], Int_t iChamber) const |
7771752e | 454 | { |
455 | // | |
683cb6c5 | 456 | /// Given the tracker track position, searches for matching digits. |
7771752e | 457 | // |
458 | ||
459 | Float_t minMatchDist[2]; | |
460 | ||
7ec3b9cf | 461 | for(Int_t cath=0; cath<2; ++cath) |
462 | { | |
463 | isMatch[cath]=kFALSE; | |
683cb6c5 | 464 | minMatchDist[cath]=fkMaxDistance/10.; |
7771752e | 465 | } |
466 | ||
7ec3b9cf | 467 | TIter next(digitStore.CreateIterator()); |
468 | AliMUONVDigit* mDigit; | |
fda59e58 | 469 | |
7ec3b9cf | 470 | while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) ) |
471 | { | |
472 | Int_t currDetElemId = mDigit->DetElemId(); | |
fda59e58 | 473 | Int_t currCh = AliMpDEManager::GetChamberId(currDetElemId); |
474 | if(currCh!=iChamber) continue; | |
7ec3b9cf | 475 | Int_t cathode = mDigit->Cathode(); |
476 | Int_t ix = mDigit->PadX(); | |
477 | Int_t iy = mDigit->PadY(); | |
478 | Float_t xpad, ypad, zpad; | |
479 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance() | |
480 | ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode)); | |
481 | ||
482 | AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE); | |
483 | Float_t xlocal1 = pad.Position().X(); | |
484 | Float_t ylocal1 = pad.Position().Y(); | |
485 | Float_t dpx = pad.Dimensions().X(); | |
486 | Float_t dpy = pad.Dimensions().Y(); | |
487 | fTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad); | |
488 | Float_t matchDist = MinDistanceFromPad(xpad, ypad, zpad, dpx, dpy, trackParam); | |
489 | if(matchDist>minMatchDist[cathode])continue; | |
490 | isMatch[cathode] = kTRUE; | |
fda59e58 | 491 | if(isMatch[0] && isMatch[1]) break; |
7ec3b9cf | 492 | minMatchDist[cathode] = matchDist; |
7771752e | 493 | } |
7771752e | 494 | } |
495 | ||
496 | ||
497 | //______________________________________________________________________________ | |
7ec3b9cf | 498 | Float_t |
499 | AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad, | |
500 | Float_t dpx, Float_t dpy, | |
501 | const AliMUONTrackParam& trackParam) const | |
7771752e | 502 | { |
503 | // | |
683cb6c5 | 504 | /// Decides if the digit belongs to the tracker track. |
7771752e | 505 | // |
7771752e | 506 | |
fda59e58 | 507 | AliMUONTrackParam trackParamAtPadZ(trackParam); |
508 | AliMUONTrackExtrap::ExtrapToZCov(&trackParamAtPadZ, zPad); | |
509 | ||
510 | Float_t xTrackAtPad = trackParamAtPadZ.GetNonBendingCoor(); | |
511 | Float_t yTrackAtPad = trackParamAtPadZ.GetBendingCoor(); | |
7771752e | 512 | |
fda59e58 | 513 | const Float_t kNSigma = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTrigger(); |
514 | ||
515 | const TMatrixD& kCovParam = trackParamAtPadZ.GetCovariances(); | |
516 | ||
517 | Float_t sigmaX = TMath::Sqrt(kCovParam(0,0)); | |
518 | Float_t sigmaY = TMath::Sqrt(kCovParam(2,2)); | |
519 | ||
520 | Float_t maxDistX = kNSigma * sigmaX; // in cm | |
521 | Float_t maxDistY = kNSigma * sigmaY; // in cm | |
7771752e | 522 | |
523 | Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx; | |
524 | Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy; | |
525 | ||
683cb6c5 | 526 | Float_t matchDist = fkMaxDistance; |
7771752e | 527 | if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY); |
fda59e58 | 528 | |
7771752e | 529 | return matchDist; |
530 | } | |
531 | ||
532 | ||
683cb6c5 | 533 | //_____________________________________________________________________________ |
534 | Int_t AliMUONTrackHitPattern::FindPadMatchingTrig(AliMUONVDigitStore& digitStore, Int_t &detElemId, | |
535 | Float_t coor[2], Bool_t isMatch[2], | |
536 | TArrayI nboard[2], TArrayF &zRealMatch, Float_t y11) const | |
537 | { | |
538 | // | |
539 | /// Check slat and board number of digit matching trigger track | |
540 | // | |
541 | ||
542 | enum {kBending, kNonBending}; | |
543 | ||
544 | Float_t minMatchDist[fgkNcathodes]; | |
545 | Int_t padsInCheckArea[fgkNcathodes]; | |
546 | ||
547 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
548 | isMatch[cath] = kFALSE; | |
549 | minMatchDist[cath] = fkMaxDistance/10.; | |
550 | padsInCheckArea[cath] = 0; | |
551 | } | |
552 | Int_t iChamber = AliMpDEManager::GetChamberId(detElemId); | |
553 | Int_t ch = iChamber-10; | |
554 | Float_t oldDeltaZ = AliMUONConstants::DefaultChamberZ(iChamber) - AliMUONConstants::DefaultChamberZ(10); | |
555 | Float_t y = coor[1]; | |
556 | Int_t iSlat = detElemId%100; | |
557 | Int_t trigDigitBendPlane = -1; | |
558 | Int_t foundDetElemId = detElemId; | |
559 | Float_t foundZmatch=999.; | |
560 | Float_t yCoorAtPadZ=999.; | |
561 | ||
562 | TIter next(digitStore.CreateIterator()); | |
563 | AliMUONVDigit* mDigit; | |
564 | Int_t idigit=0; | |
565 | ||
566 | while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) ) | |
567 | { | |
568 | idigit++; | |
569 | Int_t currDetElemId = mDigit->DetElemId(); | |
570 | Int_t currCh = AliMpDEManager::GetChamberId(currDetElemId); | |
571 | if(currCh!=iChamber) continue; | |
572 | Int_t currSlat = currDetElemId%100; | |
573 | Int_t slatDiff = TMath::Abs(currSlat-iSlat); | |
574 | if(slatDiff>1 && slatDiff<17) continue; // Check neighbour slats | |
575 | Int_t cathode = mDigit->Cathode(); | |
576 | Int_t ix = mDigit->PadX(); | |
577 | Int_t iy = mDigit->PadY(); | |
578 | Float_t xpad, ypad, zpad; | |
579 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance() | |
580 | ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode)); | |
581 | ||
582 | AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE); | |
583 | Float_t xlocal1 = pad.Position().X(); | |
584 | Float_t ylocal1 = pad.Position().Y(); | |
585 | Float_t dpx = pad.Dimensions().X(); | |
586 | Float_t dpy = pad.Dimensions().Y(); | |
587 | fTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad); | |
588 | AliDebug(2, Form("DetElemId = %i\tCathode = %i\t(x,y) Pad = (%i,%i) = (%.2f,%.2f)\tDim = (%.2f,%.2f)\tTrack = (%.2f,%.2f)\n",currDetElemId,cathode,ix,iy,xpad,ypad,dpx,dpy,coor[0],coor[1])); | |
589 | // searching track intersection with chambers (second approximation) | |
590 | if(ch%2==1){ | |
591 | //if(iChamber%2==1){ | |
592 | Float_t deltaZ = zpad - zRealMatch[0]; | |
593 | y = (coor[1]-y11)*deltaZ/oldDeltaZ + y11; | |
594 | if(TMath::Abs(y-coor[1])>0.1) AliDebug(3, Form("oldDeltaZ = %7.2f newDeltaZ = %7.2f\toldY = %7.2f new y = %7.2f\n",oldDeltaZ,deltaZ,coor[1],y)); | |
595 | } | |
596 | Float_t matchDist = PadMatchTrack(xpad, ypad, dpx, dpy, coor[0], y); | |
597 | if(matchDist<fkMaxDistance/2.) padsInCheckArea[cathode]++; | |
598 | if(matchDist>minMatchDist[cathode])continue; | |
599 | isMatch[cathode] = kTRUE; | |
600 | minMatchDist[cathode] = matchDist; | |
601 | foundDetElemId = currDetElemId; | |
602 | foundZmatch=zpad; | |
603 | yCoorAtPadZ=y; | |
604 | if(cathode==kBending) trigDigitBendPlane = idigit; | |
605 | for (Int_t loc=0; loc<pad.GetNofLocations(); loc++){ | |
606 | AliMpIntPair location = pad.GetLocation(loc); | |
607 | nboard[cathode][loc] = location.GetFirst(); | |
608 | } | |
609 | for(Int_t loc=pad.GetNofLocations(); loc<fgkNlocations; loc++){ | |
610 | nboard[cathode][loc]=-1; | |
611 | } | |
683cb6c5 | 612 | } |
613 | ||
614 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
615 | if(padsInCheckArea[cath]>2) { | |
616 | AliDebug(1, Form("padsInCheckArea[%i] = %i\n",cath,padsInCheckArea[cath])); | |
617 | return -500; | |
618 | } | |
619 | } | |
620 | ||
621 | if(isMatch[kBending] || isMatch[kNonBending]){ | |
622 | detElemId = foundDetElemId; | |
623 | zRealMatch[ch] = foundZmatch; | |
624 | coor[1] = yCoorAtPadZ; | |
625 | } | |
626 | return trigDigitBendPlane; | |
627 | } | |
628 | ||
629 | //_____________________________________________________________________________ | |
630 | Float_t AliMUONTrackHitPattern::PadMatchTrack(Float_t xPad, Float_t yPad, | |
631 | Float_t dpx, Float_t dpy, | |
632 | Float_t xTrackAtPad, Float_t yTrackAtPad) const | |
633 | { | |
634 | // | |
635 | /// Decides if the digit belongs to the trigger track. | |
636 | // | |
637 | ||
638 | Float_t maxDist = 2.;//3. // cm | |
639 | Float_t maxDistCheckArea = 6.; // cm | |
640 | ||
641 | Float_t matchDist = fkMaxDistance; | |
642 | ||
643 | Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx; | |
644 | Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy; | |
645 | Float_t maxDistX = maxDist; | |
646 | Float_t maxDistY = maxDist; | |
647 | ||
648 | if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY); | |
649 | else if(deltaX<=maxDistCheckArea && deltaY<=maxDistCheckArea) matchDist = fkMaxDistance/5.; | |
650 | return matchDist; | |
651 | } | |
652 | ||
653 | ||
654 | //_____________________________________________________________________________ | |
655 | Int_t AliMUONTrackHitPattern::DetElemIdFromPos(Float_t x, Float_t y, | |
656 | Int_t chamber, Int_t cathode) const | |
657 | { | |
658 | // | |
659 | /// Given the (x,y) position in the chamber, | |
660 | /// it returns the corresponding slat | |
661 | // | |
662 | ||
663 | Int_t resultingDetElemId = -1; | |
664 | AliMpDEIterator it; | |
665 | Float_t minDist = 999.; | |
666 | for ( it.First(chamber-1); ! it.IsDone(); it.Next() ){ | |
667 | Int_t detElemId = it.CurrentDEId(); | |
668 | Int_t ich = detElemId/100-10; | |
669 | Float_t tolerance=0.2*((Float_t)ich); | |
670 | Float_t currDist=9999.; | |
671 | ||
672 | const AliMpVSegmentation* seg = | |
673 | AliMpSegmentation::Instance() | |
674 | ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode)); | |
675 | if (!seg) continue; | |
676 | ||
677 | Float_t deltax = seg->Dimensions().X(); | |
678 | Float_t deltay = seg->Dimensions().Y(); | |
679 | Float_t xlocal1 = -deltax; | |
680 | Float_t ylocal1 = -deltay; | |
681 | Float_t xlocal2 = +deltax; | |
682 | Float_t ylocal2 = +deltay; | |
683 | Float_t xg01, yg01, zg1, xg02, yg02, zg2; | |
684 | fTransformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg01, yg01, zg1); | |
685 | fTransformer.Local2Global(detElemId, xlocal2, ylocal2, 0, xg02, yg02, zg2); | |
686 | ||
687 | Float_t xg1 = xg01, xg2 = xg02, yg1 = yg01, yg2 = yg02; | |
688 | ||
689 | if(xg01>xg02){ | |
690 | xg1 = xg02; | |
691 | xg2 = xg01; | |
692 | } | |
693 | if(yg01>yg02){ | |
694 | yg1 = yg02; | |
695 | yg2 = yg01; | |
696 | } | |
697 | ||
698 | if(x>=xg1-tolerance && x<=xg2+tolerance && y>=yg1-tolerance && y<=yg2+tolerance){ // takes into account errors in extrapolation | |
699 | if(y<yg1) currDist = yg1-y; | |
700 | else if(y>yg2) currDist = y-yg2; | |
701 | if(currDist<minDist) { | |
702 | resultingDetElemId = detElemId; | |
703 | minDist=currDist; | |
704 | continue; | |
705 | } | |
706 | resultingDetElemId = detElemId; | |
707 | break; | |
708 | } | |
709 | } // loop on detElemId | |
710 | return resultingDetElemId; | |
711 | } | |
712 | ||
713 | ||
714 | //_____________________________________________________________________________ | |
715 | void AliMUONTrackHitPattern::LocalBoardFromPos(Float_t x, Float_t y, | |
716 | Int_t detElemId, Int_t cathode, | |
717 | Int_t localBoard[4]) const | |
718 | { | |
719 | // | |
720 | /// Given the (x,y) position in the chamber, | |
721 | /// it returns the corresponding local board | |
722 | // | |
723 | ||
724 | for(Int_t loc=0; loc<fgkNlocations; loc++){ | |
725 | localBoard[loc]=-1; | |
726 | } | |
727 | Float_t xl, yl, zl; | |
728 | fTransformer.Global2Local(detElemId, x, y, 0, xl, yl, zl); | |
729 | TVector2 pos(xl,yl); | |
730 | const AliMpVSegmentation* seg = | |
731 | AliMpSegmentation::Instance() | |
732 | ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode)); | |
733 | if (seg){ | |
734 | AliMpPad pad = seg->PadByPosition(pos,kFALSE); | |
735 | for (Int_t loc=0; loc<pad.GetNofLocations(); loc++){ | |
736 | AliMpIntPair location = pad.GetLocation(loc); | |
737 | localBoard[loc] = location.GetFirst(); | |
738 | } | |
739 | } | |
740 | } | |
741 | ||
742 | ||
743 | //_____________________________________________________________________________ | |
744 | Bool_t AliMUONTrackHitPattern::PerformTrigTrackMatch(UShort_t &pattern, | |
745 | AliMUONTriggerTrack *matchedTrigTrack, | |
746 | AliMUONVDigitStore& digitStore) const | |
7771752e | 747 | { |
fda59e58 | 748 | // |
683cb6c5 | 749 | /// It searches for matching digits around the trigger track. |
fda59e58 | 750 | // |
7771752e | 751 | |
683cb6c5 | 752 | enum {kBending, kNonBending}; |
7771752e | 753 | |
683cb6c5 | 754 | Int_t chOrder[fgkNchambers] = {0,2,1,3}; |
755 | ||
756 | TArrayF zRealMatch(fgkNchambers); | |
757 | TArrayF correctFactor(fgkNcathodes); | |
758 | ||
759 | Bool_t isMatch[fgkNcathodes]; | |
760 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
761 | isMatch[cath] = kFALSE; | |
762 | } | |
763 | ||
764 | TArrayF zMeanChamber(fgkNchambers); | |
765 | for(Int_t ch=0; ch<fgkNchambers; ch++){ | |
766 | zMeanChamber[ch] = AliMUONConstants::DefaultChamberZ(10+ch); | |
767 | } | |
768 | ||
769 | TArrayI digitPerTrack(fgkNcathodes); | |
770 | ||
771 | Float_t trackIntersectCh[fgkNchambers][fgkNcathodes]; | |
772 | ||
773 | TArrayI triggeredDigits; | |
774 | triggeredDigits.Set(fgkNchambers); | |
775 | triggeredDigits.Reset(-1); | |
776 | ||
777 | TArrayI trigScheme[fgkNcathodes]; | |
778 | TArrayI slatThatTriggered[fgkNcathodes]; | |
779 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
780 | trigScheme[cath].Set(fgkNchambers); | |
781 | slatThatTriggered[cath].Set(fgkNchambers); | |
782 | } | |
783 | ||
784 | Int_t boardThatTriggered[fgkNchambers][fgkNcathodes][fgkNlocations]; | |
785 | TArrayI nboard[fgkNcathodes]; | |
786 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
787 | nboard[cath].Set(fgkNlocations); | |
788 | } | |
789 | Int_t ineffBoard[fgkNlocations]; | |
790 | for(Int_t loc=0; loc<fgkNlocations; loc++){ | |
791 | ineffBoard[loc] = -1; | |
792 | } | |
793 | ||
794 | digitPerTrack.Reset(); | |
795 | for(Int_t ch=0; ch<fgkNchambers; ch++){ | |
796 | zRealMatch[ch] = zMeanChamber[ch]; | |
797 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
798 | for(Int_t loc=0; loc<fgkNlocations; loc++){ | |
799 | boardThatTriggered[ch][cath][loc]=-1; | |
800 | } | |
801 | } | |
802 | } | |
803 | ||
804 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
805 | slatThatTriggered[cath].Reset(-1); | |
806 | trigScheme[cath].Reset(); | |
807 | } | |
808 | ||
809 | Bool_t isClearEvent = kTRUE; | |
810 | ||
811 | //Float_t x11 = matchedTrigTrack->GetX11();// x position (info from non-bending plane) | |
812 | Float_t y11 = matchedTrigTrack->GetY11();// y position (info from bending plane) | |
813 | Float_t thetaX = matchedTrigTrack->GetThetax(); | |
814 | Float_t thetaY = matchedTrigTrack->GetThetay(); | |
815 | ||
816 | for(Int_t ch=0; ch<fgkNchambers; ch++) { // chamber loop | |
817 | Int_t currCh = chOrder[ch]; | |
818 | AliDebug(2, Form("zMeanChamber[%i] = %.2f\tzRealMatch[0] = %.2f\n",currCh,zMeanChamber[currCh],zRealMatch[0])); | |
819 | ||
820 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
821 | correctFactor[cath]=1.; | |
822 | } | |
823 | // calculate corrections to trigger track theta | |
824 | if(ch>=1) correctFactor[kNonBending] = zMeanChamber[0]/zRealMatch[0];// corrects x position | |
825 | if(ch>=2) correctFactor[kBending] = (zMeanChamber[2] - zMeanChamber[0]) / (zRealMatch[2] - zRealMatch[0]);// corrects y position | |
826 | ||
827 | // searching track intersection with chambers (first approximation) | |
828 | Float_t deltaZ = zMeanChamber[currCh] - zMeanChamber[0]; | |
829 | trackIntersectCh[currCh][0] = zMeanChamber[currCh] * TMath::Tan(thetaX) * correctFactor[kNonBending];// x position (info from non-bending plane) | |
830 | trackIntersectCh[currCh][1] = y11 + deltaZ * TMath::Tan(thetaY) * correctFactor[kBending];// y position (info from bending plane) | |
831 | Int_t detElemIdFromTrack = DetElemIdFromPos(trackIntersectCh[currCh][0], trackIntersectCh[currCh][1], 11+currCh, 0); | |
832 | if(detElemIdFromTrack<0) { | |
833 | AliDebug(1, "Warning: trigger track outside trigger chamber\n"); | |
834 | continue; | |
835 | } | |
836 | ||
837 | triggeredDigits[currCh] = FindPadMatchingTrig(digitStore, detElemIdFromTrack, trackIntersectCh[currCh], isMatch, nboard, zRealMatch, y11); | |
838 | ||
839 | // if FindPadMatchingTrig = -500 => too many digits matching pad => | |
840 | // => Event not clear => Reject track | |
841 | if(triggeredDigits[currCh]<-100){ | |
842 | isClearEvent = kFALSE; | |
843 | AliDebug(1, Form("Warning: track = %p (%i) matches many pads. Rejected!\n",(void *)matchedTrigTrack, detElemIdFromTrack)); | |
844 | break; | |
845 | } | |
846 | ||
847 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
848 | if(!isMatch[cath]) continue; | |
849 | SetBit(pattern, cath, currCh); | |
850 | digitPerTrack[cath]++; | |
851 | trigScheme[cath][currCh]++; | |
852 | slatThatTriggered[cath][currCh] = detElemIdFromTrack; | |
853 | for(Int_t loc=0; loc<fgkNlocations; loc++){ | |
854 | boardThatTriggered[currCh][cath][loc] = nboard[cath][loc]; | |
855 | } | |
856 | } | |
857 | } // end chamber loop | |
858 | ||
859 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
860 | if(digitPerTrack[cath]<3) isClearEvent = kFALSE; | |
861 | if(!isClearEvent) AliDebug(1, Form("Warning: found %i digits for trigger track cathode %i.\nRejecting event\n", digitPerTrack[cath],cath)); | |
862 | } | |
863 | ||
864 | if(!isClearEvent) return kFALSE; | |
865 | ||
866 | Int_t goodForEff = kBoardEff; | |
867 | ||
868 | Int_t ineffSlat = -1; | |
869 | Int_t ineffDetElId = -1; | |
870 | Int_t firstSlat = slatThatTriggered[kBending][0]%100; | |
871 | if(firstSlat<0) firstSlat = slatThatTriggered[kBending][1]%100; | |
872 | Int_t firstBoard = boardThatTriggered[0][kBending][0]; | |
873 | if(firstBoard<0) firstBoard = boardThatTriggered[1][kBending][0]; | |
874 | for(Int_t ch=0; ch<fgkNchambers; ch++){ | |
875 | Bool_t isCurrChIneff = kFALSE; | |
876 | Int_t currSlat = slatThatTriggered[kBending][ch]%100; | |
877 | if(currSlat<0){ | |
878 | ineffDetElId = DetElemIdFromPos(trackIntersectCh[ch][0], trackIntersectCh[ch][1], 11+ch, kBending); | |
879 | currSlat = ineffDetElId%100; | |
880 | ineffSlat = currSlat; | |
881 | isCurrChIneff = kTRUE; | |
882 | } | |
883 | if(currSlat!=firstSlat) { | |
884 | AddEffInfo(pattern, 20, kChEff); | |
885 | return kTRUE; | |
886 | } | |
887 | Bool_t atLeastOneLoc=kFALSE; | |
888 | if(isCurrChIneff) LocalBoardFromPos(trackIntersectCh[ch][0], trackIntersectCh[ch][1], ineffDetElId, kBending, ineffBoard); | |
889 | for(Int_t loc=0; loc<fgkNlocations; loc++){ | |
890 | Int_t currBoard = boardThatTriggered[ch][kBending][loc]; | |
891 | if(isCurrChIneff) currBoard = ineffBoard[loc]; | |
892 | if(currBoard==firstBoard){ | |
893 | atLeastOneLoc=kTRUE; | |
894 | break; | |
895 | } | |
896 | } | |
897 | if(!atLeastOneLoc) goodForEff = kSlatEff; | |
898 | } // end chamber loop | |
899 | ||
900 | AddEffInfo(pattern, firstSlat, goodForEff); | |
901 | return kTRUE; | |
7771752e | 902 | } |