]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSmodule.cxx
stdlib.h included (HP,Sun)
[u/mrichter/AliRoot.git] / ITS / AliITSmodule.cxx
CommitLineData
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$
114da3a4 18Revision 1.8 2000/10/02 16:32:57 barbera
19Forward declarations added and formatting
20
0b2d41b4 21Revision 1.3.4.8 2000/10/02 15:55:26 barbera
22Forward declarations added and formatting
23
24Revision 1.7 2000/09/22 12:36:38 nilsen
25Minor changes to improve compilation and create less NOISE.
26
ff61221e 27Revision 1.6 2000/07/10 16:07:18 fca
28Release version of ITS code
29
3bd79107 30Revision 1.3.4.2 2000/03/02 21:42:29 nilsen
31Linked AliDetector::fDigit to AliITSmodule::fDigitsM and AliITS::fITSRecPoints
32to AliITSmodule::fRecPointsM. Renamed AliITSmodule::fPointsM to fRecPointsM.
33Removed the deletion of fDigitsM from the distructor since it is only a copy
34of what is in AliDetector. Fixed a bug in the functions LineSegmentL and
35LineSegmentG. Added two new versions of LineSegmentL and LineSegmentG to
36additionaly return track number from the hit. Removed FastPoint function,
37haven't found anywere it was used, also it had very many problems, should
38just call FastPointSPD... .
39
40Revision 1.3.4.1 2000/01/12 19:03:32 nilsen
41This is the version of the files after the merging done in December 1999.
42See the ReadMe110100.txt file for details
43
44Revision 1.3 1999/10/04 15:20:12 fca
45Correct syntax accepted by g++ but not standard for static members, remove minor warnings
46
ad0e60d9 47Revision 1.2 1999/09/29 09:24:20 fca
48Introduction of the Copyright and cvs Log
49
4c039060 50*/
51
ff61221e 52#include <TArrayI.h>
53
114da3a4 54#include <stdlib.h>
3bd79107 55
58005f18 56#include "AliRun.h"
3bd79107 57#include "AliITS.h"
ff61221e 58#include "AliITShit.h"
59#include "AliITSmodule.h"
60#include "AliITSgeom.h"
58005f18 61
62ClassImp(AliITSmodule)
63
64//_______________________________________________________________________
65//
66// Impementation of class AliITSmodule
67//
3bd79107 68// created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski
58005f18 69// R. Barbers, B. Batyunia, B. S. Nilsen
70// ver 1.0 CERN 16.09.1999
71//_______________________________________________________________________
58005f18 72//________________________________________________________________________
73//
74// Constructors and deconstructor
75//________________________________________________________________________
76//
3bd79107 77AliITSmodule::AliITSmodule() {
78 // constructor
79 fIndex = 0;
80 fHitsM = 0;
81 fTrackIndex = 0;
82 fHitIndex = 0;
83 fITS = 0;
58005f18 84
3bd79107 85}
86//_________________________________________________________________________
87AliITSmodule::AliITSmodule(Int_t index) {
88 // constructor
58005f18 89
3bd79107 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//__________________________________________________________________________
97AliITSmodule::~AliITSmodule() {
98 // The destructor for AliITSmodule. Before destoring AliITSmodule
99 // we must first destroy all of it's members.
58005f18 100
3bd79107 101 fIndex = 0;
3bd79107 102 if(fHitsM){
e8189707 103 for(Int_t i=0;i<fHitsM->GetEntriesFast();i++)
3bd79107 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//____________________________________________________________________________
113AliITSmodule::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);
58005f18 119}
120
3bd79107 121//_____________________________________________________________________________
122AliITSmodule& 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);
e8189707 128 return *this; // fake return neded on Sun
3bd79107 129}
58005f18 130
131//_________________________________________________________________________
3bd79107 132//
133// Hits management
134//__________________________________________________________________________
135Int_t AliITSmodule::AddHit(AliITShit* hit,Int_t t,Int_t h) {
136// Hits management
58005f18 137
ff61221e 138 //printf("AddHit: beginning hit %p t h %d %d\n",hit,t,h);
3bd79107 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);
e8189707 143 for(Int_t i=0;i<fTrackIndex->GetSize();i++)
3bd79107 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);
e8189707 150 for(Int_t i=0;i<fHitIndex->GetSize();i++)
3bd79107 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//___________________________________________________________________________
161void 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;
58005f18 190
3bd79107 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];
58005f18 198}
3bd79107 199//___________________________________________________________________________
200Double_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;
58005f18 206
3bd79107 207 itsHit1->GetPositionG(x1g,y1g,z1g);
208 itsHit2->GetPositionG(x2g,y2g,z2g);
58005f18 209
3bd79107 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//___________________________________________________________________________
216void 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;
58005f18 224
3bd79107 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
58005f18 245}
3bd79107 246//___________________________________________________________________________
247Bool_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;
58005f18 253
3bd79107 254 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
58005f18 255
3bd79107 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//___________________________________________________________________________
274Bool_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;
58005f18 280
3bd79107 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//___________________________________________________________________________
301Bool_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//___________________________________________________________________________
331Bool_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;
58005f18 359}
3bd79107 360//___________________________________________________________________________
361void 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);
58005f18 371
3bd79107 372 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
373 yMl = 0.0;
374 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
375}
58005f18 376//___________________________________________________________________________
3bd79107 377void 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;
58005f18 396}
3bd79107 397//___________________________________________________________________________
398void 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