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