Release version of ITS code
[u/mrichter/AliRoot.git] / ITS / AliITSgeomSPD425.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.4  2000/06/10 20:34:22  nilsen
19 Fixed compilation warning with HP unix.
20
21 Revision 1.3  2000/06/10 10:42:49  nilsen
22 Fixed bug in copy and operator =.
23
24
25 */
26
27 #include <TShape.h>
28
29 #include "AliITSgeomSPD425.h"
30
31 ClassImp(AliITSgeomSPD425)
32
33 AliITSgeomSPD425::AliITSgeomSPD425(){
34 ////////////////////////////////////////////////////////////////////////
35 //    default constructor, for ITS post TDR geometry.
36 ////////////////////////////////////////////////////////////////////////
37
38 const Float_t kdx=0.6400,kdy=0.0075,kdz=4.23625;// cm; Standard pixel detector
39                                                 // size is 2dx wide, 2dz long,
40                                                 // and 2dy thick. Geant 3.12
41                                                 // units.
42 const Float_t kbinx0 = 0.0050; // cm; Standard pixel size in x direction.
43 const Int_t   knbinx = 256;    // number of pixels along x direction.
44 const Float_t kbinz0 = 0.0425; // cm; Standard pixel size in z direction.
45 const Float_t kbinz1 = 0.0625; // cm; Special pixel size in z direction.
46 const Int_t   knbinz = 197;    // number of pixels along z direction.
47     Int_t i;
48
49     fdx = kdx;  // default value.
50     fdy = kdy;  // default value.
51     fdz = kdz;  // default value.
52     fNbinx = knbinx; // default number of bins in x.
53     fNbinz = knbinz; // default number of bins in z.
54
55     fBinSizeX = new Float_t[fNbinx]; // array of bin sizes along x.
56     for(i=0;i<fNbinx;i++) fBinSizeX[i] = kbinx0; // default x bin size.
57     fBinSizeZ = new Float_t[fNbinz]; // array of bin sizes along z.
58     for(i=0;i<fNbinz;i++) fBinSizeZ[i] = kbinz0; // default z bin size.
59     fBinSizeZ[ 31] = kbinz1;
60     fBinSizeZ[ 32] = kbinz1;
61
62     fBinSizeZ[ 64] = kbinz1;
63     fBinSizeZ[ 65] = kbinz1;
64
65     fBinSizeZ[ 97] = kbinz1;
66     fBinSizeZ[ 98] = kbinz1;
67
68     fBinSizeZ[130] = kbinz1;
69     fBinSizeZ[131] = kbinz1;
70
71     fBinSizeZ[163] = kbinz1;
72     fBinSizeZ[164] = kbinz1;
73
74     // correct detector size for bin size.
75     fdx = 0.0;
76     for(i=0;i<fNbinx;i++) fdx +=fBinSizeX[i];
77     fdx *= 0.5;
78     fdz = 0.0;
79     for(i=0;i<fNbinz;i++) fdz +=fBinSizeZ[i];
80     fdz *= 0.5;
81
82     fShapeSPD = new TBRIK("ActiveSPD","Active volume of SPD","SPD SI DET",
83                           fdx,fdy,fdz);
84 }
85 //______________________________________________________________________
86 AliITSgeomSPD425::AliITSgeomSPD425(Float_t dy,Int_t nx,Float_t *bx,
87                                                 Int_t nz,Float_t *bz){
88 ////////////////////////////////////////////////////////////////////////
89 //    default constructor, for a User modified TDR based geometry.
90 ////////////////////////////////////////////////////////////////////////
91     Int_t i;
92     fdx = 0.0;
93     fdy =  dy;
94     fdz = 0.0;
95     fNbinx = nx; // new number of bins in x.
96     fNbinz = nz; // new number of bins in z.
97
98     fBinSizeX = new Float_t[fNbinx]; // array of bin sizes along x.
99     for(i=0;i<fNbinx;i++) fBinSizeX[i] = bx[i]; // new x bin size.
100     fBinSizeZ = new Float_t[fNbinz]; // array of bin sizes along z.
101     for(i=0;i<fNbinz;i++) fBinSizeZ[i] = bz[i]; // new z bin size.
102
103     // correct detector size for bin size.
104     for(i=0;i<fNbinx;i++) fdx +=fBinSizeX[i];
105     fdx *= 0.5;
106     for(i=0;i<fNbinz;i++) fdz +=fBinSizeZ[i];
107     fdz *= 0.5;
108
109     fShapeSPD = new TBRIK("ActiveSPD","Active volume of SPD","SPD SI DET",
110                           fdx,fdy,fdz);
111 }
112 //______________________________________________________________________
113 AliITSgeomSPD425::AliITSgeomSPD425(AliITSgeomSPD425 &source){
114   // copy constructor
115     Int_t i;
116     if(&source == this) return;
117     this->fShapeSPD = new TBRIK(*(source.fShapeSPD));
118     this->fdx = source.fdx;
119     this->fdy = source.fdy;
120     this->fdz = source.fdz;
121     if(this->fBinSizeX) delete[] this->fBinSizeX; 
122     if(this->fBinSizeX) delete[] this->fBinSizeZ;
123     this->fNbinx = source.fNbinx;
124     this->fBinSizeX = new Float_t[this->fNbinx];
125     this->fNbinz = source.fNbinz;
126     this->fBinSizeZ = new Float_t[this->fNbinz];
127     for(i=0;i<fNbinx;i++) this->fBinSizeX[i] = source.fBinSizeX[i];
128     for(i=0;i<fNbinz;i++) this->fBinSizeZ[i] = source.fBinSizeZ[i];
129 }
130 //______________________________________________________________________
131 AliITSgeomSPD425& AliITSgeomSPD425::operator=(AliITSgeomSPD425 &source){
132   // = operator
133     Int_t i;
134     if(&source == this) return *this;
135     this->fShapeSPD = new TBRIK(*(source.fShapeSPD));
136     this->fdx = source.fdx;
137     this->fdy = source.fdy;
138     this->fdz = source.fdz;
139     if(this->fBinSizeX) delete[] this->fBinSizeX; 
140     if(this->fBinSizeX) delete[] this->fBinSizeZ;
141     this->fNbinx = source.fNbinx;
142     this->fBinSizeX = new Float_t[this->fNbinx];
143     this->fNbinz = source.fNbinz;
144     this->fBinSizeZ = new Float_t[this->fNbinz];
145     for(i=0;i<fNbinx;i++) this->fBinSizeX[i] = source.fBinSizeX[i];
146     for(i=0;i<fNbinz;i++) this->fBinSizeZ[i] = source.fBinSizeZ[i];
147     return *this;
148 }
149 //______________________________________________________________________
150 AliITSgeomSPD425::~AliITSgeomSPD425(){
151   // destructor
152     delete[] fBinSizeX;
153     delete[] fBinSizeZ;
154     delete   fShapeSPD;
155 }
156 //______________________________________________________________________
157 void AliITSgeomSPD425::ReSetBins(Float_t dy,Int_t nx,Float_t *bx,
158                                         Int_t nz,Float_t *bz){
159 ////////////////////////////////////////////////////////////////////////
160 //    default constructor, for a User modified TDR based geometry.
161 ////////////////////////////////////////////////////////////////////////
162     Int_t i;
163     fdx = 0.0;
164     fdy =  dy;
165     fdz = 0.0;
166     fNbinx = nx; // new number of bins in x.
167     fNbinz = nz; // new number of bins in z.
168
169     if(fBinSizeX!=0) delete[] fBinSizeX;
170     fBinSizeX = new Float_t[fNbinx]; // array of bin sizes along x.
171     for(i=0;i<fNbinx;i++) fBinSizeX[i] = bx[i]; // new x bin size.
172     if(fBinSizeZ!=0) delete[] fBinSizeZ;
173     fBinSizeZ = new Float_t[fNbinz]; // array of bin sizes along z.
174     for(i=0;i<fNbinz;i++) fBinSizeZ[i] = bz[i]; // new z bin size.
175
176     // correct detector size for bin size.
177     for(i=0;i<fNbinx;i++) fdx +=fBinSizeX[i];
178     fdx *= 0.5;
179     for(i=0;i<fNbinz;i++) fdz +=fBinSizeZ[i];
180     fdz *= 0.5;
181
182     fShapeSPD = new TBRIK("ActiveSPD","Active volume of SPD","SPD SI DET",
183                           fdx,fdy,fdz);
184 }
185 //----------------------------------------------------------------------
186 void AliITSgeomSPD425::Streamer(TBuffer &R__b){
187     // Streamer function for the class AliITSgeomSPD425.
188     Int_t i;
189     UInt_t R__s, R__c;
190
191     if(R__b.IsReading()){
192         Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
193         if(R__v==1){
194             TObject::Streamer(R__b);
195             fShapeSPD->Streamer(R__b);
196             R__b >> fdx;
197             R__b >> fdy;
198             R__b >> fdz;
199         }else if (R__v==2){
200             AliITSgeomSPD::Streamer(R__b);
201             fShapeSPD->Streamer(R__b);
202             R__b >> fdx;
203             R__b >> fdy;
204             R__b >> fdz;
205             R__b >> fNbinx;
206             if(fBinSizeX!=0) delete[] fBinSizeX;
207             fBinSizeX = new Float_t[fNbinx];
208             for(i=0;i<fNbinx;i++) R__b >> fBinSizeX[i];
209             R__b >> fNbinz;
210             if(fBinSizeZ!=0) delete[] fBinSizeZ;
211             fBinSizeZ = new Float_t[fNbinz];
212             for(i=0;i<fNbinz;i++) R__b >> fBinSizeZ[i];
213             R__b.CheckByteCount(R__s, R__c, AliITSgeomSPD425::IsA());
214         } // end if R__v==1
215     } else { // IsWriting.
216         R__c = R__b.WriteVersion(AliITSgeomSPD425::IsA(), kTRUE);
217         AliITSgeomSPD::Streamer(R__b);
218         fShapeSPD->Streamer(R__b);
219         R__b << fdx;
220         R__b << fdy;
221         R__b << fdz;
222         R__b << fNbinx;
223         for(i=0;i<fNbinx;i++) R__b << fBinSizeX[i];
224         R__b << fNbinz;
225         for(i=0;i<fNbinz;i++) R__b << fBinSizeZ[i];
226         R__b.SetByteCount(R__c, kTRUE);
227     } // end if R__b.IsReading()
228 }
229 //----------------------------------------------------------------------