Run0_9999999_v0_s1.root
[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
3d1463c8 19//-----------------------------------------------------------------------------
7771752e 20/// \class AliMUONTrackHitPattern
21///
22/// This class propagates tracks to trigger chambers
23/// searching for fired strips.
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:
35/// * GetHitPattern
36///
37/// \author Diego Stocco
3d1463c8 38//-----------------------------------------------------------------------------
7771752e 39
40
41#include "AliMUONTrackHitPattern.h"
7ec3b9cf 42
7771752e 43#include "AliMUONConstants.h"
7ec3b9cf 44#include "AliMUONVDigit.h"
45#include "AliMUONDigitMaker.h"
46#include "AliMUONDigitStoreV1.h"
7771752e 47#include "AliMUONGeometryTransformer.h"
7771752e 48#include "AliMUONLocalTrigger.h"
7771752e 49#include "AliMUONLocalTriggerBoard.h"
7ec3b9cf 50#include "AliMUONTrack.h"
51#include "AliMUONTrackExtrap.h"
52#include "AliMUONTrackParam.h"
53#include "AliMUONVTrackStore.h"
54#include "AliMUONVTriggerStore.h"
7771752e 55#include "AliMpPad.h"
7771752e 56#include "AliMpSegmentation.h"
7ec3b9cf 57#include "AliMpVSegmentation.h"
fda59e58 58#include "AliMpDEManager.h"
59#include "AliMUONReconstructor.h"
60#include "AliMUONRecoParam.h"
ea94c18b 61
62#include "AliMagF.h"
63#include "AliLog.h"
7771752e 64#include "AliTracker.h"
ea94c18b 65
7771752e 66#include <Riostream.h>
7ec3b9cf 67#include <TArrayS.h>
7771752e 68#include <TClonesArray.h>
69#include <TMath.h>
70#include <TMatrixD.h>
7771752e 71
72/// \cond CLASSIMP
73ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context
74/// \endcond
75
76
77//______________________________________________________________________________
7ec3b9cf 78AliMUONTrackHitPattern::AliMUONTrackHitPattern(const AliMUONGeometryTransformer& transformer,
79 const AliMUONDigitMaker& digitMaker)
7771752e 80 : TObject(),
7ec3b9cf 81 fTransformer(transformer),
82 fDigitMaker(digitMaker)
7771752e 83{
84 /// Default constructor
85
86 // Set magnetic field
87 const AliMagF* kField = AliTracker::GetFieldMap();
88 if (!kField) AliFatal("No field available");
89 AliMUONTrackExtrap::SetField(kField);
7771752e 90}
91
92
93//______________________________________________________________________________
94AliMUONTrackHitPattern::~AliMUONTrackHitPattern(void)
95{
7ec3b9cf 96 /// Destructor
7771752e 97}
98
99
100//______________________________________________________________________________
7ec3b9cf 101void AliMUONTrackHitPattern::GetHitPattern(AliMUONVTrackStore& trackStore,
102 const AliMUONVTriggerStore& triggerStore) const
7771752e 103{
104 //
105 /// Main method:
106 /// Loops on reco tracks, extrapolates them to trigger chambers
107 /// and searches for matching digits
108 //
fda59e58 109
7ec3b9cf 110 const Int_t kMask[2][4]= {{0x80, 0x40, 0x20, 0x10},
111 {0x08, 0x04, 0x02, 0x01}};
7771752e 112 Bool_t isMatch[2];
7ec3b9cf 113
7771752e 114 UShort_t pattern=0;
7ec3b9cf 115
116 AliMUONDigitStoreV1 digitStore;
117
118 TriggerDigits(triggerStore,digitStore);
119
120 AliMUONTrack* muonTrack;
121 TIter next(trackStore.CreateIterator());
fda59e58 122
123 const Int_t kNTrackingCh = AliMUONConstants::NTrackingCh();
124
7ec3b9cf 125 while ( ( muonTrack = static_cast<AliMUONTrack*>(next()) ) )
126 {
127 pattern = 0;
fda59e58 128 AliMUONTrackParam trackParam(*((AliMUONTrackParam*) (muonTrack->GetTrackParamAtCluster()->Last())));
129
130 ApplyMCSCorrections(trackParam);
131
7ec3b9cf 132 for(Int_t ch=0; ch<4; ++ch)
133 {
fda59e58 134 Int_t iChamber = kNTrackingCh+ch;
135 AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(iChamber));
136 FindPadMatchingTrack(digitStore, trackParam, isMatch, iChamber);
7ec3b9cf 137 for(Int_t cath=0; cath<2; ++cath)
138 {
139 if(isMatch[cath]) pattern |= kMask[cath][ch];
fda59e58 140 }
7ec3b9cf 141 }
142 muonTrack->SetHitsPatternInTrigCh(pattern);
7771752e 143 }
7771752e 144}
145
146
147//______________________________________________________________________________
7ec3b9cf 148void
149AliMUONTrackHitPattern::FindPadMatchingTrack(AliMUONVDigitStore& digitStore,
150 const AliMUONTrackParam& trackParam,
fda59e58 151 Bool_t isMatch[2], Int_t iChamber) const
7771752e 152{
153 //
154 /// Given track position, searches for matching digits.
155 //
156
157 Float_t minMatchDist[2];
158
7ec3b9cf 159 for(Int_t cath=0; cath<2; ++cath)
160 {
161 isMatch[cath]=kFALSE;
162 minMatchDist[cath]=9999.;
7771752e 163 }
164
7ec3b9cf 165 TIter next(digitStore.CreateIterator());
166 AliMUONVDigit* mDigit;
fda59e58 167
7ec3b9cf 168 while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
169 {
170 Int_t currDetElemId = mDigit->DetElemId();
fda59e58 171 Int_t currCh = AliMpDEManager::GetChamberId(currDetElemId);
172 if(currCh!=iChamber) continue;
7ec3b9cf 173 Int_t cathode = mDigit->Cathode();
174 Int_t ix = mDigit->PadX();
175 Int_t iy = mDigit->PadY();
176 Float_t xpad, ypad, zpad;
177 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()
178 ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
179
180 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
181 Float_t xlocal1 = pad.Position().X();
182 Float_t ylocal1 = pad.Position().Y();
183 Float_t dpx = pad.Dimensions().X();
184 Float_t dpy = pad.Dimensions().Y();
185 fTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad);
186 Float_t matchDist = MinDistanceFromPad(xpad, ypad, zpad, dpx, dpy, trackParam);
187 if(matchDist>minMatchDist[cathode])continue;
188 isMatch[cathode] = kTRUE;
fda59e58 189 if(isMatch[0] && isMatch[1]) break;
7ec3b9cf 190 minMatchDist[cathode] = matchDist;
7771752e 191 }
7771752e 192}
193
194
195//______________________________________________________________________________
7ec3b9cf 196Float_t
197AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad,
198 Float_t dpx, Float_t dpy,
199 const AliMUONTrackParam& trackParam) const
7771752e 200{
201 //
202 /// Decides if the digit belongs to the track.
203 //
7771752e 204
fda59e58 205 AliMUONTrackParam trackParamAtPadZ(trackParam);
206 AliMUONTrackExtrap::ExtrapToZCov(&trackParamAtPadZ, zPad);
207
208 Float_t xTrackAtPad = trackParamAtPadZ.GetNonBendingCoor();
209 Float_t yTrackAtPad = trackParamAtPadZ.GetBendingCoor();
7771752e 210
fda59e58 211 const Float_t kNSigma = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTrigger();
212
213 const TMatrixD& kCovParam = trackParamAtPadZ.GetCovariances();
214
215 Float_t sigmaX = TMath::Sqrt(kCovParam(0,0));
216 Float_t sigmaY = TMath::Sqrt(kCovParam(2,2));
217
218 Float_t maxDistX = kNSigma * sigmaX; // in cm
219 Float_t maxDistY = kNSigma * sigmaY; // in cm
7771752e 220
221 Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx;
222 Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy;
223
224 Float_t matchDist = 99999.;
225 if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
fda59e58 226
7771752e 227 return matchDist;
228}
229
230
231//______________________________________________________________________________
7ec3b9cf 232void
fda59e58 233AliMUONTrackHitPattern::ApplyMCSCorrections(AliMUONTrackParam& trackParam) const
7771752e 234{
fda59e58 235 //
236 /// Returns uncertainties on extrapolated position.
237 /// Takes into account Branson plane corrections in the iron wall.
238 //
7771752e 239
fda59e58 240 const Float_t kZFilterOut = AliMUONConstants::MuonFilterZEnd();
241 const Float_t kFilterThickness = TMath::Abs(kZFilterOut-AliMUONConstants::MuonFilterZBeg()); // cm
7771752e 242
fda59e58 243 AliMUONTrackExtrap::ExtrapToZCov(&trackParam, kZFilterOut);
244 AliMUONTrackExtrap::AddMCSEffect(&trackParam, kFilterThickness, AliMUONConstants::MuonFilterX0());
245 return;
7771752e 246}
247
248
7ec3b9cf 249//______________________________________________________________________________
250Bool_t
251AliMUONTrackHitPattern::TriggerDigits(const AliMUONVTriggerStore& triggerStore,
252 AliMUONVDigitStore& digitStore) const
7771752e 253{
7ec3b9cf 254 //
255 /// make (S)Digit for trigger
256 //
257
258 digitStore.Clear();
259
260 AliMUONLocalTrigger* locTrg;
261 TIter next(triggerStore.CreateLocalIterator());
262
263 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
264 {
24754ef8 265 if (locTrg->IsNull()) continue;
266
7ec3b9cf 267 TArrayS xyPattern[2];
24754ef8 268 locTrg->GetXPattern(xyPattern[0]);
269 locTrg->GetYPattern(xyPattern[1]);
270
271 // do we need this ? (Ch.F.)
272// for(Int_t cath=0; cath<2; ++cath)
273// {
274// for(Int_t ch=0; ch<4; ++ch)
275// {
276// if(xyPattern[cath][ch]==0) continue;
277// }
278// }
7ec3b9cf 279
280 Int_t nBoard = locTrg->LoCircuit();
281 fDigitMaker.TriggerDigits(nBoard, xyPattern, digitStore);
282 }
283 return kTRUE;
7771752e 284}