AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTrackHitPattern.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
18 
19 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
32 
33 
34 #include "AliMUONTrackHitPattern.h"
35 
36 #include "AliMUONConstants.h"
37 #include "AliMUONVDigit.h"
38 #include "AliMUONVDigitStore.h"
40 #include "AliMUONLocalTrigger.h"
41 #include "AliMUONRecoParam.h"
42 #include "AliMUONTrack.h"
43 #include "AliMUONTrackExtrap.h"
44 #include "AliMUONTrackParam.h"
45 #include "AliMUONVTrackStore.h"
46 #include "AliMUONVTriggerStore.h"
47 #include "AliMUONTriggerTrack.h"
50 
51 #include "AliMpPad.h"
52 #include "AliMpSegmentation.h"
53 #include "AliMpVSegmentation.h"
54 #include "AliMpDEManager.h"
55 #include "AliMpArea.h"
56 #include "AliMpConstants.h"
57 
58 #include "AliLog.h"
59 #include "AliESDMuonTrack.h"
60 #include "AliCodeTimer.h"
61 
62 #include <Riostream.h>
63 #include <TArrayI.h>
64 #include <TMath.h>
65 #include <TMatrixD.h>
66 #include <TVector3.h>
67 #include <TArrayF.h>
68 #include <TRandom.h>
69 
71 ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context
73 
74 
75 //______________________________________________________________________________
77  const AliMUONGeometryTransformer& transformer,
78  const AliMUONVDigitStore& digitStore,
79  const AliMUONTriggerUtilities* triggerUtilities)
80 : TObject(),
81 fkRecoParam(recoParam),
82 fkTransformer(transformer),
83 fkDigitStore(digitStore),
84 fkTriggerUtilities(triggerUtilities),
85 fkMaxDistance(99999.) // obsolete
86 {
89 }
90 
91 
92 //______________________________________________________________________________
94 {
96 }
97 
98 
99 //______________________________________________________________________________
100 void
102 {
103  //
106  //
107 
108  const Float_t kZFilterOut = AliMUONConstants::MuonFilterZEnd();
109  const Float_t kFilterThickness = kZFilterOut-AliMUONConstants::MuonFilterZBeg(); // cm
110 
111  AliMUONTrackExtrap::ExtrapToZCov(&trackParam, kZFilterOut); // Extrap to muon filter end
112  AliMUONTrackExtrap::AddMCSEffect(&trackParam, kFilterThickness, AliMUONConstants::MuonFilterX0()); // Add MCS effects
113  return;
114 }
115 
116 
117 //______________________________________________________________________________
119  const AliMUONVTriggerTrackStore& triggerTrackStore,
120  const AliMUONVTriggerStore& triggerStore) const
121 {
122  //
126  //
127 
128  // Get the hit pattern for all trigger tracks
129  AliMUONTriggerTrack* triggerTrack;
130  TIter itTriggerTrack(triggerTrackStore.CreateIterator());
131  while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack() ) ) ){
132  AliMUONTrackParam trackParam;
133  trackParam.SetNonBendingCoor(triggerTrack->GetX11());
134  trackParam.SetBendingCoor(triggerTrack->GetY11());
135  trackParam.SetZ(triggerTrack->GetZ11());
136  trackParam.SetNonBendingSlope(triggerTrack->GetSlopeX());
137  trackParam.SetBendingSlope(triggerTrack->GetSlopeY());
138  trackParam.SetInverseBendingMomentum(1.);
139  UInt_t pattern = GetHitPattern(trackParam, kTRUE);
140  // The pattern is a UInt_t, including the information
141  // on the matched local board,
142  // but for backward compatibility we fill a UShort_t
143  // which do not contain such info.
144  // In the old pattern, we use 15 bits out of 16, so the last one should
145  // be masked or it will be filled with 1 bit with the local board info.
146  triggerTrack->SetHitsPatternInTrigCh((UShort_t)(pattern & 0x7FFF));
147  AliDebug(1, Form("Hit pattern (MTR): hits 0x%x slat %2i board %3i effFlag %i",
148  pattern & 0xFF, AliESDMuonTrack::GetSlatOrInfo(pattern),triggerTrack->GetLoTrgNum(), AliESDMuonTrack::GetEffFlag(pattern)));
149  }
150 
151  // Match tracker tracks with trigger tracks.
152  TIter itTrack(trackStore.CreateIterator());
154 
155  const Int_t kFirstTrigCh = AliMUONConstants::NTrackingCh();
156 
157  while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) )
158  {
159  AliMUONTrackParam trackParam(*((AliMUONTrackParam*) (track->GetTrackParamAtCluster()->Last())));
160 
161  ApplyMCSCorrections(trackParam);
162  AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(kFirstTrigCh)); // extrap to 1st trigger chamber
163 
164  AliMUONTriggerTrack *matchedTriggerTrack = MatchTriggerTrack(track, trackParam, triggerTrackStore, triggerStore);
165  if ( matchedTriggerTrack ) track->SetHitsPatternInTrigCh(matchedTriggerTrack->GetHitsPatternInTrigCh());
166 
167  UInt_t pattern = GetHitPattern(trackParam, kFALSE);
168  track->SetHitsPatternInTrigChTrk(pattern);
169  AliDebug(1, Form("Hit pattern (MTK): hits 0x%x slat %2i board %3i effFlag %i",
170  pattern & 0xFF, AliESDMuonTrack::GetSlatOrInfo(pattern), AliESDMuonTrack::GetCrossedBoard(pattern), AliESDMuonTrack::GetEffFlag(pattern)));
171  }
172 }
173 
174 
175 //______________________________________________________________________________
177  TArrayI& matchedDetElemId, TObjArray& pads,
178  const AliMUONVDigitStore& digitStore,
179  Bool_t isTriggerTrack) const
180 {
181  //
183  //
184  enum {kBending, kNonBending};
185 
186  Double_t minMatchDist[2];
187  Int_t padsInCheckArea[2];
188 
189  AliMUONTrackParam trackParamAtPadZ(*trackParam);
190 
191  Int_t inputDetElemId = matchedDetElemId[0];
192 
193  for(Int_t cath=0; cath<2; cath++){
194  minMatchDist[cath] = 99999.;
195  padsInCheckArea[cath] = 0;
196  }
197 
198  Int_t iChamber = AliMpDEManager::GetChamberId(inputDetElemId);
199  Int_t iSlat = inputDetElemId%100;
200 
201  TIter next(digitStore.CreateTriggerIterator());
202  AliMUONVDigit* mDigit;
203 
204  Double_t xPad = 0., yPad = 0., zPad = 0.;
205  Double_t sigmaX = 0., sigmaY = 0.;
206 
207  Double_t nSigmas = ( isTriggerTrack ) ? GetRecoParam()->GetStripCutForTrigger() : GetRecoParam()->GetSigmaCutForTrigger();
208  Bool_t goodForEff = kTRUE;
209 
210  while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
211  {
212  Int_t currDetElemId = mDigit->DetElemId();
213  Int_t currCh = AliMpDEManager::GetChamberId(currDetElemId);
214  if ( currCh != iChamber ) continue;
215  Int_t currSlat = currDetElemId%100;
216  Int_t slatDiff = TMath::Abs(currSlat-iSlat);
217  if ( slatDiff>1 && slatDiff<17 ) continue; // Check neighbour slats
218 
219  Int_t cathode = mDigit->Cathode();
220  Int_t ix = mDigit->PadX();
221  Int_t iy = mDigit->PadY();
223  ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
224  AliMpPad pad = seg->PadByIndices(ix,iy,kTRUE);
225 
226  // Get local pad coordinates
227  Double_t xPadLocal = pad.GetPositionX();
228  Double_t yPadLocal = pad.GetPositionY();
229  Double_t dpx = pad.GetDimensionX();
230  Double_t dpy = pad.GetDimensionY();
231  Double_t xWidth = 2. * dpx;
232  Double_t yWidth = 2. * dpy;
233 
234  // Get global pad coordinates
235  fkTransformer.Local2Global(currDetElemId, xPadLocal, yPadLocal, 0., xPad, yPad, zPad);
236 
237  // Get track parameters at pad z
238  if ( trackParamAtPadZ.CovariancesExist() ) AliMUONTrackExtrap::LinearExtrapToZCov(&trackParamAtPadZ, zPad);
239  else AliMUONTrackExtrap::LinearExtrapToZ(&trackParamAtPadZ, zPad);
240 
241  Double_t deltaX = TMath::Abs(xPad-trackParamAtPadZ.GetNonBendingCoor()) - dpx;
242  Double_t deltaY = TMath::Abs(yPad-trackParamAtPadZ.GetBendingCoor()) - dpy;
243 
244 
245  // Get sigmas
246  if ( isTriggerTrack ) {
247  Double_t checkWidth = TMath::Min(xWidth, yWidth);
248  Double_t maxCheckArea = GetRecoParam()->GetMaxStripAreaForTrigger() * checkWidth;
249  Double_t sigma = TMath::Max(checkWidth, 2.);
250  sigmaX = sigma; // in cm
251  sigmaY = sigma; // in cm
252  if ( deltaX <= maxCheckArea && deltaY <= maxCheckArea ) {
253  padsInCheckArea[cathode]++;
254  if ( padsInCheckArea[cathode] > 2 ) {
255  goodForEff = kFALSE;
256  AliDebug(2, Form("padsInCheckArea[%i] = %i\n",cathode,padsInCheckArea[cathode]));
257  }
258  }
259  }
260  else {
261  const TMatrixD& kCovParam = trackParamAtPadZ.GetCovariances();
262  sigmaX = TMath::Sqrt(kCovParam(0,0)); // in cm
263  sigmaY = TMath::Sqrt(kCovParam(2,2)); // in cm
264  }
265 
266  AliDebug(2, Form("\nDetElemId %i Cath %i Dim = (%.2f,%.2f) Pad (%i,%i) = (%.2f,%.2f) Track = (%.2f,%.2f) Delta (%.2f,%.2f) Sigma (%.2f,%.2f) p %g\n",
267  currDetElemId,cathode,dpx,dpy,ix,iy,xPad,yPad,trackParamAtPadZ.GetNonBendingCoor(),trackParamAtPadZ.GetBendingCoor(),deltaX,deltaY,sigmaX,sigmaY,trackParamAtPadZ.P()));
268  //if ( deltaX <= maxCheckArea && deltaY <= maxCheckArea ) padsInCheckArea[cathode]++;
269  if ( deltaX > nSigmas * sigmaX || deltaY > nSigmas * sigmaY ) continue;
270  Double_t matchDist = TMath::Max(deltaX, deltaY);
271  if ( matchDist > minMatchDist[cathode] ) continue;
272  if ( pads.At(cathode) ) delete pads.RemoveAt(cathode);
273  pads.AddAt((AliMpPad*)pad.Clone(),cathode);
274  minMatchDist[cathode] = matchDist;
275  matchedDetElemId[cathode] = currDetElemId; // Set the input detection element id to the matched one
276  } // loop on digits
277 
278 // // If track matches many pads, it is not good for effciency determination.
279 // // However we still want to calculate the hit pattern.
280 // for ( Int_t cath=0; cath<2; cath++ ){
281 // if ( padsInCheckArea[cath] > 2 ) {
282 // AliDebug(2, Form("padsInCheckArea[%i] = %i\n",cath,padsInCheckArea[cath]));
283 // return kFALSE;
284 // }
285 // }
286 
287  return goodForEff;
288 }
289 
290 
291 //_____________________________________________________________________________
292 UInt_t AliMUONTrackHitPattern::GetHitPattern(const AliMUONTrackParam& trackParam, Bool_t isTriggerTrack) const
293 {
294  //
296  //
297 
298  AliCodeTimerAuto("",0);
299 
300  TArrayI digitPerTrack(2);
301  digitPerTrack.Reset();
302 
303  UInt_t pattern = 0;
304 
305  TObjArray trackParamList, matchedPads(2), maskedPads(2), padsFromPos(4), validPads(2);
306  trackParamList.SetOwner(); matchedPads.SetOwner(); maskedPads.SetOwner(); padsFromPos.SetOwner();
307 
308  Int_t firstSlat = -1, firstBoard = -1;
309  AliESDMuonTrack::EAliTriggerChPatternFlag goodForEff = AliESDMuonTrack::kBoardEff;
310  TArrayI matchedDetElemId(2), maskedDetElemId(2), detElemIdFromTrack(2), validDetElemId(2);
311 
312  for(Int_t ich=0; ich<AliMUONConstants::NTriggerCh(); ich++) { // chamber loop
313 
314  trackParamList.Delete(); matchedPads.Delete(); maskedPads.Delete(); padsFromPos.Delete(); validPads.Clear();
315 
316  Int_t nFound = GetTrackParamAtChamber(trackParam, 11+ich, trackParamList, detElemIdFromTrack, padsFromPos);
317  if ( nFound == 0 ) {
318  // track is rejected since the extrapolated track
319  // does not match a slat (border effects)
320  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackOutsideGeometry);
321  goodForEff = AliESDMuonTrack::kNoEff;
322  AliDebug(2, "Warning: trigger track outside trigger chamber\n");
323  continue;
324  }
325 
326  // Search for masked pads
327  maskedDetElemId.Reset(detElemIdFromTrack[0]);
328  FindMatchingPads((AliMUONTrackParam*)trackParamList.At(0), maskedDetElemId, maskedPads, *(fkTriggerUtilities->GetMaskedDigits()), isTriggerTrack);
329  if ( maskedPads.GetEntries() > 0 ) {
330  AliESDMuonTrack::AddEffInfo(pattern,AliESDMuonTrack::kTrackMatchesMasks); // pad is masked
331  goodForEff = AliESDMuonTrack::kNoEff;
332  for ( Int_t icath=0; icath<2; icath++ ) {
333  AliMpPad* currPad = (AliMpPad*)maskedPads.UncheckedAt(icath);
334  if ( ! currPad ) continue;
335  AliDebug(2,Form("DetElemId %i cath %i board %i strip %i is masked: effFlag 0", matchedDetElemId[icath], icath, currPad->GetLocalBoardId(0), currPad->GetLocalBoardChannel(0)));
336  }
337  // continue;
338  // We want to calculate the hit pattern in any case, so we do not "continue"
339  // However we set the flag in such a way not to use the track for efficiency calculations
340  }
341 
342  // If no masked pads matched, search for active pads
343  matchedDetElemId.Reset(detElemIdFromTrack[0]);
344  if ( ! FindMatchingPads((AliMUONTrackParam*)trackParamList.At(0), matchedDetElemId, matchedPads, fkDigitStore, isTriggerTrack) ) {
345  // if ! FindPadMatchingTrig => too many digits matching pad =>
346  // => Event not clear => Do not use for efficiency calculation
347  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackMatchesManyPads);
348  goodForEff = AliESDMuonTrack::kNoEff;
349  AliDebug(2, Form("Warning: track in %i matches many pads. Rejected!\n", matchedDetElemId[0]));
350  }
351 
352  Int_t nMatched = 0;
353 
354  Int_t mostProbDEmatched = detElemIdFromTrack[0];
355  for ( Int_t icath=0; icath<2; icath++ ) {
356  if ( matchedPads.UncheckedAt(icath) ) {
357  nMatched++;
358  // Fill pattern anyway
359  AliESDMuonTrack::SetFiredChamber(pattern, icath, ich);
360  digitPerTrack[icath]++;
361  mostProbDEmatched = matchedDetElemId[icath];
362  }
363  }
364  Int_t mostProbDEindex = 0;
365  for ( Int_t ifound=0; ifound<nFound; ifound++ ) {
366  if ( detElemIdFromTrack[ifound] == mostProbDEmatched ) {
367  mostProbDEindex = ifound;
368  break;
369  }
370  }
371 
372  if ( goodForEff == AliESDMuonTrack::kNoEff ) continue;
373 
374  for ( Int_t icath=0; icath<2; icath++ ) {
375  if ( matchedPads.UncheckedAt(icath) ) {
376  validPads.AddAt(matchedPads.UncheckedAt(icath),icath);
377  validDetElemId[icath] = matchedDetElemId[icath];
378  }
379  else {
380  validPads.AddAt(padsFromPos.UncheckedAt(2*mostProbDEindex + icath),icath);
381  validDetElemId[icath] = detElemIdFromTrack[mostProbDEindex];
382  }
383  }
384 
385  Int_t currSlat = mostProbDEmatched%100;
386  if ( firstSlat < 0 ) firstSlat = currSlat;
387 
388  if ( currSlat != firstSlat || validDetElemId[0] != validDetElemId[1] ) {
389  goodForEff = AliESDMuonTrack::kChEff;
390  firstSlat = AliESDMuonTrack::kCrossDifferentSlats;
391  }
392 
393  if ( firstBoard < 0 ) firstBoard = ((AliMpPad*)validPads.UncheckedAt(0))->GetLocalBoardId(0);
394 
395  for ( Int_t icath=0; icath<2; icath++ ){
396 
397  if ( goodForEff == AliESDMuonTrack::kBoardEff) {
398  Bool_t atLeastOneLoc = kFALSE;
399  AliMpPad* currPad = (AliMpPad*)validPads.UncheckedAt(icath);
400  for ( Int_t iloc=0; iloc<currPad->GetNofLocations(); iloc++) {
401  if ( currPad->GetLocalBoardId(iloc) == firstBoard ) {
402  atLeastOneLoc = kTRUE;
403  break;
404  }
405  } // loop on locations
406  if ( ! atLeastOneLoc ) goodForEff = AliESDMuonTrack::kSlatEff;
407  }
408  } // loop on cathodes
409  // } // if track good for efficiency
410  } // end chamber loop
411 
412  if ( goodForEff == AliESDMuonTrack::kNoEff ) return pattern;
413 
414  for(Int_t cath=0; cath<2; cath++){
415  if(digitPerTrack[cath]<3) {
416  // track is rejected since the number of associated
417  // digits found is less than 3.
418  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackMatchesFewPads);
419  goodForEff = AliESDMuonTrack::kNoEff;
420  AliDebug(2, Form("Warning: found %i digits for trigger track cathode %i.\nRejecting event\n", digitPerTrack[cath],cath));
421  }
422  } // loop on cathodes
423 
424  if ( goodForEff == AliESDMuonTrack::kNoEff ) return pattern;
425 
426  AliESDMuonTrack::AddEffInfo(pattern, firstSlat, firstBoard, goodForEff);
427  return pattern;
428 }
429 
430 
431 
432 //_____________________________________________________________________________
433 Int_t AliMUONTrackHitPattern::GetTrackParamAtChamber(const AliMUONTrackParam& inputTrackParam, Int_t chamber,
434  TObjArray& trackParamList, TArrayI& foundDetElemId,
435  TObjArray& padsFromPos) const
436 {
437  //
441  //
442 
443  Int_t nFound = 0;
444  foundDetElemId[0] = foundDetElemId[1] = 0;
445  AliMUONTrackParam trackParamCopy(inputTrackParam);
446  TVector3 globalPoint1(trackParamCopy.GetNonBendingCoor(), trackParamCopy.GetBendingCoor(), trackParamCopy.GetZ());
447  AliMUONTrackExtrap::LinearExtrapToZ(&trackParamCopy, trackParamCopy.GetZ() + 20.);
448  TVector3 globalPoint2(trackParamCopy.GetNonBendingCoor(), trackParamCopy.GetBendingCoor(), trackParamCopy.GetZ());
449  TVector3 localCoor;
450 
451  // AliMpArea pointArea(x, y, 2.*AliMpConstants::LengthTolerance(), 2.*AliMpConstants::LengthTolerance());
452  AliMpDEIterator it;
453  Double_t xGlobal, yGlobal, zGlobal;
454  for ( it.First(chamber-1); ! it.IsDone(); it.Next() ){
455  Int_t detElemId = it.CurrentDEId();
456  PosInDetElemIdLocal(localCoor, globalPoint1, globalPoint2, detElemId);
457  fkTransformer.Local2Global(detElemId, localCoor.X(), localCoor.Y(), localCoor.Z(), xGlobal, yGlobal, zGlobal);
458  AliMpArea pointArea(xGlobal, yGlobal, 2.*AliMpConstants::LengthTolerance(), 2.*AliMpConstants::LengthTolerance());
459  AliMpArea* deArea = fkTransformer.GetDEArea(detElemId);
460  if ( deArea->Contains(pointArea) ) {
461  // Check if track matches valid pads
462  // (this is not trivial for cut RPC)
463  Int_t validPads = 0;
464  for ( Int_t icath=0; icath<2; icath++ ) {
465  const AliMpVSegmentation* seg =
467  ->GetMpSegmentation(detElemId,AliMp::GetCathodType(icath));
468  AliMpPad pad = seg->PadByPosition(localCoor.X(),localCoor.Y(),kFALSE);
469  if ( pad.IsValid() ) {
470  padsFromPos.AddAt(pad.Clone(), 2*nFound + icath);
471  validPads++;
472  }
473  }
474  if ( validPads < 2 ) continue;
475  AliMUONTrackParam* extrapTrackParam = new AliMUONTrackParam(inputTrackParam);
476  if ( extrapTrackParam->CovariancesExist() ) AliMUONTrackExtrap::LinearExtrapToZCov(extrapTrackParam, zGlobal);
477  else AliMUONTrackExtrap::LinearExtrapToZ(extrapTrackParam, zGlobal);
478  trackParamList.AddAt(extrapTrackParam,nFound);
479  foundDetElemId[nFound] = detElemId;
480  nFound++;
481  if ( nFound == 2 ) break;
482  }
483  else if ( nFound > 0 ) break;
484  } // loop on detElemId
485 
486  return nFound;
487 }
488 
489 
490 //______________________________________________________________________________
493  AliMUONTrackParam& trackParam,
494  const AliMUONVTriggerTrackStore& triggerTrackStore,
495  const AliMUONVTriggerStore& triggerStore) const
496 {
497  //
499  //
500 
501  Int_t matchTrigger = 0;
502  Int_t loTrgNum(-1);
503  TMatrixD paramDiff(3,1);
504  Double_t chi2;
505  Double_t chi2MatchTrigger = 0., minChi2MatchTrigger = 999.;
506  Int_t doubleMatch = -1; // Check if track matches 2 trigger tracks
507  Double_t doubleChi2 = -1.;
508  AliMUONTriggerTrack* doubleTriggerTrack = 0x0;
509  AliMUONTriggerTrack* matchedTriggerTrack = 0x0;
510 
511 
512  // Covariance matrix 3x3 (X,Y,slopeY) for trigger tracks
513  TMatrixD trackCov(3,3);
514 
515  AliMUONTriggerTrack *triggerTrack;
516  TIter itTriggerTrack(triggerTrackStore.CreateIterator());
517  while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack() ) ) )
518  {
519  AliMUONTrackExtrap::LinearExtrapToZCov(&trackParam, triggerTrack->GetZ11());
520  const TMatrixD& kParamCov = trackParam.GetCovariances();
521 
522  Double_t xTrack = trackParam.GetNonBendingCoor();
523  Double_t yTrack = trackParam.GetBendingCoor();
524  Double_t ySlopeTrack = trackParam.GetBendingSlope();
525 
526  paramDiff(0,0) = triggerTrack->GetX11() - xTrack;
527  paramDiff(1,0) = triggerTrack->GetY11() - yTrack;
528  paramDiff(2,0) = triggerTrack->GetSlopeY() - ySlopeTrack;
529 
530  // Covariance matrix 3x3 (X,Y,slopeY) for tracker tracks
531  trackCov.Zero();
532  trackCov(0,0) = kParamCov(0,0);
533  trackCov(1,1) = kParamCov(2,2);
534  trackCov(2,2) = kParamCov(3,3);
535  trackCov(1,2) = kParamCov(2,3);
536  trackCov(2,1) = kParamCov(3,2);
537 
538  // Covariance matrix 3x3 (X,Y,slopeY) for trigger tracks
539  TMatrixD trigCov(triggerTrack->GetCovariances());
540 
541  TMatrixD sumCov(trackCov,TMatrixD::kPlus,trigCov);
542  if (sumCov.Determinant() != 0) {
543  sumCov.Invert();
544 
545  TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff);
546  TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp);
547  chi2 = chi2M(0,0);
548  } else {
549  AliWarning(" Determinant = 0");
550  Double_t sigma2 = 0.;
551  chi2 = 0.;
552  for (Int_t iVar = 0; iVar < 3; iVar++) {
553  sigma2 = trackCov(iVar,iVar) + trigCov(iVar,iVar);
554  chi2 += paramDiff(iVar,0) * paramDiff(iVar,0) / sigma2;
555  }
556  }
557 
558  chi2 /= 3.; // Normalized Chi2: 3 degrees of freedom (X,Y,slopeY)
559  if (chi2 < GetRecoParam()->GetMaxNormChi2MatchTrigger())
560  {
561  Bool_t isDoubleTrack = (TMath::Abs(chi2 - minChi2MatchTrigger)<1.);
562  if (chi2 < minChi2MatchTrigger && chi2 < GetRecoParam()->GetMaxNormChi2MatchTrigger())
563  {
564  if(isDoubleTrack)
565  {
566  doubleMatch = loTrgNum;
567  doubleChi2 = chi2MatchTrigger;
568  doubleTriggerTrack = matchedTriggerTrack;
569  }
570  minChi2MatchTrigger = chi2;
571  chi2MatchTrigger = chi2;
572  loTrgNum = triggerTrack->GetLoTrgNum();
573  matchedTriggerTrack = triggerTrack;
574  AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(loTrgNum);
575  matchTrigger = 1;
576  if(locTrg->LoLpt()>0) matchTrigger = 2;
577  if(locTrg->LoHpt()>0) matchTrigger = 3;
578  }
579  else if(isDoubleTrack)
580  {
581  doubleMatch = triggerTrack->GetLoTrgNum();
582  doubleChi2 = chi2;
583  }
584  }
585  }
586  if(doubleMatch>=0)
587  { // If two trigger tracks match, select the one passing more trigger cuts
588  AliDebug(1, Form("Two candidates found: %i and %i",loTrgNum,doubleMatch));
589  AliMUONLocalTrigger* locTrg1 = triggerStore.FindLocal(doubleMatch);
590  if((locTrg1->LoLpt()>0 && matchTrigger<2) || (locTrg1->LoHpt() && matchTrigger<3))
591  {
592  if(locTrg1->LoHpt()>0) matchTrigger=3;
593  else matchTrigger = 2;
594  loTrgNum = doubleMatch;
595  chi2MatchTrigger = doubleChi2;
596  matchedTriggerTrack = doubleTriggerTrack;
597  }
598  }
599 
600  track->SetMatchTrigger(matchTrigger);
601  track->SetChi2MatchTrigger(chi2MatchTrigger);
602 
603  AliMUONLocalTrigger* locTrg = static_cast<AliMUONLocalTrigger*>(triggerStore.FindLocal(loTrgNum));
604 
605  if (locTrg)
606  {
607  track->SetLocalTrigger(locTrg->LoCircuit(),
608  locTrg->LoStripX(),
609  locTrg->LoStripY(),
610  locTrg->GetDeviation(),
611  locTrg->LoLpt(),
612  locTrg->LoHpt(),
613  locTrg->GetTriggerWithoutChamber());
614  }
615 
616  return matchedTriggerTrack;
617 }
618 
619 
620 //_____________________________________________________________________________
621 Bool_t AliMUONTrackHitPattern::PosInDetElemIdLocal(TVector3& localCoor, const TVector3& globalPoint1,
622  const TVector3& globalPoint2, Int_t detElemId) const
623 {
626 
627  Double_t xloc, yloc, zloc;
628  fkTransformer.Global2Local(detElemId, globalPoint1.X(), globalPoint1.Y(), globalPoint1.Z(), xloc, yloc, zloc);
629  TVector3 localPoint1(xloc, yloc, zloc);
630  fkTransformer.Global2Local(detElemId, globalPoint2.X(), globalPoint2.Y(), globalPoint2.Z(), xloc, yloc, zloc);
631  TVector3 localPoint2(xloc, yloc, zloc);
632  localCoor = localPoint1 - ( localPoint1.Z() / ( localPoint2.Z() - localPoint1.Z() ) ) * ( localPoint2 - localPoint1 );
633 
634  return kTRUE;
635 }
636 
637 
638 // THE FOLLOWING METHODS ARE OBSOLETE
639 
640 //______________________________________________________________________________
641 UInt_t AliMUONTrackHitPattern::GetHitPattern(const AliMUONTriggerTrack* matchedTriggerTrack) const
642 {
643  //
645  //
646  UInt_t pattern = 0;
647  PerformTrigTrackMatch(pattern, matchedTriggerTrack);
648  return pattern;
649 }
650 
651 
652 //______________________________________________________________________________
654 {
655  //
657  //
658  UInt_t pattern = 0;
659  Bool_t isMatch[2];
660  const Int_t kNTrackingCh = AliMUONConstants::NTrackingCh();
661 
662  for(Int_t ch=0; ch<4; ++ch)
663  {
664  Int_t iChamber = kNTrackingCh+ch;
666  FindPadMatchingTrack(*trackParam, isMatch, iChamber);
667  for(Int_t cath=0; cath<2; ++cath)
668  {
669  if(isMatch[cath]) AliESDMuonTrack::SetFiredChamber(pattern, cath, ch);
670  }
671  }
672 
673  // pattern obtained by propagation of tracker track
674  // when it does not match the trigger.
675  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackerTrackPattern);
676 
677  return pattern;
678 }
679 
680 
681 //______________________________________________________________________________
682 void
684  Bool_t isMatch[2], Int_t iChamber) const
685 {
686  //
688  //
689 
690  Float_t minMatchDist[2];
691 
692  for(Int_t cath=0; cath<2; ++cath)
693  {
694  isMatch[cath]=kFALSE;
695  minMatchDist[cath]=fkMaxDistance/10.;
696  }
697 
698  TIter next(fkDigitStore.CreateTriggerIterator());
699  AliMUONVDigit* mDigit;
700 
701  while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
702  {
703  Int_t currDetElemId = mDigit->DetElemId();
704  Int_t currCh = AliMpDEManager::GetChamberId(currDetElemId);
705  if(currCh!=iChamber) continue;
706  Int_t cathode = mDigit->Cathode();
707  Int_t ix = mDigit->PadX();
708  Int_t iy = mDigit->PadY();
709  Float_t xpad, ypad, zpad;
711  ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
712 
713  AliMpPad pad = seg->PadByIndices(ix,iy,kTRUE);
714  Float_t xlocal1 = pad.GetPositionX();
715  Float_t ylocal1 = pad.GetPositionY();
716  Float_t dpx = pad.GetDimensionX();
717  Float_t dpy = pad.GetDimensionY();
718 
719  fkTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad);
720  Float_t matchDist = MinDistanceFromPad(xpad, ypad, zpad, dpx, dpy, trackParam);
721  if(matchDist>minMatchDist[cathode])continue;
722  isMatch[cathode] = kTRUE;
723  if(isMatch[0] && isMatch[1]) break;
724  minMatchDist[cathode] = matchDist;
725  }
726 }
727 
728 
729 //______________________________________________________________________________
730 Float_t
731 AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad,
732  Float_t dpx, Float_t dpy,
733  const AliMUONTrackParam& trackParam) const
734 {
735  //
737  //
738 
739  AliMUONTrackParam trackParamAtPadZ(trackParam);
740  AliMUONTrackExtrap::LinearExtrapToZCov(&trackParamAtPadZ, zPad);
741 
742  Float_t xTrackAtPad = trackParamAtPadZ.GetNonBendingCoor();
743  Float_t yTrackAtPad = trackParamAtPadZ.GetBendingCoor();
744 
745  const Float_t kNSigma = GetRecoParam()->GetSigmaCutForTrigger();
746 
747  const TMatrixD& kCovParam = trackParamAtPadZ.GetCovariances();
748 
749  Float_t sigmaX = TMath::Sqrt(kCovParam(0,0));
750  Float_t sigmaY = TMath::Sqrt(kCovParam(2,2));
751 
752  Float_t maxDistX = kNSigma * sigmaX; // in cm
753  Float_t maxDistY = kNSigma * sigmaY; // in cm
754 
755  Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx;
756  Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy;
757 
758  Float_t matchDist = fkMaxDistance;
759  if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
760 
761  return matchDist;
762 }
763 
764 
765 //_____________________________________________________________________________
766 Bool_t AliMUONTrackHitPattern::FindPadMatchingTrig(const TVector3& vec11, const TVector3& vec21,
767  Int_t matchedDetElemId[2], TObjArray& pads) const
768 {
769  //
771  //
772 
773  enum {kBending, kNonBending};
774 
775  Float_t minMatchDist[2];
776  Int_t padsInCheckArea[2];
777 
778  Int_t inputDetElemId = matchedDetElemId[0];
779 
780  for(Int_t cath=0; cath<2; cath++){
781  minMatchDist[cath] = fkMaxDistance/10.;
782  padsInCheckArea[cath] = 0;
783  }
784 
785  Int_t iChamber = AliMpDEManager::GetChamberId(inputDetElemId);
786  Int_t iSlat = inputDetElemId%100;
787 
788  TIter next(fkDigitStore.CreateTriggerIterator());
789  AliMUONVDigit* mDigit;
790  TVector3 localExtrap;
791 
792  Int_t previousDetElemId = -1;
793 
794  while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
795  {
796  Int_t currDetElemId = mDigit->DetElemId();
797  Int_t currCh = AliMpDEManager::GetChamberId(currDetElemId);
798  if ( currCh != iChamber ) continue;
799  Int_t currSlat = currDetElemId%100;
800  Int_t slatDiff = TMath::Abs(currSlat-iSlat);
801  if ( slatDiff>1 && slatDiff<17 ) continue; // Check neighbour slats
802  Int_t cathode = mDigit->Cathode();
803  Int_t ix = mDigit->PadX();
804  Int_t iy = mDigit->PadY();
806  ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
807 
808  AliMpPad pad = seg->PadByIndices(ix,iy,kTRUE);
809 
810  if ( currDetElemId != previousDetElemId ) {
811  PosInDetElemIdLocal(localExtrap, vec11, vec21, currDetElemId);
812  previousDetElemId = currDetElemId;
813  }
814 
815  AliDebug(11, Form("\nDetElemId = %i Cathode = %i Pad = (%i,%i) = (%.2f,%.2f) Dim = (%.2f,%.2f) Track = (%.2f,%.2f)\n",
816  currDetElemId,cathode,ix,iy,pad.GetPositionX(),pad.GetPositionY(),pad.GetDimensionX(),pad.GetDimensionY(),localExtrap.X(),localExtrap.Y()));
817  Float_t matchDist = PadMatchTrack(pad, localExtrap);
818  if ( matchDist < fkMaxDistance/2. ) padsInCheckArea[cathode]++;
819  if ( matchDist > minMatchDist[cathode] ) continue;
820  if ( pads.At(cathode) ) delete pads.RemoveAt(cathode);
821  pads.AddAt((AliMpPad*)pad.Clone(),cathode);
822  minMatchDist[cathode] = matchDist;
823  matchedDetElemId[cathode] = currDetElemId; // Set the input detection element id to the matched one
824  } // loop on digits
825 
826  // If track matches many pads, it is not good for effciency determination.
827  // However we still want to calculate the hit pattern.
828  for ( Int_t cath=0; cath<2; cath++ ){
829  if ( padsInCheckArea[cath] > 2 ) {
830  AliDebug(10, Form("padsInCheckArea[%i] = %i\n",cath,padsInCheckArea[cath]));
831  return kFALSE;
832  }
833  }
834 
835  return kTRUE;
836 }
837 
838 //_____________________________________________________________________________
839 Float_t AliMUONTrackHitPattern::PadMatchTrack(const AliMpPad& pad, const TVector3& trackPosAtPad) const
840 {
841  //
843  //
844 
845  Float_t xPad = pad.GetPositionX();
846  Float_t yPad = pad.GetPositionY();
847  Float_t dpx = pad.GetDimensionX();
848  Float_t dpy = pad.GetDimensionY();
849 
850 
851  Float_t maxDist = GetRecoParam()->GetStripCutForTrigger() * 2. * TMath::Min(dpx,dpy); // cm
852  if ( maxDist<2. ) maxDist = 2.;
853  Float_t maxDistCheckArea = GetRecoParam()->GetMaxStripAreaForTrigger() * 2. * TMath::Min(dpx,dpy); // cm
854 
855  Float_t matchDist = fkMaxDistance;
856 
857  Float_t deltaX = TMath::Abs(xPad-trackPosAtPad.X())-dpx;
858  Float_t deltaY = TMath::Abs(yPad-trackPosAtPad.Y())-dpy;
859  Float_t maxDistX = maxDist;
860  Float_t maxDistY = maxDist;
861 
862  if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
863  else if(deltaX<=maxDistCheckArea && deltaY<=maxDistCheckArea) matchDist = fkMaxDistance/5.;
864  return matchDist;
865 }
866 
867 
868 //_____________________________________________________________________________
869 Int_t AliMUONTrackHitPattern::DetElemIdFromPos(Float_t x, Float_t y,
870  Int_t chamber, Int_t foundDetElemId[2]) const
871 {
872  //
876  //
877 
878  Int_t nFound = 0;
879 
880  foundDetElemId[0] = foundDetElemId[1] = 0;
882  AliMpDEIterator it;
883  for ( it.First(chamber-1); ! it.IsDone(); it.Next() ){
884  Int_t detElemId = it.CurrentDEId();
885  AliMpArea* deArea = fkTransformer.GetDEArea(detElemId);
886 
887  if ( deArea->Contains(pointArea) ) {
888  foundDetElemId[nFound++] = detElemId;
889  if ( nFound == 2 ) break;
890  }
891  else if ( nFound > 0 ) break;
892  } // loop on detElemId
893 
894  return nFound;
895 }
896 
897 
898 
899 //_____________________________________________________________________________
900 Bool_t AliMUONTrackHitPattern::PadsFromPos(const TVector3& vec11, const TVector3& vec21,
901  Int_t detElemId, TObjArray& pads) const
902 {
903  //
906  //
907 
908  pads.Delete();
909 
910  TVector3 localCoor;
911  PosInDetElemIdLocal(localCoor, vec11, vec21, detElemId);
912  for ( Int_t icath=0; icath<2; icath++ ) {
913  const AliMpVSegmentation* seg =
915  ->GetMpSegmentation(detElemId,AliMp::GetCathodType(icath));
916  AliMpPad pad = seg->PadByPosition(localCoor.X(),localCoor.Y(),kFALSE);
917  if ( pad.IsValid() ) {
918  pads.AddAt(pad.Clone(), icath);
919  }
920  }
921 
922  return pads.GetEntries();
923 }
924 
925 
926 //_____________________________________________________________________________
927 Bool_t AliMUONTrackHitPattern::IsCloseToAccEdge(TObjArray& pads, Int_t detElemId, Float_t coor[2]) const
928 {
929  AliMpArea* deArea = fkTransformer.GetDEArea(detElemId);
930  Float_t dpx = ((AliMpPad*)pads.At(1))->GetDimensionX();
931  Float_t dpy = ((AliMpPad*)pads.At(0))->GetDimensionY();
932  Float_t resolution[2] = { static_cast<Float_t>(0.75*dpx), static_cast<Float_t>(0.75*dpy) };
933  Float_t sign[3] = {0., 1., -1.};
934  for ( Int_t ineighx=0; ineighx<3; ineighx++ ) {
935  for ( Int_t ineighy=0; ineighy<3; ineighy++ ) {
936  AliMpArea pointArea(coor[0]+sign[ineighx]*resolution[0],
937  coor[1]+sign[ineighy]*resolution[1],
940  if ( ! deArea->Contains(pointArea) ) return kTRUE;
941  } // loop on y neighbours
942  } // loop on x neighbours
943  return kFALSE;
944 }
945 
946 
947 //_____________________________________________________________________________
948 Bool_t AliMUONTrackHitPattern::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode, const TVector3& vec11, const TVector3& vec21) const
949 {
950  //
952  //
953 
954  Int_t nMasked = 0;
955 
956  if ( fkTriggerUtilities->IsMasked(pad, detElemId, cathode) ) ++nMasked;
957 
958  // Check closest neighbour
959 
960  TVector3 localCoor;
961  PosInDetElemIdLocal(localCoor, vec11, vec21, detElemId);
962 
963  Float_t padPos[2] = { static_cast<Float_t>(pad.GetPositionX()), static_cast<Float_t>(pad.GetPositionY())};
964  Float_t padDim[2] = { static_cast<Float_t>(pad.GetDimensionX()), static_cast<Float_t>(pad.GetDimensionY())};
965  Float_t inpactPos[2] = { static_cast<Float_t>(localCoor.X()), static_cast<Float_t>(localCoor.Y())};
966  Float_t sign[2] = {-1., 1.};
967  Int_t icoor = 1-cathode;
968  Int_t addSlatSign[3] = {0,1,-1};
969  Int_t inputCh = AliMpDEManager::GetChamberId(detElemId)+1;
970  Int_t inputSlat = detElemId%100;
971 
972  Float_t newPos[2];
973  for ( Int_t ineigh=0; ineigh<2; ineigh++ ) {
974  newPos[1-icoor] = inpactPos[1-icoor];
975  newPos[icoor] = inpactPos[icoor] + 1.05 * sign[ineigh] * padDim[icoor];
976  if ( TMath::Abs(newPos[icoor] - padPos[icoor]) < padDim[icoor] ) continue;
977  const AliMpVSegmentation* seg =
979  AliMpPad neighPad = seg->PadByPosition(newPos[0],newPos[1],kFALSE);
980  if ( neighPad.IsValid() ) {
981  if ( fkTriggerUtilities->IsMasked(neighPad, detElemId, cathode) ) ++nMasked;
982  }
983  else {
984  TVector3 deltaVec(newPos[0]-inpactPos[0],newPos[1]-inpactPos[1],0.);
985  TVector3 transVec11 = vec11+deltaVec;
986  TVector3 transVec21 = vec21+deltaVec;
987  TObjArray padsFromPos;
988  padsFromPos.SetOwner();
989  for ( Int_t iAddSlat=0; iAddSlat<2; iAddSlat++ ) {
990  Int_t currSlat = (inputSlat + addSlatSign[iAddSlat])%18;
991  Int_t currDetElemId = 100 * inputCh + currSlat;
992  PadsFromPos(transVec11,transVec21,currDetElemId,padsFromPos);
993  AliMpPad* currPad = (AliMpPad*)padsFromPos.UncheckedAt(cathode);
994  Bool_t isMasked = ( currPad ) ? fkTriggerUtilities->IsMasked(*currPad, currDetElemId, cathode) : kFALSE;
995  padsFromPos.Delete();
996  if ( isMasked ) ++nMasked;
997  }
998  } // loop on slats
999  } // loop on neigbours
1000 
1001  Double_t maskedProb = ((Double_t)nMasked)/3.;
1002  if ( gRandom->Rndm() < maskedProb ) return kTRUE;
1003 
1004  return kFALSE;
1005 }
1006 
1007 
1008 //_____________________________________________________________________________
1010  const AliMUONTriggerTrack* matchedTrigTrack) const
1011 {
1012  //
1014  //
1015 
1016  AliCodeTimerAuto("",0);
1017 
1018  enum {kBending, kNonBending};
1019 
1020  TArrayF zMeanChamber(AliMUONConstants::NTriggerCh());
1021  zMeanChamber[0] = matchedTrigTrack->GetZ11();
1022  zMeanChamber[1] = matchedTrigTrack->GetZ11() + AliMUONConstants::DefaultChamberZ(11) - AliMUONConstants::DefaultChamberZ(10);
1023  zMeanChamber[2] = matchedTrigTrack->GetZ21();
1024  zMeanChamber[3] = matchedTrigTrack->GetZ21() + AliMUONConstants::DefaultChamberZ(13) - AliMUONConstants::DefaultChamberZ(12);
1025 
1026  TArrayI digitPerTrack(2);
1027  digitPerTrack.Reset();
1028 
1029  Float_t trackIntersectCh[2];
1030 
1031  Float_t slopeX = matchedTrigTrack->GetSlopeX();
1032  Float_t slopeY = matchedTrigTrack->GetSlopeY();
1033 
1034  Float_t z11 = matchedTrigTrack->GetZ11();
1035  Float_t x11 = slopeX * z11;
1036  Float_t y11 = matchedTrigTrack->GetY11();
1037  Float_t z21 = matchedTrigTrack->GetZ21();
1038  Float_t x21 = slopeX * z21;
1039  Float_t y21 = y11 + slopeY * (z21-z11);
1040  TVector3 vec11(x11, y11, z11), vec21(x21, y21, z21);
1041 
1042  Int_t firstSlat = -1, firstBoard = -1;
1043  AliESDMuonTrack::EAliTriggerChPatternFlag goodForEff = AliESDMuonTrack::kBoardEff;
1044  TObjArray matchedPads(2), padsFromPos(2), validPads(2);
1045  matchedPads.SetOwner(); padsFromPos.SetOwner();
1046  Int_t matchedDetElemId[2], detElemIdFromTrack[2];
1047 
1048  for(Int_t ich=0; ich<AliMUONConstants::NTriggerCh(); ich++) { // chamber loop
1049 
1050  // searching track intersection with chambers (first approximation)
1051  Float_t deltaZ = zMeanChamber[ich] - zMeanChamber[0];
1052  trackIntersectCh[0] = zMeanChamber[ich] * slopeX;
1053  trackIntersectCh[1] = y11 + deltaZ * slopeY;
1054  Int_t nFound = DetElemIdFromPos(trackIntersectCh[0], trackIntersectCh[1], 11+ich, detElemIdFromTrack);
1055  if ( nFound == 0 ) {
1056  // track is rejected since the extrapolated track
1057  // does not match a slat (border effects)
1058  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackOutsideGeometry);
1059  goodForEff = AliESDMuonTrack::kNoEff;
1060  AliDebug(10, "Warning: trigger track outside trigger chamber\n");
1061  continue;
1062  }
1063 
1064  matchedDetElemId[0] = matchedDetElemId[1] = detElemIdFromTrack[0];
1065 
1066  if ( ! FindPadMatchingTrig(vec11, vec21, matchedDetElemId, matchedPads) ) {
1067  // if ! FindPadMatchingTrig => too many digits matching pad =>
1068  // => Event not clear => Do not use for efficiency calculation
1069  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackMatchesManyPads);
1070  goodForEff = AliESDMuonTrack::kNoEff;
1071  AliDebug(10, Form("Warning: track = %p (%i) matches many pads. Rejected!\n",(void *)matchedTrigTrack, matchedDetElemId[0]));
1072  }
1073 
1074  Int_t nMatched = 0;
1075 
1076  Int_t mostProbDEmatched = detElemIdFromTrack[0];
1077  for ( Int_t icath=0; icath<2; icath++ ) {
1078  if ( matchedPads.UncheckedAt(icath) ) {
1079  nMatched++;
1080  // Fill pattern anyway
1081  AliESDMuonTrack::SetFiredChamber(pattern, icath, ich);
1082  digitPerTrack[icath]++;
1083  mostProbDEmatched = matchedDetElemId[icath];
1084  }
1085  }
1086  Int_t mostProbDEfromTrack = detElemIdFromTrack[0];
1087  for ( Int_t ifound=0; ifound<nFound; ifound++ ) {
1088  if ( detElemIdFromTrack[ifound] == mostProbDEmatched ) {
1089  mostProbDEfromTrack = mostProbDEmatched;
1090  break;
1091  }
1092  }
1093 
1094  if ( goodForEff == AliESDMuonTrack::kNoEff ) continue;
1095 
1096  if ( nMatched < 2 ) PadsFromPos(vec11, vec21, mostProbDEfromTrack, padsFromPos);
1097 
1098  for ( Int_t cath=0; cath<2; cath++ ) {
1099  if ( matchedPads.UncheckedAt(cath) ) validPads.AddAt(matchedPads.UncheckedAt(cath),cath);
1100  else if ( padsFromPos.UncheckedAt(cath) ) {
1101  AliMpPad* currPad = (AliMpPad*)padsFromPos.UncheckedAt(cath);
1102  validPads.AddAt(currPad,cath);
1103  if ( IsMasked(*currPad, mostProbDEfromTrack, cath, vec11, vec21) ) {
1104  // Check if strip was masked (if inefficient strip is found)
1105  AliESDMuonTrack::AddEffInfo(pattern,AliESDMuonTrack::kTrackMatchesMasks); // pad is masked
1106  AliDebug(10,Form("DetElemId %i cath %i board %i strip %i is masked: effFlag 0", mostProbDEfromTrack, cath, currPad->GetLocalBoardId(0), currPad->GetLocalBoardChannel(0)));
1107  goodForEff = AliESDMuonTrack::kNoEff;
1108  }
1109  }
1110  else goodForEff = AliESDMuonTrack::kNoEff;
1111  } // loop on cathodes
1112 
1113  if ( goodForEff != AliESDMuonTrack::kNoEff ) {
1114 
1115  if ( nMatched == 0 && IsCloseToAccEdge(padsFromPos, mostProbDEfromTrack, trackIntersectCh) ) {
1116  // Non of cathodes is fired.
1117  // If we are close to the edge of the RPC
1118  // it could be a problem of acceptance
1119  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackOutsideGeometry);
1120  goodForEff = AliESDMuonTrack::kNoEff;
1121  AliDebug(10, "Warning: trigger track at the edge of the chamber\n");
1122  }
1123 
1124  Int_t currSlat = mostProbDEmatched%100;
1125  if ( firstSlat < 0 ) firstSlat = currSlat;
1126  else if ( currSlat != firstSlat ) {
1127  goodForEff = AliESDMuonTrack::kChEff;
1128  firstSlat = AliESDMuonTrack::kCrossDifferentSlats;
1129  }
1130 
1131  if ( firstBoard < 0 ) firstBoard = ((AliMpPad*)validPads[kBending])->GetLocalBoardId(0);
1132 
1133  for ( Int_t cath=0; cath<2; cath++ ){
1134 
1135  if ( goodForEff == AliESDMuonTrack::kBoardEff) {
1136  Bool_t atLeastOneLoc = kFALSE;
1137  AliMpPad* currPad = (AliMpPad*)validPads.UncheckedAt(cath);
1138  for ( Int_t iloc=0; iloc<currPad->GetNofLocations(); iloc++) {
1139  if ( currPad->GetLocalBoardId(iloc) == firstBoard ) {
1140  atLeastOneLoc = kTRUE;
1141  break;
1142  }
1143  } // loop on locations
1144  if ( ! atLeastOneLoc ) goodForEff = AliESDMuonTrack::kSlatEff;
1145  }
1146  } // loop on cathodes
1147  } // if track good for efficiency
1148  matchedPads.Delete();
1149  padsFromPos.Delete();
1150  } // end chamber loop
1151 
1152  if ( goodForEff == AliESDMuonTrack::kNoEff ) return kFALSE;
1153 
1154  for(Int_t cath=0; cath<2; cath++){
1155  if(digitPerTrack[cath]<3) {
1156  // track is rejected since the number of associated
1157  // digits found is less than 3.
1158  AliESDMuonTrack::AddEffInfo(pattern, AliESDMuonTrack::kTrackMatchesFewPads);
1159  goodForEff = AliESDMuonTrack::kNoEff;
1160  AliDebug(10, Form("Warning: found %i digits for trigger track cathode %i.\nRejecting event\n", digitPerTrack[cath],cath));
1161  }
1162  } // loop on cathodes
1163 
1164  if ( goodForEff == AliESDMuonTrack::kNoEff ) return kFALSE;
1165 
1166  AliESDMuonTrack::AddEffInfo(pattern, firstSlat, firstBoard, goodForEff);
1167  return kTRUE;
1168 }
Int_t GetNofLocations() const
Definition: AliMpPad.cxx:325
Bool_t FindMatchingPads(const AliMUONTrackParam *trackParam, TArrayI &matchedDetElemId, TObjArray &pads, const AliMUONVDigitStore &digitStore, Bool_t isTriggerTrack) const
Bool_t IsCloseToAccEdge(TObjArray &pads, Int_t detElemId, Float_t coor[2]) const
Base class of a track container.
Int_t DetElemIdFromPos(Float_t x, Float_t y, Int_t chamber, Int_t foundDetElemId[2]) const
UShort_t GetHitsPatternInTrigCh() const
Get word telling which trigger chambers where hit by track.
The iterator over detection elements.
AliMUONVDigitStore * GetMaskedDigits() const
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
Bool_t FindPadMatchingTrig(const TVector3 &vec11, const TVector3 &vec21, Int_t matchedDetElemId[2], TObjArray &matchedPads) const
Interface for a digit container.
virtual TIterator * CreateIterator() const =0
Iterator to loop over tracks.
void ApplyMCSCorrections(AliMUONTrackParam &trackParam) const
AliMpArea * GetDEArea(Int_t detElemId) const
static AliMpSegmentation * Instance(Bool_t warn=true)
#define TObjArray
const TMatrixD & GetCovariances() const
static Int_t NTrackingCh()
Return number of tracking chambers.
Float_t PadMatchTrack(const AliMpPad &pad, const TVector3 &trackPosAtPad) const
Double_t GetBendingCoor() const
return bending coordinate (cm)
virtual TIterator * CreateIterator() const =0
Create an iterator to loop over tracks.
Top container class for geometry transformations.
Int_t GetLoTrgNum() const
Return local trigger number.
Bool_t IsDone() const
Bool_t CovariancesExist() const
return kTRUE if the covariance matrix exist, kFALSE if not
Int_t GetTrackParamAtChamber(const AliMUONTrackParam &inputTrackParam, Int_t chamber, TObjArray &trackParamList, TArrayI &foundDetElemId, TObjArray &padsFromPos) const
Double_t GetZ() const
return Z coordinate (cm)
Int_t LoLpt() const
Return Low pt.
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
Track parameters in ALICE dimuon spectrometer.
const AliMUONVDigitStore & fkDigitStore
! digitStore
Int_t CurrentDEId() const
Class with MUON reconstruction parameters.
AliTPCfastTrack * track
void SetNonBendingCoor(Double_t nonBendingCoor)
set non bending coordinate (cm)
Reconstructed trigger track in ALICE dimuon spectrometer.
Bool_t PosInDetElemIdLocal(TVector3 &localCoor, const TVector3 &globalPoint1, const TVector3 &globalPoint2, Int_t detElemId) const
Utilities for trigger (check if pad is masked)
Float_t MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad, Float_t dpx, Float_t dpy, const AliMUONTrackParam &trackParam) const
Double_t GetStripCutForTrigger() const
return the cut in strips to apply on trigger track during trigger chamber efficiency ...
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
Int_t LoHpt() const
Return High p.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
Int_t LoStripY() const
Return Y strip in MT11.
Float_t GetX11() const
Return x position of fired Y strip in MC11.
Base class of a trigger information store.
const AliMUONGeometryTransformer & fkTransformer
! geometry transformer
static Double_t MuonFilterX0()
Return radiation length (in cm) of muon filter.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static Double_t LengthTolerance()
Return the length precision for tests.
Float_t GetSlopeY() const
Return track slope in Y.
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
Double_t GetBendingSlope() const
return bending slope (cm ** -1)
Int_t LoStripX() const
Return X strip in MT11.
void Local2Global(Int_t detElemId, Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
Double_t GetMaxNormChi2MatchTrigger() const
return the maximum normalized chi2 of tracking/trigger track matching
void SetBendingSlope(Double_t bendingSlope)
set bending slope (cm ** -1)
Double_t chi2
Definition: AnalyzeLaser.C:7
Double_t GetMaxStripAreaForTrigger() const
return the maximum search area in strips to apply on trigger track during trigger chamber efficiency ...
static Bool_t ExtrapToZCov(AliMUONTrackParam *trackParam, Double_t zEnd, Bool_t updatePropagator=kFALSE)
static Double_t MuonFilterZEnd()
Return z-position of muon filter end.
Reconstructed Local Trigger object.
static void LinearExtrapToZCov(AliMUONTrackParam *trackParam, Double_t zEnd, Bool_t updatePropagator=kFALSE)
static void LinearExtrapToZ(AliMUONTrackParam *trackParam, Double_t zEnd)
Class for the MUON track hit pattern.
virtual TIterator * CreateTriggerIterator() const =0
Create an iterator to loop over trigger digits only.
void FindPadMatchingTrack(const AliMUONTrackParam &trackParam, Bool_t isMatch[2], Int_t iChamber) const
Bool_t IsMasked(const AliMUONVDigit &digit) const
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
static Double_t MuonFilterZBeg()
Return z-position of muon filter begining.
void SetLocalTrigger(Int_t loCirc, Int_t loStripX, Int_t loStripY, Int_t loDev, Int_t loLpt, Int_t loHpt, UChar_t respWithoutChamber=0)
set local trigger information for the matched trigger track
static void AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0)
Float_t GetY11() const
Return y position of fired X strip in MC11.
Double_t P() const
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
static Int_t NTriggerCh()
Return number of trigger chambers.
void SetNonBendingSlope(Double_t nonBendingSlope)
set non bending slope (cm ** -1)
Base class of a trigger track store.
AliMUONTriggerTrack * MatchTriggerTrack(AliMUONTrack *track, AliMUONTrackParam &trackParam, const AliMUONVTriggerTrackStore &triggerTrackStore, const AliMUONVTriggerStore &triggerStore) const
const AliMUONTriggerUtilities * fkTriggerUtilities
! trigger utilities for mapping
Bool_t PadsFromPos(const TVector3 &vec11, const TVector3 &vec21, Int_t detElemId, TObjArray &pads) const
void SetMatchTrigger(Int_t matchTrigger)
set the flag telling whether track matches with trigger track or not
Definition: AliMUONTrack.h:83
UInt_t GetHitPattern(const AliMUONTrackParam &trackParam, Bool_t isTriggerTrack) const
Int_t GetLocalBoardId(Int_t i) const
Definition: AliMpPad.cxx:347
Float_t GetZ21() const
Return z position of fired X strip in MC21.
const Float_t fkMaxDistance
! Maximum distance for reference // obsolete
void ExecuteValidation(const AliMUONVTrackStore &trackStore, const AliMUONVTriggerTrackStore &triggerTrackStore, const AliMUONVTriggerStore &triggerStore) const
Float_t GetZ11() const
Return z position of fired X strip in MC11.
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
void SetInverseBendingMomentum(Double_t inverseBendingMomentum)
set inverse bending momentum (GeV/c ** -1) times the charge (assumed forward motion) ...
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
void Global2Local(Int_t detElemId, Float_t xg, Float_t yg, Float_t zg, Float_t &xl, Float_t &yl, Float_t &zl) const
Double_t GetSigmaCutForTrigger() const
return the cut in sigma to apply on track during trigger hit pattern search
void SetBendingCoor(Double_t bendingCoor)
set bending coordinate (cm)
The abstract base class for the segmentation.
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
static Float_t * DefaultChamberZ()
Return pointer to array of positions.
Bool_t PerformTrigTrackMatch(UInt_t &pattern, const AliMUONTriggerTrack *matchedTrigTrack) const
UChar_t GetTriggerWithoutChamber() const
Triggers from the re-calculated trigger response after removing chambers one-by-one.
Double_t GetNonBendingCoor() const
return non bending coordinate (cm)
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
Reconstructed track in ALICE dimuon spectrometer.
Definition: AliMUONTrack.h:24
Bool_t Contains(const AliMpArea &area) const
Definition: AliMpArea.cxx:193
const AliMUONRecoParam * GetRecoParam() const
Return reco parameters.
Bool_t IsMasked(const AliMpPad &pad, Int_t detElemId, Int_t cathode, const TVector3 &vec11, const TVector3 &vec21) const
void SetZ(Double_t z)
set Z coordinate (cm)
Int_t GetLocalBoardChannel(Int_t i) const
Definition: AliMpPad.cxx:358
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
const TMatrixD & GetCovariances() const
virtual AliMUONLocalTrigger * FindLocal(Int_t boardNumber) const =0
Find a local trigger by the board number (not an index, it is a number really)
Int_t LoCircuit() const
Return Circuit number.
void SetChi2MatchTrigger(Double_t chi2MatchTrigger)
set the chi2 of trigger/track matching
Definition: AliMUONTrack.h:87
void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh)
Set word telling which trigger chambers where hit by track.
Float_t GetSlopeX() const
Return track slope in X.