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