]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCConfMapPoint.cxx
- coverity fix 14179
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCConfMapPoint.cxx
CommitLineData
a6c02c85 1// @(#) $Id$
4aa41877 2// Original: AliHLTConfMapPoint.cxx,v 1.10 2005/06/23 17:46:55 hristov
a6c02c85 3
2a083ac4 4/**************************************************************************
9be2600f 5 * This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
2a083ac4 7 * *
9be2600f 8 * Primary Authors: Anders Vestbo, maintained by *
9 * Matthias Richter <Matthias.Richter@ift.uib.no> *
10 * for The ALICE HLT Project. *
2a083ac4 11 * *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
20
21/** @file AliHLTTPCConfMapPoint.cxx
22 @author Anders Vestbo, maintained by Matthias Richter
23 @date
24 @brief Hit class for conformal mapper
25*/
a6c02c85 26
055fed30 27#include <cassert>
a6c02c85 28#include "AliHLTTPCLogging.h"
29#include "AliHLTTPCConfMapPoint.h"
30#include "AliHLTTPCSpacePointData.h"
31#include "AliHLTTPCVertex.h"
32#include "AliHLTTPCConfMapTrack.h"
33
34/**
35<pre>
36//_____________________________________________________________
37// AliHLTTPCConfMapPoint
38//
39// Hit class for conformal mapper
86268ca8 40</pre>
a6c02c85 41*/
42
86268ca8 43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTTPCConfMapPoint);
a6c02c85 45
46Bool_t AliHLTTPCConfMapPoint::fgDontMap=kFALSE;
47
48AliHLTTPCConfMapPoint::AliHLTTPCConfMapPoint()
e419b223 49 :
50 fHitNumber(-1),
51 fTrackNumber(0),
52 fNextHitNumber(0),
055fed30 53 fUsed(kFALSE),
e419b223 54 fPadrow(0),
55 fSector(0),
56 fx(0),
57 fy(0),
58 fz(0),
59 fxerr(0),
60 fyerr(0),
61 fzerr(0),
62 fWxy(0),
63 fWz(0),
64 fs(0),
65 fXt(0),
66 fYt(0),
67 fZt(0),
68 fXterr(0),
69 fYterr(0),
70 fZterr(0),
71 fXprime(0),
72 fYprime(0),
73 fXprimeerr(0),
74 fYprimeerr(0),
75 fXv(0),
76 fYv(0),
77 fZv(0),
78 fXverr(0),
79 fYverr(0),
80 fZverr(0),
81 fPhi(0),
82 fEta(0),
055fed30 83 fNextVolumeHit(NULL),
84 fNextRowHit(NULL),
85 fNextTrackHit(NULL),
e419b223 86 fPhiIndex(0),
87 fEtaIndex(0),
88 fXYChi2(0),
89 fSZChi2(0)
a6c02c85 90{
91 //Constructor
055fed30 92 fMCTrackID[0]=-1;
93 fMCTrackID[1]=-1;
94 fMCTrackID[2]=-1;
95}
96
97AliHLTTPCConfMapPoint::AliHLTTPCConfMapPoint(const AliHLTTPCConfMapPoint& src)
98 :
99 fHitNumber(src.fHitNumber),
100 fTrackNumber(src.fTrackNumber),
101 fNextHitNumber(src.fNextHitNumber),
102 fUsed(src.fUsed),
103 fPadrow(src.fPadrow),
104 fSector(src.fSector),
105 fx(src.fx),
106 fy(src.fy),
107 fz(src.fz),
108 fxerr(src.fxerr),
109 fyerr(src.fyerr),
110 fzerr(src.fzerr),
111 fWxy(src.fWxy),
112 fWz(src.fWz),
113 fs(src.fs),
114 fXt(src.fXt),
115 fYt(src.fYt),
116 fZt(src.fZt),
117 fXterr(src.fXterr),
118 fYterr(src.fYterr),
119 fZterr(src.fZterr),
120 fXprime(src.fXprime),
121 fYprime(src.fYprime),
122 fXprimeerr(src.fXprimeerr),
123 fYprimeerr(src.fYprimeerr),
124 fXv(src.fXv),
125 fYv(src.fYv),
126 fZv(src.fZv),
127 fXverr(src.fXverr),
128 fYverr(src.fYverr),
129 fZverr(src.fZverr),
130 fPhi(src.fPhi),
131 fEta(src.fEta),
132 fNextVolumeHit(src.fNextVolumeHit),
133 fNextRowHit(src.fNextRowHit),
134 fNextTrackHit(src.fNextTrackHit),
135 fPhiIndex(src.fPhiIndex),
136 fEtaIndex(src.fEtaIndex),
137 fXYChi2(src.fXYChi2),
138 fSZChi2(src.fSZChi2)
139{
140 //Copy Constructor
141 fMCTrackID[0]=src.fMCTrackID[0];
142 fMCTrackID[1]=src.fMCTrackID[1];
143 fMCTrackID[2]=src.fMCTrackID[2];
144}
145
146AliHLTTPCConfMapPoint& AliHLTTPCConfMapPoint::operator=(const AliHLTTPCConfMapPoint& src)
147{
148 fHitNumber=src.fHitNumber;
149 fTrackNumber=src.fTrackNumber;
150 fNextHitNumber=src.fNextHitNumber;
151 fUsed=src.fUsed;
152 fPadrow=src.fPadrow;
153 fSector=src.fSector;
154 fx=src.fx;
155 fy=src.fy;
156 fz=src.fz;
157 fxerr=src.fxerr;
158 fyerr=src.fyerr;
159 fzerr=src.fzerr;
160 fWxy=src.fWxy;
161 fWz=src.fWz;
162 fs=src.fs;
163 fXt=src.fXt;
164 fYt=src.fYt;
165 fZt=src.fZt;
166 fXterr=src.fXterr;
167 fYterr=src.fYterr;
168 fZterr=src.fZterr;
169 fXprime=src.fXprime;
170 fYprime=src.fYprime;
171 fXprimeerr=src.fXprimeerr;
172 fYprimeerr=src.fYprimeerr;
173 fXv=src.fXv;
174 fYv=src.fYv;
175 fZv=src.fZv;
176 fXverr=src.fXverr;
177 fYverr=src.fYverr;
178 fZverr=src.fZverr;
179 fPhi=src.fPhi;
180 fEta=src.fEta;
181 fNextVolumeHit=src.fNextVolumeHit;
182 fNextRowHit=src.fNextRowHit;
183 fNextTrackHit=src.fNextTrackHit;
184 fPhiIndex=src.fPhiIndex;
185 fEtaIndex=src.fEtaIndex;
186 fXYChi2=src.fXYChi2;
187 fSZChi2=src.fSZChi2;
188 fMCTrackID[0]=src.fMCTrackID[0];
189 fMCTrackID[1]=src.fMCTrackID[1];
190 fMCTrackID[2]=src.fMCTrackID[2];
191
192 return *this;
a6c02c85 193}
194
195AliHLTTPCConfMapPoint::~AliHLTTPCConfMapPoint()
196{
197 // Destructor.
a6c02c85 198}
199
055fed30 200Bool_t AliHLTTPCConfMapPoint::Read(const AliHLTTPCSpacePointData& hit)
a6c02c85 201{
202 //read the hits
055fed30 203 SetHitNumber(hit.fID);
a371a266 204 SetPadRow(hit.fPadRow);
205 SetSector(hit.GetSlice());
055fed30 206 SetX(hit.fX);
207 SetY(hit.fY);
208 SetZ(hit.fZ);
209 SetXerr(sqrt(hit.fSigmaY2));
210 SetYerr(sqrt(hit.fSigmaY2));
211 SetZerr(sqrt(hit.fSigmaZ2));
a6c02c85 212 return kTRUE;
213}
214
215void AliHLTTPCConfMapPoint::Reset()
216{
217 //Reset this point.
218 SetUsage(kFALSE);
219 SetS(0);
055fed30 220 fNextRowHit = NULL;
221 fNextVolumeHit=NULL;
222 fNextTrackHit=NULL;
a6c02c85 223}
224
225void AliHLTTPCConfMapPoint::Setup(AliHLTTPCVertex *vertex)
226{
227 //Setup. Sets the vertex, conformal coordinates,
228 //and phi and eta of each hit.
229
230 SetIntPoint(vertex->GetX(), vertex->GetY(), vertex->GetZ(),
231 vertex->GetXErr(), vertex->GetYErr(), vertex->GetZErr());
232 SetShiftedCoord();
233 SetConfCoord();
234 // The angles are set properly if they are set after
235 // the interaction point and the shifted coordinates
236 SetAngles();
237 //SetDist(0., 0.);
238 return;
239}
240
241void AliHLTTPCConfMapPoint::SetIntPoint(Double_t inx, Double_t iny, Double_t inz,
242 Double_t inxerr, Double_t inyerr, Double_t inzerr)
243{
244 // Defines a new interaction point. This point is needed to calculate
245 // the conformal coordinates.
246
247 SetXt(inx);
248 SetYt(iny);
249 SetZt(inz);
250 SetXterr(inxerr);
251 SetYterr(inyerr);
252 SetZterr(inzerr);
253
254 return;
255}
256
257void AliHLTTPCConfMapPoint::SetAllCoord(const AliHLTTPCConfMapPoint *precedinghit)
258{
259 // Sets the interaction point, the shifted coordinates, and the conformal mapping coordinates.
260 // These values are calculated from the interaction point of the given cluster which should be a
261 // already found cluster on the same track.
262
263 if (this == precedinghit) {
264 SetIntPoint(precedinghit->GetX(), precedinghit->GetY(), precedinghit->GetZ(),
265 precedinghit->GetXerr(), precedinghit->GetYerr(), precedinghit->GetZerr());
266 }
267
268 else {
269 SetIntPoint(precedinghit->GetXt(), precedinghit->GetYt(), precedinghit->GetZt(),
270 precedinghit->GetXterr(), precedinghit->GetYterr(), precedinghit->GetZterr());
271 }
272
273 SetShiftedCoord();
274 SetConfCoord();
275
276 return;
277}
278
279void AliHLTTPCConfMapPoint::SetShiftedCoord()
280{
281 // Sets the coordinates with resepct to the given vertex point
282
283 SetXv(GetX() - fXt);
284 SetYv(GetY() - fYt);
285 SetZv(GetZ() - fZt);
286 /*
287 SetXverr(TMath::Sqrt(GetXerr()*GetXerr() + fXterr*fXterr));
288 SetYverr(TMath::Sqrt(GetYerr()*GetYerr() + fYterr*fYterr));
289 SetZverr(TMath::Sqrt(GetZerr()*GetZerr() + fZterr*fZterr));
290 */
291 return;
292}
293
294void AliHLTTPCConfMapPoint::SetConfCoord()
295{
296 // Calculates the conformal coordinates of one cluster.
297 // If the option "vertex_constraint" applies the interaction point is
298 // assumed to be at (0, 0, 0). Otherwise the function will use the
299 // interaction point specified by fXt and fYt.
300
301 if(fgDontMap){
302 fXprime = fx;
303 fYprime = fy;
304 fWxy = 0;
305 fs = 0; //track trajectory
306 fWz = 0;
307 return;
308 }
309
310 Double_t r2;
311 Double_t xyErrorScale = 1;
312 Double_t szErrorScale = 1;
313
314 if ((r2 = fXv*fXv + fYv*fYv))
315 {
316 fXprime = fXv / r2;
317 fYprime = -fYv / r2;
318
319 //set weights:
320 fWxy = r2*r2 / ((xyErrorScale*xyErrorScale)*((fxerr*fxerr)+(fyerr*fyerr)));
321 fs = 0; //track trajectory
322 fWz = (Double_t)(1./(szErrorScale*fzerr*fzerr));
323 } else {
324 fXprime = 0.;
325 fYprime = 0.;
326 fXprimeerr = 0.;
327 fYprimeerr = 0.;
328 fWxy = 0;
329 fWz = 0;
330 fs = 0;
331 }
332
333 return;
334}
335
336void AliHLTTPCConfMapPoint::SetAngles()
337{
338 // Calculates the angle phi and the pseudorapidity eta for each cluster.
339 /*
340 Double_t r = TMath::Sqrt(x*x + y*y);
341
342 fPhi = TMath::ATan2(y,x);
343 if(fPhi<0) fPhi = fPhi + 2*TMath::Pi();
344 fEta = 3.*z/(TMath::Abs(z)+2.*r);
345 return;
346 */
347 // Double_t r3dim = TMath::Sqrt(fXv*fXv + fYv*fYv + fZv*fZv);
348 Double_t r3dim = sqrt(fXv*fXv + fYv*fYv + fZv*fZv);
349 //Double_t r2dim = TMath::Sqrt(fXv*fXv + fYv*fYv);
350
351 /*if (r2dim == 0.) {
352 // If r2dim == 0 the pseudorapidity eta cannot be calculated (division by zero)!
353 // This can only happen if the point is lying on the z-axis and this should never be possible.
354 cerr << "The pseudorapidity eta cannot be calculated (division by zero)! Set to 1.e-10." << endl;
355 r2dim = 1.e-10;
356 }
357
358 if (fXv == 0.) {
359 fPhi = (fYv > 0.) ? TMath::Pi() / 2. : - TMath::Pi() / 2.;
360 }
361
362 else {
363 fPhi = (fXv > 0.) ? TMath::ASin(fYv/r2dim) : TMath::Pi() - TMath::ASin(fYv/r2dim);
364 }
365
366 if (fPhi < 0.) {
367 fPhi += 2. * TMath::Pi();
368 }
369 */
370 //fPhi = TMath::ATan2(y,x);
371 fPhi = atan2(fy,fx);
372 //if(fPhi<0) fPhi = fPhi + 2*TMath::Pi();
373
374 //fEta = 0.5 * TMath::Log((r3dim + fZv)/(r3dim - fZv));
375 fEta = 0.5 * log((r3dim + fZv)/(r3dim - fZv));
376 return;
377}
378
379/*
380AliHLTTPCConfMapTrack *AliHLTTPCConfMapPoint::GetTrack(TClonesArray *tracks) const
381{
382 // Returns the pointer to the track to which this hit belongs.
383
384 return (AliHLTTPCConfMapTrack*)tracks->At(this->GetTrackNumber());
385}
386*/