]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSmodule.cxx
Removing obsolete macros
[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.15  2003/03/21 13:58:14  masera
19 Fix to avoid out-of-detector fast rec points (problem occurring for tracks entering and exiting the same side of a sensitive volume)
20
21 Revision 1.14  2002/10/14 14:57:00  hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
23
24 Revision 1.10.4.2  2002/07/24 09:27:50  alibrary
25 Updating on VirtualMC
26
27 Revision 1.13  2002/06/12 18:59:47  nilsen
28 Added Starting track location to hit class and related changes to modules.
29 This is at present still fully backwards compatible since starting hits
30 are still written to the file. When aliroot v4.0 will be released, this
31 backwards compatiblity will be broken by removing the enterence hit, and making
32 the nessesary changes to module at that time.
33
34 Revision 1.12  2002/06/10 17:31:03  nilsen
35 Replaced TArrayI expansion with Root version.
36
37 Revision 1.11  2002/06/04 18:43:15  nilsen
38 Fix to avoid divide by zero problem in MedianHitG and MedianHitL for track
39 that enter and exit the same side of a detector sensitive volume. Needed
40 for Fast simulation. Thanks to Nicola Carrer.
41
42 Revision 1.10  2002/03/15 17:21:54  nilsen
43 Removed zero-ing of fModules variable in constructors.
44
45 Revision 1.9  2000/10/04 19:46:39  barbera
46 Corrected by F. Carminati for v3.04
47
48 Revision 1.8  2000/10/02 16:32:57  barbera
49 Forward declarations added and formatting
50
51 Revision 1.3.4.8  2000/10/02 15:55:26  barbera
52 Forward declarations added and formatting
53
54 Revision 1.7  2000/09/22 12:36:38  nilsen
55 Minor changes to improve compilation and create less NOISE.
56
57 Revision 1.6  2000/07/10 16:07:18  fca
58 Release version of ITS code
59
60 Revision 1.3.4.2  2000/03/02 21:42:29  nilsen 
61 Linked AliDetector::fDigit to AliITSmodule::fDigitsM and AliITS::fITSRecPoints
62 to AliITSmodule::fRecPointsM. Renamed AliITSmodule::fPointsM to fRecPointsM.
63 Removed the deletion of fDigitsM from the distructor since it is only a copy
64 of what is in AliDetector. Fixed a bug in the functions LineSegmentL and
65 LineSegmentG. Added two new versions of LineSegmentL and LineSegmentG to
66 additionaly return track number from the hit. Removed FastPoint function,
67 haven't found anywere it was used, also it had very many problems, should
68 just call FastPointSPD... .
69
70 Revision 1.3.4.1  2000/01/12 19:03:32  nilsen
71 This is the version of the files after the merging done in December 1999.
72 See the ReadMe110100.txt file for details
73
74 Revision 1.3  1999/10/04 15:20:12  fca
75 Correct syntax accepted by g++ but not standard for static members, remove minor warnings
76
77 Revision 1.2  1999/09/29 09:24:20  fca
78 Introduction of the Copyright and cvs Log
79
80 */
81
82 #include <TArrayI.h>
83
84 #include <stdlib.h>
85
86 #include "AliRun.h"
87 #include "AliITS.h"
88 #include "AliITShit.h"
89 #include "AliITSmodule.h"
90 #include "AliITSgeom.h"
91
92 ClassImp(AliITSmodule)
93
94 //_______________________________________________________________________
95 //
96 // Impementation of class AliITSmodule
97 //
98 // created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski 
99 //             R. Barbers, B. Batyunia, B. S. Nilsen
100 // ver 1.0     CERN 16.09.1999
101 //_______________________________________________________________________
102 //________________________________________________________________________
103 // 
104 // Constructors and deconstructor
105 //________________________________________________________________________
106 //
107 AliITSmodule::AliITSmodule() {
108     // constructor
109
110     fHitsM       = 0;
111     fTrackIndex  = 0;
112     fHitIndex    = 0;
113     fITS         = 0;
114
115 }
116 //_________________________________________________________________________
117 AliITSmodule::AliITSmodule(Int_t index) {
118   // constructor
119
120     fIndex      = index;
121     fHitsM      = new TObjArray();
122     fTrackIndex = new TArrayI(16);
123     fHitIndex   = new TArrayI(16);
124     fITS        = (AliITS*)(gAlice->GetDetector("ITS"));
125 }
126 //__________________________________________________________________________
127 AliITSmodule::~AliITSmodule() {
128     // The destructor for AliITSmodule. Before destoring AliITSmodule
129     // we must first destroy all of it's members.
130
131     if(fHitsM){
132       fHitsM->Delete();
133       delete fHitsM;
134       fHitsM = 0;
135     } // end if
136     delete fTrackIndex;
137     delete fHitIndex;
138     fITS = 0; // We don't delete this pointer since it is just a copy.
139 }
140 //____________________________________________________________________________
141 AliITSmodule::AliITSmodule(const AliITSmodule &source){
142 ////////////////////////////////////////////////////////////////////////
143 //     Copy Constructor 
144 ////////////////////////////////////////////////////////////////////////
145   printf("AliITSmodule error: AliITSmodule class has not to be copied! Exit.\n");
146   exit(1);
147 }
148
149 //_____________________________________________________________________________
150 AliITSmodule& AliITSmodule::operator=(const AliITSmodule &source){
151 ////////////////////////////////////////////////////////////////////////
152 //    Assignment operator 
153 ////////////////////////////////////////////////////////////////////////
154   printf("AliITSmodule error: AliITSmodule class has not to be copied! Exit.\n");
155   exit(1);
156   return *this; // fake return neded on Sun
157
158
159 //_________________________________________________________________________
160 // 
161 // Hits management
162 //__________________________________________________________________________
163 Int_t AliITSmodule::AddHit(AliITShit* hit,Int_t t,Int_t h) {
164 // Hits management
165
166   //printf("AddHit: beginning hit %p t h %d %d\n",hit,t,h);
167     fHitsM->AddLast(new AliITShit(*hit));
168     Int_t fNhitsM = fHitsM->GetEntriesFast();
169     if(fNhitsM-1>=fTrackIndex->GetSize()){ // need to expand the TArrayI
170       fTrackIndex->Set(fNhitsM+64);
171     } // end if
172     if(fNhitsM-1>=fHitIndex->GetSize()){ // need to expand the TArrayI
173       fHitIndex->Set(fNhitsM+64);
174     } // end if
175     (*fTrackIndex)[fNhitsM-1] = t;
176     (*fHitIndex)[fNhitsM-1]   = h;
177     return fNhitsM;
178 }
179 //___________________________________________________________________________
180 Double_t AliITSmodule::PathLength(Int_t index,AliITShit *itsHit1,
181                                   AliITShit *itsHit2){
182   // path lenght
183    Float_t  x1g,y1g,z1g;   
184    Float_t  x2g,y2g,z2g;
185    Double_t s;
186
187    itsHit1->GetPositionG(x1g,y1g,z1g);
188    itsHit2->GetPositionG(x2g,y2g,z2g);
189
190    s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
191                     ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
192                     ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g))  );
193    return s;
194 }
195 //___________________________________________________________________________
196 void AliITSmodule::PathLength(Int_t index,
197                               Float_t x,Float_t y,Float_t z,
198                               Int_t status,Int_t &nseg,
199                               Float_t &x1,Float_t &y1,Float_t &z1,
200                               Float_t &dx1,Float_t &dy1,Float_t &dz1,
201                               Int_t &flag){
202   // path length
203     static Float_t x0,y0,z0;
204
205     if ((status&0x0002)!=0){ // entering
206         x0 = x;
207         y0 = y;
208         z0 = z;
209         nseg = 0;
210         flag = 1;
211     }else{
212         x1 = x0;
213         y1 = y0;
214         z1 = z0;
215         dx1 = x-x1;
216         dy1 = y-y1;
217         dz1 = z-z1;
218         nseg++;
219         if ((status&0x0004)!=0) flag = 0; //exiting
220         if ((status&0x0001)!=0) flag = 2; // inside
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 Bool_t AliITSmodule::MedianHitG(AliITShit *h1,AliITShit *h2,
343                                 Float_t &x,Float_t &y,Float_t &z){
344     // Computes the mean hit location for a set of hits that make up a track
345     // passing through a volume. Returns kFALSE untill the the track leaves
346     // the volume.
347     // median hit
348    AliITSgeom *gm = fITS->GetITSgeom();
349    Float_t x1l=0.,y1l=0.,z1l=0.;
350    Float_t x2l=0.,y2l=0.,z2l=0.;
351    Float_t xMl,yMl=0,zMl;
352    Float_t l[3], g[3];
353
354    h1->GetPositionG(x1l,y1l,z1l);
355    h2->GetPositionG(x2l,y2l,z2l);
356
357    if((y2l*y1l)<0.) {
358      xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
359      zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
360    } else {
361      xMl = 0.5*(x1l+x2l);
362      zMl = 0.5*(z1l+z2l);
363    }
364
365    l[0] = xMl;
366    l[1] = yMl;
367    l[2] = zMl;
368    gm->LtoG(h1->GetModule(),l,g);
369    x = g[0];
370    y = g[1];
371    z = g[2];
372    return kTRUE;
373 }
374 //___________________________________________________________________________
375 void AliITSmodule::MedianHitG(Int_t index,
376                               Float_t hitx1,Float_t hity1,Float_t hitz1,
377                               Float_t hitx2,Float_t hity2,Float_t hitz2,
378                               Float_t &xMg, Float_t &yMg, Float_t &zMg){
379   // median hit
380    AliITSgeom *gm = fITS->GetITSgeom();
381    Float_t x1l,y1l,z1l;
382    Float_t x2l,y2l,z2l;
383    Float_t xMl,yMl=0,zMl;
384    Float_t l[3], g[3];
385
386    g[0] = hitx1;
387    g[1] = hity1;
388    g[2] = hitz1;
389    gm->GtoL(index,g,l);
390    x1l = l[0];
391    y1l = l[1];
392    z1l = l[2];
393
394    g[0] = hitx2;
395    g[1] = hity2;
396    g[2] = hitz2;
397    gm->GtoL(index,g,l);
398    x2l = l[0];
399    y2l = l[1];
400    z2l = l[2];
401
402    if((y2l*y1l)<0.) {
403      xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
404      zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
405    } else {
406      xMl = 0.5*(x1l+x2l);
407      zMl = 0.5*(z1l+z2l);
408    }
409
410    l[0] = xMl;
411    l[1] = yMl;
412    l[2] = zMl;
413    gm->LtoG(index,l,g);
414    xMg = g[0];
415    yMg = g[1];
416    zMg = g[2];
417 }
418 //___________________________________________________________________________
419 Bool_t AliITSmodule::MedianHitL( AliITShit *itsHit1, 
420                              AliITShit *itsHit2, 
421                              Float_t &xMl, Float_t &yMl, Float_t &zMl){
422   // median hit
423    Float_t x1l,y1l,z1l;
424    Float_t x2l,y2l,z2l;
425
426    itsHit1->GetPositionL(x1l,y1l,z1l);
427    itsHit2->GetPositionL(x2l,y2l,z2l);
428
429    yMl = 0.0;
430    if((y2l*y1l)<0.) {
431      xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
432      zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;       
433    } else {
434      xMl = 0.5*(x1l+x2l);
435      zMl = 0.5*(z1l+z2l);
436    }
437    return kTRUE;
438 }
439 //___________________________________________________________________________
440 void AliITSmodule::MedianHit(Int_t index,
441                              Float_t xg,Float_t yg,Float_t zg,
442                              Int_t status,
443                              Float_t &xMg,Float_t &yMg,Float_t &zMg,
444                              Int_t &flag){
445   // median hit
446    static Float_t x1,y1,z1;
447
448    if ((status&0x0002)!=0){ // entering
449        x1 = xg;
450        y1 = yg;
451        z1 = zg;
452        flag = 1;
453    } else if ((status&0x0004)!=0){ // exiting
454        MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
455        flag = 0;
456    } // end if
457    else  flag = 1;
458 }
459 //___________________________________________________________________________
460 void AliITSmodule::GetID(Int_t &lay,Int_t &lad,Int_t &det){
461   // get ID
462         fITS->GetITSgeom()->GetModuleId(fIndex,lay,lad,det);
463         return ;
464 }
465