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