Project
Loading...
Searching...
No Matches
FairGeoEltu.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 : 28/06/99 by Ilse Koenig
11
13//
14// FairGeoEltu
15//
16// class for the GEANT shape ELTU
17//
18// The size of a ELTU is defined by 3 'points'.
19// point 0: origin of starting ellipse of the eltu;
20// point 1: semi-axis of the ellipse along x,
21// semi-axis of the ellipse along y;
22// (z-component not used)
23// point 2: origin of ending ellipse of the eltu;
24// Warning: The x- and y-values of point 0 and 2 have to be the same!!!!
25// A rotation has to be desribed via the rotation matrix.
26//
27// The intrinsic coordinate system of a ELTU, which sits in the CAVE and is
28// not rotated, is identical with the laboratory system.
29//
31#include "FairGeoEltu.h"
32
33#include "FairGeoTransform.h" // for FairGeoTransform
34#include "FairGeoVector.h" // for FairGeoVector
35#include "FairGeoVolume.h" // for FairGeoVolume
36
37#include <TArrayD.h> // for TArrayD
38#include <TMathBase.h> // for Abs
39#include <TString.h> // for TString
40#include <fstream>
41#include <ostream> // for fstream, etc
42#include <stdio.h> // for printf, sprintf, sscanf
43#include <string.h> // for strlen
44
46
49{
50 // constructor
51 fName = "ELTU";
52 nPoints = 3;
53 nParam = 3;
54 param = new TArrayD(nParam);
55}
56
58{
59 // default destructor
60 if (param) {
61 delete param;
62 param = 0;
63 }
64 if (center) {
65 delete center;
66 center = 0;
67 }
68 if (position) {
69 delete position;
70 position = 0;
71 }
72}
73
74Int_t FairGeoEltu::readPoints(std::fstream* pFile, FairGeoVolume* volu)
75{
76 // reads the 3 'points' decribed above from ascii file
77 // if the array of points is not existing in the volume it is created and
78 // the values are stored inside
79 // returns the number of points
80 if (!pFile) {
81 return 0;
82 }
83 if (volu->getNumPoints() != nPoints) {
84 volu->createPoints(nPoints);
85 }
86 Double_t x, y, z;
87 const Int_t maxbuf = 155;
88 Text_t buf[maxbuf];
89 for (Int_t i = 0; i < nPoints; i++) {
90 pFile->getline(buf, maxbuf);
91 if (i != 1) {
92 sscanf(buf, "%lf%lf%lf", &x, &y, &z);
93 volu->setPoint(i, x, y, z);
94 } else {
95 sscanf(buf, "%lf%lf", &x, &y);
96 volu->setPoint(i, x, y, 0.0);
97 }
98 }
99 return nPoints;
100}
101
102Bool_t FairGeoEltu::writePoints(std::fstream* pFile, FairGeoVolume* volu)
103{
104 // writes the 3 'points' decribed above to ascii file
105 if (!pFile) {
106 return kFALSE;
107 }
108 Text_t buf[155];
109 for (Int_t i = 0; i < nPoints; i++) {
110 FairGeoVector& v = *(volu->getPoint(i));
111 if (i != 1) {
112 sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2));
113 } else {
114 sprintf(buf, "%9.3f%10.3f\n", v(0), v(1));
115 }
116 pFile->write(buf, strlen(buf));
117 }
118 return kTRUE;
119}
120
122{
123 // prints volume points to screen
124 for (Int_t i = 0; i < nPoints; i++) {
125 FairGeoVector& v = *(volu->getPoint(i));
126 if (i != 1) {
127 printf("%9.3f%10.3f%10.3f\n", v(0), v(1), v(2));
128 } else {
129 printf("%9.3f%10.3f\n", v(0), v(1));
130 }
131 }
132}
133
135{
136 // calculates the parameters needed to create the shape ELTU
137 Double_t fac = 10.;
138 FairGeoVector& v1 = *(volu->getPoint(1));
139 param->AddAt(v1(0) / fac, 0);
140 param->AddAt(v1(1) / fac, 1);
141 FairGeoVector v = *(volu->getPoint(2)) - *(volu->getPoint(0));
142 param->AddAt(TMath::Abs(v(2)) / fac / 2., 2);
143 return param;
144}
145
147{
148 // calculates the position of the center of the volume in the intrinsic
149 // coordinate system and stores it in the data element 'center'
150 // calls the function posInMother(...) to calculate the position of the
151 // volume in its mother
152 Double_t t[3] = {0., 0., 0.};
153 FairGeoVector v = *(volu->getPoint(2)) + *(volu->getPoint(0));
154 t[2] = v(2) / 2.;
155 center->clear();
157 posInMother(dTC, mTR);
158}
ClassImp(FairGeoEltu)
int32_t i
FairGeoTransform * center
void posInMother(const FairGeoTransform &, const FairGeoTransform &)
FairGeoTransform * position
void printPoints(FairGeoVolume *volu)
Int_t readPoints(std::fstream *, FairGeoVolume *)
void calcVoluPosition(FairGeoVolume *, const FairGeoTransform &, const FairGeoTransform &)
Bool_t writePoints(std::fstream *, FairGeoVolume *)
TArrayD * calcVoluParam(FairGeoVolume *)
void setTransVector(const FairGeoVector &t)
FairGeoVector * getPoint(const Int_t n)
void setPoint(const Int_t, const Double_t, const Double_t, const Double_t)
Int_t getNumPoints()
void createPoints(const Int_t)
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLint y
Definition glcorearb.h:270
GLfloat GLfloat v1
Definition glcorearb.h:812
GLenum GLfloat param
Definition glcorearb.h:271
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glcorearb.h:2514
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843