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