]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALTrack.cxx
call storage area LED instead of Signal
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTrack.cxx
CommitLineData
fe17d4cb 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//========================================================================
8d71d459 15//
fe17d4cb 16// Class AliEMCALTrack
17// ---------------------
18// A class implementing a track which is propagated to EMCAL and
19// matches and EMCAL cluster.
20// This track object will not update Kalman parameters, but it
21// allows for track propagation and suitable energy loss correction,
22// even in an environment with a variable magnetic field, which is not
23// well managed in the AliExternalTrackParam class.
24// ------------------------------------------------------------------------
25// author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
26//=========================================================================
27
28#include "Riostream.h"
29
c61f0e70 30#include "TVector3.h"
31
fe17d4cb 32#include "AliLog.h"
33#include "AliTracker.h"
34#include "AliESDtrack.h"
35
36#include "AliEMCALTrack.h"
37
38Bool_t AliEMCALTrack::fgUseOuterParams = kTRUE;
c61f0e70 39Bool_t AliEMCALTrack::fgCorrectForEL = kFALSE;
40Bool_t AliEMCALTrack::fgSortByPt = kTRUE;
fe17d4cb 41
42ClassImp(AliEMCALTrack)
43//
44//------------------------------------------------------------------------------
45//
46AliEMCALTrack::AliEMCALTrack()
47 : AliExternalTrackParam(),
48 fClusterIndex(-1),
c61f0e70 49 fClusterDist(1000.0), // default: extremely large distance
50 fMass(0.13957018), // default: pion mass
fe17d4cb 51 fSeedIndex(-1),
52 fSeedLabel(-1)
53{
54 //
55 // Default constructor.
56 // Sets to meaningless values the indexes corresponding to
57 // ESD seed track and matched cluster.
58 //
8d71d459 59
fe17d4cb 60}
61//
62//------------------------------------------------------------------------------
63//
fe17d4cb 64AliEMCALTrack::AliEMCALTrack(const AliESDtrack& t)
65 : AliExternalTrackParam(),
66 fClusterIndex(-1),
67 fClusterDist(1000.0),
68 fMass(t.GetMass()),
69 fSeedIndex(-1),
70 fSeedLabel(t.GetLabel())
71{
72 //
73 // Constructor from AliESDtrack
74 //
75
76 // parameters are chosen according to static variable fUseOuterParams
77 Double_t alpha, x, params[5], cov[15];
78 if (fgUseOuterParams) {
8d71d459 79 if(t.GetOuterParam()){
80 t.GetOuterExternalParameters(alpha, x, params);
81 t.GetOuterExternalCovariance(cov);
82 }
83 else{ // no outer param available leave the default as is
84 return;
85 }
fe17d4cb 86 }
87 else {
88 alpha = t.GetAlpha();
89 t.GetExternalParameters(x, params);
90 t.GetExternalCovariance(cov);
91 }
92
93 if (alpha < -TMath::Pi()) alpha += TMath::TwoPi();
94 else if (alpha >= TMath::Pi()) alpha -= TMath::TwoPi();
95
96 // set this accordingly
97 Set(x, alpha, params, cov);
c61f0e70 98}
99//
100//------------------------------------------------------------------------------
101//
102AliEMCALTrack::AliEMCALTrack(const AliEMCALTrack& t)
103 : AliExternalTrackParam(t),
104 fClusterIndex(t.fClusterIndex),
105 fClusterDist(t.fClusterDist),
106 fMass(t.fMass),
107 fSeedIndex(t.fSeedIndex),
108 fSeedLabel(t.fSeedLabel)
109{
110 //
111 // Copy constructor.
112 //
113}
fe17d4cb 114//
115//------------------------------------------------------------------------------
116//
117AliEMCALTrack& AliEMCALTrack::operator=(const AliEMCALTrack &t)
118{
119 //
120 // Assignment operator
121 // Works like copy constructor
122 //
123
124 fClusterIndex = t.fClusterIndex;
125 fClusterDist = t.fClusterDist;
126
127 fMass = t.fMass;
128
129 fSeedIndex = t.fSeedIndex;
130 fSeedLabel = t.fSeedLabel;
fe17d4cb 131 return *this;
132}
133//
134//------------------------------------------------------------------------------
135//
136Int_t AliEMCALTrack::Compare(const TObject *obj) const
137{
138 //
c61f0e70 139 // Compare tracks.
140 // How tracks are compared depends on the static flag
141 // "fSortByPt" (boolean):
142 // true => tracks are compared w.r. to their transverse momentum
143 // false => tracks are compared w.r. to their distance from cluster
fe17d4cb 144 //
145
146 AliEMCALTrack *that = (AliEMCALTrack*)obj;
147
c61f0e70 148 Double_t thisP[3], thisVal, thatP[3], thatVal;
149
150 if (fgSortByPt) {
151 this->GetPxPyPz(thisP);
152 that->GetPxPyPz(thatP);
153 thisVal = TMath::Sqrt(thisP[0]*thisP[0] + thisP[1]*thisP[1]);
154 thatVal = TMath::Sqrt(thatP[0]*thatP[0] + thatP[1]*thatP[1]);
155 }
156 else {
157 thisVal = this->GetClusterDist();
158 thatVal = that->GetClusterDist();
159 }
fe17d4cb 160
c61f0e70 161 if (thisVal > thatVal) return 1;
162 else if (thisVal < thatVal) return -1;
163 else return 0;
fe17d4cb 164}
165//
166//------------------------------------------------------------------------------
167//
168Double_t AliEMCALTrack::GetBz() const
169{
170 //
c61f0e70 171 // Returns Z-component of the magnetic field in kG.
172 // In case it B is not constant, its value is returned
173 // at the current position of the track (local X,Y,Z)
fe17d4cb 174 //
175
c61f0e70 176 // if magnetic field is constant...
177 if (AliTracker::UniformField()) return AliTracker::GetBz();
fe17d4cb 178
c61f0e70 179 // ...else:
180 Double_t r[3];
181 GetXYZ(r);
182 return AliTracker::GetBz(r);
fe17d4cb 183}
184//
185//------------------------------------------------------------------------------
186//
c61f0e70 187Bool_t AliEMCALTrack::PropagateTo(Double_t xk, Double_t d, Double_t x0)
fe17d4cb 188{
189 //
190 // Propagates a track to the plane defined by x='xk'.
c61f0e70 191 // Second parameter is the width (in units of rad. length) crossed by the track.
192 // Third parameter is the reference radiation length used.
fe17d4cb 193 // Track propagation includes computing energy loss (modifies curvature)
c61f0e70 194 // and multiple scattering perturbation (alters covariance matrix), if requested.
fe17d4cb 195 // Method returns kFALSE when something goes wrong with computations.
196 //
c61f0e70 197 // An additional operation (thanks to Yuri Belikov) is done to check
198 // when the track crosses a sector boundary. If this happens,
199 // the local track reference frame is adjusted accordingly.
200 //
201
202 Double_t y;
203 Double_t field = GetBz();
204 Double_t width = TMath::Pi() / 9.0; // width of TPC/TRD/EMCAL sector (= 20 deg)
205 Double_t ymax = TMath::Abs(xk * TMath::Tan(0.5 * width)); // max allowed Y in local coords at distance xk
206
207 // first check: try to compute the local 'y' at the distance 'xk':
208 // if this attempt fails, the propagation cannot be done
209 if (!GetYAt(xk, field, y)) return kFALSE;
210
211 // if is -ymax < y < ymax ==> 'direct' propagation is done;
212 if (TMath::Abs(y) <= ymax) return SimplePropagation(xk, d, x0);
213
214 // otherwise, try change a sector to find one where the propagation is ok
215 Int_t i, incr, istart, nloops;
216 Double_t alpha = GetAlpha();
217 incr = (y > ymax) ? 1 : -1;
218 if (alpha < 0.0) alpha += TMath::TwoPi();
219 istart = (Int_t)(alpha / width);
220 for (i = istart, nloops = 0; nloops < 18; i += incr, nloops++) {
221 if (i == 18) i = 0;
222 if (i == -1) i = 17;
223 alpha = ((Double_t)i + 0.5) * width;
224 if (Rotate(alpha)) {
225 if (GetYAt(xk, field, y)) {
226 if (TMath::Abs(y) <= ymax) {
b0001dd8 227 AliDebug(1,Form("Required change from sector %d to sector %d to succeed in propagation", istart, i));
c61f0e70 228 return SimplePropagation(xk, d, x0);
229 }
230 }
231 }
232 }
233
234 // if the routine exits from the loop and reaches this point,
235 // it means that none of the rotations succeeded
236 AliWarning("Track propagation fails in every sector. Impossible to propagate.");
237 return kFALSE;
238}
239//
240//------------------------------------------------------------------------------
241//
242Double_t AliEMCALTrack::StraightPropagateTo(Double_t xk, Double_t &x, Double_t &y, Double_t &z)
243{
244 //
245 // Does propagation with a straight line approximation.
246 // This operation does not update track parameters, but it returns a point
247 // in space, according to this propagation, which is stored in
248 // the arguments #2, #3 and #4
249 //
250
251 Double_t oldX = GetX(), oldY = GetY(), oldZ = GetZ();
252 Double_t newPos[3];
253
254 newPos[0] = xk;
255 newPos[1] = oldY * xk / oldX;
256 newPos[2] = oldZ * xk / oldX;
257
258 Double_t cs = TMath::Cos(GetAlpha()), sn = TMath::Sin(GetAlpha());
259 x = newPos[0]*cs - newPos[1]*sn;
260 y = newPos[0]*sn + newPos[1]*cs;
261 z = newPos[2];
262
263 return newPos[1];
264}
265//
266//------------------------------------------------------------------------------
267//
268Bool_t AliEMCALTrack::PropagateToGlobal(Double_t x, Double_t y, Double_t z, Double_t d, Double_t x0)
269{
270 //
271 // Propagate to a point specified with its global XYZ coordinates.
272 // Here, the correct value of the 'X' parameter to be sent to "PropagateTo" is computed.
273 //
274
275 TVector3 vc(x, y, z);
276 Double_t width = 20.0; // width of TPC/TRD/EMCAL sector
277 Double_t phi = vc.Phi() * TMath::RadToDeg();
278 if (phi < 0.0) phi += 360.0;
279
280 Int_t isector = (Int_t)(phi / width);
281 Double_t rotation = ((Double_t)isector + 0.5) * width;
69d7454f 282 vc.RotateZ(-rotation * TMath::DegToRad());
c61f0e70 283
284 return PropagateTo(vc.X(), d, x0);
285}
286//
287//------------------------------------------------------------------------------
288//
289Bool_t AliEMCALTrack::SimplePropagation(Double_t xk, Double_t d, Double_t x0)
290{
291 //
292 // Recall base class method for track propagation.
293 //
fe17d4cb 294
295 Double_t field = GetBz();
296
c61f0e70 297 // propagation...
fe17d4cb 298 if (!AliExternalTrackParam::PropagateTo(xk, field)) return kFALSE;
c61f0e70 299
300 // EL correction is computed only if requested...
301 if (!fgCorrectForEL) return kTRUE;
c3c15772 302 return AliExternalTrackParam::CorrectForMeanMaterial(d, x0, GetMass());
c61f0e70 303}