For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[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//
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//___________________________________________________________________________
122Double_t AliITSmodule::PathLength(Int_t index,AliITShit *itsHit1,
7d62fb64 123 AliITShit *itsHit2) {
3bd79107 124 // path lenght
125 Float_t x1g,y1g,z1g;
126 Float_t x2g,y2g,z2g;
127 Double_t s;
58005f18 128
ac74f489 129 index = 0;
3bd79107 130 itsHit1->GetPositionG(x1g,y1g,z1g);
131 itsHit2->GetPositionG(x2g,y2g,z2g);
58005f18 132
3bd79107 133 s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
134 ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
135 ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g)) );
136 return s;
137}
138//___________________________________________________________________________
139void AliITSmodule::PathLength(Int_t index,
140 Float_t x,Float_t y,Float_t z,
141 Int_t status,Int_t &nseg,
142 Float_t &x1,Float_t &y1,Float_t &z1,
143 Float_t &dx1,Float_t &dy1,Float_t &dz1,
7d62fb64 144 Int_t &flag) const{
3bd79107 145 // path length
146 static Float_t x0,y0,z0;
58005f18 147
ac74f489 148 index = 0;
7e3ded1b 149 if ((status&0x0002)!=0){ // entering
3bd79107 150 x0 = x;
151 y0 = y;
152 z0 = z;
153 nseg = 0;
154 flag = 1;
155 }else{
156 x1 = x0;
157 y1 = y0;
158 z1 = z0;
159 dx1 = x-x1;
160 dy1 = y-y1;
161 dz1 = z-z1;
162 nseg++;
7e3ded1b 163 if ((status&0x0004)!=0) flag = 0; //exiting
164 if ((status&0x0001)!=0) flag = 2; // inside
165 else flag = 2; //inside ?
3bd79107 166 x0 = x;
167 y0 = y;
168 z0 = z;
169 } // end if
58005f18 170}
3bd79107 171//___________________________________________________________________________
172Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
173 Double_t &c,Double_t &d,
174 Double_t &e,Double_t &f,Double_t &de){
175 // line segment
88cb7938 176 AliITShit *h1;
177 Double_t t;
58005f18 178
3bd79107 179 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
58005f18 180
3bd79107 181 h1 = (AliITShit *) (fHitsM->At(hitindex));
182 if(h1->StatusEntering()){ // if track entering volume, get index for next
183 // step
3bd79107 184 return kFALSE;
185 } // end if StatusEntering()
186 // else stepping
3bd79107 187 de = h1->GetIonization();
88cb7938 188 h1->GetPositionL0(a,c,e,t);
3bd79107 189 h1->GetPositionL(b,d,f);
190 b = b - a;
191 d = d - c;
192 f = f - e;
3bd79107 193 return kTRUE;
194}
195//___________________________________________________________________________
196Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
197 Double_t &c,Double_t &d,
198 Double_t &e,Double_t &f,Double_t &de){
199 // line segment
88cb7938 200 AliITShit *h1;
201 Double_t t;
58005f18 202
3bd79107 203 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
204
205 h1 = (AliITShit *) (fHitsM->At(hitindex));
206 if(h1->StatusEntering()){ // if track entering volume, get index for next
207 // step
3bd79107 208 return kFALSE;
209 } // end if StatusEntering()
210 // else stepping
3bd79107 211 de = h1->GetIonization();
88cb7938 212 h1->GetPositionG0(a,c,e,t);
3bd79107 213 h1->GetPositionG(b,d,f);
214 b = b - a;
215 d = d - c;
216 f = f - e;
3bd79107 217 return kTRUE;
218}
219//___________________________________________________________________________
220Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
221 Double_t &c,Double_t &d,
222 Double_t &e,Double_t &f,
223 Double_t &de,Int_t &track){
224 // line segmente
88cb7938 225 AliITShit *h1;
226 Double_t t;
3bd79107 227
228 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
229
230 h1 = (AliITShit *) (fHitsM->At(hitindex));
231 if(h1->StatusEntering()){ // if track entering volume, get index for next
232 // step
3bd79107 233 track = h1->GetTrack();
234 return kFALSE;
235 } // end if StatusEntering()
236 // else stepping
3bd79107 237 de = h1->GetIonization();
88cb7938 238 h1->GetPositionL0(a,c,e,t);
3bd79107 239 h1->GetPositionL(b,d,f);
240 b = b - a;
241 d = d - c;
242 f = f - e;
3bd79107 243 track = h1->GetTrack();
244 return kTRUE;
245}
246//___________________________________________________________________________
247Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
248 Double_t &c,Double_t &d,
249 Double_t &e,Double_t &f,
250 Double_t &de,Int_t &track){
251 // line segment
88cb7938 252 AliITShit *h1;
253 Double_t t;
3bd79107 254
255 if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
256
257 h1 = (AliITShit *) (fHitsM->At(hitindex));
258 if(h1->StatusEntering()){ // if track entering volume, get index for next
259 // step
3bd79107 260 track = h1->GetTrack();
261 return kFALSE;
262 } // end if StatusEntering()
263 // else stepping
3bd79107 264 de = h1->GetIonization();
88cb7938 265 h1->GetPositionG0(a,c,e,t);
3bd79107 266 h1->GetPositionG(b,d,f);
267 b = b - a;
268 d = d - c;
269 f = f - e;
3bd79107 270 track = h1->GetTrack();
271 return kTRUE;
58005f18 272}
7e3ded1b 273//______________________________________________________________________
274Bool_t AliITSmodule::MedianHitG(AliITShit *h1,AliITShit *h2,
275 Float_t &x,Float_t &y,Float_t &z){
276 // Computes the mean hit location for a set of hits that make up a track
277 // passing through a volume. Returns kFALSE untill the the track leaves
278 // the volume.
279 // median hit
280 AliITSgeom *gm = fITS->GetITSgeom();
281 Float_t x1l=0.,y1l=0.,z1l=0.;
282 Float_t x2l=0.,y2l=0.,z2l=0.;
283 Float_t xMl,yMl=0,zMl;
284 Float_t l[3], g[3];
285
286 h1->GetPositionG(x1l,y1l,z1l);
287 h2->GetPositionG(x2l,y2l,z2l);
288
6d48704c 289 if((y2l*y1l)<0.) {
7e3ded1b 290 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
291 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
292 } else {
293 xMl = 0.5*(x1l+x2l);
294 zMl = 0.5*(z1l+z2l);
295 }
296
297 l[0] = xMl;
298 l[1] = yMl;
299 l[2] = zMl;
300 gm->LtoG(h1->GetModule(),l,g);
301 x = g[0];
302 y = g[1];
303 z = g[2];
304 return kTRUE;
305}
306//___________________________________________________________________________
307void AliITSmodule::MedianHitG(Int_t index,
308 Float_t hitx1,Float_t hity1,Float_t hitz1,
309 Float_t hitx2,Float_t hity2,Float_t hitz2,
310 Float_t &xMg, Float_t &yMg, Float_t &zMg){
311 // median hit
312 AliITSgeom *gm = fITS->GetITSgeom();
313 Float_t x1l,y1l,z1l;
314 Float_t x2l,y2l,z2l;
315 Float_t xMl,yMl=0,zMl;
316 Float_t l[3], g[3];
317
318 g[0] = hitx1;
319 g[1] = hity1;
320 g[2] = hitz1;
321 gm->GtoL(index,g,l);
322 x1l = l[0];
323 y1l = l[1];
324 z1l = l[2];
325
326 g[0] = hitx2;
327 g[1] = hity2;
328 g[2] = hitz2;
329 gm->GtoL(index,g,l);
330 x2l = l[0];
331 y2l = l[1];
332 z2l = l[2];
333
6d48704c 334 if((y2l*y1l)<0.) {
7e3ded1b 335 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
336 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
337 } else {
338 xMl = 0.5*(x1l+x2l);
339 zMl = 0.5*(z1l+z2l);
340 }
341
342 l[0] = xMl;
343 l[1] = yMl;
344 l[2] = zMl;
345 gm->LtoG(index,l,g);
346 xMg = g[0];
347 yMg = g[1];
348 zMg = g[2];
349}
3bd79107 350//___________________________________________________________________________
7e3ded1b 351Bool_t AliITSmodule::MedianHitL( AliITShit *itsHit1,
3bd79107 352 AliITShit *itsHit2,
7d62fb64 353 Float_t &xMl, Float_t &yMl, Float_t &zMl) const{
3bd79107 354 // median hit
355 Float_t x1l,y1l,z1l;
356 Float_t x2l,y2l,z2l;
357
358 itsHit1->GetPositionL(x1l,y1l,z1l);
359 itsHit2->GetPositionL(x2l,y2l,z2l);
58005f18 360
3bd79107 361 yMl = 0.0;
6d48704c 362 if((y2l*y1l)<0.) {
37ffef26 363 xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
364 zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
365 } else {
366 xMl = 0.5*(x1l+x2l);
367 zMl = 0.5*(z1l+z2l);
368 }
7e3ded1b 369 return kTRUE;
3bd79107 370}
58005f18 371//___________________________________________________________________________
3bd79107 372void AliITSmodule::MedianHit(Int_t index,
373 Float_t xg,Float_t yg,Float_t zg,
374 Int_t status,
375 Float_t &xMg,Float_t &yMg,Float_t &zMg,
376 Int_t &flag){
377 // median hit
378 static Float_t x1,y1,z1;
379
7e3ded1b 380 if ((status&0x0002)!=0){ // entering
3bd79107 381 x1 = xg;
382 y1 = yg;
383 z1 = zg;
384 flag = 1;
7e3ded1b 385 } else if ((status&0x0004)!=0){ // exiting
3bd79107 386 MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
387 flag = 0;
388 } // end if
7e3ded1b 389 else flag = 1;
58005f18 390}
3bd79107 391//___________________________________________________________________________
392void AliITSmodule::GetID(Int_t &lay,Int_t &lad,Int_t &det){
393 // get ID
394 fITS->GetITSgeom()->GetModuleId(fIndex,lay,lad,det);
395 return ;
396}
397