]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomSSD.cxx
Transition to newIO
[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 AliITSgeomSSD::AliITSgeomSSD(const AliITSgeomSSD &source){
98 ////////////////////////////////////////////////////////////////////////
99 //    copy  constructor
100 ////////////////////////////////////////////////////////////////////////
101     Int_t i;
102
103     if(this == &source) return;
104     this->fShapeSSD = new TBRIK(*(source.fShapeSSD));
105     this->fNp = source.fNp;
106     this->fNn = source.fNn;
107     delete fLowEdgeP;
108     delete fLowEdgeN;
109     this->fAngleP = source.fAngleP;
110     this->fAngleN = source.fAngleN;
111     fLowEdgeP = new Float_t[fNp];
112     fLowEdgeN = new Float_t[fNn];
113     for(i=0;i<fNp;i++) this->fLowEdgeP[i] = source.fLowEdgeP[i];
114     for(i=0;i<fNn;i++) this->fLowEdgeN[i] = source.fLowEdgeN[i];
115     return;
116 }  
117
118 AliITSgeomSSD& AliITSgeomSSD::operator=(const AliITSgeomSSD &source) {
119 ////////////////////////////////////////////////////////////////////////
120 //    assignment operator
121 ////////////////////////////////////////////////////////////////////////
122     Int_t i;
123
124     if(this == &source) return *this;
125     this->fShapeSSD = new TBRIK(*(source.fShapeSSD));
126     this->fNp = source.fNp;
127     this->fNn = source.fNn;
128     delete fLowEdgeP;
129     delete fLowEdgeN;
130     this->fAngleP = source.fAngleP;
131     this->fAngleN = source.fAngleN;
132     fLowEdgeP = new Float_t[fNp];
133     fLowEdgeN = new Float_t[fNn];
134     for(i=0;i<fNp;i++) this->fLowEdgeP[i] = source.fLowEdgeP[i];
135     for(i=0;i<fNn;i++) this->fLowEdgeN[i] = source.fLowEdgeN[i];
136     return *this;
137 }
138 //______________________________________________________________________
139 void AliITSgeomSSD::Local2Det(Float_t x,Float_t z,Int_t &a,Int_t &c){
140     // Given a GEANT detector local coordinate, cm, this function returns
141     // the detector specific P and N side strip numbers.
142     // Inputs are:
143     // Float_t x   Geant detector local x coordinate in cm
144     // Float_t z   Geant detector local z coordinate in cm
145     // outputs are:
146     // Int_t &a    Detector anode strip number (P side)
147     // Int_t &c    Detector cathode strip number (N side)
148     Float_t d,b;
149     Int_t i;
150
151     // project on to bonding edges.
152     d = x*TMath::Cos(fAngleP)+z*TMath::Sin(fAngleP);
153     b = x*TMath::Cos(fAngleN)+z*TMath::Sin(fAngleN);
154     if(d<fLowEdgeP[0]) i=-1;
155     else for(i=0;i<fNp;i++){
156         if(fLowEdgeP[i]<d) break;
157     } // end for i
158     a = i;
159     if(b<fLowEdgeN[0]) i=-1;
160     else for(i=0;i<fNn;i++){
161         if(fLowEdgeN[i]<b) break;
162     } // end for i
163     c = i;
164     return;
165 }
166 //______________________________________________________________________
167 void AliITSgeomSSD::Det2Local(Int_t a,Int_t c,Float_t &x,Float_t &z){
168 //    Float_t d,b;
169 //    Int_t i;
170
171     return;
172 }
173 //______________________________________________________________________
174 void AliITSgeomSSD::Print(ostream *os) const {
175 ////////////////////////////////////////////////////////////////////////
176 // Standard output format for this class.
177 ////////////////////////////////////////////////////////////////////////
178     Int_t i;
179 #if defined __GNUC__
180 #if __GNUC__ > 2
181     ios::fmtflags fmt;
182 #else
183     Int_t fmt;
184 #endif
185 #else
186 #if defined __ICC || defined __ECC
187     ios::fmtflags fmt;
188 #else
189     Int_t fmt;
190 #endif
191 #endif
192
193     fmt = os->setf(ios::scientific);  // set scientific floating point output
194     *os << "TBRIK" << " ";
195     *os << setprecision(16) << GetDx() << " ";
196     *os << setprecision(16) << GetDy() << " ";
197     *os << setprecision(16) << GetDz() << " ";
198     *os << fNp << " " << fNn << " ";
199     *os << setprecision(16) << fAngleP << " ";
200     *os << setprecision(16) << fAngleN << " ";
201     for(i=0;i<fNp;i++) *os << setprecision(16) << fLowEdgeP[i] << " ";
202     for(i=0;i<fNn;i++) *os << setprecision(16) << fLowEdgeN[i] << " ";
203     *os << endl;
204     os->flags(fmt); // reset back to old formating.
205     return;
206 }
207 //______________________________________________________________________
208 void AliITSgeomSSD::Read(istream *is){
209 ////////////////////////////////////////////////////////////////////////
210 // Standard input format for this class.
211 ////////////////////////////////////////////////////////////////////////
212     Float_t dx,dy,dz;
213     Int_t i;
214     char shp[20];
215
216     *is >> shp;
217     *is >> dx >> dy >> dz;
218     if(fShapeSSD!=0) delete fShapeSSD;
219     fShapeSSD = new TBRIK("ActiveSSD","Active volume of SSD","SSD SI DET",
220                             dx,dy,dz);
221     *is >> fNp >> fNn;
222     *is >> fAngleP >> fAngleN;
223     if(fLowEdgeP !=0) delete fLowEdgeP;
224     if(fLowEdgeN !=0) delete fLowEdgeN;
225     fLowEdgeP = new Float_t[fNp];
226     fLowEdgeN = new Float_t[fNn];
227     for(i=0;i<fNp;i++) *is >> fLowEdgeP[i];
228     for(i=0;i<fNn;i++) *is >> fLowEdgeN[i];
229     return;
230 }
231 //----------------------------------------------------------------------
232 ostream &operator<<(ostream &os,AliITSgeomSSD &p){
233 ////////////////////////////////////////////////////////////////////////
234 // Standard output streaming function.
235 ////////////////////////////////////////////////////////////////////////
236
237     p.Print(&os);
238     return os;
239 }
240 //----------------------------------------------------------------------
241 istream &operator>>(istream &is,AliITSgeomSSD &r){
242 ////////////////////////////////////////////////////////////////////////
243 // Standard input streaming function.
244 ////////////////////////////////////////////////////////////////////////
245
246     r.Read(&is);
247     return is;
248 }
249 //======================================================================
250
251 ClassImp(AliITSgeomSSD175)
252
253 AliITSgeomSSD175::AliITSgeomSSD175() : AliITSgeomSSD(){
254 ////////////////////////////////////////////////////////////////////////
255 //    default constructor
256 ////////////////////////////////////////////////////////////////////////
257     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
258     // Size of sensitive detector area x,y(thickness),z
259     const Float_t kangle   = 0.0175; // angle in rad. of anode and cathodes
260     const Float_t kpitch   = 0.0095;// cm anode separation.
261     const Int_t   kNstrips = 768; // number of anode or cathode strips.
262     Float_t *leA,*leC; // array of low edges anode and cathorde.
263     Int_t i;
264
265     leA = new Float_t[kNstrips+1];
266     leC = new Float_t[kNstrips+1];
267     leA[0] = -kDxyz[0];
268     leA[1] = -kpitch*(0.5*kNstrips-1);
269     leC[0] =  kDxyz[0];
270     leC[1] =  kpitch*(0.5*kNstrips-1);
271     for(i=1;i<kNstrips;i++){
272         leA[i+1] = leA[i] + kpitch;
273         leC[i+1] = leC[i] - kpitch;
274     } // end for i
275     leA[kNstrips] =  kDxyz[0];
276     leC[kNstrips] = -kDxyz[0];
277 //    cout << "AliITSgeomSSD175 default creator called: start" << endl;
278     AliITSgeomSSD::ResetSSD(kDxyz,kangle,-kangle,
279                                  kNstrips+1,leA,kNstrips+1,leC);
280     delete leA;
281     delete leC;
282 //    cout << "AliITSgeomSSD175 default creator called: end" << endl;
283 }
284 //________________________________________________________________________
285 ostream &operator<<(ostream &os,AliITSgeomSSD175 &p){
286 ////////////////////////////////////////////////////////////////////////
287 // Standard output streaming function.
288 ////////////////////////////////////////////////////////////////////////
289
290     p.Print(&os);
291     return os;
292 }
293 //----------------------------------------------------------------------
294 istream &operator>>(istream &is,AliITSgeomSSD175 &r){
295 ////////////////////////////////////////////////////////////////////////
296 // Standard input streaming function.
297 ////////////////////////////////////////////////////////////////////////
298
299     r.Read(&is);
300     return is;
301 }
302 //======================================================================
303
304 ClassImp(AliITSgeomSSD275and75)
305
306 AliITSgeomSSD275and75::AliITSgeomSSD275and75() : AliITSgeomSSD(){
307 ////////////////////////////////////////////////////////////////////////
308 //    default constructor
309 ////////////////////////////////////////////////////////////////////////
310 }
311 //----------------------------------------------------------------------
312 AliITSgeomSSD275and75::AliITSgeomSSD275and75(Int_t npar,Float_t *par) : 
313                                                             AliITSgeomSSD(){
314     // Default constructor for AliITSgeomSSD with strip angles of
315     // 275 miliradians and 75 miliradians. This constructor initlizes
316     // AliITSgeomSSD with the correct values. This is the miror image
317     // of the AliITSgeomSSD75and275 class.
318     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
319     // Size of sensitive detector area x,y(thickness),z
320     const Float_t kangleA  = 0.0275; // angle in rad. of anode and cathodes
321     const Float_t kangleC  = 0.0075; // angle in rad. of anode and cathodes
322     const Float_t kpitch   = 0.0095;// cm anode separation.
323     const Int_t   kNstrips = 768; // number of anode or cathode strips.
324     Float_t *leA,*leC; // array of low edges anode and cathorde.
325     Int_t i;
326
327     leA = new Float_t[kNstrips+1];
328     leC = new Float_t[kNstrips+1];
329     leA[0] = -kDxyz[0];
330     leA[1] = -kpitch*(0.5*kNstrips-1);
331     leC[0] =  kDxyz[0];
332     leC[1] =  kpitch*(0.5*kNstrips-1);
333     for(i=1;i<kNstrips;i++){
334         leA[i+1] = leA[i] + kpitch;
335         leC[i+1] = leC[i] - kpitch;
336     } // end for i
337     leA[kNstrips] =  kDxyz[0];
338     leC[kNstrips] = -kDxyz[0];
339 //    cout << "AliITSgeomSSD275and75 default creator called: start" << endl;
340     AliITSgeomSSD::ResetSSD(par,kangleA,kangleC,
341                                  kNstrips+1,leA,kNstrips+1,leC);
342     delete [] leA;
343     delete [] leC;
344 //    cout << "AliITSgeomSSD275and75 default creator called: end" << endl;
345 }
346 //________________________________________________________________________
347 ostream &operator<<(ostream &os,AliITSgeomSSD275and75 &p){
348 ////////////////////////////////////////////////////////////////////////
349 // Standard output streaming function.
350 ////////////////////////////////////////////////////////////////////////
351
352     p.Print(&os);
353     return os;
354 }
355 //----------------------------------------------------------------------
356 istream &operator>>(istream &is,AliITSgeomSSD275and75 &r){
357 ////////////////////////////////////////////////////////////////////////
358 // Standard input streaming function.
359 ////////////////////////////////////////////////////////////////////////
360
361     r.Read(&is);
362     return is;
363 }
364 //======================================================================
365
366 ClassImp(AliITSgeomSSD75and275)
367
368 AliITSgeomSSD75and275::AliITSgeomSSD75and275() : AliITSgeomSSD(){
369 ////////////////////////////////////////////////////////////////////////
370 //    default constructor
371 ////////////////////////////////////////////////////////////////////////
372 }
373 AliITSgeomSSD75and275::AliITSgeomSSD75and275(Int_t npar,Float_t *par) : 
374                                                             AliITSgeomSSD(){
375     // Default constructor for AliITSgeomSSD with strip angles of
376     // 75 miliradians and 275 miliradians. This constructor initlizes
377     // AliITSgeomSSD with the correct values. This is the miror image
378     // of the AliITSgeomSSD275and75 class.
379     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
380     // Size of sensitive detector area x,y(thickness),z
381     const Float_t kangleA  = 0.0075; // angle in rad. of anode and cathodes
382     const Float_t kangleC  = 0.0275; // angle in rad. of anode and cathodes
383     const Float_t kpitch   = 0.0095;// cm anode separation.
384     const Int_t   kNstrips = 768; // number of anode or cathode strips.
385     Float_t *leA,*leC; // array of low edges anode and cathorde.
386     Int_t i;
387
388     leA = new Float_t[kNstrips+1];
389     leC = new Float_t[kNstrips+1];
390     leA[0] = -kDxyz[0];
391     leA[1] = -kpitch*(0.5*kNstrips-1);
392     leC[0] =  kDxyz[0];
393     leC[1] =  kpitch*(0.5*kNstrips-1);
394     for(i=1;i<kNstrips;i++){
395         leA[i+1] = leA[i] + kpitch;
396         leC[i+1] = leC[i] - kpitch;
397     } // end for i
398     leA[kNstrips] =  kDxyz[0];
399     leC[kNstrips] = -kDxyz[0];
400 //    cout << "AliITSgeomSSD275and75 default creator called: start" << endl;
401     AliITSgeomSSD::ResetSSD(par,kangleA,kangleC,
402                                  kNstrips+1,leA,kNstrips+1,leC);
403     delete leA;
404     delete leC;
405 //    cout << "AliITSgeomSSD275and75 default creator called: end" << endl;
406 }
407 //________________________________________________________________________
408 ostream &operator<<(ostream &os,AliITSgeomSSD75and275 &p){
409 ////////////////////////////////////////////////////////////////////////
410 // Standard output streaming function.
411 ////////////////////////////////////////////////////////////////////////
412
413     p.Print(&os);
414     return os;
415 }
416 //----------------------------------------------------------------------
417 istream &operator>>(istream &is,AliITSgeomSSD75and275 &r){
418 ////////////////////////////////////////////////////////////////////////
419 // Standard input streaming function.
420 ////////////////////////////////////////////////////////////////////////
421
422     r.Read(&is);
423     return is;
424 }
425 //======================================================================