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