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