]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUModule.cxx
Lot of update + directory with test setup
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUModule.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id: AliITSUModule.cxx 53509 2011-12-10 18:55:52Z masera $ */
17
18 #include <TArrayI.h>
19
20 #include <stdlib.h>
21
22 #include "AliRun.h"
23 #include "AliITS.h"
24 #include "AliITSUModule.h"
25 #include "AliITSUGeomTGeo.h"
26
27 ClassImp(AliITSUModule)
28
29 //_______________________________________________________________________
30 //
31 // Impementation of class AliITSUModule
32 //
33 // created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski 
34 //             R. Barbers, B. Batyunia, B. S. Nilsen
35 // ver 1.0     CERN 16.09.1999
36 //_______________________________________________________________________
37 //________________________________________________________________________
38 // 
39 // Constructors and deconstructor
40 //________________________________________________________________________
41 //
42 AliITSUModule::AliITSUModule()
43 :  fHitsM(0)
44   ,fGeomTG(0)
45 {
46   // constructor
47 }
48
49 //_________________________________________________________________________
50 AliITSUModule::AliITSUModule(Int_t index, AliITSUGeomTGeo* tg)
51   :fHitsM(new TObjArray())
52   ,fGeomTG(tg)
53 {
54   // constructor
55   SetIndex(index);
56 }
57
58 //__________________________________________________________________________
59 AliITSUModule::~AliITSUModule() 
60 {
61   // The destructor for AliITSUModule. Before destoring AliITSUModule
62   // we must first destroy all of it's members.
63   if (fHitsM) fHitsM->Clear();
64   delete fHitsM;
65 }
66
67 //____________________________________________________________________________
68 AliITSUModule::AliITSUModule(const AliITSUModule &source)
69  :TObject(source)
70  ,fHitsM(source.fHitsM)
71  ,fGeomTG(source.fGeomTG)
72 {
73 //     Copy Constructor 
74 }
75
76 //_____________________________________________________________________________
77 AliITSUModule& AliITSUModule::operator=(const AliITSUModule &source)
78 {
79   //    Assignment operator 
80   if (this!=&source) {
81     this->~AliITSUModule();
82     new(this) AliITSUModule(source);
83   }
84   return *this;
85 }
86
87 //___________________________________________________________________________
88 Double_t AliITSUModule::PathLength(const AliITSUHit *itsHit1,const AliITSUHit *itsHit2) 
89 {
90   // path lenght
91   Float_t  x1g,y1g,z1g;   
92   Float_t  x2g,y2g,z2g;
93   Double_t s;
94   //
95   itsHit1->GetPositionG(x1g,y1g,z1g);
96   itsHit2->GetPositionG(x2g,y2g,z2g);
97   //
98   s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
99                    ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
100                    ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g))  );
101    return s;
102 }
103
104 //___________________________________________________________________________
105 void AliITSUModule::PathLength(Float_t x,Float_t y,Float_t z,Int_t status,Int_t &nseg,Float_t &x1,Float_t &y1,Float_t &z1,
106                               Float_t &dx1,Float_t &dy1,Float_t &dz1,Int_t &flag) const
107 {
108   // path length
109   static Float_t x0,y0,z0;
110   //
111   if ((status&0x0002)!=0){ // entering
112     x0 = x;
113     y0 = y;
114     z0 = z;
115     nseg = 0;
116     flag = 1;
117   }else{
118     x1 = x0;
119     y1 = y0;
120     z1 = z0;
121     dx1 = x-x1;
122     dy1 = y-y1;
123     dz1 = z-z1;
124     nseg++;
125     if ((status&0x0004)!=0) flag = 0; //exiting
126     if ((status&0x0001)!=0) flag = 2; // inside
127     else flag = 2; //inside ?
128     x0 = x;
129     y0 = y;
130     z0 = z;
131   } // end if
132 }
133
134 //___________________________________________________________________________
135 Bool_t AliITSUModule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
136                                   Double_t &e,Double_t &f,Double_t &de)
137 {
138   // line segment
139   AliITSUHit *h1;
140   Double_t t;
141   //  
142   if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
143   //
144   h1 = (AliITSUHit *) (fHitsM->At(hitindex));
145   if(h1->StatusEntering()) return kFALSE; // if track entering volume, get index for next step
146   de = h1->GetIonization();
147   h1->GetPositionL0(a,c,e,t);
148   h1->GetPositionL(b,d,f);
149   b = b - a;
150   d = d - c;
151   f = f - e;
152   return kTRUE;
153 }
154
155 //___________________________________________________________________________
156 Bool_t AliITSUModule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
157                                   Double_t &e,Double_t &f,Double_t &de)
158 {
159   // line segment
160   AliITSUHit *h1;
161   Double_t t;
162   //
163   if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
164   h1 = (AliITSUHit *) (fHitsM->At(hitindex));
165   if(h1->StatusEntering()) return kFALSE; // if track entering volume, get index for next step
166   de = h1->GetIonization();
167   h1->GetPositionG0(a,c,e,t);
168   h1->GetPositionG(b,d,f);
169   b = b - a;
170   d = d - c;
171   f = f - e;
172   return kTRUE;
173 }
174
175 //___________________________________________________________________________
176 Bool_t AliITSUModule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
177                                   Double_t &e,Double_t &f,Double_t &de,Int_t &track)
178 {
179   // line segmente
180   AliITSUHit *h1;
181   Double_t t;
182   //
183   if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
184   //
185   h1 = (AliITSUHit *) (fHitsM->At(hitindex));
186   if(h1->StatusEntering()){ // if track entering volume, get index for next
187     // step
188     track = h1->GetTrack();
189     return kFALSE;
190   } // end if StatusEntering()
191     // else stepping
192   de = h1->GetIonization();
193   h1->GetPositionL0(a,c,e,t);
194   h1->GetPositionL(b,d,f);
195   b = b - a;
196   d = d - c;
197   f = f - e;
198   track = h1->GetTrack();
199   return kTRUE;
200 }
201
202 //___________________________________________________________________________
203 Bool_t AliITSUModule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
204                                   Double_t &e,Double_t &f,Double_t &de,Int_t &track)
205 {
206   // line segment
207   AliITSUHit *h1;
208   Double_t t;
209   //
210   if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
211   //
212   h1 = (AliITSUHit *) (fHitsM->At(hitindex));
213   if(h1->StatusEntering()){ // if track entering volume, get index for next
214     // step
215     track = h1->GetTrack();
216     return kFALSE;
217   } // end if StatusEntering()
218   de = h1->GetIonization();
219   h1->GetPositionG0(a,c,e,t);
220   h1->GetPositionG(b,d,f);
221   b = b - a;
222   d = d - c;
223   f = f - e;
224   track = h1->GetTrack();
225   return kTRUE;
226 }
227
228 //______________________________________________________________________
229 Bool_t AliITSUModule::MedianHitG(AliITSUHit *h1,AliITSUHit *h2,Float_t &x,Float_t &y,Float_t &z)
230 {
231   // Computes the mean hit location for a set of hits that make up a track
232   // passing through a volume. Returns kFALSE untill the the track leaves
233   // the volume.
234   // median hit
235   Float_t x1l=0.,y1l=0.,z1l=0.;
236   Float_t x2l=0.,y2l=0.,z2l=0.;
237   Float_t xMl,yMl=0,zMl;
238   Double_t l[3], g[3];
239   
240   h1->GetPositionG(x1l,y1l,z1l);
241   h2->GetPositionG(x2l,y2l,z2l);
242   
243   if((y2l*y1l)<0.) {
244     xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
245     zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
246   } else {
247     xMl = 0.5*(x1l+x2l);
248     zMl = 0.5*(z1l+z2l);
249   }
250   
251   l[0] = xMl;
252   l[1] = yMl;
253   l[2] = zMl;
254   fGeomTG->LocalToGlobal(h1->GetModule(),l,g);
255   x = g[0];
256   y = g[1];
257   z = g[2];
258   return kTRUE;
259 }
260
261 //___________________________________________________________________________
262 void AliITSUModule::MedianHitG(Int_t index,Float_t hitx1,Float_t hity1,Float_t hitz1,Float_t hitx2,Float_t hity2,Float_t hitz2,
263                                  Float_t &xMg, Float_t &yMg, Float_t &zMg)
264 {
265   // median hit
266   Float_t x1l,y1l,z1l;
267   Float_t x2l,y2l,z2l;
268   Float_t xMl,yMl=0,zMl;
269   Double_t l[3], g[3];
270   
271   g[0] = hitx1;
272   g[1] = hity1;
273   g[2] = hitz1;
274   fGeomTG->GlobalToLocal(index,g,l);
275   x1l = l[0];
276   y1l = l[1];
277   z1l = l[2];
278   
279   g[0] = hitx2;
280   g[1] = hity2;
281   g[2] = hitz2;
282   fGeomTG->GlobalToLocal(index,g,l);
283   x2l = l[0];
284   y2l = l[1];
285   z2l = l[2];
286   
287   if((y2l*y1l)<0.) {
288     xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
289     zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
290   } else {
291     xMl = 0.5*(x1l+x2l);
292     zMl = 0.5*(z1l+z2l);
293   }
294   
295   l[0] = xMl;
296   l[1] = yMl;
297   l[2] = zMl;
298   fGeomTG->LocalToGlobal(index,l,g);
299   xMg = g[0];
300   yMg = g[1];
301   zMg = g[2];
302 }
303
304 //___________________________________________________________________________
305 Bool_t AliITSUModule::MedianHitL( AliITSUHit *itsHit1,AliITSUHit *itsHit2, Float_t &xMl, Float_t &yMl, Float_t &zMl) const
306 {
307   // median hit
308   Float_t x1l,y1l,z1l;
309   Float_t x2l,y2l,z2l;
310   
311   itsHit1->GetPositionL(x1l,y1l,z1l);
312   itsHit2->GetPositionL(x2l,y2l,z2l);
313   
314   yMl = 0.0;
315   if((y2l*y1l)<0.) {
316     xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
317     zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;        
318   } else {
319     xMl = 0.5*(x1l+x2l);
320     zMl = 0.5*(z1l+z2l);
321   }
322   return kTRUE;
323 }
324
325 //___________________________________________________________________________
326 void AliITSUModule::MedianHit(Int_t index,Float_t xg,Float_t yg,Float_t zg,Int_t status,
327                              Float_t &xMg,Float_t &yMg,Float_t &zMg,Int_t &flag)
328 {
329   // median hit
330   static Float_t x1,y1,z1;
331   //
332   if ((status&0x0002)!=0){ // entering
333     x1 = xg;
334     y1 = yg;
335     z1 = zg;
336     flag = 1;
337   } else if ((status&0x0004)!=0){ // exiting
338     MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
339     flag = 0;
340   } // end if
341   else  flag = 1;
342 }
343
344