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