]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSmodule.cxx
Class now derived from TObject as required. Fixed copy constructor and
[u/mrichter/AliRoot.git] / ITS / AliITSmodule.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
803d1ab0 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
803d1ab0 16/* $Id$ */
4c039060 17
ff61221e 18#include <TArrayI.h>
19
114da3a4 20#include <stdlib.h>
3bd79107 21
58005f18 22#include "AliRun.h"
3bd79107 23#include "AliITS.h"
ff61221e 24#include "AliITShit.h"
25#include "AliITSmodule.h"
26#include "AliITSgeom.h"
58005f18 27
28ClassImp(AliITSmodule)
29
30//_______________________________________________________________________
31//
32// Impementation of class AliITSmodule
33//
3bd79107 34// created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski
58005f18 35// R. Barbers, B. Batyunia, B. S. Nilsen
36// ver 1.0 CERN 16.09.1999
37//_______________________________________________________________________
58005f18 38//________________________________________________________________________
39//
40// Constructors and deconstructor
41//________________________________________________________________________
42//
3bd79107 43AliITSmodule::AliITSmodule() {
b0f0d5a5 44 // constructor
45
3bd79107 46 fHitsM = 0;
47 fTrackIndex = 0;
48 fHitIndex = 0;
49 fITS = 0;
58005f18 50
3bd79107 51}
52//_________________________________________________________________________
53AliITSmodule::AliITSmodule(Int_t index) {
54 // constructor
58005f18 55
3bd79107 56 fIndex = index;
57 fHitsM = new TObjArray();
58 fTrackIndex = new TArrayI(16);
59 fHitIndex = new TArrayI(16);
60 fITS = (AliITS*)(gAlice->GetDetector("ITS"));
61}
62//__________________________________________________________________________
63AliITSmodule::~AliITSmodule() {
64 // The destructor for AliITSmodule. Before destoring AliITSmodule
65 // we must first destroy all of it's members.
58005f18 66
3bd79107 67 if(fHitsM){
279a35d7 68 fHitsM->Delete();
69 delete fHitsM;
70 fHitsM = 0;
3bd79107 71 } // end if
72 delete fTrackIndex;
73 delete fHitIndex;
74 fITS = 0; // We don't delete this pointer since it is just a copy.
75}
76//____________________________________________________________________________
77AliITSmodule::AliITSmodule(const AliITSmodule &source){
78////////////////////////////////////////////////////////////////////////
79// Copy Constructor
80////////////////////////////////////////////////////////////////////////
88cb7938 81 Error("AliITSmodule","AliITSmodule class has not to be copied! Exit.");
3bd79107 82 exit(1);
58005f18 83}
3bd79107 84//_____________________________________________________________________________
85AliITSmodule& AliITSmodule::operator=(const AliITSmodule &source){
86////////////////////////////////////////////////////////////////////////
87// Assignment operator
88////////////////////////////////////////////////////////////////////////
88cb7938 89 Error("AliITSmodule","AliITSmodule class has not to be copied! Exit.");
3bd79107 90 exit(1);
e8189707 91 return *this; // fake return neded on Sun
88cb7938 92}
58005f18 93//_________________________________________________________________________
3bd79107 94//
95// Hits management
96//__________________________________________________________________________
97Int_t AliITSmodule::AddHit(AliITShit* hit,Int_t t,Int_t h) {
98// Hits management
58005f18 99
ff61221e 100 //printf("AddHit: beginning hit %p t h %d %d\n",hit,t,h);
3bd79107 101 fHitsM->AddLast(new AliITShit(*hit));
102 Int_t fNhitsM = fHitsM->GetEntriesFast();
103 if(fNhitsM-1>=fTrackIndex->GetSize()){ // need to expand the TArrayI
ea008941 104 fTrackIndex->Set(fNhitsM+64);
3bd79107 105 } // end if
106 if(fNhitsM-1>=fHitIndex->GetSize()){ // need to expand the TArrayI
ea008941 107 fHitIndex->Set(fNhitsM+64);
3bd79107 108 } // end if
109 (*fTrackIndex)[fNhitsM-1] = t;
110 (*fHitIndex)[fNhitsM-1] = h;
111 return fNhitsM;
112}
3bd79107 113//___________________________________________________________________________
114Double_t AliITSmodule::PathLength(Int_t index,AliITShit *itsHit1,
115 AliITShit *itsHit2){
116 // path lenght
117 Float_t x1g,y1g,z1g;
118 Float_t x2g,y2g,z2g;
119 Double_t s;
58005f18 120
3bd79107 121 itsHit1->GetPositionG(x1g,y1g,z1g);
122 itsHit2->GetPositionG(x2g,y2g,z2g);
58005f18 123
3bd79107 124 s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
125 ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
126 ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g)) );
127 return s;
128}
129//___________________________________________________________________________
130void AliITSmodule::PathLength(Int_t index,
131 Float_t x,Float_t y,Float_t z,
132 Int_t status,Int_t &nseg,
133 Float_t &x1,Float_t &y1,Float_t &z1,
134 Float_t &dx1,Float_t &dy1,Float_t &dz1,
135 Int_t &flag){
136 // path length
137 static Float_t x0,y0,z0;
58005f18 138
7e3ded1b 139 if ((status&0x0002)!=0){ // entering
3bd79107 140 x0 = x;
141 y0 = y;
142 z0 = z;
143 nseg = 0;
144 flag = 1;
145 }else{
146 x1 = x0;
147 y1 = y0;
148 z1 = z0;
149 dx1 = x-x1;
150 dy1 = y-y1;
151 dz1 = z-z1;
152 nseg++;
7e3ded1b 153 if ((status&0x0004)!=0) flag = 0; //exiting
154 if ((status&0x0001)!=0) flag = 2; // inside
155 else flag = 2; //inside ?
3bd79107 156 x0 = x;
157 y0 = y;
158 z0 = z;
159 } // end if
58005f18 160}
3bd79107 161//___________________________________________________________________________
162Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
163 Double_t &c,Double_t &d,
164 Double_t &e,Double_t &f,Double_t &de){
165 // line segment
88cb7938 166 AliITShit *h1;
167 Double_t t;
58005f18 168
3bd79107 169 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
58005f18 170
3bd79107 171 h1 = (AliITShit *) (fHitsM->At(hitindex));
172 if(h1->StatusEntering()){ // if track entering volume, get index for next
173 // step
3bd79107 174 return kFALSE;
175 } // end if StatusEntering()
176 // else stepping
3bd79107 177 de = h1->GetIonization();
88cb7938 178 h1->GetPositionL0(a,c,e,t);
3bd79107 179 h1->GetPositionL(b,d,f);
180 b = b - a;
181 d = d - c;
182 f = f - e;
3bd79107 183 return kTRUE;
184}
185//___________________________________________________________________________
186Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
187 Double_t &c,Double_t &d,
188 Double_t &e,Double_t &f,Double_t &de){
189 // line segment
88cb7938 190 AliITShit *h1;
191 Double_t t;
58005f18 192
3bd79107 193 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
194
195 h1 = (AliITShit *) (fHitsM->At(hitindex));
196 if(h1->StatusEntering()){ // if track entering volume, get index for next
197 // step
3bd79107 198 return kFALSE;
199 } // end if StatusEntering()
200 // else stepping
3bd79107 201 de = h1->GetIonization();
88cb7938 202 h1->GetPositionG0(a,c,e,t);
3bd79107 203 h1->GetPositionG(b,d,f);
204 b = b - a;
205 d = d - c;
206 f = f - e;
3bd79107 207 return kTRUE;
208}
209//___________________________________________________________________________
210Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
211 Double_t &c,Double_t &d,
212 Double_t &e,Double_t &f,
213 Double_t &de,Int_t &track){
214 // line segmente
88cb7938 215 AliITShit *h1;
216 Double_t t;
3bd79107 217
218 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
219
220 h1 = (AliITShit *) (fHitsM->At(hitindex));
221 if(h1->StatusEntering()){ // if track entering volume, get index for next
222 // step
3bd79107 223 track = h1->GetTrack();
224 return kFALSE;
225 } // end if StatusEntering()
226 // else stepping
3bd79107 227 de = h1->GetIonization();
88cb7938 228 h1->GetPositionL0(a,c,e,t);
3bd79107 229 h1->GetPositionL(b,d,f);
230 b = b - a;
231 d = d - c;
232 f = f - e;
3bd79107 233 track = h1->GetTrack();
234 return kTRUE;
235}
236//___________________________________________________________________________
237Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
238 Double_t &c,Double_t &d,
239 Double_t &e,Double_t &f,
240 Double_t &de,Int_t &track){
241 // line segment
88cb7938 242 AliITShit *h1;
243 Double_t t;
3bd79107 244
245 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
246
247 h1 = (AliITShit *) (fHitsM->At(hitindex));
248 if(h1->StatusEntering()){ // if track entering volume, get index for next
249 // step
3bd79107 250 track = h1->GetTrack();
251 return kFALSE;
252 } // end if StatusEntering()
253 // else stepping
3bd79107 254 de = h1->GetIonization();
88cb7938 255 h1->GetPositionG0(a,c,e,t);
3bd79107 256 h1->GetPositionG(b,d,f);
257 b = b - a;
258 d = d - c;
259 f = f - e;
3bd79107 260 track = h1->GetTrack();
261 return kTRUE;
58005f18 262}
7e3ded1b 263//______________________________________________________________________
264Bool_t AliITSmodule::MedianHitG(AliITShit *h1,AliITShit *h2,
265 Float_t &x,Float_t &y,Float_t &z){
266 // Computes the mean hit location for a set of hits that make up a track
267 // passing through a volume. Returns kFALSE untill the the track leaves
268 // the volume.
269 // median hit
270 AliITSgeom *gm = fITS->GetITSgeom();
271 Float_t x1l=0.,y1l=0.,z1l=0.;
272 Float_t x2l=0.,y2l=0.,z2l=0.;
273 Float_t xMl,yMl=0,zMl;
274 Float_t l[3], g[3];
275
276 h1->GetPositionG(x1l,y1l,z1l);
277 h2->GetPositionG(x2l,y2l,z2l);
278
6d48704c 279 if((y2l*y1l)<0.) {
7e3ded1b 280 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
281 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
282 } else {
283 xMl = 0.5*(x1l+x2l);
284 zMl = 0.5*(z1l+z2l);
285 }
286
287 l[0] = xMl;
288 l[1] = yMl;
289 l[2] = zMl;
290 gm->LtoG(h1->GetModule(),l,g);
291 x = g[0];
292 y = g[1];
293 z = g[2];
294 return kTRUE;
295}
296//___________________________________________________________________________
297void AliITSmodule::MedianHitG(Int_t index,
298 Float_t hitx1,Float_t hity1,Float_t hitz1,
299 Float_t hitx2,Float_t hity2,Float_t hitz2,
300 Float_t &xMg, Float_t &yMg, Float_t &zMg){
301 // median hit
302 AliITSgeom *gm = fITS->GetITSgeom();
303 Float_t x1l,y1l,z1l;
304 Float_t x2l,y2l,z2l;
305 Float_t xMl,yMl=0,zMl;
306 Float_t l[3], g[3];
307
308 g[0] = hitx1;
309 g[1] = hity1;
310 g[2] = hitz1;
311 gm->GtoL(index,g,l);
312 x1l = l[0];
313 y1l = l[1];
314 z1l = l[2];
315
316 g[0] = hitx2;
317 g[1] = hity2;
318 g[2] = hitz2;
319 gm->GtoL(index,g,l);
320 x2l = l[0];
321 y2l = l[1];
322 z2l = l[2];
323
6d48704c 324 if((y2l*y1l)<0.) {
7e3ded1b 325 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
326 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
327 } else {
328 xMl = 0.5*(x1l+x2l);
329 zMl = 0.5*(z1l+z2l);
330 }
331
332 l[0] = xMl;
333 l[1] = yMl;
334 l[2] = zMl;
335 gm->LtoG(index,l,g);
336 xMg = g[0];
337 yMg = g[1];
338 zMg = g[2];
339}
3bd79107 340//___________________________________________________________________________
7e3ded1b 341Bool_t AliITSmodule::MedianHitL( AliITShit *itsHit1,
3bd79107 342 AliITShit *itsHit2,
343 Float_t &xMl, Float_t &yMl, Float_t &zMl){
344 // median hit
345 Float_t x1l,y1l,z1l;
346 Float_t x2l,y2l,z2l;
347
348 itsHit1->GetPositionL(x1l,y1l,z1l);
349 itsHit2->GetPositionL(x2l,y2l,z2l);
58005f18 350
3bd79107 351 yMl = 0.0;
6d48704c 352 if((y2l*y1l)<0.) {
37ffef26 353 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
354 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
355 } else {
356 xMl = 0.5*(x1l+x2l);
357 zMl = 0.5*(z1l+z2l);
358 }
7e3ded1b 359 return kTRUE;
3bd79107 360}
58005f18 361//___________________________________________________________________________
3bd79107 362void AliITSmodule::MedianHit(Int_t index,
363 Float_t xg,Float_t yg,Float_t zg,
364 Int_t status,
365 Float_t &xMg,Float_t &yMg,Float_t &zMg,
366 Int_t &flag){
367 // median hit
368 static Float_t x1,y1,z1;
369
7e3ded1b 370 if ((status&0x0002)!=0){ // entering
3bd79107 371 x1 = xg;
372 y1 = yg;
373 z1 = zg;
374 flag = 1;
7e3ded1b 375 } else if ((status&0x0004)!=0){ // exiting
3bd79107 376 MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
377 flag = 0;
378 } // end if
7e3ded1b 379 else flag = 1;
58005f18 380}
3bd79107 381//___________________________________________________________________________
382void AliITSmodule::GetID(Int_t &lay,Int_t &lad,Int_t &det){
383 // get ID
384 fITS->GetITSgeom()->GetModuleId(fIndex,lay,lad,det);
385 return ;
386}
387