1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 ////////////////////////////////////
21 /// \class AliMUONTrackHitPattern
23 /// This class propagates tracks to trigger chambers
24 /// searching for fired strips.
26 /// To each track, a hit pattern for trigger chambers is set.
27 /// The hit pattern is a UShort_t with 8 bits used:
31 /// ----------- ------------
32 /// chamber: 11 12 13 14 | 11 12 13 14
33 /// cathode: bending | non-bending
35 /// The main method is:
38 /// \author Diego Stocco
40 ////////////////////////////////////
43 #include "AliMUONTrackHitPattern.h"
45 #include "AliMUONConstants.h"
46 #include "AliMUONVDigit.h"
47 #include "AliMUONDigitMaker.h"
48 #include "AliMUONDigitStoreV1.h"
49 #include "AliMUONGeometryTransformer.h"
50 #include "AliMUONLocalTrigger.h"
51 #include "AliMUONLocalTriggerBoard.h"
52 #include "AliMUONTrack.h"
53 #include "AliMUONTrackExtrap.h"
54 #include "AliMUONTrackParam.h"
55 #include "AliMUONVTrackStore.h"
56 #include "AliMUONVTriggerStore.h"
58 #include "AliMpSegmentation.h"
59 #include "AliMpVSegmentation.h"
63 #include "AliTracker.h"
65 #include <Riostream.h>
67 #include <TClonesArray.h>
72 ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context
76 //______________________________________________________________________________
77 AliMUONTrackHitPattern::AliMUONTrackHitPattern(const AliMUONGeometryTransformer& transformer,
78 const AliMUONDigitMaker& digitMaker)
80 fTransformer(transformer),
81 fDigitMaker(digitMaker)
83 /// Default constructor
86 const AliMagF* kField = AliTracker::GetFieldMap();
87 if (!kField) AliFatal("No field available");
88 AliMUONTrackExtrap::SetField(kField);
92 //______________________________________________________________________________
93 AliMUONTrackHitPattern::~AliMUONTrackHitPattern(void)
99 //______________________________________________________________________________
100 void AliMUONTrackHitPattern::GetHitPattern(AliMUONVTrackStore& trackStore,
101 const AliMUONVTriggerStore& triggerStore) const
105 /// Loops on reco tracks, extrapolates them to trigger chambers
106 /// and searches for matching digits
109 const Int_t kMask[2][4]= {{0x80, 0x40, 0x20, 0x10},
110 {0x08, 0x04, 0x02, 0x01}};
115 AliMUONDigitStoreV1 digitStore;
117 TriggerDigits(triggerStore,digitStore);
119 AliMUONTrack* muonTrack;
120 TIter next(trackStore.CreateIterator());
122 while ( ( muonTrack = static_cast<AliMUONTrack*>(next()) ) )
125 AliMUONTrackParam *trackParam = static_cast<AliMUONTrackParam*>
126 (muonTrack->GetTrackParamAtHit()->Last());
128 for(Int_t ch=0; ch<4; ++ch)
130 AliMUONTrackExtrap::ExtrapToZCov(trackParam, AliMUONConstants::DefaultChamberZ(10+ch));
131 FindPadMatchingTrack(digitStore,*trackParam, isMatch, ch);
132 for(Int_t cath=0; cath<2; ++cath)
134 if(isMatch[cath]) pattern |= kMask[cath][ch];
137 muonTrack->SetHitsPatternInTrigCh(pattern);
142 //______________________________________________________________________________
144 AliMUONTrackHitPattern::FindPadMatchingTrack(AliMUONVDigitStore& digitStore,
145 const AliMUONTrackParam& trackParam,
146 Bool_t isMatch[2], Int_t /*iChamber*/) const
149 /// Given track position, searches for matching digits.
152 Float_t minMatchDist[2];
154 for(Int_t cath=0; cath<2; ++cath)
156 isMatch[cath]=kFALSE;
157 minMatchDist[cath]=9999.;
160 TIter next(digitStore.CreateIterator());
161 AliMUONVDigit* mDigit;
163 while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
165 Int_t currDetElemId = mDigit->DetElemId();
166 Int_t cathode = mDigit->Cathode();
167 Int_t ix = mDigit->PadX();
168 Int_t iy = mDigit->PadY();
169 Float_t xpad, ypad, zpad;
170 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()
171 ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
173 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
174 Float_t xlocal1 = pad.Position().X();
175 Float_t ylocal1 = pad.Position().Y();
176 Float_t dpx = pad.Dimensions().X();
177 Float_t dpy = pad.Dimensions().Y();
178 fTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad);
179 Float_t matchDist = MinDistanceFromPad(xpad, ypad, zpad, dpx, dpy, trackParam);
180 if(matchDist>minMatchDist[cathode])continue;
181 isMatch[cathode] = kTRUE;
182 minMatchDist[cathode] = matchDist;
187 //______________________________________________________________________________
189 AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad,
190 Float_t dpx, Float_t dpy,
191 const AliMUONTrackParam& trackParam) const
194 /// Decides if the digit belongs to the track.
196 Float_t xTrackAtPad = trackParam.GetNonBendingCoor();
197 Float_t yTrackAtPad = trackParam.GetBendingCoor();
199 Float_t sigmaX, sigmaY, sigmaMS;
200 GetPosUncertainty(trackParam, zPad, sigmaX, sigmaY, sigmaMS);
202 Float_t maxDistX = 3.*(sigmaX + sigmaMS); // in cm
203 Float_t maxDistY = 3.*(sigmaY + sigmaMS); // in cm
205 Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx;
206 Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy;
208 Float_t matchDist = 99999.;
209 if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
214 //______________________________________________________________________________
216 AliMUONTrackHitPattern::GetPosUncertainty(const AliMUONTrackParam& trackParam,
218 Float_t &sigmaX, Float_t &sigmaY,
219 Float_t &sigmaMS) const
222 /// Returns uncertainties on extrapolated position.
223 /// Takes into account Branson plane corrections in the iron wall.
226 const Float_t kAlpha = 0.1123; // GeV/c
228 // Find a better way to get such parameters ???
229 const Float_t kZFilterIn = 1471.; // From STRUCT/SHILConst2.h
230 const Float_t kZFilterOut = kZFilterIn + 120.; // From STRUCT/SHILConst2.h
232 const Float_t kZBranson = - (kZFilterIn + (kZFilterOut - kZFilterIn)*2./3. ); // - sign because distance are positive
233 Float_t zDistFromWall = TMath::Abs(zChamber - kZBranson);
234 Float_t zDistFromLastTrackCh = TMath::Abs(zChamber - AliMUONConstants::DefaultChamberZ(9));
236 const TMatrixD& kCovParam = trackParam.GetCovariances();
238 sigmaX = kCovParam(0,0);
239 sigmaY = kCovParam(2,2);
241 // If covariance matrix is not extrapolated, use "reasonable" errors
242 // (To be removed as soon as covariance matrix is correctly propagated).
243 if (sigmaX==0.)sigmaX = 0.003 * zDistFromLastTrackCh;
244 if (sigmaY==0.)sigmaY = 0.004 * zDistFromLastTrackCh;
246 Float_t p = trackParam.P();
247 Float_t thetaMS = kAlpha/p;
248 sigmaMS = zDistFromWall * TMath::Tan(thetaMS);
252 //______________________________________________________________________________
254 AliMUONTrackHitPattern::TriggerDigits(const AliMUONVTriggerStore& triggerStore,
255 AliMUONVDigitStore& digitStore) const
258 /// make (S)Digit for trigger
263 AliMUONLocalTrigger* locTrg;
264 TIter next(triggerStore.CreateLocalIterator());
266 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
268 if (locTrg->IsNull()) continue;
270 TArrayS xyPattern[2];
271 locTrg->GetXPattern(xyPattern[0]);
272 locTrg->GetYPattern(xyPattern[1]);
274 // do we need this ? (Ch.F.)
275 // for(Int_t cath=0; cath<2; ++cath)
277 // for(Int_t ch=0; ch<4; ++ch)
279 // if(xyPattern[cath][ch]==0) continue;
283 Int_t nBoard = locTrg->LoCircuit();
284 fDigitMaker.TriggerDigits(nBoard, xyPattern, digitStore);