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