- Adding comment lines to class description needed for Root documentation
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackHitPattern.cxx
CommitLineData
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
7771752e 19////////////////////////////////////
20///
21/// \class AliMUONTrackHitPattern
22///
23/// This class propagates tracks to trigger chambers
24/// searching for fired strips.
25///
26/// To each track, a hit pattern for trigger chambers is set.
27/// The hit pattern is a UShort_t with 8 bits used:
28///
29/// 1 1 0 1 1 1 0 1
30/// | | |
31/// ----------- ------------
32/// chamber: 11 12 13 14 | 11 12 13 14
33/// cathode: bending | non-bending
34///
35/// The main method is:
36/// * GetHitPattern
37///
38/// \author Diego Stocco
39///
40////////////////////////////////////
41
42
43#include "AliMUONTrackHitPattern.h"
7ec3b9cf 44
7771752e 45#include "AliMUONConstants.h"
7ec3b9cf 46#include "AliMUONVDigit.h"
47#include "AliMUONDigitMaker.h"
48#include "AliMUONDigitStoreV1.h"
7771752e 49#include "AliMUONGeometryTransformer.h"
7771752e 50#include "AliMUONLocalTrigger.h"
7771752e 51#include "AliMUONLocalTriggerBoard.h"
7ec3b9cf 52#include "AliMUONTrack.h"
53#include "AliMUONTrackExtrap.h"
54#include "AliMUONTrackParam.h"
55#include "AliMUONVTrackStore.h"
56#include "AliMUONVTriggerStore.h"
7771752e 57#include "AliMpPad.h"
7771752e 58#include "AliMpSegmentation.h"
7ec3b9cf 59#include "AliMpVSegmentation.h"
ea94c18b 60
61#include "AliMagF.h"
62#include "AliLog.h"
7771752e 63#include "AliTracker.h"
ea94c18b 64
7771752e 65#include <Riostream.h>
7ec3b9cf 66#include <TArrayS.h>
7771752e 67#include <TClonesArray.h>
68#include <TMath.h>
69#include <TMatrixD.h>
7771752e 70
71/// \cond CLASSIMP
72ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context
73/// \endcond
74
75
76//______________________________________________________________________________
7ec3b9cf 77AliMUONTrackHitPattern::AliMUONTrackHitPattern(const AliMUONGeometryTransformer& transformer,
78 const AliMUONDigitMaker& digitMaker)
7771752e 79 : TObject(),
7ec3b9cf 80 fTransformer(transformer),
81 fDigitMaker(digitMaker)
7771752e 82{
83 /// Default constructor
84
85 // Set magnetic field
86 const AliMagF* kField = AliTracker::GetFieldMap();
87 if (!kField) AliFatal("No field available");
88 AliMUONTrackExtrap::SetField(kField);
7771752e 89}
90
91
92//______________________________________________________________________________
93AliMUONTrackHitPattern::~AliMUONTrackHitPattern(void)
94{
7ec3b9cf 95 /// Destructor
7771752e 96}
97
98
99//______________________________________________________________________________
7ec3b9cf 100void AliMUONTrackHitPattern::GetHitPattern(AliMUONVTrackStore& trackStore,
101 const AliMUONVTriggerStore& triggerStore) const
7771752e 102{
103 //
104 /// Main method:
105 /// Loops on reco tracks, extrapolates them to trigger chambers
106 /// and searches for matching digits
107 //
108
7ec3b9cf 109 const Int_t kMask[2][4]= {{0x80, 0x40, 0x20, 0x10},
110 {0x08, 0x04, 0x02, 0x01}};
7771752e 111 Bool_t isMatch[2];
7ec3b9cf 112
7771752e 113 UShort_t pattern=0;
7ec3b9cf 114
115 AliMUONDigitStoreV1 digitStore;
116
117 TriggerDigits(triggerStore,digitStore);
118
119 AliMUONTrack* muonTrack;
120 TIter next(trackStore.CreateIterator());
121
122 while ( ( muonTrack = static_cast<AliMUONTrack*>(next()) ) )
123 {
124 pattern = 0;
125 AliMUONTrackParam *trackParam = static_cast<AliMUONTrackParam*>
126 (muonTrack->GetTrackParamAtHit()->Last());
127
128 for(Int_t ch=0; ch<4; ++ch)
129 {
130 AliMUONTrackExtrap::ExtrapToZCov(trackParam, AliMUONConstants::DefaultChamberZ(10+ch));
131 FindPadMatchingTrack(digitStore,*trackParam, isMatch, ch);
132 for(Int_t cath=0; cath<2; ++cath)
133 {
134 if(isMatch[cath]) pattern |= kMask[cath][ch];
7771752e 135 }
7ec3b9cf 136 }
137 muonTrack->SetHitsPatternInTrigCh(pattern);
7771752e 138 }
7771752e 139}
140
141
142//______________________________________________________________________________
7ec3b9cf 143void
144AliMUONTrackHitPattern::FindPadMatchingTrack(AliMUONVDigitStore& digitStore,
145 const AliMUONTrackParam& trackParam,
146 Bool_t isMatch[2], Int_t /*iChamber*/) const
7771752e 147{
148 //
149 /// Given track position, searches for matching digits.
150 //
151
152 Float_t minMatchDist[2];
153
7ec3b9cf 154 for(Int_t cath=0; cath<2; ++cath)
155 {
156 isMatch[cath]=kFALSE;
157 minMatchDist[cath]=9999.;
7771752e 158 }
159
7ec3b9cf 160 TIter next(digitStore.CreateIterator());
161 AliMUONVDigit* mDigit;
162
163 while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
164 {
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));
172
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;
7771752e 183 }
7771752e 184}
185
186
187//______________________________________________________________________________
7ec3b9cf 188Float_t
189AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad,
190 Float_t dpx, Float_t dpy,
191 const AliMUONTrackParam& trackParam) const
7771752e 192{
193 //
194 /// Decides if the digit belongs to the track.
195 //
7ec3b9cf 196 Float_t xTrackAtPad = trackParam.GetNonBendingCoor();
197 Float_t yTrackAtPad = trackParam.GetBendingCoor();
7771752e 198
199 Float_t sigmaX, sigmaY, sigmaMS;
200 GetPosUncertainty(trackParam, zPad, sigmaX, sigmaY, sigmaMS);
201
202 Float_t maxDistX = 3.*(sigmaX + sigmaMS); // in cm
203 Float_t maxDistY = 3.*(sigmaY + sigmaMS); // in cm
204
205 Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx;
206 Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy;
207
208 Float_t matchDist = 99999.;
209 if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
210 return matchDist;
211}
212
213
214//______________________________________________________________________________
7ec3b9cf 215void
216AliMUONTrackHitPattern::GetPosUncertainty(const AliMUONTrackParam& trackParam,
217 Float_t zChamber,
218 Float_t &sigmaX, Float_t &sigmaY,
219 Float_t &sigmaMS) const
7771752e 220{
221 //
222 /// Returns uncertainties on extrapolated position.
223 /// Takes into account Branson plane corrections in the iron wall.
224 //
225
7dc68cf4 226 const Float_t kAlpha = 0.1123; // GeV/c
7771752e 227
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
231
7dc68cf4 232 const Float_t kZBranson = - (kZFilterIn + (kZFilterOut - kZFilterIn)*2./3. ); // - sign because distance are positive
233 Float_t zDistFromWall = TMath::Abs(zChamber - kZBranson);
7771752e 234 Float_t zDistFromLastTrackCh = TMath::Abs(zChamber - AliMUONConstants::DefaultChamberZ(9));
235
ea94c18b 236 const TMatrixD& kCovParam = trackParam.GetCovariances();
7771752e 237
ea94c18b 238 sigmaX = kCovParam(0,0);
239 sigmaY = kCovParam(2,2);
7771752e 240
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;
245
7ec3b9cf 246 Float_t p = trackParam.P();
7dc68cf4 247 Float_t thetaMS = kAlpha/p;
7771752e 248 sigmaMS = zDistFromWall * TMath::Tan(thetaMS);
7771752e 249}
250
251
7ec3b9cf 252//______________________________________________________________________________
253Bool_t
254AliMUONTrackHitPattern::TriggerDigits(const AliMUONVTriggerStore& triggerStore,
255 AliMUONVDigitStore& digitStore) const
7771752e 256{
7ec3b9cf 257 //
258 /// make (S)Digit for trigger
259 //
260
261 digitStore.Clear();
262
263 AliMUONLocalTrigger* locTrg;
264 TIter next(triggerStore.CreateLocalIterator());
265
266 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
267 {
24754ef8 268 if (locTrg->IsNull()) continue;
269
7ec3b9cf 270 TArrayS xyPattern[2];
24754ef8 271 locTrg->GetXPattern(xyPattern[0]);
272 locTrg->GetYPattern(xyPattern[1]);
273
274 // do we need this ? (Ch.F.)
275// for(Int_t cath=0; cath<2; ++cath)
276// {
277// for(Int_t ch=0; ch<4; ++ch)
278// {
279// if(xyPattern[cath][ch]==0) continue;
280// }
281// }
7ec3b9cf 282
283 Int_t nBoard = locTrg->LoCircuit();
284 fDigitMaker.TriggerDigits(nBoard, xyPattern, digitStore);
285 }
286 return kTRUE;
7771752e 287}