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