Adding the AliAnalysisGUI class which is the main class that controls the GUI.
[u/mrichter/AliRoot.git] / ITS / AliITSNeuralPoint.cxx
CommitLineData
7d62fb64 1///////////////////////////////////////////////////////////////
2// AliITSneuralPoint //
3// //
4// A class which resumes the information of ITS clusters //
5// in the global reference frame. //
6// Author: A. Pulvirenti //
7///////////////////////////////////////////////////////////////
853a0f19 8//#include <stdlib.h>
9//#include <Riostream.h>
b9d722bc 10
11#include <TString.h>
12
13#include "AliITSRecPoint.h"
00a7cc50 14#include "AliITSRecPoint.h"
b9d722bc 15#include "AliITSgeom.h"
16#include "AliITSgeomMatrix.h"
17
18#include "AliITSNeuralPoint.h"
19
20
21ClassImp(AliITSNeuralPoint)
22//
23//------------------------------------------------------------------------------------------------------
24//
cb729508 25AliITSNeuralPoint::AliITSNeuralPoint():
26fX(0),
27fY(0),
28fZ(0),
29fConfX(0),
30fConfY(0),
31fEX(0),
32fEY(0),
33fEZ(0),
34fCharge(0),
35fModule(0),
36fIndex(0),
37fLayer(0),
38fUser(0),
39fZSort(0){
b9d722bc 40 // Default constructor.
41 // Defines the point as a noise point in the origin.
42
b9d722bc 43 fLabel[0] = fLabel[1] = fLabel[2] = -1;
cb729508 44
b9d722bc 45}
46//
47//------------------------------------------------------------------------------------------------------
48//
49AliITSNeuralPoint::AliITSNeuralPoint(AliITSNeuralPoint *p) :
cb729508 50fX(p->fX),
51fY(p->fY),
52fZ(p->fZ),
53fConfX(p->fConfX),
54fConfY(p->fConfY),
55fEX(p->fEX),
56fEY(p->fEY),
57fEZ(p->fEZ),
58fCharge(p->fCharge),
59fModule(p->fModule),
60fIndex(p->fIndex),
61fLayer(p->fLayer),
62fUser(p->fUser),
63fZSort(p->fZSort)
b9d722bc 64{
65 // Modified copy constructor.
66 // Accepts a pointer to a like object and copies its datamembers.
67
cb729508 68
b9d722bc 69 for (Int_t i = 0; i < 3; i++) fLabel[i] = p->fLabel[i];
cb729508 70
b9d722bc 71}
72//
73//------------------------------------------------------------------------------------------------------
74//
cb729508 75AliITSNeuralPoint::AliITSNeuralPoint(AliITSRecPoint *rp, AliITSgeomMatrix *gm):
76fX(0),
77fY(0),
78fZ(0),
79fConfX(0),
80fConfY(0),
81fEX(0),
82fEY(0),
83fEZ(0),
84fCharge(0),
85fModule(0),
86fIndex(0),
87fLayer(0),
88fUser(0),
89fZSort(0)
b9d722bc 90{
91 // Conversion constructor.
92 // Accepts a AliITSRecPoint and a AliITSgeomMatrix,
93 // and converts the local coord of the AliITSRecPoint object into global
94
95 Int_t i, k;
96 Double_t locPos[3], globPos[3], locErr[3][3], globErr[3][3];
97 for (i = 0; i < 3; i++) {
98 globPos[i] = 0.0;
99 for (k = 0; k < 3; k++) {
100 locErr[i][k] = 0.0;
101 globErr[i][k] = 0.0;
102 }
103 }
104
105 // local to global conversions of coords
00a7cc50 106 locPos[0] = rp->GetDetLocalX();
b9d722bc 107 locPos[1] = 0.0;
00a7cc50 108 locPos[2] = rp->GetDetLocalZ();
b9d722bc 109 gm->LtoGPosition(locPos, globPos);
110 fX = globPos[0];
111 fY = globPos[1];
112 fZ = globPos[2];
113
114 // local to global conversions of sigmas
00a7cc50 115 locErr[0][0] = rp->GetSigmaDetLocX2();
116 locErr[2][2] = rp->GetSigmaZ2();
b9d722bc 117 gm->LtoGPositionError(locErr, globErr);
00a7cc50 118 for (i = 0; i < 3; i++) fLabel[i] = rp->GetLabel(i);
b9d722bc 119 fEX = TMath::Sqrt(globErr[0][0]);
120 fEY = TMath::Sqrt(globErr[1][1]);
121 fEZ = TMath::Sqrt(globErr[2][2]);
122
123 // copy of other data-members
00a7cc50 124 fCharge = rp->GetQ();
b9d722bc 125 fLayer = 0;
126 fIndex = 0;
127 fModule = 0;
128 fUser = 0;
129}
130//
131//-------------------------------------------------------------------------------------------------
132//
cb729508 133AliITSNeuralPoint::AliITSNeuralPoint(AliITSRecPoint *rp, AliITSgeom *geom, Short_t module, Short_t index):
134fX(0),
135fY(0),
136fZ(0),
137fConfX(0),
138fConfY(0),
139fEX(0),
140fEY(0),
141fEZ(0),
142fCharge(0),
143fModule(0),
144fIndex(0),
145fLayer(0),
146fUser(0),
147fZSort(0)
b9d722bc 148{
853a0f19 149 // Conversion constructor.
00a7cc50 150 // Accepts a AliITSRecPoint and an AliITSgeom,
151 // and converts the local coord of the AliITSRecPoint object into global
853a0f19 152
b9d722bc 153 Int_t mod = (Int_t)module, lay, lad, det;
154 fModule = module;
155 fIndex = index;
156 geom->GetModuleId(mod, lay, lad, det);
157 fLayer = (Short_t)lay;
158
159 Double_t rot[9];
160 Float_t tx, ty, tz;
161 geom->GetRotMatrix(fModule, rot);
162 geom->GetTrans(fLayer, lad, det, tx, ty, tz);
163
164 Double_t r, phi, cosPhi, sinPhi;
165 r = -tx*rot[1] + ty*rot[0];
166 if (lay == 1) r = -r;
167 phi = TMath::ATan2(rot[1], rot[0]);
168 if (lay==1) phi -= 3.1415927;
169 cosPhi = TMath::Cos(phi);
170 sinPhi = TMath::Sin(phi);
171 fX = r*cosPhi + rp->GetY()*sinPhi;
172 fY = -r*sinPhi + rp->GetY()*cosPhi;
173 fZ = rp->GetZ();
174 fEX = TMath::Sqrt(rp->GetSigmaY2())*sinPhi;
175 fEY = TMath::Sqrt(rp->GetSigmaY2())*cosPhi;
176 fEZ = TMath::Sqrt(rp->GetSigmaZ2());
177 fLayer--;
178}
179//
180//-------------------------------------------------------------------------------------------------
181//
182Double_t AliITSNeuralPoint::GetPhi() const
b9d722bc 183{
853a0f19 184 // Returns the azimuthal coordinate in the range 0-2pi
b9d722bc 185 Double_t q;
186 q = TMath::ATan2(fY,fX);
187 if (q >= 0.)
188 return q;
189 else
190 return q + 2.0*TMath::Pi();
191}
192//
193//------------------------------------------------------------------------------------------------------
194//
195Double_t AliITSNeuralPoint::GetError(Option_t *option)
853a0f19 196{
b9d722bc 197// Returns the error or the square error of
198// values related to the coordinates in different systems.
199// The option argument specifies the coordinate error desired:
200//
201// "R2" --> error in transverse radius
202// "R3" --> error in spherical radius
203// "PHI" --> error in azimuthal angle
204// "THETA" --> error in polar angle
205// "SQ" --> get the square of error
206//
207// In order to get the error on the cartesian coordinates
208// reference to the inline ErrX(), ErrY() adn ErrZ() methods.
853a0f19 209
b9d722bc 210 TString opt(option);
211 Double_t errorSq = 0.0;
212 opt.ToUpper();
213
214 if (opt.Contains("R2")) {
215 errorSq = fX*fX*fEX*fEX + fY*fY*fEY*fEY;
216 errorSq /= GetR2sq();
217 }
218 else if (opt.Contains("R3")) {
219 errorSq = fX*fX*fEX*fEX + fY*fY*fEY*fEY + fZ*fZ*fEZ*fEZ;
220 errorSq /= GetR3sq();
221 }
222 else if (opt.Contains("PHI")) {
223 errorSq = fY*fY*fEX*fEX;
224 errorSq += fX*fX*fEY*fEY;
225 errorSq /= GetR2sq() * GetR2sq();
226 }
227 else if (opt.Contains("THETA")) {
228 errorSq = fZ*fZ * (fX*fX*fEX*fEX + fY*fY*fEY*fEY);
229 errorSq += GetR2sq() * GetR2sq() * fEZ*fEZ;
230 errorSq /= GetR3sq() * GetR3sq() * GetR2() * GetR2();
231 }
232
233 if (!opt.Contains("SQ"))
234 return TMath::Sqrt(errorSq);
235 else
236 return errorSq;
237}
238//
239//------------------------------------------------------------------------------------------------------
240//
853a0f19 241Bool_t AliITSNeuralPoint::HasID(Int_t ID) const
242{
b9d722bc 243// Checks if the recpoint belongs to the GEANT track
244// whose label is specified in the argument
b9d722bc 245 if (ID<0)
246 return kFALSE;
247 else
248 return (fLabel[0]==ID || fLabel[1]==ID || fLabel[2]==ID);
249}
250//
251//------------------------------------------------------------------------------------------------------
252//
7d62fb64 253Int_t* AliITSNeuralPoint::SharedID(AliITSNeuralPoint *p) const
853a0f19 254{
b9d722bc 255// Checks if there is a GEANT track owning both
256// <this> and the recpoint in the argument
257// The return value is an array of 4 integers.
258// The firs integer returns the count of matches between labels of
259// <this> and labels of the argument (0 to 3)
260// The other three return the matched labels.
261// If a NULL pointer is passed, the array will be returned as:
262// {0, -1, -1, -1}
853a0f19 263
b9d722bc 264 Int_t i, *shared = new Int_t[4];
265 for (i = 0; i < 4; i++) shared[i] = -1;
266 shared[0] = 0;
267 if (!p) return shared;
268 for (i = 0; i < 3; i++) {
269 if (HasID(p->fLabel[i])) shared[i + 1] = p->fLabel[i];
270 shared[0]++;
271 }
272 return shared;
273}
274//
275//
276//
277void AliITSNeuralPoint::ConfMap(Double_t vx, Double_t vy)
278{
853a0f19 279// Performs conformal mapping vertex-constrained
280
b9d722bc 281 Double_t dx = fX - vx;
282 Double_t dy = vy - fY;
283 Double_t r2 = dx*dx + dy*dy;
284 fConfX = dx / r2;
285 fConfY = dy / r2;
286}