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