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