]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSmodule.cxx
Release version of ITS code
[u/mrichter/AliRoot.git] / ITS / AliITSmodule.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 /*
17 $Log$
18 Revision 1.3.4.2  2000/03/02 21:42:29  nilsen 
19 Linked AliDetector::fDigit to AliITSmodule::fDigitsM and AliITS::fITSRecPoints
20 to AliITSmodule::fRecPointsM. Renamed AliITSmodule::fPointsM to fRecPointsM.
21 Removed the deletion of fDigitsM from the distructor since it is only a copy
22 of what is in AliDetector. Fixed a bug in the functions LineSegmentL and
23 LineSegmentG. Added two new versions of LineSegmentL and LineSegmentG to
24 additionaly return track number from the hit. Removed FastPoint function,
25 haven't found anywere it was used, also it had very many problems, should
26 just call FastPointSPD... .
27
28 Revision 1.3.4.1  2000/01/12 19:03:32  nilsen
29 This is the version of the files after the merging done in December 1999.
30 See the ReadMe110100.txt file for details
31
32 Revision 1.3  1999/10/04 15:20:12  fca
33 Correct syntax accepted by g++ but not standard for static members, remove minor warnings
34
35 Revision 1.2  1999/09/29 09:24:20  fca
36 Introduction of the Copyright and cvs Log
37
38 */
39
40
41 #include "AliRun.h"
42 #include "AliITS.h"
43
44 ClassImp(AliITSmodule)
45
46 //_______________________________________________________________________
47 //
48 // Impementation of class AliITSmodule
49 //
50 // created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski 
51 //             R. Barbers, B. Batyunia, B. S. Nilsen
52 // ver 1.0     CERN 16.09.1999
53 //_______________________________________________________________________
54 //________________________________________________________________________
55 // 
56 // Constructors and deconstructor
57 //________________________________________________________________________
58 //
59 AliITSmodule::AliITSmodule() {
60   // constructor
61     fIndex       = 0;
62     fHitsM       = 0;
63     fTrackIndex  = 0;
64     fHitIndex    = 0;
65     fITS         = 0;
66
67 }
68 //_________________________________________________________________________
69 AliITSmodule::AliITSmodule(Int_t index) {
70   // constructor
71
72     fIndex      = index;
73     fHitsM      = new TObjArray();
74     fTrackIndex = new TArrayI(16);
75     fHitIndex   = new TArrayI(16);
76     fITS        = (AliITS*)(gAlice->GetDetector("ITS"));
77 }
78 //__________________________________________________________________________
79 AliITSmodule::~AliITSmodule() {
80     // The destructor for AliITSmodule. Before destoring AliITSmodule
81     // we must first destroy all of it's members.
82
83     fIndex   = 0;
84     if(fHitsM){
85         for(Int_t i=0;i<fHitsM->GetEntriesFast();i++) 
86             delete ((AliITShit *)(fHitsM->At(i)));
87         // must delete each object in the TObjArray.
88         delete fHitsM;
89     } // end if
90     delete fTrackIndex;
91     delete fHitIndex;
92     fITS = 0; // We don't delete this pointer since it is just a copy.
93 }
94 //____________________________________________________________________________
95 AliITSmodule::AliITSmodule(const AliITSmodule &source){
96 ////////////////////////////////////////////////////////////////////////
97 //     Copy Constructor 
98 ////////////////////////////////////////////////////////////////////////
99   printf("AliITSmodule error: AliITSmodule class has not to be copied! Exit.\n");
100   exit(1);
101 }
102
103 //_____________________________________________________________________________
104 AliITSmodule& AliITSmodule::operator=(const AliITSmodule &source){
105 ////////////////////////////////////////////////////////////////////////
106 //    Assignment operator 
107 ////////////////////////////////////////////////////////////////////////
108   printf("AliITSmodule error: AliITSmodule class has not to be copied! Exit.\n");
109   exit(1);
110   return *this; // fake return neded on Sun
111
112
113 //_________________________________________________________________________
114 // 
115 // Hits management
116 //__________________________________________________________________________
117 Int_t AliITSmodule::AddHit(AliITShit* hit,Int_t t,Int_t h) {
118 // Hits management
119
120     fHitsM->AddLast(new AliITShit(*hit));
121     Int_t fNhitsM = fHitsM->GetEntriesFast();
122     if(fNhitsM-1>=fTrackIndex->GetSize()){ // need to expand the TArrayI
123         TArrayI *p = new TArrayI(fNhitsM+64);
124         for(Int_t i=0;i<fTrackIndex->GetSize();i++) 
125             (*p)[i] = fTrackIndex->At(i);
126         delete fTrackIndex;
127         fTrackIndex = p;
128     } // end if
129     if(fNhitsM-1>=fHitIndex->GetSize()){ // need to expand the TArrayI
130         TArrayI *p = new TArrayI(fNhitsM+64);
131         for(Int_t i=0;i<fHitIndex->GetSize();i++) 
132             (*p)[i] = fHitIndex->At(i);
133         delete fHitIndex;
134         fHitIndex = p;
135     } // end if
136     (*fTrackIndex)[fNhitsM-1] = t;
137     (*fHitIndex)[fNhitsM-1]   = h;
138     return fNhitsM;
139 }
140
141 //___________________________________________________________________________
142 void AliITSmodule::MedianHitG(Int_t index,
143                               Float_t hitx1,Float_t hity1,Float_t hitz1,
144                               Float_t hitx2,Float_t hity2,Float_t hitz2,
145                               Float_t &xMg, Float_t &yMg, Float_t &zMg){
146   // median hit
147    AliITSgeom *gm = fITS->GetITSgeom();
148    Float_t x1l,y1l,z1l;
149    Float_t x2l,y2l,z2l;
150    Float_t xMl,yMl=0,zMl;
151    Float_t l[3], g[3];
152
153    g[0] = hitx1;
154    g[1] = hity1;
155    g[2] = hitz1;
156    gm->GtoL(index,g,l);
157    x1l = l[0];
158    y1l = l[1];
159    z1l = l[2];
160
161    g[0] = hitx2;
162    g[1] = hity2;
163    g[2] = hitz2;
164    gm->GtoL(index,g,l);
165    x2l = l[0];
166    y2l = l[1];
167    z2l = l[2];
168
169    xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
170    zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
171
172    l[0] = xMl;
173    l[1] = yMl;
174    l[2] = zMl;
175    gm->LtoG(index,l,g);
176    xMg = g[0];
177    yMg = g[1];
178    zMg = g[2];
179 }
180 //___________________________________________________________________________
181 Double_t AliITSmodule::PathLength(Int_t index,AliITShit *itsHit1,
182                                   AliITShit *itsHit2){
183   // path lenght
184    Float_t  x1g,y1g,z1g;   
185    Float_t  x2g,y2g,z2g;
186    Double_t s;
187
188    itsHit1->GetPositionG(x1g,y1g,z1g);
189    itsHit2->GetPositionG(x2g,y2g,z2g);
190
191    s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
192                     ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
193                     ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g))  );
194    return s;
195 }
196 //___________________________________________________________________________
197 void AliITSmodule::PathLength(Int_t index,
198                               Float_t x,Float_t y,Float_t z,
199                               Int_t status,Int_t &nseg,
200                               Float_t &x1,Float_t &y1,Float_t &z1,
201                               Float_t &dx1,Float_t &dy1,Float_t &dz1,
202                               Int_t &flag){
203   // path length
204     static Float_t x0,y0,z0;
205
206     if (status == 66){ // entering
207         x0 = x;
208         y0 = y;
209         z0 = z;
210         nseg = 0;
211         flag = 1;
212     }else{
213         x1 = x0;
214         y1 = y0;
215         z1 = z0;
216         dx1 = x-x1;
217         dy1 = y-y1;
218         dz1 = z-z1;
219         nseg++;
220         if (status == 68) flag = 0; //exiting
221         else flag = 2; //inside
222         x0 = x;
223         y0 = y;
224         z0 = z;
225     } // end if
226 }
227 //___________________________________________________________________________
228 Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
229                                   Double_t &c,Double_t &d,
230                                   Double_t &e,Double_t &f,Double_t &de){
231   // line segment
232     static Int_t hitindex0;
233     AliITShit *h0,*h1;
234
235     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
236
237     h1 = (AliITShit *) (fHitsM->At(hitindex));
238     if(h1->StatusEntering()){ // if track entering volume, get index for next
239                               // step
240         hitindex0 = hitindex;
241         return kFALSE;
242     } // end if StatusEntering()
243     // else stepping
244     h0 = (AliITShit *) (fHitsM->At(hitindex0));
245     de = h1->GetIonization();
246     h0->GetPositionL(a,c,e);
247     h1->GetPositionL(b,d,f);
248     b = b - a;
249     d = d - c;
250     f = f - e;
251     hitindex0 = hitindex;
252     return kTRUE;
253 }
254 //___________________________________________________________________________
255 Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
256                                   Double_t &c,Double_t &d,
257                                   Double_t &e,Double_t &f,Double_t &de){
258   // line segment
259     static Int_t hitindex0;
260     AliITShit *h0,*h1;
261
262     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
263
264     h1 = (AliITShit *) (fHitsM->At(hitindex));
265     if(h1->StatusEntering()){ // if track entering volume, get index for next
266                               // step
267         hitindex0 = hitindex;
268         return kFALSE;
269     } // end if StatusEntering()
270     // else stepping
271     h0 = (AliITShit *) (fHitsM->At(hitindex0));
272     de = h1->GetIonization();
273     h0->GetPositionG(a,c,e);
274     h1->GetPositionG(b,d,f);
275     b = b - a;
276     d = d - c;
277     f = f - e;
278     hitindex0 = hitindex;
279     return kTRUE;
280 }
281 //___________________________________________________________________________
282 Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
283                                   Double_t &c,Double_t &d,
284                                   Double_t &e,Double_t &f,
285                                   Double_t &de,Int_t &track){
286   // line segmente
287     static Int_t hitindex0;
288     AliITShit *h0,*h1;
289
290     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
291
292     h1 = (AliITShit *) (fHitsM->At(hitindex));
293     if(h1->StatusEntering()){ // if track entering volume, get index for next
294                               // step
295         hitindex0 = hitindex;
296         track = h1->GetTrack();
297         return kFALSE;
298     } // end if StatusEntering()
299     // else stepping
300     h0 = (AliITShit *) (fHitsM->At(hitindex0));
301     de = h1->GetIonization();
302     h0->GetPositionL(a,c,e);
303     h1->GetPositionL(b,d,f);
304     b = b - a;
305     d = d - c;
306     f = f - e;
307     hitindex0 = hitindex;
308     track = h1->GetTrack();
309     return kTRUE;
310 }
311 //___________________________________________________________________________
312 Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
313                                   Double_t &c,Double_t &d,
314                                   Double_t &e,Double_t &f,
315                                   Double_t &de,Int_t &track){
316   // line segment
317     static Int_t hitindex0;
318     AliITShit *h0,*h1;
319
320     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
321
322     h1 = (AliITShit *) (fHitsM->At(hitindex));
323     if(h1->StatusEntering()){ // if track entering volume, get index for next
324                               // step
325         hitindex0 = hitindex;
326         track = h1->GetTrack();
327         return kFALSE;
328     } // end if StatusEntering()
329     // else stepping
330     h0 = (AliITShit *) (fHitsM->At(hitindex0));
331     de = h1->GetIonization();
332     h0->GetPositionG(a,c,e);
333     h1->GetPositionG(b,d,f);
334     b = b - a;
335     d = d - c;
336     f = f - e;
337     hitindex0 = hitindex;
338     track = h1->GetTrack();
339     return kTRUE;
340 }
341 //___________________________________________________________________________
342 void AliITSmodule::MedianHitL(Int_t index, 
343                              AliITShit *itsHit1, 
344                              AliITShit *itsHit2, 
345                              Float_t &xMl, Float_t &yMl, Float_t &zMl){
346   // median hit
347    Float_t x1l,y1l,z1l;
348    Float_t x2l,y2l,z2l;
349
350    itsHit1->GetPositionL(x1l,y1l,z1l);
351    itsHit2->GetPositionL(x2l,y2l,z2l);
352
353    xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
354    yMl = 0.0;
355    zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;         
356 }
357 //___________________________________________________________________________
358 void AliITSmodule::MedianHit(Int_t index,
359                              Float_t xg,Float_t yg,Float_t zg,
360                              Int_t status,
361                              Float_t &xMg,Float_t &yMg,Float_t &zMg,
362                              Int_t &flag){
363   // median hit
364    static Float_t x1,y1,z1;
365
366    if (status == 66){ // entering
367        x1 = xg;
368        y1 = yg;
369        z1 = zg;
370        flag = 1;
371    } // end if
372    if (status == 68){ // exiting
373        MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
374        flag = 0;
375    } // end if
376    if ((status != 66) && (status != 68)) flag = 1;
377 }
378 //___________________________________________________________________________
379 void AliITSmodule::GetID(Int_t &lay,Int_t &lad,Int_t &det){
380   // get ID
381         fITS->GetITSgeom()->GetModuleId(fIndex,lay,lad,det);
382         return ;
383 }
384