]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCConfMapPoint.cxx
Bogdan: new version of MUON visualization.
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCConfMapPoint.cxx
1 // @(#) $Id$
2 // Original: AliHLTConfMapPoint.cxx,v 1.10 2005/06/23 17:46:55 hristov 
3
4 /**************************************************************************
5  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6  *                                                                        *
7  * Authors: Anders Vestbo                                                 *
8  *          Matthias Richter <Matthias.Richter@ift.uib.no>                *
9  *          for The ALICE Off-line Project.                               *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /** @file   AliHLTTPCConfMapPoint.cxx
21     @author Anders Vestbo, maintained by Matthias Richter
22     @date   
23     @brief  Hit class for conformal mapper
24 */
25
26 #include "AliHLTTPCLogging.h"
27 #include "AliHLTTPCConfMapPoint.h"
28 #include "AliHLTTPCSpacePointData.h"
29 #include "AliHLTTPCVertex.h"
30 #include "AliHLTTPCConfMapTrack.h"
31
32 /**
33 <pre>
34 //_____________________________________________________________
35 // AliHLTTPCConfMapPoint
36 //
37 // Hit class for conformal mapper
38 </pre
39 */
40
41 ClassImp(AliHLTTPCConfMapPoint)
42
43 Bool_t AliHLTTPCConfMapPoint::fgDontMap=kFALSE;
44
45 AliHLTTPCConfMapPoint::AliHLTTPCConfMapPoint()
46 {
47   //Constructor
48   
49   SetUsage(false);
50   SetHitNumber(-1);
51   SetX(0);
52   SetY(0);
53   SetZ(0);
54   SetXerr(0);
55   SetYerr(0);
56   SetZerr(0);
57
58   SetPhi(0.);
59   SetEta(0.);
60   
61   SetXprime(0.);
62   SetYprime(0.);
63   SetXprimeerr(0.);
64   SetYprimeerr(0.);
65   SetIntPoint(0., 0., 0., 0., 0., 0.);
66   SetShiftedCoord();
67   SetMCTrackID(0,0,0);
68 }
69
70 AliHLTTPCConfMapPoint::AliHLTTPCConfMapPoint(const AliHLTTPCConfMapPoint&)
71 {
72   // dummy copy constructor
73   //HLTFatal("copy constructor untested");
74 }
75
76 AliHLTTPCConfMapPoint& AliHLTTPCConfMapPoint::operator=(const AliHLTTPCConfMapPoint&)
77
78   // dummy assignment operator
79   //HLTFatal("assignment operator untested");
80   return *this;
81 }
82
83 AliHLTTPCConfMapPoint::~AliHLTTPCConfMapPoint()
84 {
85   // Destructor.
86 }
87
88 Bool_t AliHLTTPCConfMapPoint::ReadHits(AliHLTTPCSpacePointData* hits )
89 {
90   //read the hits
91   SetHitNumber(hits->fID);
92   SetPadRow(hits->fPadRow);
93   Int_t slice = (hits->fID>>25) & 0x7f;
94   SetSector(slice);
95   SetX(hits->fX);
96   SetY(hits->fY);
97   SetZ(hits->fZ);
98   SetXerr(sqrt(hits->fSigmaY2));
99   SetYerr(sqrt(hits->fSigmaY2));
100   SetZerr(sqrt(hits->fSigmaZ2));
101   return kTRUE;
102 }
103
104 void AliHLTTPCConfMapPoint::Reset()
105 {
106   //Reset this point.
107   SetUsage(kFALSE);
108   SetS(0);
109   fNextRowHit = 0;
110   fNextVolumeHit=0;
111   fNextTrackHit=0;
112 }
113
114 void AliHLTTPCConfMapPoint::Setup(AliHLTTPCVertex *vertex)
115 {
116   //Setup. Sets the vertex, conformal coordinates, 
117   //and phi and eta of each hit.
118   
119   SetIntPoint(vertex->GetX(),    vertex->GetY(),    vertex->GetZ(),
120               vertex->GetXErr(), vertex->GetYErr(), vertex->GetZErr());
121   SetShiftedCoord();
122   SetConfCoord();
123   // The angles are set properly if they are set after 
124   // the interaction point and the shifted coordinates
125   SetAngles();
126   //SetDist(0., 0.);
127   return;
128 }
129
130 void AliHLTTPCConfMapPoint::SetIntPoint(Double_t inx, Double_t iny, Double_t inz,
131                                     Double_t inxerr, Double_t inyerr, Double_t inzerr)
132 {
133   // Defines a new interaction point. This point is needed to calculate
134   // the conformal coordinates.
135
136   SetXt(inx);
137   SetYt(iny);
138   SetZt(inz);
139   SetXterr(inxerr);
140   SetYterr(inyerr);
141   SetZterr(inzerr);
142
143   return;
144 }
145
146 void AliHLTTPCConfMapPoint::SetAllCoord(const AliHLTTPCConfMapPoint *precedinghit)
147 {
148   // Sets the interaction point, the shifted coordinates, and the conformal mapping coordinates.
149   // These values are calculated from the interaction point of the given cluster which should be a
150   // already found cluster on the same track.
151
152   if (this == precedinghit) {
153     SetIntPoint(precedinghit->GetX(),    precedinghit->GetY(),    precedinghit->GetZ(),
154                 precedinghit->GetXerr(), precedinghit->GetYerr(), precedinghit->GetZerr());
155   }
156
157   else {
158     SetIntPoint(precedinghit->GetXt(),    precedinghit->GetYt(),    precedinghit->GetZt(),
159                 precedinghit->GetXterr(), precedinghit->GetYterr(), precedinghit->GetZterr());
160   }
161
162   SetShiftedCoord();
163   SetConfCoord();
164
165   return;
166 }
167
168 void AliHLTTPCConfMapPoint::SetShiftedCoord()
169 {
170   // Sets the coordinates with resepct to the given vertex point
171
172   SetXv(GetX() - fXt);
173   SetYv(GetY() - fYt);
174   SetZv(GetZ() - fZt);
175   /*
176   SetXverr(TMath::Sqrt(GetXerr()*GetXerr() + fXterr*fXterr));
177   SetYverr(TMath::Sqrt(GetYerr()*GetYerr() + fYterr*fYterr));
178   SetZverr(TMath::Sqrt(GetZerr()*GetZerr() + fZterr*fZterr));
179   */
180   return;
181 }
182
183 void AliHLTTPCConfMapPoint::SetConfCoord()
184 {
185   // Calculates the conformal coordinates of one cluster.
186   // If the option "vertex_constraint" applies the interaction point is
187   // assumed to be at (0, 0, 0). Otherwise the function will use the
188   // interaction point specified by fXt and fYt.
189
190   if(fgDontMap){
191     fXprime = fx;
192     fYprime = fy;
193     fWxy = 0;
194     fs = 0; //track trajectory
195     fWz = 0;
196     return;
197   }
198
199   Double_t r2;
200   Double_t xyErrorScale = 1;
201   Double_t szErrorScale = 1;
202
203   if ((r2 = fXv*fXv + fYv*fYv)) 
204     {
205       fXprime =  fXv / r2;
206       fYprime = -fYv / r2;
207       
208       //set weights:
209       fWxy = r2*r2 / ((xyErrorScale*xyErrorScale)*((fxerr*fxerr)+(fyerr*fyerr)));
210       fs = 0; //track trajectory
211       fWz = (Double_t)(1./(szErrorScale*fzerr*fzerr));
212     } else {
213     fXprime    = 0.;
214     fYprime    = 0.;
215     fXprimeerr = 0.;
216     fYprimeerr = 0.;
217     fWxy = 0;
218     fWz = 0;
219     fs = 0;
220   }
221
222   return;
223 }
224
225 void AliHLTTPCConfMapPoint::SetAngles()
226 {
227   // Calculates the angle phi and the pseudorapidity eta for each cluster.
228   /*
229   Double_t r = TMath::Sqrt(x*x + y*y);
230
231   fPhi = TMath::ATan2(y,x);
232   if(fPhi<0) fPhi = fPhi + 2*TMath::Pi();
233   fEta = 3.*z/(TMath::Abs(z)+2.*r);
234   return;
235   */
236   //  Double_t r3dim = TMath::Sqrt(fXv*fXv + fYv*fYv + fZv*fZv);
237   Double_t r3dim = sqrt(fXv*fXv + fYv*fYv + fZv*fZv);
238   //Double_t r2dim = TMath::Sqrt(fXv*fXv + fYv*fYv);
239
240   /*if (r2dim == 0.) {
241   // If r2dim == 0 the pseudorapidity eta cannot be calculated (division by zero)!
242   // This can only happen if the point is lying on the z-axis and this should never be possible.
243     cerr << "The pseudorapidity eta cannot be calculated (division by zero)! Set to 1.e-10." << endl;
244     r2dim = 1.e-10;
245   }
246
247   if (fXv == 0.) {
248     fPhi = (fYv > 0.) ? TMath::Pi() / 2. : - TMath::Pi() / 2.;
249   }
250
251   else {
252     fPhi = (fXv > 0.) ? TMath::ASin(fYv/r2dim) : TMath::Pi() - TMath::ASin(fYv/r2dim);
253   }
254
255   if (fPhi < 0.) {
256     fPhi += 2. * TMath::Pi();
257   }
258   */
259   //fPhi = TMath::ATan2(y,x);
260   fPhi = atan2(fy,fx);
261   //if(fPhi<0) fPhi = fPhi + 2*TMath::Pi();
262   
263   //fEta = 0.5 * TMath::Log((r3dim + fZv)/(r3dim - fZv));
264   fEta = 0.5 * log((r3dim + fZv)/(r3dim - fZv));
265   return;
266 }
267
268 /*
269 AliHLTTPCConfMapTrack *AliHLTTPCConfMapPoint::GetTrack(TClonesArray *tracks) const
270 {
271   // Returns the pointer to the track to which this hit belongs.
272   
273   return (AliHLTTPCConfMapTrack*)tracks->At(this->GetTrackNumber());
274 }
275 */