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