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