EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
FairGeoPgon.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairGeoPgon.cxx
1
//*-- AUTHOR : Ilse Koenig
2
//*-- Modified : 11/11/2003 by Ilse Koenig
3
//*-- Modified : 26/11/2001 by Ilse Koenig
4
6
//
7
// FairGeoPgon
8
//
9
// class for the GEANT shape PGON
10
//
11
// The size of a PGON is defined by a variable number of 'points'.
12
// point 0: number of planes perpendicular to the z axis where the
13
// dimension of the section is given;
14
// point 1: azimutal angle phi at which the volume begins,
15
// opening angle dphi of the volume,
16
// number of sides of the cross section between the phi-limits;
17
// point 2ff: z coordinate of the section,
18
// inner radius at position z,
19
// outer radius at position z;
20
//
21
// The intrinsic coordinate system of a PGON, which sits in the CAVE and is
22
// not rotated, is identical with the laboratory system.
23
//
25
26
#include "
FairGeoPgon.h
"
27
28
#include "
FairGeoVolume.h
"
29
#include "
FairGeoVector.h
"
30
31
#include "TArrayD.h"
32
33
ClassImp
(
FairGeoPgon
)
34
35
FairGeoPgon
::
FairGeoPgon
()
36
:
FairGeoBasicShape
()
37
{
38
// constructor
39
fName=
"PGON"
;
40
nPoints=0;
41
nParam=0;
42
}
43
44
45
FairGeoPgon::~FairGeoPgon
()
46
{
47
// default destructor
48
if
(
param
) {
49
delete
param
;
50
param
=0;
51
}
52
if
(
center
) {
53
delete
center
;
54
center
=0;
55
}
56
if
(
position
) {
57
delete
position
;
58
position
=0;
59
}
60
}
61
62
63
Int_t
FairGeoPgon::readPoints
(std::fstream* pFile,
FairGeoVolume
* volu)
64
{
65
// reads the 'points' decribed above from ascii file and stores them in the
66
// array 'points' of the volume
67
// returns the number of points
68
if
(!pFile) {
return
0; }
69
Double_t
x
,
y
,
z
;
70
const
Int_t maxbuf=155;
71
Text_t buf[maxbuf];
72
pFile->getline(buf,maxbuf);
73
Int_t
n
;
74
sscanf(buf,
"%i"
,&n);
75
if
(n<=0) {
return
0; }
76
nPoints
=n+2;
77
if
(volu->
getNumPoints
()!=
nPoints
) { volu->
createPoints
(
nPoints
); }
78
volu->
setPoint
(0,(Double_t)n,0.0,0.0);
79
for
(Int_t i=1; i<
nPoints
; i++) {
80
pFile->getline(buf,maxbuf);
81
sscanf(buf,
"%lf%lf%lf"
,&x,&y,&z);
82
volu->
setPoint
(i,x,y,z);
83
}
84
return
nPoints
;
85
}
86
87
88
Bool_t
FairGeoPgon::writePoints
(std::fstream* pFile,
FairGeoVolume
* volu)
89
{
90
// writes the 'points' decribed above to ascii file
91
if
(!pFile) {
return
kFALSE; }
92
Text_t buf[155];
93
for
(Int_t i=0; i<volu->
getNumPoints
(); i++) {
94
FairGeoVector
&
v
=*(volu->
getPoint
(i));
95
if
(i!=0) { sprintf(buf,
"%9.3f%10.3f%10.3f\n"
,
v
(0),
v
(1),
v
(2)); }
96
else
{ sprintf(buf,
"%3i\n"
,(Int_t)
v
(0)); }
97
pFile->write(buf,strlen(buf));
98
}
99
return
kTRUE;
100
}
101
102
103
void
FairGeoPgon::printPoints
(
FairGeoVolume
* volu)
104
{
105
// prints volume points to screen
106
for
(Int_t i=0; i<volu->
getNumPoints
(); i++) {
107
FairGeoVector
&
v
=*(volu->
getPoint
(i));
108
if
(i!=0) {
printf
(
"%9.3f%10.3f%10.3f\n"
,
v
(0),
v
(1),
v
(2)); }
109
else
{
printf
(
"%3i\n"
,(Int_t)
v
(0)); }
110
}
111
}
112
113
114
TArrayD*
FairGeoPgon::calcVoluParam
(
FairGeoVolume
* volu)
115
{
116
// calculates the parameters needed to create the shape PGON
117
Double_t fac=10.;
118
nPoints
=volu->
getNumPoints
();
119
nParam
=
nPoints
*3-2;
120
if
(
param
&&
param
->GetSize()!=
nParam
) {
121
delete
param
;
122
param
=0;
123
}
124
if
(!
param
) {
param
=
new
TArrayD(
nParam
); }
125
FairGeoVector
&
v1
=*(volu->
getPoint
(1));
126
Int_t
k
=0;
127
param
->AddAt(
v1
(0),k++);
128
param
->AddAt(
v1
(1),k++);
129
param
->AddAt(
v1
(2),k++);
130
param
->AddAt((
nPoints
-2),k++);
131
for
(Int_t i=2; i<
nPoints
; i++) {
132
FairGeoVector
&
v
=*(volu->
getPoint
(i));
133
param
->AddAt(
v
(0)/fac,k++);
134
param
->AddAt(
v
(1)/fac,k++);
135
param
->AddAt(
v
(2)/fac,k++);
136
}
137
return
param
;
138
}
139
140
141
void
FairGeoPgon::calcVoluPosition
(
FairGeoVolume
*,
142
const
FairGeoTransform
& dTC,
const
FairGeoTransform
& mTR)
143
{
144
// calls the function posInMother(...) to calculate the position of the
145
// volume in its mother
146
center
->
clear
();
147
posInMother
(dTC,mTR);
148
}
EicRoot
blob
master
geobase
FairGeoPgon.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:36
using
1.8.2 with
EIC GitHub integration