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