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