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