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