]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3bd79107 | 3 | * * |
4c039060 | 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$ | |
6d48704c | 18 | Revision 1.14 2002/10/14 14:57:00 hristov |
19 | Merging the VirtualMC branch to the main development branch (HEAD) | |
20 | ||
b9d0a01d | 21 | Revision 1.10.4.2 2002/07/24 09:27:50 alibrary |
22 | Updating on VirtualMC | |
23 | ||
24 | Revision 1.13 2002/06/12 18:59:47 nilsen | |
25 | Added Starting track location to hit class and related changes to modules. | |
26 | This is at present still fully backwards compatible since starting hits | |
27 | are still written to the file. When aliroot v4.0 will be released, this | |
28 | backwards compatiblity will be broken by removing the enterence hit, and making | |
29 | the nessesary changes to module at that time. | |
30 | ||
7e3ded1b | 31 | Revision 1.12 2002/06/10 17:31:03 nilsen |
32 | Replaced TArrayI expansion with Root version. | |
33 | ||
ea008941 | 34 | Revision 1.11 2002/06/04 18:43:15 nilsen |
35 | Fix to avoid divide by zero problem in MedianHitG and MedianHitL for track | |
36 | that enter and exit the same side of a detector sensitive volume. Needed | |
37 | for Fast simulation. Thanks to Nicola Carrer. | |
38 | ||
37ffef26 | 39 | Revision 1.10 2002/03/15 17:21:54 nilsen |
40 | Removed zero-ing of fModules variable in constructors. | |
41 | ||
b0f0d5a5 | 42 | Revision 1.9 2000/10/04 19:46:39 barbera |
43 | Corrected by F. Carminati for v3.04 | |
44 | ||
114da3a4 | 45 | Revision 1.8 2000/10/02 16:32:57 barbera |
46 | Forward declarations added and formatting | |
47 | ||
0b2d41b4 | 48 | Revision 1.3.4.8 2000/10/02 15:55:26 barbera |
49 | Forward declarations added and formatting | |
50 | ||
51 | Revision 1.7 2000/09/22 12:36:38 nilsen | |
52 | Minor changes to improve compilation and create less NOISE. | |
53 | ||
ff61221e | 54 | Revision 1.6 2000/07/10 16:07:18 fca |
55 | Release version of ITS code | |
56 | ||
3bd79107 | 57 | Revision 1.3.4.2 2000/03/02 21:42:29 nilsen |
58 | Linked AliDetector::fDigit to AliITSmodule::fDigitsM and AliITS::fITSRecPoints | |
59 | to AliITSmodule::fRecPointsM. Renamed AliITSmodule::fPointsM to fRecPointsM. | |
60 | Removed the deletion of fDigitsM from the distructor since it is only a copy | |
61 | of what is in AliDetector. Fixed a bug in the functions LineSegmentL and | |
62 | LineSegmentG. Added two new versions of LineSegmentL and LineSegmentG to | |
63 | additionaly return track number from the hit. Removed FastPoint function, | |
64 | haven't found anywere it was used, also it had very many problems, should | |
65 | just call FastPointSPD... . | |
66 | ||
67 | Revision 1.3.4.1 2000/01/12 19:03:32 nilsen | |
68 | This is the version of the files after the merging done in December 1999. | |
69 | See the ReadMe110100.txt file for details | |
70 | ||
71 | Revision 1.3 1999/10/04 15:20:12 fca | |
72 | Correct syntax accepted by g++ but not standard for static members, remove minor warnings | |
73 | ||
ad0e60d9 | 74 | Revision 1.2 1999/09/29 09:24:20 fca |
75 | Introduction of the Copyright and cvs Log | |
76 | ||
4c039060 | 77 | */ |
78 | ||
ff61221e | 79 | #include <TArrayI.h> |
80 | ||
114da3a4 | 81 | #include <stdlib.h> |
3bd79107 | 82 | |
58005f18 | 83 | #include "AliRun.h" |
3bd79107 | 84 | #include "AliITS.h" |
ff61221e | 85 | #include "AliITShit.h" |
86 | #include "AliITSmodule.h" | |
87 | #include "AliITSgeom.h" | |
58005f18 | 88 | |
89 | ClassImp(AliITSmodule) | |
90 | ||
91 | //_______________________________________________________________________ | |
92 | // | |
93 | // Impementation of class AliITSmodule | |
94 | // | |
3bd79107 | 95 | // created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski |
58005f18 | 96 | // R. Barbers, B. Batyunia, B. S. Nilsen |
97 | // ver 1.0 CERN 16.09.1999 | |
98 | //_______________________________________________________________________ | |
58005f18 | 99 | //________________________________________________________________________ |
100 | // | |
101 | // Constructors and deconstructor | |
102 | //________________________________________________________________________ | |
103 | // | |
3bd79107 | 104 | AliITSmodule::AliITSmodule() { |
b0f0d5a5 | 105 | // constructor |
106 | ||
3bd79107 | 107 | fHitsM = 0; |
108 | fTrackIndex = 0; | |
109 | fHitIndex = 0; | |
110 | fITS = 0; | |
58005f18 | 111 | |
3bd79107 | 112 | } |
113 | //_________________________________________________________________________ | |
114 | AliITSmodule::AliITSmodule(Int_t index) { | |
115 | // constructor | |
58005f18 | 116 | |
3bd79107 | 117 | fIndex = index; |
118 | fHitsM = new TObjArray(); | |
119 | fTrackIndex = new TArrayI(16); | |
120 | fHitIndex = new TArrayI(16); | |
121 | fITS = (AliITS*)(gAlice->GetDetector("ITS")); | |
122 | } | |
123 | //__________________________________________________________________________ | |
124 | AliITSmodule::~AliITSmodule() { | |
125 | // The destructor for AliITSmodule. Before destoring AliITSmodule | |
126 | // we must first destroy all of it's members. | |
58005f18 | 127 | |
3bd79107 | 128 | if(fHitsM){ |
e8189707 | 129 | for(Int_t i=0;i<fHitsM->GetEntriesFast();i++) |
3bd79107 | 130 | delete ((AliITShit *)(fHitsM->At(i))); |
131 | // must delete each object in the TObjArray. | |
132 | delete fHitsM; | |
133 | } // end if | |
134 | delete fTrackIndex; | |
135 | delete fHitIndex; | |
136 | fITS = 0; // We don't delete this pointer since it is just a copy. | |
137 | } | |
138 | //____________________________________________________________________________ | |
139 | AliITSmodule::AliITSmodule(const AliITSmodule &source){ | |
140 | //////////////////////////////////////////////////////////////////////// | |
141 | // Copy Constructor | |
142 | //////////////////////////////////////////////////////////////////////// | |
143 | printf("AliITSmodule error: AliITSmodule class has not to be copied! Exit.\n"); | |
144 | exit(1); | |
58005f18 | 145 | } |
146 | ||
3bd79107 | 147 | //_____________________________________________________________________________ |
148 | AliITSmodule& AliITSmodule::operator=(const AliITSmodule &source){ | |
149 | //////////////////////////////////////////////////////////////////////// | |
150 | // Assignment operator | |
151 | //////////////////////////////////////////////////////////////////////// | |
152 | printf("AliITSmodule error: AliITSmodule class has not to be copied! Exit.\n"); | |
153 | exit(1); | |
e8189707 | 154 | return *this; // fake return neded on Sun |
3bd79107 | 155 | } |
58005f18 | 156 | |
157 | //_________________________________________________________________________ | |
3bd79107 | 158 | // |
159 | // Hits management | |
160 | //__________________________________________________________________________ | |
161 | Int_t AliITSmodule::AddHit(AliITShit* hit,Int_t t,Int_t h) { | |
162 | // Hits management | |
58005f18 | 163 | |
ff61221e | 164 | //printf("AddHit: beginning hit %p t h %d %d\n",hit,t,h); |
3bd79107 | 165 | fHitsM->AddLast(new AliITShit(*hit)); |
166 | Int_t fNhitsM = fHitsM->GetEntriesFast(); | |
167 | if(fNhitsM-1>=fTrackIndex->GetSize()){ // need to expand the TArrayI | |
ea008941 | 168 | fTrackIndex->Set(fNhitsM+64); |
3bd79107 | 169 | } // end if |
170 | if(fNhitsM-1>=fHitIndex->GetSize()){ // need to expand the TArrayI | |
ea008941 | 171 | fHitIndex->Set(fNhitsM+64); |
3bd79107 | 172 | } // end if |
173 | (*fTrackIndex)[fNhitsM-1] = t; | |
174 | (*fHitIndex)[fNhitsM-1] = h; | |
175 | return fNhitsM; | |
176 | } | |
3bd79107 | 177 | //___________________________________________________________________________ |
178 | Double_t AliITSmodule::PathLength(Int_t index,AliITShit *itsHit1, | |
179 | AliITShit *itsHit2){ | |
180 | // path lenght | |
181 | Float_t x1g,y1g,z1g; | |
182 | Float_t x2g,y2g,z2g; | |
183 | Double_t s; | |
58005f18 | 184 | |
3bd79107 | 185 | itsHit1->GetPositionG(x1g,y1g,z1g); |
186 | itsHit2->GetPositionG(x2g,y2g,z2g); | |
58005f18 | 187 | |
3bd79107 | 188 | s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) + |
189 | ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) + | |
190 | ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g)) ); | |
191 | return s; | |
192 | } | |
193 | //___________________________________________________________________________ | |
194 | void AliITSmodule::PathLength(Int_t index, | |
195 | Float_t x,Float_t y,Float_t z, | |
196 | Int_t status,Int_t &nseg, | |
197 | Float_t &x1,Float_t &y1,Float_t &z1, | |
198 | Float_t &dx1,Float_t &dy1,Float_t &dz1, | |
199 | Int_t &flag){ | |
200 | // path length | |
201 | static Float_t x0,y0,z0; | |
58005f18 | 202 | |
7e3ded1b | 203 | if ((status&0x0002)!=0){ // entering |
3bd79107 | 204 | x0 = x; |
205 | y0 = y; | |
206 | z0 = z; | |
207 | nseg = 0; | |
208 | flag = 1; | |
209 | }else{ | |
210 | x1 = x0; | |
211 | y1 = y0; | |
212 | z1 = z0; | |
213 | dx1 = x-x1; | |
214 | dy1 = y-y1; | |
215 | dz1 = z-z1; | |
216 | nseg++; | |
7e3ded1b | 217 | if ((status&0x0004)!=0) flag = 0; //exiting |
218 | if ((status&0x0001)!=0) flag = 2; // inside | |
219 | else flag = 2; //inside ? | |
3bd79107 | 220 | x0 = x; |
221 | y0 = y; | |
222 | z0 = z; | |
223 | } // end if | |
58005f18 | 224 | } |
3bd79107 | 225 | //___________________________________________________________________________ |
226 | Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b, | |
227 | Double_t &c,Double_t &d, | |
228 | Double_t &e,Double_t &f,Double_t &de){ | |
229 | // line segment | |
230 | static Int_t hitindex0; | |
231 | AliITShit *h0,*h1; | |
58005f18 | 232 | |
3bd79107 | 233 | if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE; |
58005f18 | 234 | |
3bd79107 | 235 | h1 = (AliITShit *) (fHitsM->At(hitindex)); |
236 | if(h1->StatusEntering()){ // if track entering volume, get index for next | |
237 | // step | |
238 | hitindex0 = hitindex; | |
239 | return kFALSE; | |
240 | } // end if StatusEntering() | |
241 | // else stepping | |
242 | h0 = (AliITShit *) (fHitsM->At(hitindex0)); | |
243 | de = h1->GetIonization(); | |
244 | h0->GetPositionL(a,c,e); | |
245 | h1->GetPositionL(b,d,f); | |
246 | b = b - a; | |
247 | d = d - c; | |
248 | f = f - e; | |
249 | hitindex0 = hitindex; | |
250 | return kTRUE; | |
251 | } | |
252 | //___________________________________________________________________________ | |
253 | Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b, | |
254 | Double_t &c,Double_t &d, | |
255 | Double_t &e,Double_t &f,Double_t &de){ | |
256 | // line segment | |
257 | static Int_t hitindex0; | |
258 | AliITShit *h0,*h1; | |
58005f18 | 259 | |
3bd79107 | 260 | if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE; |
261 | ||
262 | h1 = (AliITShit *) (fHitsM->At(hitindex)); | |
263 | if(h1->StatusEntering()){ // if track entering volume, get index for next | |
264 | // step | |
265 | hitindex0 = hitindex; | |
266 | return kFALSE; | |
267 | } // end if StatusEntering() | |
268 | // else stepping | |
269 | h0 = (AliITShit *) (fHitsM->At(hitindex0)); | |
270 | de = h1->GetIonization(); | |
271 | h0->GetPositionG(a,c,e); | |
272 | h1->GetPositionG(b,d,f); | |
273 | b = b - a; | |
274 | d = d - c; | |
275 | f = f - e; | |
276 | hitindex0 = hitindex; | |
277 | return kTRUE; | |
278 | } | |
279 | //___________________________________________________________________________ | |
280 | Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b, | |
281 | Double_t &c,Double_t &d, | |
282 | Double_t &e,Double_t &f, | |
283 | Double_t &de,Int_t &track){ | |
284 | // line segmente | |
285 | static Int_t hitindex0; | |
286 | AliITShit *h0,*h1; | |
287 | ||
288 | if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE; | |
289 | ||
290 | h1 = (AliITShit *) (fHitsM->At(hitindex)); | |
291 | if(h1->StatusEntering()){ // if track entering volume, get index for next | |
292 | // step | |
293 | hitindex0 = hitindex; | |
294 | track = h1->GetTrack(); | |
295 | return kFALSE; | |
296 | } // end if StatusEntering() | |
297 | // else stepping | |
298 | h0 = (AliITShit *) (fHitsM->At(hitindex0)); | |
299 | de = h1->GetIonization(); | |
300 | h0->GetPositionL(a,c,e); | |
301 | h1->GetPositionL(b,d,f); | |
302 | b = b - a; | |
303 | d = d - c; | |
304 | f = f - e; | |
305 | hitindex0 = hitindex; | |
306 | track = h1->GetTrack(); | |
307 | return kTRUE; | |
308 | } | |
309 | //___________________________________________________________________________ | |
310 | Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b, | |
311 | Double_t &c,Double_t &d, | |
312 | Double_t &e,Double_t &f, | |
313 | Double_t &de,Int_t &track){ | |
314 | // line segment | |
315 | static Int_t hitindex0; | |
316 | AliITShit *h0,*h1; | |
317 | ||
318 | if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE; | |
319 | ||
320 | h1 = (AliITShit *) (fHitsM->At(hitindex)); | |
321 | if(h1->StatusEntering()){ // if track entering volume, get index for next | |
322 | // step | |
323 | hitindex0 = hitindex; | |
324 | track = h1->GetTrack(); | |
325 | return kFALSE; | |
326 | } // end if StatusEntering() | |
327 | // else stepping | |
328 | h0 = (AliITShit *) (fHitsM->At(hitindex0)); | |
329 | de = h1->GetIonization(); | |
330 | h0->GetPositionG(a,c,e); | |
331 | h1->GetPositionG(b,d,f); | |
332 | b = b - a; | |
333 | d = d - c; | |
334 | f = f - e; | |
335 | hitindex0 = hitindex; | |
336 | track = h1->GetTrack(); | |
337 | return kTRUE; | |
58005f18 | 338 | } |
7e3ded1b | 339 | //______________________________________________________________________ |
340 | Bool_t AliITSmodule::MedianHitG(AliITShit *h1,AliITShit *h2, | |
341 | Float_t &x,Float_t &y,Float_t &z){ | |
342 | // Computes the mean hit location for a set of hits that make up a track | |
343 | // passing through a volume. Returns kFALSE untill the the track leaves | |
344 | // the volume. | |
345 | // median hit | |
346 | AliITSgeom *gm = fITS->GetITSgeom(); | |
347 | Float_t x1l=0.,y1l=0.,z1l=0.; | |
348 | Float_t x2l=0.,y2l=0.,z2l=0.; | |
349 | Float_t xMl,yMl=0,zMl; | |
350 | Float_t l[3], g[3]; | |
351 | ||
352 | h1->GetPositionG(x1l,y1l,z1l); | |
353 | h2->GetPositionG(x2l,y2l,z2l); | |
354 | ||
6d48704c | 355 | if((y2l*y1l)<0.) { |
7e3ded1b | 356 | xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l; |
357 | zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l; | |
358 | } else { | |
359 | xMl = 0.5*(x1l+x2l); | |
360 | zMl = 0.5*(z1l+z2l); | |
361 | } | |
362 | ||
363 | l[0] = xMl; | |
364 | l[1] = yMl; | |
365 | l[2] = zMl; | |
366 | gm->LtoG(h1->GetModule(),l,g); | |
367 | x = g[0]; | |
368 | y = g[1]; | |
369 | z = g[2]; | |
370 | return kTRUE; | |
371 | } | |
372 | //___________________________________________________________________________ | |
373 | void AliITSmodule::MedianHitG(Int_t index, | |
374 | Float_t hitx1,Float_t hity1,Float_t hitz1, | |
375 | Float_t hitx2,Float_t hity2,Float_t hitz2, | |
376 | Float_t &xMg, Float_t &yMg, Float_t &zMg){ | |
377 | // median hit | |
378 | AliITSgeom *gm = fITS->GetITSgeom(); | |
379 | Float_t x1l,y1l,z1l; | |
380 | Float_t x2l,y2l,z2l; | |
381 | Float_t xMl,yMl=0,zMl; | |
382 | Float_t l[3], g[3]; | |
383 | ||
384 | g[0] = hitx1; | |
385 | g[1] = hity1; | |
386 | g[2] = hitz1; | |
387 | gm->GtoL(index,g,l); | |
388 | x1l = l[0]; | |
389 | y1l = l[1]; | |
390 | z1l = l[2]; | |
391 | ||
392 | g[0] = hitx2; | |
393 | g[1] = hity2; | |
394 | g[2] = hitz2; | |
395 | gm->GtoL(index,g,l); | |
396 | x2l = l[0]; | |
397 | y2l = l[1]; | |
398 | z2l = l[2]; | |
399 | ||
6d48704c | 400 | if((y2l*y1l)<0.) { |
7e3ded1b | 401 | xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l; |
402 | zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l; | |
403 | } else { | |
404 | xMl = 0.5*(x1l+x2l); | |
405 | zMl = 0.5*(z1l+z2l); | |
406 | } | |
407 | ||
408 | l[0] = xMl; | |
409 | l[1] = yMl; | |
410 | l[2] = zMl; | |
411 | gm->LtoG(index,l,g); | |
412 | xMg = g[0]; | |
413 | yMg = g[1]; | |
414 | zMg = g[2]; | |
415 | } | |
3bd79107 | 416 | //___________________________________________________________________________ |
7e3ded1b | 417 | Bool_t AliITSmodule::MedianHitL( AliITShit *itsHit1, |
3bd79107 | 418 | AliITShit *itsHit2, |
419 | Float_t &xMl, Float_t &yMl, Float_t &zMl){ | |
420 | // median hit | |
421 | Float_t x1l,y1l,z1l; | |
422 | Float_t x2l,y2l,z2l; | |
423 | ||
424 | itsHit1->GetPositionL(x1l,y1l,z1l); | |
425 | itsHit2->GetPositionL(x2l,y2l,z2l); | |
58005f18 | 426 | |
3bd79107 | 427 | yMl = 0.0; |
6d48704c | 428 | if((y2l*y1l)<0.) { |
37ffef26 | 429 | xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l; |
430 | zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l; | |
431 | } else { | |
432 | xMl = 0.5*(x1l+x2l); | |
433 | zMl = 0.5*(z1l+z2l); | |
434 | } | |
7e3ded1b | 435 | return kTRUE; |
3bd79107 | 436 | } |
58005f18 | 437 | //___________________________________________________________________________ |
3bd79107 | 438 | void AliITSmodule::MedianHit(Int_t index, |
439 | Float_t xg,Float_t yg,Float_t zg, | |
440 | Int_t status, | |
441 | Float_t &xMg,Float_t &yMg,Float_t &zMg, | |
442 | Int_t &flag){ | |
443 | // median hit | |
444 | static Float_t x1,y1,z1; | |
445 | ||
7e3ded1b | 446 | if ((status&0x0002)!=0){ // entering |
3bd79107 | 447 | x1 = xg; |
448 | y1 = yg; | |
449 | z1 = zg; | |
450 | flag = 1; | |
7e3ded1b | 451 | } else if ((status&0x0004)!=0){ // exiting |
3bd79107 | 452 | MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg); |
453 | flag = 0; | |
454 | } // end if | |
7e3ded1b | 455 | else flag = 1; |
58005f18 | 456 | } |
3bd79107 | 457 | //___________________________________________________________________________ |
458 | void AliITSmodule::GetID(Int_t &lay,Int_t &lad,Int_t &det){ | |
459 | // get ID | |
460 | fITS->GetITSgeom()->GetModuleId(fIndex,lay,lad,det); | |
461 | return ; | |
462 | } | |
463 |