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