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