EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairGeoSphe.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairGeoSphe.cxx
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Modified : 11/11/2003 by Ilse Koenig
3 //*-- Modified : 29/06/99 by Ilse Koenig
4 
6 //
7 // FairGeoSphe
8 //
9 // class for the GEANT shape SPHE
10 //
11 // The size of a SPHE is defined by 3 'points' (The z-components are not used)
12 // point 0: inner radius of the shell
13 // outer radius of the shell;
14 // point 1: starting polar angle of the shell,
15 // ending polar angle of the shell;
16 // point 2: starting azimuthal angle of the shell,
17 // ending azimuthal angle of the shell; )
18 //
19 // The intrinsic coordinate system of a SPHE, which sits in the CAVE and is
20 // not rotated, is identical with the laboratory system.
21 //
23 
24 #include "FairGeoSphe.h"
25 
26 #include "FairGeoVolume.h"
27 #include "FairGeoVector.h"
28 
29 #include "TArrayD.h"
30 
32 
35 {
36  // constructor
37  fName="SPHE";
38  nPoints=3;
39  nParam=6;
40  param=new TArrayD(nParam);
41 }
42 
43 
45 {
46  // default destructor
47  if (param) {
48  delete param;
49  param=0;
50  }
51  if (center) {
52  delete center;
53  center=0;
54  }
55  if (position) {
56  delete position;
57  position=0;
58  }
59 }
60 
61 
62 Int_t FairGeoSphe::readPoints(std::fstream* pFile,FairGeoVolume* volu)
63 {
64  // reads the 3 'points' decribed above from ascii file
65  // if the array of points is not existing in the volume it is created and
66  // the values are stored inside
67  // returns the number of points
68  if (!pFile) { return 0; }
69  if (volu->getNumPoints()!=nPoints) { volu->createPoints(nPoints); }
70  Double_t x,y;
71  const Int_t maxbuf=155;
72  Text_t buf[maxbuf];
73  for(Int_t i=0; i<nPoints; i++) {
74  pFile->getline(buf,maxbuf);
75  sscanf(buf,"%lf%lf",&x,&y);
76  volu->setPoint(i,x,y,0.0);
77  }
78  return nPoints;
79 }
80 
81 
82 Bool_t FairGeoSphe::writePoints(std::fstream* pFile,FairGeoVolume* volu)
83 {
84  // writes the 3 'points' decribed above to ascii file
85  if (!pFile) {
86  return kFALSE;
87  } else {
88  Text_t buf[155];
89  for(Int_t i=0; i<nPoints; i++) {
90  FairGeoVector& v=*(volu->getPoint(i));
91  sprintf(buf,"%9.3f%10.3f\n",v(0),v(1));
92  pFile->write(buf,strlen(buf));
93  }
94  return kTRUE;
95  }
96 }
97 
98 
100 {
101  // prints volume points to screen
102  for(Int_t i=0; i<nPoints; i++) {
103  FairGeoVector& v=*(volu->getPoint(i));
104  printf("%9.3f%10.3f\n",v(0),v(1));
105  }
106 }
107 
108 
110 {
111  // calculates the parameters needed to create the shape SPHE
112  Double_t fac=10.;
113  FairGeoVector& v0=*(volu->getPoint(0));
114  FairGeoVector& v1=*(volu->getPoint(1));
115  FairGeoVector& v2=*(volu->getPoint(2));
116  param->AddAt(v0(0)/fac,0);
117  param->AddAt(v0(1)/fac,1);
118  param->AddAt(v1(0),2);
119  param->AddAt(v1(1),3);
120  param->AddAt(v2(0),4);
121  param->AddAt(v2(1),5);
122  return param;
123 }
124 
125 
127  const FairGeoTransform& dTC,const FairGeoTransform& mTR)
128 {
129  // calls the function posInMother(...) to calculate the position of the
130  // volume in its mother
131  center->clear();
132  posInMother(dTC,mTR);
133 }