Adding some further mother volumes to speed-up the overlap checking and particle...
[u/mrichter/AliRoot.git] / ITS / AliITSgeomSPD.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
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
88cb7938 16/* $Id$ */
8253cd9a 17
85f1e34a 18////////////////////////////////////////////////////////////////////////
19// This class is for the Silicon Pixel Detector, SPD, specific geometry.
20// It is being replaced by AliITSsegmentationSPD class. This file also
21// constains classes derived from AliITSgeomSPD which do nothing but
22// initilize this one with predefined values.
23////////////////////////////////////////////////////////////////////////
24
4ae5bbc4 25#include <Riostream.h>
8253cd9a 26#include <TShape.h>
31b8cd63 27#include <TMath.h>
8253cd9a 28
29#include "AliITSgeomSPD.h"
30
31ClassImp(AliITSgeomSPD)
32
023ae34b 33AliITSgeomSPD::AliITSgeomSPD():
34TObject(),
35fName(),
36fTitle(),
37fMat(),
38fDx(0.0),
39fDy(0.0),
40fDz(0.0),
41fNbinx(0),
42fNbinz(0),
43fLowBinEdgeX(0),
44fLowBinEdgeZ(0){
8253cd9a 45// Default Constructor. Set everthing to null.
8253cd9a 46}
47//______________________________________________________________________
48AliITSgeomSPD::AliITSgeomSPD(Float_t dy,Int_t nx,Float_t *bx,
023ae34b 49 Int_t nz,Float_t *bz):
50TObject(),
51fName(),
52fTitle(),
53fMat(),
54fDx(0.0),
55fDy(0.0),
56fDz(0.0),
57fNbinx(0),
58fNbinz(0),
59fLowBinEdgeX(0),
60fLowBinEdgeZ(0){
8253cd9a 61// Standard Constructor. Set everthing to null.
62
8253cd9a 63 ReSetBins(dy,nx,bx,nz,bz);
64 return;
65}
66//______________________________________________________________________
67void AliITSgeomSPD::ReSetBins(Float_t dy,Int_t nx,Float_t *bx,
68 Int_t nz,Float_t *bz){
69// delets the contents of this and replaces it with the given values.
70 Int_t i;
71 Float_t dx = 0.0, dz = 0.0;
72
73 // Compute size in x and z (based on bins).
74 for(i=0;i<nx;i++) dx += bx[i];
75 for(i=0;i<nz;i++) dz += bz[i];
76 dx *= 0.5;
77 dz *= 0.5;
78
023ae34b 79 if(fLowBinEdgeX) delete[] fLowBinEdgeX; // delete existing
80 if(fLowBinEdgeZ) delete[] fLowBinEdgeZ; // delete existing
81 fLowBinEdgeX = 0;
82 fLowBinEdgeZ = 0;
8253cd9a 83
84 SetNbinX(nx);
85 SetNbinZ(nz);
86 InitLowBinEdgeX();
87 InitLowBinEdgeZ();
88 fLowBinEdgeX[0] = -dx;
89 fLowBinEdgeZ[0] = -dz;
90 for(i=0;i<nx;i++) fLowBinEdgeX[i+1] = fLowBinEdgeX[i] + bx[i];
91 for(i=0;i<nz;i++) fLowBinEdgeZ[i+1] = fLowBinEdgeZ[i] + bz[i];
023ae34b 92 SetShape("ActiveSPD","Active volume of SPD","",dx,dy,dz);
8253cd9a 93 return;
94}
95//______________________________________________________________________
e56160b8 96AliITSgeomSPD::AliITSgeomSPD(AliITSgeomSPD &source) : TObject(source),
97fName(source.fName),
98fTitle(source.fTitle),
99fMat(source.fMat),
100fDx(source.fDx),
101fDy(source.fDy),
102fDz(source.fDz),
103fNbinx(source.fNbinx),
104fNbinz(source.fNbinz),
105fLowBinEdgeX(0),
106fLowBinEdgeZ(0){
8253cd9a 107 // Copy constructor
e56160b8 108 InitLowBinEdgeX();
109 InitLowBinEdgeZ();
110 for(Int_t i=0;i<fNbinx;i++) fLowBinEdgeX[i] = source.fLowBinEdgeX[i];
111 for(Int_t i=0;i<fNbinz;i++) fLowBinEdgeZ[i] = source.fLowBinEdgeZ[i];
8253cd9a 112
e56160b8 113
8253cd9a 114}
115//______________________________________________________________________
116AliITSgeomSPD& AliITSgeomSPD::operator=(AliITSgeomSPD &source){
117 // = operator
e56160b8 118 this->~AliITSgeomSPD();
119 new(this) AliITSgeomSPD(source);
120 return *this;
8253cd9a 121}
122//______________________________________________________________________
123AliITSgeomSPD::~AliITSgeomSPD(){
124// Destructor
125
023ae34b 126 if(fLowBinEdgeX) delete[] fLowBinEdgeX;
127 if(fLowBinEdgeZ) delete[] fLowBinEdgeZ;
8253cd9a 128 fNbinx = 0;
129 fNbinz = 0;
130 fLowBinEdgeX = 0;
131 fLowBinEdgeZ = 0;
132}
133//______________________________________________________________________
023ae34b 134void AliITSgeomSPD::SetShape(const char *name,const char *title,
24e270ad 135 const char * /*mat*/,Float_t dx,Float_t dy,Float_t dz){
023ae34b 136 // Delete any existing shape info and replace it with a new
137 // shape information.
138 // Inputs:
139 // char * name Name of the shape
140 // char * title Title of the shape
141 // char * mat Material name for the shape
142 // Float_t dx half width of the shape [cm]
143 // Float_t dy half thickness of the shape [cm]
144 // Float_t dz half length of the shape [cm]
145 // Outputs:
146 // none.
147 // Return:
148 // none.
149
150 fName = name;
151 fTitle = title;
152 fDx = dx;
153 fDy = dy;
154 fDz = dz;
155 return;
156}
157//______________________________________________________________________
8253cd9a 158void AliITSgeomSPD::LToDet(Float_t xl,Float_t zl,Int_t &row,Int_t &col){
159// Returns the row and column pixel numbers for a given local coordinate
160// system. If they are outside then it will return -1 or fNbinx/z.
161 Int_t i;
162
163 if(xl<fLowBinEdgeX[0]) row = -1;
164 else{
165 for(i=0;i<fNbinx;i++) if(xl<=fLowBinEdgeX[i]) break;
166 row = i;
167 } //end if too low.
168 if(zl<fLowBinEdgeX[0]) col = -1;
169 else{
170 for(i=0;i<fNbinz;i++) if(zl<=fLowBinEdgeZ[i]) break;
171 col = i;
172 } //end if too low.
173 return;
174}
175//______________________________________________________________________
176void AliITSgeomSPD::DetToL(Int_t row,Int_t col,Float_t &xl,Float_t &zl){
177// returns the pixel center local coordinate system location for a given
178// row and column number. It the row or column number is outside of the
179// defined range then it will return the nearest detector edge.
180
181 if(row>=0||row<fNbinx-1) xl = 0.5*(fLowBinEdgeX[row]+fLowBinEdgeX[row+1]);
182 else if(row<0) xl = fLowBinEdgeX[0];else xl = fLowBinEdgeX[fNbinx-1];
183 if(col>=0||col<fNbinz-1) zl = 0.5*(fLowBinEdgeZ[col]+fLowBinEdgeZ[col+1]);
184 else if(col<0) zl = fLowBinEdgeZ[0];else zl = fLowBinEdgeZ[fNbinz-1];
185 return;
186}
187//______________________________________________________________________
31b8cd63 188void AliITSgeomSPD::Print(ostream *os) const {
8253cd9a 189// Standard output format for this class
190 Int_t i;
431a7819 191#if defined __GNUC__
192#if __GNUC__ > 2
193 ios::fmtflags fmt;
194#else
195 Int_t fmt;
196#endif
197#else
9f69211c 198#if defined __ICC || defined __ECC || defined __xlC__
94831058 199 ios::fmtflags fmt;
200#else
31b8cd63 201 Int_t fmt;
b48af428 202#endif
94831058 203#endif
8253cd9a 204
205 fmt = os->setf(ios::scientific); // set scientific floating point output
206 *os << "TBRIK" << " ";
207 *os << setprecision(16) << GetDx() << " ";
208 *os << setprecision(16) << GetDy() << " ";
209 *os << setprecision(16) << GetDz() << " ";
210 *os << fNbinx-1 << " " << fNbinz-1 << " ";
211 for(i=0;i<fNbinx;i++) *os << setprecision(16) << fLowBinEdgeX[i] << " ";
31b8cd63 212 for(i=0;i<fNbinz;i++) *os << setprecision(16) << fLowBinEdgeZ[i] << " ";
8253cd9a 213 *os << endl;
214 os->flags(fmt);
215 return;
216}
217//______________________________________________________________________
218void AliITSgeomSPD::Read(istream *is){
219// Standard input format for this class
220 Int_t i,j;
221 Float_t dx,dy,dz;
222 char shape[20];
223
224 for(i=0;i<20;i++) shape[i]='\0';
225 *is >> shape;
226 if(strcmp(shape,"TBRIK")) Warning("::Read","Shape not a TBRIK");
227 *is >> dx >> dy >> dz;
023ae34b 228 SetShape("ActiveSPD","Active volume of SPD","",dx,dy,dz);
8253cd9a 229 *is >> i >> j;
230 SetNbinX(i);
231 SetNbinZ(j);
232 InitLowBinEdgeX();
233 InitLowBinEdgeZ();
234 for(i=0;i<fNbinx;i++) *is >> fLowBinEdgeX[i];
235 for(i=0;i<fNbinz;i++) *is >> fLowBinEdgeZ[i];
236 return;
237}
238//----------------------------------------------------------------------
239ostream &operator<<(ostream &os,AliITSgeomSPD &p){
240////////////////////////////////////////////////////////////////////////
241// Standard output streaming function.
242////////////////////////////////////////////////////////////////////////
243
244 p.Print(&os);
245 return os;
246}
247//----------------------------------------------------------------------
248istream &operator>>(istream &is,AliITSgeomSPD &r){
249////////////////////////////////////////////////////////////////////////
250// Standard input streaming function.
251////////////////////////////////////////////////////////////////////////
252
253 r.Read(&is);
254 return is;
255}
256//=====================================================================
257
8253cd9a 258ClassImp(AliITSgeomSPD300)
259
260AliITSgeomSPD300::AliITSgeomSPD300() : AliITSgeomSPD(){
261////////////////////////////////////////////////////////////////////////
262// default constructor, for ITS TDR geometry. This only consists of
263// a default constructor to construct the defalut TDR SPD detector geometry
264// 256 X 279 300 by 50 micron pixels.
265////////////////////////////////////////////////////////////////////////
266const Float_t kdx=0.6400,kdy=0.0075,kdz=4.1900; // cm; Standard pixel detector
267 // size is 2dx wide, 2dz long,
268 // and 2dy thick. Geant 3.12
269 // units.
270const Float_t kbinx0 = 0.0050; // cm; Standard pixel size in x direction.
271const Int_t knbinx = 256; // number of pixels along x direction.
272const Float_t kbinz0 = 0.0300; // cm; Standard pixel size in z direction.
273const Float_t kbinz1 = 0.0350; // cm; Edge pixel size in z direction.
274const Int_t knbinz = 279; // number of pixels along z direction.
275 Int_t i;
276 Float_t dx=0.0,dz=0.0;
277
8253cd9a 278 SetNbinX(knbinx); // default number of bins in x.
279 SetNbinZ(knbinz); // default number of bins in z.
280
281 for(i=0;i<knbinx;i++) dx += kbinx0; // Compute size x.
282 dx *= 0.5;
283 for(i=0;i<knbinz;i++) dz += kbinz0; // Compute size z.
284 dz += 2.0*(kbinz1-kbinz0);
285 dz *= 0.5;
286 InitLowBinEdgeX();
287 InitLowBinEdgeZ();
288 SetLowBinEdgeX(0,-dx); // Starting position X
289 for(i=0;i<knbinx;i++) SetLowBinEdgeX(i+1,GetBinLowEdgeX(i)+kbinx0);
290 SetLowBinEdgeZ(0,-dz); // Starting position z
291 SetLowBinEdgeZ(1,GetBinLowEdgeZ(0)+kbinz1);
292 for(i=1;i<knbinz;i++) SetLowBinEdgeZ(i+1,GetBinLowEdgeZ(i)+kbinz0);
293 SetLowBinEdgeZ(knbinz,GetBinLowEdgeZ(knbinz-1)+kbinz1);
294
31b8cd63 295 if(TMath::Abs(dx-kdx)>1.0E-4 || TMath::Abs(dz-kdz)>1.0E-4)
296 Warning("Default Creator","Detector size may not be write.");
023ae34b 297 SetShape("ActiveSPD","Active volume of SPD","",dx,kdy,dz);
8253cd9a 298}
299//----------------------------------------------------------------------
300ostream &operator<<(ostream &os,AliITSgeomSPD300 &p){
301////////////////////////////////////////////////////////////////////////
302// Standard output streaming function.
303////////////////////////////////////////////////////////////////////////
304
305 p.Print(&os);
306 return os;
307}
308//----------------------------------------------------------------------
309istream &operator>>(istream &is,AliITSgeomSPD300 &r){
310////////////////////////////////////////////////////////////////////////
311// Standard input streaming function.
312////////////////////////////////////////////////////////////////////////
313
314 r.Read(&is);
315 return is;
316}
317//=====================================================================
8253cd9a 318
319ClassImp(AliITSgeomSPD425Short)
320
e99dbc71 321AliITSgeomSPD425Short::AliITSgeomSPD425Short() : AliITSgeomSPD(){
8253cd9a 322////////////////////////////////////////////////////////////////////////
323// default constructor, for ITS post TDR geometry. This only consists of
324// a default constructor to construct the defalut post TDR SPD detector
325// geometry 256 X 197 425 by 50 micron pixels with interleaved 625 by 50
326// micron pixels (large detector).
327////////////////////////////////////////////////////////////////////////
e99dbc71 328}
329//----------------------------------------------------------------------
330AliITSgeomSPD425Short::AliITSgeomSPD425Short(Int_t npar,Float_t *par) :
331 AliITSgeomSPD(){
332////////////////////////////////////////////////////////////////////////
333// Standard constructor, for ITS post TDR geometry. This only consists of
334// a default constructor to construct the defalut post TDR SPD detector
335// geometry 256 X 197 425 by 50 micron pixels with interleaved 625 by 50
336// micron pixels (large detector).
337////////////////////////////////////////////////////////////////////////
8253cd9a 338
85f1e34a 339 const Float_t kdx=0.6400/*,kdy=0.015*/,kdz=3.480; // cm; Standard pixel
340 // detector size is 2dx
341 // wide, 2dz long, and
342 // 2dy thick. Geant 3.12
343 // units.
8253cd9a 344 const Float_t kbinx0 = 0.0050; // cm; Standard pixel size in x direction.
345 const Int_t knbinx = 256; // number of pixels along x direction.
346 const Float_t kbinz0 = 0.0425; // cm; Standard pixel size in z direction.
347 const Float_t kbinz1 = 0.0625; // cm; Special pixel size in z direction.
e99dbc71 348 const Int_t knbinz = 160; // number of pixels along z direction.
8253cd9a 349 Int_t i;
350 Float_t dx,dz,*binSizeX,*binSizeZ;
195d8dfe 351
8253cd9a 352 SetNbinX(knbinx); // default number of bins in x.
353 SetNbinZ(knbinz); // default number of bins in z.
1cea8f13 354
8253cd9a 355 binSizeX = new Float_t[knbinx]; // array of bin sizes along x.
356 for(i=0;i<knbinx;i++) binSizeX[i] = kbinx0; // default x bin size.
357 binSizeZ = new Float_t[knbinz]; // array of bin sizes along z.
358 for(i=0;i<knbinz;i++) binSizeZ[i] = kbinz0; // default z bin size.
359 binSizeZ[ 31] = kbinz1;
360 binSizeZ[ 32] = kbinz1;
361
31b8cd63 362 binSizeZ[ 63] = kbinz1;
8253cd9a 363 binSizeZ[ 64] = kbinz1;
8253cd9a 364
31b8cd63 365 binSizeZ[ 95] = kbinz1;
366 binSizeZ[ 96] = kbinz1;
8253cd9a 367
31b8cd63 368 binSizeZ[127] = kbinz1;
369 binSizeZ[128] = kbinz1;
8253cd9a 370
371 // correct detector size for bin size.
372 dx = 0.0;
373 for(i=0;i<knbinx;i++) dx += binSizeX[i];
374 dx *= 0.5;
375 dz = 0.0;
376 for(i=0;i<knbinz;i++) dz += binSizeZ[i];
377 dz *= 0.5;
378
ac74f489 379 if(npar<3){
380 Error("AliITSgeomSPD425Short",
381 "npar=%d<3 array par must be at least [3] or larger",npar);
382 return;
383 } // end if
023ae34b 384 SetShape("ActiveSPD","Active volume of SPD","",
e99dbc71 385 par[0],par[1],par[2]);
31b8cd63 386 if(TMath::Abs(dx-kdx)>1.0E-4 || TMath::Abs(dz-kdz)>1.0E-4)
387 Warning("Default Creator","Detector size may not be write.");
8253cd9a 388
389 InitLowBinEdgeX(); // array of bin sizes along x.
390 InitLowBinEdgeZ(); // array of bin sizes along x.
391 SetLowBinEdgeX(0,-dx);
392 SetLowBinEdgeZ(0,-dz);
393 for(i=0;i<knbinx;i++) SetLowBinEdgeX(i+1,GetBinLowEdgeX(i)+binSizeX[i]);
394 for(i=0;i<knbinz;i++) SetLowBinEdgeZ(i+1,GetBinLowEdgeZ(i)+binSizeZ[i]);
395}
396//----------------------------------------------------------------------
397ostream &operator<<(ostream &os,AliITSgeomSPD425Short &p){
398////////////////////////////////////////////////////////////////////////
399// Standard output streaming function.
400////////////////////////////////////////////////////////////////////////
401
402 p.Print(&os);
403 return os;
404}
405//----------------------------------------------------------------------
406istream &operator>>(istream &is,AliITSgeomSPD425Short &r){
407////////////////////////////////////////////////////////////////////////
408// Standard input streaming function.
409////////////////////////////////////////////////////////////////////////
410
411 r.Read(&is);
412 return is;
413}
414//======================================================================
415
8253cd9a 416ClassImp(AliITSgeomSPD425Long)
417
418AliITSgeomSPD425Long::AliITSgeomSPD425Long(){
419////////////////////////////////////////////////////////////////////////
420// default constructor, for ITS post TDR geometry. This only consists of
421// a default constructor to construct the defalut post TDR SPD detector
422// geometry 256 X 197 425 by 50 micron pixels with interleaved 625 by 50
423// micron pixels (large detector).
424////////////////////////////////////////////////////////////////////////
425
426 const Float_t kdx=0.6400,kdy=0.0075,kdz=4.2650; // cm; Standard pixel
427 // detector size is 2dx
428 // wide, 2dz long, and
429 // 2dy thick. Geant 3.12
430 // units.
431 const Float_t kbinx0 = 0.0050; // cm; Standard pixel size in x direction.
432 const Int_t knbinx = 256; // number of pixels along x direction.
433 const Float_t kbinz0 = 0.0425; // cm; Standard pixel size in z direction.
434 const Float_t kbinz1 = 0.0625; // cm; Special pixel size in z direction.
2d408567 435 const Int_t knbinz = 192; // number of pixels along z direction.
8253cd9a 436 Int_t i;
437 Float_t dx,dz,*binSizeX,*binSizeZ;
438
439 SetNbinX(knbinx); // default number of bins in x.
440 SetNbinZ(knbinz); // default number of bins in z.
441
442 binSizeX = new Float_t[knbinx]; // array of bin sizes along x.
443 for(i=0;i<knbinx;i++) binSizeX[i] = kbinx0; // default x bin size.
444 binSizeZ = new Float_t[knbinz]; // array of bin sizes along z.
445 for(i=0;i<knbinz;i++) binSizeZ[i] = kbinz0; // default z bin size.
446 binSizeZ[ 31] = kbinz1;
447 binSizeZ[ 32] = kbinz1;
448
2d408567 449 binSizeZ[ 63] = kbinz1;
8253cd9a 450 binSizeZ[ 64] = kbinz1;
8253cd9a 451
2d408567 452 binSizeZ[ 95] = kbinz1;
453 binSizeZ[ 96] = kbinz1;
195d8dfe 454
2d408567 455 binSizeZ[127] = kbinz1;
456 binSizeZ[128] = kbinz1;
8253cd9a 457
2d408567 458 binSizeZ[159] = kbinz1;
459 binSizeZ[160] = kbinz1;
8253cd9a 460
461 // correct detector size for bin size.
462 dx = 0.0;
463 for(i=0;i<knbinx;i++) dx += binSizeX[i];
464 dx *= 0.5;
465 dz = 0.0;
466 for(i=0;i<knbinz;i++) dz += binSizeZ[i];
467 dz *= 0.5;
468
023ae34b 469 SetShape("ActiveSPD","Active volume of SPD","",dx,kdy,dz);
31b8cd63 470 if(TMath::Abs(dx-kdx)>1.0E-4 || TMath::Abs(dz-kdz)>1.0E-4)
471 Warning("Default Creator","Detector size may not be write.");
8253cd9a 472
473 InitLowBinEdgeX(); // array of bin sizes along x.
474 InitLowBinEdgeZ(); // array of bin sizes along x.
475 SetLowBinEdgeX(0,-dx);
476 SetLowBinEdgeZ(0,-dz);
477 for(i=0;i<knbinx;i++) SetLowBinEdgeX(i+1,GetBinLowEdgeX(i)+binSizeX[i]);
478 for(i=0;i<knbinz;i++) SetLowBinEdgeZ(i+1,GetBinLowEdgeZ(i)+binSizeZ[i]);
479}
480//----------------------------------------------------------------------
481ostream &operator<<(ostream &os,AliITSgeomSPD425Long &p){
1cea8f13 482////////////////////////////////////////////////////////////////////////
8253cd9a 483// Standard output streaming function.
1cea8f13 484////////////////////////////////////////////////////////////////////////
1cea8f13 485
8253cd9a 486 p.Print(&os);
487 return os;
488}
489//----------------------------------------------------------------------
490istream &operator>>(istream &is,AliITSgeomSPD425Long &r){
491////////////////////////////////////////////////////////////////////////
492// Standard input streaming function.
493////////////////////////////////////////////////////////////////////////
195d8dfe 494
8253cd9a 495 r.Read(&is);
496 return is;
497}
498//======================================================================