]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomSPD.cxx
Bug fix.
[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 /*
17 $Log$
18 Revision 1.9  2001/02/09 00:00:57  nilsen
19 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
20 bugs in iostream based streamers used to read and write .det files. Fixed
21 some detector sizes. Fixed bugs in some default-special constructors.
22
23 Revision 1.8  2001/02/03 00:00:30  nilsen
24 New version of AliITSgeom and related files. Now uses automatic streamers,
25 set up for new formatted .det file which includes detector information.
26 Additional smaller modifications are still to come.
27
28 */
29
30 #include <iostream.h>
31 #include <iomanip.h>
32 #include <TShape.h>
33 #include <TMath.h>
34
35 #include "AliITSgeomSPD.h"
36
37 ClassImp(AliITSgeomSPD)
38
39 AliITSgeomSPD::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 //______________________________________________________________________
49 AliITSgeomSPD::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 //______________________________________________________________________
62 void 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 //______________________________________________________________________
90 AliITSgeomSPD::AliITSgeomSPD(AliITSgeomSPD &source){
91     // Copy constructor
92
93     *this = source; // just use the = operator for now.
94     return;
95 }
96 //______________________________________________________________________
97 AliITSgeomSPD& 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 //______________________________________________________________________
114 AliITSgeomSPD::~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 //______________________________________________________________________
127 void 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 //______________________________________________________________________
145 void 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 //______________________________________________________________________
157 void AliITSgeomSPD::Print(ostream *os) const {
158 // Standard output format for this class
159     Int_t i;
160     Int_t fmt;
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] << " ";
169     for(i=0;i<fNbinz;i++) *os << setprecision(16) << fLowBinEdgeZ[i] << " ";
170     *os << endl;
171     os->flags(fmt);
172     return;
173 }
174 //______________________________________________________________________
175 void 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 //----------------------------------------------------------------------
197 ostream &operator<<(ostream &os,AliITSgeomSPD &p){
198 ////////////////////////////////////////////////////////////////////////
199 // Standard output streaming function.
200 ////////////////////////////////////////////////////////////////////////
201
202     p.Print(&os);
203     return os;
204 }
205 //----------------------------------------------------------------------
206 istream &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$
218 Revision 1.9  2001/02/09 00:00:57  nilsen
219 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
220 bugs in iostream based streamers used to read and write .det files. Fixed
221 some detector sizes. Fixed bugs in some default-special constructors.
222
223 Revision 1.8  2001/02/03 00:00:30  nilsen
224 New version of AliITSgeom and related files. Now uses automatic streamers,
225 set up for new formatted .det file which includes detector information.
226 Additional smaller modifications are still to come.
227
228 Revision 1.7  2000/10/02 16:32:35  barbera
229 Forward declaration added
230
231 Revision 1.1.2.8  2000/10/02 15:52:05  barbera
232 Forward declaration added
233
234 Revision 1.6  2000/07/10 16:07:18  fca
235 Release version of ITS code
236
237 Revision 1.4  2000/06/10 20:34:37  nilsen
238 Fixed compilation warning with HP unix.
239
240 Revision 1.3  2000/06/10 10:43:04  nilsen
241 Fixed bug in copy and operator =.
242
243 */
244
245 //#include "AliITSgeomSPD300.h"
246
247 ClassImp(AliITSgeomSPD300)
248
249 AliITSgeomSPD300::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 ////////////////////////////////////////////////////////////////////////
255 const 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.
259 const Float_t kbinx0 = 0.0050; // cm; Standard pixel size in x direction.
260 const Int_t   knbinx = 256;    // number of pixels along x direction.
261 const Float_t kbinz0 = 0.0300; // cm; Standard pixel size in z direction.
262 const Float_t kbinz1 = 0.0350; // cm; Edge pixel size in z direction.
263 const 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
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.");
288     SetShape("ActiveSPD","Active volume of SPD","SPD SI DET",dx,kdy,dz);
289 //    cout << "AliITSgeomSPD300 default creator called: end" << endl;
290 }
291 //----------------------------------------------------------------------
292 ostream &operator<<(ostream &os,AliITSgeomSPD300 &p){
293 ////////////////////////////////////////////////////////////////////////
294 // Standard output streaming function.
295 ////////////////////////////////////////////////////////////////////////
296
297     p.Print(&os);
298     return os;
299 }
300 //----------------------------------------------------------------------
301 istream &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$
312 Revision 1.9  2001/02/09 00:00:57  nilsen
313 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
314 bugs in iostream based streamers used to read and write .det files. Fixed
315 some detector sizes. Fixed bugs in some default-special constructors.
316
317 Revision 1.8  2001/02/03 00:00:30  nilsen
318 New version of AliITSgeom and related files. Now uses automatic streamers,
319 set up for new formatted .det file which includes detector information.
320 Additional smaller modifications are still to come.
321
322 Revision 1.7  2000/10/02 16:32:35  barbera
323 Forward declaration added
324
325 Revision 1.1.2.8  2000/10/02 15:52:05  barbera
326 Forward declaration added
327
328 Revision 1.6  2000/07/10 16:07:18  fca
329 Release version of ITS code
330
331 Revision 1.4  2000/06/10 20:34:22  nilsen
332 Fixed compilation warning with HP unix.
333
334 Revision 1.3  2000/06/10 10:42:49  nilsen
335 Fixed bug in copy and operator =.
336
337
338 */
339
340 //#include "AliITSgeomSPD425Short.h"
341
342 ClassImp(AliITSgeomSPD425Short)
343
344 AliITSgeomSPD425Short::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
352     const Float_t kdx=0.6400,kdy=0.015,kdz=3.480;   // cm; Standard pixel
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.
361     const Int_t   knbinz = 161;    // number of pixels along z direction.
362     Int_t i;
363     Float_t dx,dz,*binSizeX,*binSizeZ;
364
365     SetNbinX(knbinx); // default number of bins in x.
366     SetNbinZ(knbinz); // default number of bins in z.
367
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
375     binSizeZ[ 63] = kbinz1;
376     binSizeZ[ 64] = kbinz1;
377
378     binSizeZ[ 95] = kbinz1;
379     binSizeZ[ 96] = kbinz1;
380
381     binSizeZ[127] = kbinz1;
382     binSizeZ[128] = kbinz1;
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);
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.");
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 //----------------------------------------------------------------------
404 ostream &operator<<(ostream &os,AliITSgeomSPD425Short &p){
405 ////////////////////////////////////////////////////////////////////////
406 // Standard output streaming function.
407 ////////////////////////////////////////////////////////////////////////
408
409     p.Print(&os);
410     return os;
411 }
412 //----------------------------------------------------------------------
413 istream &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$
425 Revision 1.9  2001/02/09 00:00:57  nilsen
426 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
427 bugs in iostream based streamers used to read and write .det files. Fixed
428 some detector sizes. Fixed bugs in some default-special constructors.
429
430 Revision 1.8  2001/02/03 00:00:30  nilsen
431 New version of AliITSgeom and related files. Now uses automatic streamers,
432 set up for new formatted .det file which includes detector information.
433 Additional smaller modifications are still to come.
434
435 Revision 1.7  2000/10/02 16:32:35  barbera
436 Forward declaration added
437
438 Revision 1.1.2.8  2000/10/02 15:52:05  barbera
439 Forward declaration added
440
441 Revision 1.6  2000/07/10 16:07:18  fca
442 Release version of ITS code
443
444 Revision 1.4  2000/06/10 20:34:22  nilsen
445 Fixed compilation warning with HP unix.
446
447 Revision 1.3  2000/06/10 10:42:49  nilsen
448 Fixed bug in copy and operator =.
449
450
451 */
452
453 //#include "AliITSgeomSPD425Long.h"
454
455 ClassImp(AliITSgeomSPD425Long)
456
457 AliITSgeomSPD425Long::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.
474     const Int_t   knbinz = 192;    // number of pixels along z direction.
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
488     binSizeZ[ 63] = kbinz1;
489     binSizeZ[ 64] = kbinz1;
490
491     binSizeZ[ 95] = kbinz1;
492     binSizeZ[ 96] = kbinz1;
493
494     binSizeZ[127] = kbinz1;
495     binSizeZ[128] = kbinz1;
496
497     binSizeZ[159] = kbinz1;
498     binSizeZ[160] = kbinz1;
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);
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.");
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 //----------------------------------------------------------------------
520 ostream &operator<<(ostream &os,AliITSgeomSPD425Long &p){
521 ////////////////////////////////////////////////////////////////////////
522 // Standard output streaming function.
523 ////////////////////////////////////////////////////////////////////////
524
525     p.Print(&os);
526     return os;
527 }
528 //----------------------------------------------------------------------
529 istream &operator>>(istream &is,AliITSgeomSPD425Long &r){
530 ////////////////////////////////////////////////////////////////////////
531 // Standard input streaming function.
532 ////////////////////////////////////////////////////////////////////////
533
534     r.Read(&is);
535     return is;
536 }
537 //======================================================================