Allowing to switch off branches (calo+FMD for PDC06) - Andreas)
[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:
27///
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
33///
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"
ea94c18b 58
59#include "AliMagF.h"
60#include "AliLog.h"
7771752e 61#include "AliTracker.h"
ea94c18b 62
7771752e 63#include <Riostream.h>
7ec3b9cf 64#include <TArrayS.h>
7771752e 65#include <TClonesArray.h>
66#include <TMath.h>
67#include <TMatrixD.h>
7771752e 68
69/// \cond CLASSIMP
70ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context
71/// \endcond
72
73
74//______________________________________________________________________________
7ec3b9cf 75AliMUONTrackHitPattern::AliMUONTrackHitPattern(const AliMUONGeometryTransformer& transformer,
76 const AliMUONDigitMaker& digitMaker)
7771752e 77 : TObject(),
7ec3b9cf 78 fTransformer(transformer),
79 fDigitMaker(digitMaker)
7771752e 80{
81 /// Default constructor
82
83 // Set magnetic field
84 const AliMagF* kField = AliTracker::GetFieldMap();
85 if (!kField) AliFatal("No field available");
86 AliMUONTrackExtrap::SetField(kField);
7771752e 87}
88
89
90//______________________________________________________________________________
91AliMUONTrackHitPattern::~AliMUONTrackHitPattern(void)
92{
7ec3b9cf 93 /// Destructor
7771752e 94}
95
96
97//______________________________________________________________________________
7ec3b9cf 98void AliMUONTrackHitPattern::GetHitPattern(AliMUONVTrackStore& trackStore,
99 const AliMUONVTriggerStore& triggerStore) const
7771752e 100{
101 //
102 /// Main method:
103 /// Loops on reco tracks, extrapolates them to trigger chambers
104 /// and searches for matching digits
105 //
106
7ec3b9cf 107 const Int_t kMask[2][4]= {{0x80, 0x40, 0x20, 0x10},
108 {0x08, 0x04, 0x02, 0x01}};
7771752e 109 Bool_t isMatch[2];
7ec3b9cf 110
7771752e 111 UShort_t pattern=0;
7ec3b9cf 112
113 AliMUONDigitStoreV1 digitStore;
114
115 TriggerDigits(triggerStore,digitStore);
116
117 AliMUONTrack* muonTrack;
118 TIter next(trackStore.CreateIterator());
119
120 while ( ( muonTrack = static_cast<AliMUONTrack*>(next()) ) )
121 {
122 pattern = 0;
e658c384 123 AliMUONTrackParam trackParam = (*(static_cast<AliMUONTrackParam*>
96ebe67e 124 (muonTrack->GetTrackParamAtCluster()->Last())));
7ec3b9cf 125
126 for(Int_t ch=0; ch<4; ++ch)
127 {
e658c384 128 AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(10+ch));
129 FindPadMatchingTrack(digitStore,trackParam, isMatch, ch);
7ec3b9cf 130 for(Int_t cath=0; cath<2; ++cath)
131 {
132 if(isMatch[cath]) pattern |= kMask[cath][ch];
7771752e 133 }
7ec3b9cf 134 }
135 muonTrack->SetHitsPatternInTrigCh(pattern);
7771752e 136 }
7771752e 137}
138
139
140//______________________________________________________________________________
7ec3b9cf 141void
142AliMUONTrackHitPattern::FindPadMatchingTrack(AliMUONVDigitStore& digitStore,
143 const AliMUONTrackParam& trackParam,
144 Bool_t isMatch[2], Int_t /*iChamber*/) const
7771752e 145{
146 //
147 /// Given track position, searches for matching digits.
148 //
149
150 Float_t minMatchDist[2];
151
7ec3b9cf 152 for(Int_t cath=0; cath<2; ++cath)
153 {
154 isMatch[cath]=kFALSE;
155 minMatchDist[cath]=9999.;
7771752e 156 }
157
7ec3b9cf 158 TIter next(digitStore.CreateIterator());
159 AliMUONVDigit* mDigit;
160
161 while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
162 {
163 Int_t currDetElemId = mDigit->DetElemId();
164 Int_t cathode = mDigit->Cathode();
165 Int_t ix = mDigit->PadX();
166 Int_t iy = mDigit->PadY();
167 Float_t xpad, ypad, zpad;
168 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()
169 ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
170
171 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
172 Float_t xlocal1 = pad.Position().X();
173 Float_t ylocal1 = pad.Position().Y();
174 Float_t dpx = pad.Dimensions().X();
175 Float_t dpy = pad.Dimensions().Y();
176 fTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad);
177 Float_t matchDist = MinDistanceFromPad(xpad, ypad, zpad, dpx, dpy, trackParam);
178 if(matchDist>minMatchDist[cathode])continue;
179 isMatch[cathode] = kTRUE;
180 minMatchDist[cathode] = matchDist;
7771752e 181 }
7771752e 182}
183
184
185//______________________________________________________________________________
7ec3b9cf 186Float_t
187AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad,
188 Float_t dpx, Float_t dpy,
189 const AliMUONTrackParam& trackParam) const
7771752e 190{
191 //
192 /// Decides if the digit belongs to the track.
193 //
7ec3b9cf 194 Float_t xTrackAtPad = trackParam.GetNonBendingCoor();
195 Float_t yTrackAtPad = trackParam.GetBendingCoor();
7771752e 196
197 Float_t sigmaX, sigmaY, sigmaMS;
198 GetPosUncertainty(trackParam, zPad, sigmaX, sigmaY, sigmaMS);
199
200 Float_t maxDistX = 3.*(sigmaX + sigmaMS); // in cm
201 Float_t maxDistY = 3.*(sigmaY + sigmaMS); // in cm
202
203 Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx;
204 Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy;
205
206 Float_t matchDist = 99999.;
207 if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
208 return matchDist;
209}
210
211
212//______________________________________________________________________________
7ec3b9cf 213void
214AliMUONTrackHitPattern::GetPosUncertainty(const AliMUONTrackParam& trackParam,
215 Float_t zChamber,
216 Float_t &sigmaX, Float_t &sigmaY,
217 Float_t &sigmaMS) const
7771752e 218{
219 //
220 /// Returns uncertainties on extrapolated position.
221 /// Takes into account Branson plane corrections in the iron wall.
222 //
223
7dc68cf4 224 const Float_t kAlpha = 0.1123; // GeV/c
7771752e 225
226 // Find a better way to get such parameters ???
227 const Float_t kZFilterIn = 1471.; // From STRUCT/SHILConst2.h
228 const Float_t kZFilterOut = kZFilterIn + 120.; // From STRUCT/SHILConst2.h
229
7dc68cf4 230 const Float_t kZBranson = - (kZFilterIn + (kZFilterOut - kZFilterIn)*2./3. ); // - sign because distance are positive
231 Float_t zDistFromWall = TMath::Abs(zChamber - kZBranson);
7771752e 232 Float_t zDistFromLastTrackCh = TMath::Abs(zChamber - AliMUONConstants::DefaultChamberZ(9));
233
ea94c18b 234 const TMatrixD& kCovParam = trackParam.GetCovariances();
7771752e 235
ea94c18b 236 sigmaX = kCovParam(0,0);
237 sigmaY = kCovParam(2,2);
7771752e 238
239 // If covariance matrix is not extrapolated, use "reasonable" errors
240 // (To be removed as soon as covariance matrix is correctly propagated).
241 if (sigmaX==0.)sigmaX = 0.003 * zDistFromLastTrackCh;
242 if (sigmaY==0.)sigmaY = 0.004 * zDistFromLastTrackCh;
243
7ec3b9cf 244 Float_t p = trackParam.P();
7dc68cf4 245 Float_t thetaMS = kAlpha/p;
7771752e 246 sigmaMS = zDistFromWall * TMath::Tan(thetaMS);
7771752e 247}
248
249
7ec3b9cf 250//______________________________________________________________________________
251Bool_t
252AliMUONTrackHitPattern::TriggerDigits(const AliMUONVTriggerStore& triggerStore,
253 AliMUONVDigitStore& digitStore) const
7771752e 254{
7ec3b9cf 255 //
256 /// make (S)Digit for trigger
257 //
258
259 digitStore.Clear();
260
261 AliMUONLocalTrigger* locTrg;
262 TIter next(triggerStore.CreateLocalIterator());
263
264 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
265 {
24754ef8 266 if (locTrg->IsNull()) continue;
267
7ec3b9cf 268 TArrayS xyPattern[2];
24754ef8 269 locTrg->GetXPattern(xyPattern[0]);
270 locTrg->GetYPattern(xyPattern[1]);
271
272 // do we need this ? (Ch.F.)
273// for(Int_t cath=0; cath<2; ++cath)
274// {
275// for(Int_t ch=0; ch<4; ++ch)
276// {
277// if(xyPattern[cath][ch]==0) continue;
278// }
279// }
7ec3b9cf 280
281 Int_t nBoard = locTrg->LoCircuit();
282 fDigitMaker.TriggerDigits(nBoard, xyPattern, digitStore);
283 }
284 return kTRUE;
7771752e 285}