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