]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomSSD.cxx
Update class version number
[u/mrichter/AliRoot.git] / ITS / AliITSgeomSSD.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 Strip Detector, SSD, specific geometry.
20 // It is being replaced by AliITSsegmentationSSD class. This file also
21 // constains classes derived from AliITSgeomSSD which do nothing but
22 // initilize this one with predefined values.
23 ////////////////////////////////////////////////////////////////////////
24
25 #include <Riostream.h>
26 #include <stdlib.h>
27 #include <TShape.h>
28 #include <TBRIK.h>
29
30 #include "AliITSgeomSSD.h"
31
32 ClassImp(AliITSgeomSSD)
33
34
35 AliITSgeomSSD::AliITSgeomSSD(){
36 // Default constructor
37     fShapeSSD = 0;
38     fNp       = 0;
39     fNn       = 0;
40     fLowEdgeP = 0;
41     fLowEdgeN = 0;
42     fAngleP   = 0.0;
43     fAngleN   = 0.0;
44 }
45 //----------------------------------------------------------------------
46 AliITSgeomSSD::AliITSgeomSSD(const Float_t *box,Float_t ap,Float_t an,
47                              Int_t np,Float_t *p,Int_t nn,Float_t *n){
48 ////////////////////////////////////////////////////////////////////////
49 //    Standard Constructor. *box={dx,dy,dz}, ap=anode angle, an=cathode angle,
50 // nn= number of cathodes+1,*n= array of cathode low edges+highest edge,
51 // np= number of anodes+1, *p= array of anode low edges+lighest edge.
52 ///////////////////////////////////////////////////////////////////////
53     fShapeSSD = 0;
54     fNp       = 0;
55     fNn       = 0;
56     fLowEdgeP = 0;
57     fLowEdgeN = 0;
58     fAngleP   = 0.0;
59     fAngleN   = 0.0;
60     ResetSSD(box,ap,an,np,p,nn,n);
61 }
62 //----------------------------------------------------------------------
63 void AliITSgeomSSD::ResetSSD(const Float_t *box,Float_t ap,Float_t an,
64                              Int_t np,Float_t *p,Int_t nn,Float_t *n){
65 ////////////////////////////////////////////////////////////////////////
66 //    Standard Filler. *box={dx,dy,dz}, ap=anode angle, an=cathode angle,
67 // nn= number of cathodes+1,*n= array of cathode low edges+highest edge,
68 // np= number of anodes+1, *p= array of anode low edges+lighest edge.
69 ///////////////////////////////////////////////////////////////////////
70     Int_t i;
71
72     fShapeSSD = new TBRIK("ActiveSSD","Active volume of SSD","SSD SI DET",
73                           box[0],box[1],box[2]);
74 //    if(fLowEdgeP!=0) delete fLowEdgeP;
75 //    if(fLowEdgeN!=0) delete fLowEdgeN;
76     fNp = np;
77     fNn = nn;
78     fAngleP = ap;
79     fAngleN = an;
80     fLowEdgeP = new Float_t[fNp];
81     fLowEdgeN = new Float_t[fNn];
82     for(i=0;i<fNp;i++) fLowEdgeP[i] = p[i];
83     for(i=0;i<fNn;i++) fLowEdgeN[i] = n[i];
84 }
85 //______________________________________________________________________
86 AliITSgeomSSD::~AliITSgeomSSD(){
87     // Destructor.
88
89     if(fLowEdgeP) delete [] fLowEdgeP; fLowEdgeP = 0;
90     if(fLowEdgeN) delete [] fLowEdgeN; fLowEdgeN = 0;
91     if(fShapeSSD) delete  fShapeSSD; fShapeSSD = 0;
92     fNp = 0;
93     fNn = 0;
94     fAngleP = 0.0;
95     fAngleN = 0.0;
96 }
97 //______________________________________________________________________
98 AliITSgeomSSD::AliITSgeomSSD(const AliITSgeomSSD &source) : TObject(source){
99 ////////////////////////////////////////////////////////////////////////
100 //    copy  constructor
101 ////////////////////////////////////////////////////////////////////////
102     Int_t i;
103
104     if(this == &source) return;
105     this->fShapeSSD = new TBRIK(*(source.fShapeSSD));
106     this->fNp = source.fNp;
107     this->fNn = source.fNn;
108     delete fLowEdgeP;
109     delete fLowEdgeN;
110     this->fAngleP = source.fAngleP;
111     this->fAngleN = source.fAngleN;
112     fLowEdgeP = new Float_t[fNp];
113     fLowEdgeN = new Float_t[fNn];
114     for(i=0;i<fNp;i++) this->fLowEdgeP[i] = source.fLowEdgeP[i];
115     for(i=0;i<fNn;i++) this->fLowEdgeN[i] = source.fLowEdgeN[i];
116     return;
117 }  
118
119 AliITSgeomSSD& AliITSgeomSSD::operator=(const AliITSgeomSSD &source) {
120 ////////////////////////////////////////////////////////////////////////
121 //    assignment operator
122 ////////////////////////////////////////////////////////////////////////
123     Int_t i;
124
125     if(this == &source) return *this;
126     this->fShapeSSD = new TBRIK(*(source.fShapeSSD));
127     this->fNp = source.fNp;
128     this->fNn = source.fNn;
129     delete fLowEdgeP;
130     delete fLowEdgeN;
131     this->fAngleP = source.fAngleP;
132     this->fAngleN = source.fAngleN;
133     fLowEdgeP = new Float_t[fNp];
134     fLowEdgeN = new Float_t[fNn];
135     for(i=0;i<fNp;i++) this->fLowEdgeP[i] = source.fLowEdgeP[i];
136     for(i=0;i<fNn;i++) this->fLowEdgeN[i] = source.fLowEdgeN[i];
137     return *this;
138 }
139 //______________________________________________________________________
140 void AliITSgeomSSD::Local2Det(Float_t x,Float_t z,Int_t &a,Int_t &c){
141     // Given a GEANT detector local coordinate, cm, this function returns
142     // the detector specific P and N side strip numbers.
143     // Inputs are:
144     // Float_t x   Geant detector local x coordinate in cm
145     // Float_t z   Geant detector local z coordinate in cm
146     // outputs are:
147     // Int_t &a    Detector anode strip number (P side)
148     // Int_t &c    Detector cathode strip number (N side)
149     Float_t d,b;
150     Int_t i;
151
152     // project on to bonding edges.
153     d = x*TMath::Cos(fAngleP)+z*TMath::Sin(fAngleP);
154     b = x*TMath::Cos(fAngleN)+z*TMath::Sin(fAngleN);
155     if(d<fLowEdgeP[0]) i=-1;
156     else for(i=0;i<fNp;i++){
157         if(fLowEdgeP[i]<d) break;
158     } // end for i
159     a = i;
160     if(b<fLowEdgeN[0]) i=-1;
161     else for(i=0;i<fNn;i++){
162         if(fLowEdgeN[i]<b) break;
163     } // end for i
164     c = i;
165     return;
166 }
167 //______________________________________________________________________
168 void AliITSgeomSSD::Det2Local(Int_t a,Int_t c,Float_t &x,Float_t &z){
169 //    Float_t d,b;
170 //    Int_t i;
171     // use AliITSsegmentationSSD.
172
173     x=a;
174     z=c;
175     Error("Det2Locat","Use AliITSsegmentationSSD");
176     return;
177 }
178 //______________________________________________________________________
179 void AliITSgeomSSD::Print(ostream *os) const {
180 ////////////////////////////////////////////////////////////////////////
181 // Standard output format for this class.
182 ////////////////////////////////////////////////////////////////////////
183     Int_t i;
184 #if defined __GNUC__
185 #if __GNUC__ > 2
186     ios::fmtflags fmt;
187 #else
188     Int_t fmt;
189 #endif
190 #else
191 #if defined __ICC || defined __ECC || defined __xlC__
192     ios::fmtflags fmt;
193 #else
194     Int_t fmt;
195 #endif
196 #endif
197
198     fmt = os->setf(ios::scientific);  // set scientific floating point output
199     *os << "TBRIK" << " ";
200     *os << setprecision(16) << GetDx() << " ";
201     *os << setprecision(16) << GetDy() << " ";
202     *os << setprecision(16) << GetDz() << " ";
203     *os << fNp << " " << fNn << " ";
204     *os << setprecision(16) << fAngleP << " ";
205     *os << setprecision(16) << fAngleN << " ";
206     for(i=0;i<fNp;i++) *os << setprecision(16) << fLowEdgeP[i] << " ";
207     for(i=0;i<fNn;i++) *os << setprecision(16) << fLowEdgeN[i] << " ";
208     *os << endl;
209     os->flags(fmt); // reset back to old formating.
210     return;
211 }
212 //______________________________________________________________________
213 void AliITSgeomSSD::Read(istream *is){
214 ////////////////////////////////////////////////////////////////////////
215 // Standard input format for this class.
216 ////////////////////////////////////////////////////////////////////////
217     Float_t dx,dy,dz;
218     Int_t i;
219     char shp[20];
220
221     *is >> shp;
222     *is >> dx >> dy >> dz;
223     if(fShapeSSD!=0) delete fShapeSSD;
224     fShapeSSD = new TBRIK("ActiveSSD","Active volume of SSD","SSD SI DET",
225                             dx,dy,dz);
226     *is >> fNp >> fNn;
227     *is >> fAngleP >> fAngleN;
228     if(fLowEdgeP !=0) delete fLowEdgeP;
229     if(fLowEdgeN !=0) delete fLowEdgeN;
230     fLowEdgeP = new Float_t[fNp];
231     fLowEdgeN = new Float_t[fNn];
232     for(i=0;i<fNp;i++) *is >> fLowEdgeP[i];
233     for(i=0;i<fNn;i++) *is >> fLowEdgeN[i];
234     return;
235 }
236 //----------------------------------------------------------------------
237 ostream &operator<<(ostream &os,AliITSgeomSSD &p){
238 ////////////////////////////////////////////////////////////////////////
239 // Standard output streaming function.
240 ////////////////////////////////////////////////////////////////////////
241
242     p.Print(&os);
243     return os;
244 }
245 //----------------------------------------------------------------------
246 istream &operator>>(istream &is,AliITSgeomSSD &r){
247 ////////////////////////////////////////////////////////////////////////
248 // Standard input streaming function.
249 ////////////////////////////////////////////////////////////////////////
250
251     r.Read(&is);
252     return is;
253 }
254 //======================================================================
255
256 ClassImp(AliITSgeomSSD175)
257
258 AliITSgeomSSD175::AliITSgeomSSD175() : AliITSgeomSSD(){
259 ////////////////////////////////////////////////////////////////////////
260 //    default constructor
261 ////////////////////////////////////////////////////////////////////////
262     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
263     // Size of sensitive detector area x,y(thickness),z
264     const Float_t kangle   = 0.0175; // angle in rad. of anode and cathodes
265     const Float_t kpitch   = 0.0095;// cm anode separation.
266     const Int_t   kNstrips = 768; // number of anode or cathode strips.
267     Float_t *leA,*leC; // array of low edges anode and cathorde.
268     Int_t i;
269
270     leA = new Float_t[kNstrips+1];
271     leC = new Float_t[kNstrips+1];
272     leA[0] = -kDxyz[0];
273     leA[1] = -kpitch*(0.5*kNstrips-1);
274     leC[0] =  kDxyz[0];
275     leC[1] =  kpitch*(0.5*kNstrips-1);
276     for(i=1;i<kNstrips;i++){
277         leA[i+1] = leA[i] + kpitch;
278         leC[i+1] = leC[i] - kpitch;
279     } // end for i
280     leA[kNstrips] =  kDxyz[0];
281     leC[kNstrips] = -kDxyz[0];
282 //    cout << "AliITSgeomSSD175 default creator called: start" << endl;
283     AliITSgeomSSD::ResetSSD(kDxyz,kangle,-kangle,
284                                  kNstrips+1,leA,kNstrips+1,leC);
285     delete leA;
286     delete leC;
287 //    cout << "AliITSgeomSSD175 default creator called: end" << endl;
288 }
289 //________________________________________________________________________
290 ostream &operator<<(ostream &os,AliITSgeomSSD175 &p){
291 ////////////////////////////////////////////////////////////////////////
292 // Standard output streaming function.
293 ////////////////////////////////////////////////////////////////////////
294
295     p.Print(&os);
296     return os;
297 }
298 //----------------------------------------------------------------------
299 istream &operator>>(istream &is,AliITSgeomSSD175 &r){
300 ////////////////////////////////////////////////////////////////////////
301 // Standard input streaming function.
302 ////////////////////////////////////////////////////////////////////////
303
304     r.Read(&is);
305     return is;
306 }
307 //======================================================================
308
309 ClassImp(AliITSgeomSSD275and75)
310
311 AliITSgeomSSD275and75::AliITSgeomSSD275and75() : AliITSgeomSSD(){
312 ////////////////////////////////////////////////////////////////////////
313 //    default constructor
314 ////////////////////////////////////////////////////////////////////////
315 }
316 //----------------------------------------------------------------------
317 AliITSgeomSSD275and75::AliITSgeomSSD275and75(Int_t npar,Float_t *par) : 
318                                                             AliITSgeomSSD(){
319     // Default constructor for AliITSgeomSSD with strip angles of
320     // 275 miliradians and 75 miliradians. This constructor initlizes
321     // AliITSgeomSSD with the correct values. This is the miror image
322     // of the AliITSgeomSSD75and275 class.
323     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
324     // Size of sensitive detector area x,y(thickness),z
325     const Float_t kangleA  = 0.0275; // angle in rad. of anode and cathodes
326     const Float_t kangleC  = 0.0075; // angle in rad. of anode and cathodes
327     const Float_t kpitch   = 0.0095;// cm anode separation.
328     const Int_t   kNstrips = 768; // number of anode or cathode strips.
329     Float_t *leA,*leC; // array of low edges anode and cathorde.
330     Int_t i;
331
332     if(npar<3){
333         Error("AliITSgeomSSD275and75",
334               "npar=%d<3. array par must be [3] or larger.",npar);
335         return;
336     } // end if
337     leA = new Float_t[kNstrips+1];
338     leC = new Float_t[kNstrips+1];
339     leA[0] = -kDxyz[0];
340     leA[1] = -kpitch*(0.5*kNstrips-1);
341     leC[0] =  kDxyz[0];
342     leC[1] =  kpitch*(0.5*kNstrips-1);
343     for(i=1;i<kNstrips;i++){
344         leA[i+1] = leA[i] + kpitch;
345         leC[i+1] = leC[i] - kpitch;
346     } // end for i
347     leA[kNstrips] =  kDxyz[0];
348     leC[kNstrips] = -kDxyz[0];
349 //    cout << "AliITSgeomSSD275and75 default creator called: start" << endl;
350     AliITSgeomSSD::ResetSSD(par,kangleA,kangleC,
351                                  kNstrips+1,leA,kNstrips+1,leC);
352     delete [] leA;
353     delete [] leC;
354 //    cout << "AliITSgeomSSD275and75 default creator called: end" << endl;
355 }
356 //________________________________________________________________________
357 ostream &operator<<(ostream &os,AliITSgeomSSD275and75 &p){
358 ////////////////////////////////////////////////////////////////////////
359 // Standard output streaming function.
360 ////////////////////////////////////////////////////////////////////////
361
362     p.Print(&os);
363     return os;
364 }
365 //----------------------------------------------------------------------
366 istream &operator>>(istream &is,AliITSgeomSSD275and75 &r){
367 ////////////////////////////////////////////////////////////////////////
368 // Standard input streaming function.
369 ////////////////////////////////////////////////////////////////////////
370
371     r.Read(&is);
372     return is;
373 }
374 //======================================================================
375
376 ClassImp(AliITSgeomSSD75and275)
377
378 AliITSgeomSSD75and275::AliITSgeomSSD75and275() : AliITSgeomSSD(){
379 ////////////////////////////////////////////////////////////////////////
380 //    default constructor
381 ////////////////////////////////////////////////////////////////////////
382 }
383 AliITSgeomSSD75and275::AliITSgeomSSD75and275(Int_t npar,Float_t *par) : 
384                                                             AliITSgeomSSD(){
385     // Default constructor for AliITSgeomSSD with strip angles of
386     // 75 miliradians and 275 miliradians. This constructor initlizes
387     // AliITSgeomSSD with the correct values. This is the miror image
388     // of the AliITSgeomSSD275and75 class.
389     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
390     // Size of sensitive detector area x,y(thickness),z
391     const Float_t kangleA  = 0.0075; // angle in rad. of anode and cathodes
392     const Float_t kangleC  = 0.0275; // angle in rad. of anode and cathodes
393     const Float_t kpitch   = 0.0095;// cm anode separation.
394     const Int_t   kNstrips = 768; // number of anode or cathode strips.
395     Float_t *leA,*leC; // array of low edges anode and cathorde.
396     Int_t i;
397
398     if(npar<3){
399         Error("AliITSgeomSSD75and275",
400               "npar=%d<3. array par must be [3] or larger.",npar);
401         return;
402     } // end if
403     leA = new Float_t[kNstrips+1];
404     leC = new Float_t[kNstrips+1];
405     leA[0] = -kDxyz[0];
406     leA[1] = -kpitch*(0.5*kNstrips-1);
407     leC[0] =  kDxyz[0];
408     leC[1] =  kpitch*(0.5*kNstrips-1);
409     for(i=1;i<kNstrips;i++){
410         leA[i+1] = leA[i] + kpitch;
411         leC[i+1] = leC[i] - kpitch;
412     } // end for i
413     leA[kNstrips] =  kDxyz[0];
414     leC[kNstrips] = -kDxyz[0];
415 //    cout << "AliITSgeomSSD275and75 default creator called: start" << endl;
416     AliITSgeomSSD::ResetSSD(par,kangleA,kangleC,
417                                  kNstrips+1,leA,kNstrips+1,leC);
418     delete leA;
419     delete leC;
420 //    cout << "AliITSgeomSSD275and75 default creator called: end" << endl;
421 }
422 //________________________________________________________________________
423 ostream &operator<<(ostream &os,AliITSgeomSSD75and275 &p){
424 ////////////////////////////////////////////////////////////////////////
425 // Standard output streaming function.
426 ////////////////////////////////////////////////////////////////////////
427
428     p.Print(&os);
429     return os;
430 }
431 //----------------------------------------------------------------------
432 istream &operator>>(istream &is,AliITSgeomSSD75and275 &r){
433 ////////////////////////////////////////////////////////////////////////
434 // Standard input streaming function.
435 ////////////////////////////////////////////////////////////////////////
436
437     r.Read(&is);
438     return is;
439 }
440 //======================================================================