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