]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomSSD.cxx
Conversion code moved to AliG3toRoot
[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 /*
17 $Log$
18 Revision 1.10  2001/02/09 00:00:57  nilsen
19 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
20 bugs in iostream based streamers used to read and write .det files. Fixed
21 some detector sizes. Fixed bugs in some default-special constructors.
22
23 Revision 1.9  2001/02/03 00:00:30  nilsen
24 New version of AliITSgeom and related files. Now uses automatic streamers,
25 set up for new formatted .det file which includes detector information.
26 Additional smaller modifications are still to come.
27
28 Revision 1.8  2000/10/02 16:32:43  barbera
29 Forward declaration added
30
31 Revision 1.2.4.8  2000/10/02 15:53:49  barbera
32 Forward declaration added
33
34 Revision 1.7  2000/07/10 16:07:18  fca
35 Release version of ITS code
36
37 Revision 1.2.4.2  2000/03/04 23:55:59  nilsen
38 Fixed up the comments/documentation
39
40 Revision 1.2.4.1  2000/01/12 19:03:32  nilsen
41 This is the version of the files after the merging done in December 1999.
42 See the ReadMe110100.txt file for details
43
44 Revision 1.2  1999/09/29 09:24:20  fca
45 Introduction of the Copyright and cvs Log
46
47 */
48 #include <iostream.h>
49 #include <iomanip.h>
50 #include <stdlib.h>
51 #include <TShape.h>
52 #include <TBRIK.h>
53
54 #include "AliITSgeomSSD.h"
55
56 ClassImp(AliITSgeomSSD)
57
58
59 AliITSgeomSSD::AliITSgeomSSD(){
60 // Default constructor
61     fShapeSSD = 0;
62     fNp       = 0;
63     fNn       = 0;
64     fLowEdgeP = 0;
65     fLowEdgeN = 0;
66     fAngleP   = 0.0;
67     fAngleN   = 0.0;
68 }
69 //----------------------------------------------------------------------
70 AliITSgeomSSD::AliITSgeomSSD(const Float_t *box,Float_t ap,Float_t an,
71                              Int_t np,Float_t *p,Int_t nn,Float_t *n){
72 ////////////////////////////////////////////////////////////////////////
73 //    Standard Constructor. *box={dx,dy,dz}, ap=anode angle, an=cathode angle,
74 // nn= number of cathodes+1,*n= array of cathode low edges+highest edge,
75 // np= number of anodes+1, *p= array of anode low edges+lighest edge.
76 ///////////////////////////////////////////////////////////////////////
77     fShapeSSD = 0;
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     fShapeSSD = new TBRIK("ActiveSSD","Active volume of SSD","SSD SI DET",
97                           box[0],box[1],box[2]);
98 //    if(fLowEdgeP!=0) delete fLowEdgeP;
99 //    if(fLowEdgeN!=0) delete fLowEdgeN;
100     fNp = np;
101     fNn = nn;
102     fAngleP = ap;
103     fAngleN = an;
104     fLowEdgeP = new Float_t[fNp];
105     fLowEdgeN = new Float_t[fNn];
106     for(i=0;i<fNp;i++) fLowEdgeP[i] = p[i];
107     for(i=0;i<fNn;i++) fLowEdgeN[i] = n[i];
108 }
109 //______________________________________________________________________
110 AliITSgeomSSD::~AliITSgeomSSD(){
111     // Destructor.
112
113     delete fLowEdgeP; fLowEdgeP = 0;
114     delete fLowEdgeN; fLowEdgeN = 0;
115     delete fShapeSSD; fShapeSSD = 0;
116     fNp = 0;
117     fNn = 0;
118     fAngleP = 0.0;
119     fAngleN = 0.0;
120 }
121 AliITSgeomSSD::AliITSgeomSSD(const AliITSgeomSSD &source){
122 ////////////////////////////////////////////////////////////////////////
123 //    copy  constructor
124 ////////////////////////////////////////////////////////////////////////
125     Int_t i;
126
127     if(this == &source) return;
128     this->fShapeSSD = new TBRIK(*(source.fShapeSSD));
129     this->fNp = source.fNp;
130     this->fNn = source.fNn;
131     delete fLowEdgeP;
132     delete fLowEdgeN;
133     this->fAngleP = source.fAngleP;
134     this->fAngleN = source.fAngleN;
135     fLowEdgeP = new Float_t[fNp];
136     fLowEdgeN = new Float_t[fNn];
137     for(i=0;i<fNp;i++) this->fLowEdgeP[i] = source.fLowEdgeP[i];
138     for(i=0;i<fNn;i++) this->fLowEdgeN[i] = source.fLowEdgeN[i];
139     return;
140 }  
141
142 AliITSgeomSSD& AliITSgeomSSD::operator=(const AliITSgeomSSD &source) {
143 ////////////////////////////////////////////////////////////////////////
144 //    assignment operator
145 ////////////////////////////////////////////////////////////////////////
146     Int_t i;
147
148     if(this == &source) return *this;
149     this->fShapeSSD = new TBRIK(*(source.fShapeSSD));
150     this->fNp = source.fNp;
151     this->fNn = source.fNn;
152     delete fLowEdgeP;
153     delete fLowEdgeN;
154     this->fAngleP = source.fAngleP;
155     this->fAngleN = source.fAngleN;
156     fLowEdgeP = new Float_t[fNp];
157     fLowEdgeN = new Float_t[fNn];
158     for(i=0;i<fNp;i++) this->fLowEdgeP[i] = source.fLowEdgeP[i];
159     for(i=0;i<fNn;i++) this->fLowEdgeN[i] = source.fLowEdgeN[i];
160     return *this;
161 }
162 //______________________________________________________________________
163 void AliITSgeomSSD::Local2Det(Float_t x,Float_t z,Int_t &a,Int_t &c){
164     Float_t d,b;
165     Int_t i;
166
167     // project on to bonding edges.
168     d = x*TMath::Cos(fAngleP)+z*TMath::Sin(fAngleP);
169     b = x*TMath::Cos(fAngleN)+z*TMath::Sin(fAngleN);
170     if(d<fLowEdgeP[0]) i=-1;
171     else for(i=0;i<fNp;i++){
172         if(fLowEdgeP[i]<d) break;
173     } // end for i
174     a = i;
175     if(b<fLowEdgeN[0]) i=-1;
176     else for(i=0;i<fNn;i++){
177         if(fLowEdgeN[i]<b) break;
178     } // end for i
179     c = i;
180     return;
181 }
182 //______________________________________________________________________
183 void AliITSgeomSSD::Det2Local(Int_t a,Int_t c,Float_t &x,Float_t &z){
184 //    Float_t d,b;
185 //    Int_t i;
186
187     return;
188 }
189 //______________________________________________________________________
190 void AliITSgeomSSD::Print(ostream *os) const {
191 ////////////////////////////////////////////////////////////////////////
192 // Standard output format for this class.
193 ////////////////////////////////////////////////////////////////////////
194     Int_t fmt;
195     Int_t i;
196
197     fmt = os->setf(ios::scientific);  // set scientific floating point output
198     *os << "TBRIK" << " ";
199     *os << setprecision(16) << GetDx() << " ";
200     *os << setprecision(16) << GetDy() << " ";
201     *os << setprecision(16) << GetDz() << " ";
202     *os << fNp << " " << fNn << " ";
203     *os << setprecision(16) << fAngleP << " ";
204     *os << setprecision(16) << fAngleN << " ";
205     for(i=0;i<fNp;i++) *os << setprecision(16) << fLowEdgeP[i] << " ";
206     for(i=0;i<fNn;i++) *os << setprecision(16) << fLowEdgeN[i] << " ";
207     *os << endl;
208     os->flags(fmt); // reset back to old formating.
209     return;
210 }
211 //______________________________________________________________________
212 void AliITSgeomSSD::Read(istream *is){
213 ////////////////////////////////////////////////////////////////////////
214 // Standard input format for this class.
215 ////////////////////////////////////////////////////////////////////////
216     Float_t dx,dy,dz;
217     Int_t i;
218     char shp[20];
219
220     *is >> shp;
221     *is >> dx >> dy >> dz;
222     if(fShapeSSD!=0) delete fShapeSSD;
223     fShapeSSD = new TBRIK("ActiveSSD","Active volume of SSD","SSD SI DET",
224                             dx,dy,dz);
225     *is >> fNp >> fNn;
226     *is >> fAngleP >> fAngleN;
227     if(fLowEdgeP !=0) delete fLowEdgeP;
228     if(fLowEdgeN !=0) delete fLowEdgeN;
229     fLowEdgeP = new Float_t[fNp];
230     fLowEdgeN = new Float_t[fNn];
231     for(i=0;i<fNp;i++) *is >> fLowEdgeP[i];
232     for(i=0;i<fNn;i++) *is >> fLowEdgeN[i];
233     return;
234 }
235 //----------------------------------------------------------------------
236 ostream &operator<<(ostream &os,AliITSgeomSSD &p){
237 ////////////////////////////////////////////////////////////////////////
238 // Standard output streaming function.
239 ////////////////////////////////////////////////////////////////////////
240
241     p.Print(&os);
242     return os;
243 }
244 //----------------------------------------------------------------------
245 istream &operator>>(istream &is,AliITSgeomSSD &r){
246 ////////////////////////////////////////////////////////////////////////
247 // Standard input streaming function.
248 ////////////////////////////////////////////////////////////////////////
249
250     r.Read(&is);
251     return is;
252 }
253 //======================================================================
254 /*
255 $Log$
256 Revision 1.10  2001/02/09 00:00:57  nilsen
257 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
258 bugs in iostream based streamers used to read and write .det files. Fixed
259 some detector sizes. Fixed bugs in some default-special constructors.
260
261 Revision 1.9  2001/02/03 00:00:30  nilsen
262 New version of AliITSgeom and related files. Now uses automatic streamers,
263 set up for new formatted .det file which includes detector information.
264 Additional smaller modifications are still to come.
265
266 */
267
268 //#include "AliITSgeomSSD175.h"
269
270 ClassImp(AliITSgeomSSD175)
271
272 AliITSgeomSSD175::AliITSgeomSSD175() : AliITSgeomSSD(){
273 ////////////////////////////////////////////////////////////////////////
274 //    default constructor
275 ////////////////////////////////////////////////////////////////////////
276     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
277     // Size of sensitive detector area x,y(thickness),z
278     const Float_t kangle   = 0.0175; // angle in rad. of anode and cathodes
279     const Float_t kpitch   = 0.0095;// cm anode separation.
280     const Int_t   kNstrips = 768; // number of anode or cathode strips.
281     Float_t *leA,*leC; // array of low edges anode and cathorde.
282     Int_t i;
283
284     leA = new Float_t[kNstrips+1];
285     leC = new Float_t[kNstrips+1];
286     leA[0] = -kDxyz[0];
287     leA[1] = -kpitch*(0.5*kNstrips-1);
288     leC[0] =  kDxyz[0];
289     leC[1] =  kpitch*(0.5*kNstrips-1);
290     for(i=1;i<kNstrips;i++){
291         leA[i+1] = leA[i] + kpitch;
292         leC[i+1] = leC[i] - kpitch;
293     } // end for i
294     leA[kNstrips] =  kDxyz[0];
295     leC[kNstrips] = -kDxyz[0];
296 //    cout << "AliITSgeomSSD175 default creator called: start" << endl;
297     AliITSgeomSSD::ResetSSD(kDxyz,kangle,-kangle,
298                                  kNstrips+1,leA,kNstrips+1,leC);
299     delete leA;
300     delete leC;
301 //    cout << "AliITSgeomSSD175 default creator called: end" << endl;
302 }
303 //________________________________________________________________________
304 ostream &operator<<(ostream &os,AliITSgeomSSD175 &p){
305 ////////////////////////////////////////////////////////////////////////
306 // Standard output streaming function.
307 ////////////////////////////////////////////////////////////////////////
308
309     p.Print(&os);
310     return os;
311 }
312 //----------------------------------------------------------------------
313 istream &operator>>(istream &is,AliITSgeomSSD175 &r){
314 ////////////////////////////////////////////////////////////////////////
315 // Standard input streaming function.
316 ////////////////////////////////////////////////////////////////////////
317
318     r.Read(&is);
319     return is;
320 }
321 //======================================================================
322 /*
323 $Log$
324 Revision 1.10  2001/02/09 00:00:57  nilsen
325 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
326 bugs in iostream based streamers used to read and write .det files. Fixed
327 some detector sizes. Fixed bugs in some default-special constructors.
328
329 Revision 1.9  2001/02/03 00:00:30  nilsen
330 New version of AliITSgeom and related files. Now uses automatic streamers,
331 set up for new formatted .det file which includes detector information.
332 Additional smaller modifications are still to come.
333
334 */
335
336 //#include "AliITSgeomSSD275and75.h"
337
338 ClassImp(AliITSgeomSSD275and75)
339
340 AliITSgeomSSD275and75::AliITSgeomSSD275and75() : AliITSgeomSSD(){
341 ////////////////////////////////////////////////////////////////////////
342 //    default constructor
343 ////////////////////////////////////////////////////////////////////////
344 }
345 //----------------------------------------------------------------------
346 AliITSgeomSSD275and75::AliITSgeomSSD275and75(Int_t npar,Float_t *par) : 
347                                                             AliITSgeomSSD(){
348     const Float_t kDxyz[] ={3.6500,0.0150,2.000};//cm. (Geant 3.12 units)
349     // Size of sensitive detector area x,y(thickness),z
350     const Float_t kangleA  = 0.0275; // angle in rad. of anode and cathodes
351     const Float_t kangleC  = 0.0075; // angle in rad. of anode and cathodes
352     const Float_t kpitch   = 0.0095;// cm anode separation.
353     const Int_t   kNstrips = 768; // number of anode or cathode strips.
354     Float_t *leA,*leC; // array of low edges anode and cathorde.
355     Int_t i;
356
357     leA = new Float_t[kNstrips+1];
358     leC = new Float_t[kNstrips+1];
359     leA[0] = -kDxyz[0];
360     leA[1] = -kpitch*(0.5*kNstrips-1);
361     leC[0] =  kDxyz[0];
362     leC[1] =  kpitch*(0.5*kNstrips-1);
363     for(i=1;i<kNstrips;i++){
364         leA[i+1] = leA[i] + kpitch;
365         leC[i+1] = leC[i] - kpitch;
366     } // end for i
367     leA[kNstrips] =  kDxyz[0];
368     leC[kNstrips] = -kDxyz[0];
369 //    cout << "AliITSgeomSSD275and75 default creator called: start" << endl;
370     AliITSgeomSSD::ResetSSD(par,kangleA,kangleC,
371                                  kNstrips+1,leA,kNstrips+1,leC);
372     delete leA;
373     delete leC;
374 //    cout << "AliITSgeomSSD275and75 default creator called: end" << endl;
375 }
376 //________________________________________________________________________
377 ostream &operator<<(ostream &os,AliITSgeomSSD275and75 &p){
378 ////////////////////////////////////////////////////////////////////////
379 // Standard output streaming function.
380 ////////////////////////////////////////////////////////////////////////
381
382     p.Print(&os);
383     return os;
384 }
385 //----------------------------------------------------------------------
386 istream &operator>>(istream &is,AliITSgeomSSD275and75 &r){
387 ////////////////////////////////////////////////////////////////////////
388 // Standard input streaming function.
389 ////////////////////////////////////////////////////////////////////////
390
391     r.Read(&is);
392     return is;
393 }
394 //======================================================================
395 /*
396 $Log$
397 Revision 1.10  2001/02/09 00:00:57  nilsen
398 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
399 bugs in iostream based streamers used to read and write .det files. Fixed
400 some detector sizes. Fixed bugs in some default-special constructors.
401
402 Revision 1.9  2001/02/03 00:00:30  nilsen
403 New version of AliITSgeom and related files. Now uses automatic streamers,
404 set up for new formatted .det file which includes detector information.
405 Additional smaller modifications are still to come.
406
407 */
408 //#include "AliITSgeomSSD75and275.h"
409
410 ClassImp(AliITSgeomSSD75and275)
411
412 AliITSgeomSSD75and275::AliITSgeomSSD75and275() : AliITSgeomSSD(){
413 ////////////////////////////////////////////////////////////////////////
414 //    default constructor
415 ////////////////////////////////////////////////////////////////////////
416 }
417 AliITSgeomSSD75and275::AliITSgeomSSD75and275(Int_t npar,Float_t *par) : 
418                                                             AliITSgeomSSD(){
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     leA = new Float_t[kNstrips+1];
429     leC = new Float_t[kNstrips+1];
430     leA[0] = -kDxyz[0];
431     leA[1] = -kpitch*(0.5*kNstrips-1);
432     leC[0] =  kDxyz[0];
433     leC[1] =  kpitch*(0.5*kNstrips-1);
434     for(i=1;i<kNstrips;i++){
435         leA[i+1] = leA[i] + kpitch;
436         leC[i+1] = leC[i] - kpitch;
437     } // end for i
438     leA[kNstrips] =  kDxyz[0];
439     leC[kNstrips] = -kDxyz[0];
440 //    cout << "AliITSgeomSSD275and75 default creator called: start" << endl;
441     AliITSgeomSSD::ResetSSD(par,kangleA,kangleC,
442                                  kNstrips+1,leA,kNstrips+1,leC);
443     delete leA;
444     delete leC;
445 //    cout << "AliITSgeomSSD275and75 default creator called: end" << endl;
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 //======================================================================