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