EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairGeoTorus.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairGeoTorus.cxx
1 //*-- AUTHOR : M. Al-Turany 06/11/2006
2 
4 //
5 // FairGeoTorus
6 //
7 // class for the shape Torus
8 // A torus has 5 parameters :
9 // R - axial radius
10 // Rmin - inner radius
11 // Rmax - outer radius
12 // Phi1 - starting phi
13 // Dphi - phi extent
15 
16 #include "FairGeoTorus.h"
17 
18 #include "FairGeoVolume.h"
19 #include "FairGeoVector.h"
20 
21 #include "TArrayD.h"
22 
24 
27 {
28  // constructor
29  fName="TORUS";
30  nPoints=5;
31  nParam=5;
32  param=new TArrayD(nParam);
33 }
34 
35 
37 {
38  // destructor
39  if (param) {
40  delete param;
41  param=0;
42  }
43  if (center) {
44  delete center;
45  center=0;
46  }
47  if (position) {
48  delete position;
49  position=0;
50  }
51 }
52 
53 Int_t FairGeoTorus::readPoints(std::fstream* pFile,FairGeoVolume* volu)
54 {
55  // reads nPoints with 3 components from Ascii file
56  // if the array of points is not existing in the volume it is created and
57  // the values are stored inside
58  // returns the number of points
59  if (!pFile) { return 0; }
60  if (volu->getNumPoints()!=nPoints) { volu->createPoints(nPoints); }
61  Double_t x;
62  const Int_t maxbuf=155;
63  Text_t buf[maxbuf];
64  for(Int_t i=0; i<nPoints; i++) {
65  pFile->getline(buf,maxbuf);
66  sscanf(buf,"%lf",&x);
67  volu->setPoint(i,x,0,0);
68  }
69  return nPoints;
70 }
71 
72 
74 {
75  // calculates the parameters needed to create the shape
76 
77  for(Int_t i=0; i<3; i++) {
78  FairGeoVector v=*(volu->getPoint(i));
79  v*=(1/10.);
80  param->AddAt(v(0),i);
81  }
82  FairGeoVector v=*(volu->getPoint(3));
83  param->AddAt(v(0),3);
84 
85  v=*(volu->getPoint(4));
86  param->AddAt(v(0),4);
87 
88 
89  return param;
90 }
91 
92 Bool_t FairGeoTorus::writePoints(std::fstream* pFile,FairGeoVolume* volu)
93 {
94  // writes the 4 'points' decribed above to ascii file
95  if (!pFile) { return kFALSE; }
96  Text_t buf[155];
97  for(Int_t i=0; i<nPoints; i++) {
98  FairGeoVector& v=*(volu->getPoint(i));
99  sprintf(buf,"%9.3f\n",v(0));
100  pFile->write(buf,strlen(buf));
101  }
102  return kTRUE;
103 }
104 
105 
107 {
108  // prints volume points to screen
109  for(Int_t i=0; i<nPoints; i++) {
110  FairGeoVector& v=*(volu->getPoint(i));
111  printf("%9.3f\n",v(0));
112  }
113 }
114 
115 
116 
118  const FairGeoTransform& dTC,const FairGeoTransform& mTR)
119 {
120  // calls the function posInMother(...) to calculate the position of the
121  // volume in its mother
122  Double_t t[3]= {0.,0.,0.};
124  posInMother(dTC,mTR);
125 }
126