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
FairGeoCons.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairGeoCons.cxx
1
//*-- AUTHOR : Ilse Koenig
2
//*-- Modified : 11/11/2003 by Ilse Koenig
3
//*-- Modified : 28/06/99 by Ilse Koenig
4
6
//
7
// FairGeoCons
8
//
9
// class for the GEANT shape CONS
10
//
11
// The size of a CONS is defined by 5 'points'.
12
// point 0: origin of starting circle of the cons;
13
// point 1: inner radius of starting circle,
14
// outer radius of starting circle;
15
// (z-component not used)
16
// point 2: origin of ending circle of the cons;
17
// point 3: inner radius of ending circle,
18
// outer radius of ending circle;
19
// (z-component not used)
20
// point 4: starting angle of the segment,
21
// ending angle of the segment;
22
// (z-component not used)
23
// Warning: The x- and y-values of point 0 and 2 have to be the same!!!!
24
// A rotation has to be desribed via the rotation matrix.
25
//
26
// The intrinsic coordinate system of a CONS, which sits in the CAVE and is
27
// not rotated, is identical with the laboratory system.
28
//
30
31
#include "
FairGeoCons.h
"
32
33
#include "
FairGeoVolume.h
"
34
#include "
FairGeoVector.h
"
35
36
#include "TArrayD.h"
37
38
ClassImp
(
FairGeoCons
)
39
40
FairGeoCons
::
FairGeoCons
()
41
:
FairGeoBasicShape
()
42
{
43
// constructor
44
fName=
"CONS"
;
45
nPoints=5;
46
nParam=7;
47
param=
new
TArrayD(nParam);
48
}
49
50
51
FairGeoCons::~FairGeoCons
()
52
{
53
// default destructor
54
if
(
param
) {
55
delete
param
;
56
param
=0;
57
}
58
if
(
center
) {
59
delete
center
;
60
center
=0;
61
}
62
if
(
position
) {
63
delete
position
;
64
position
=0;
65
}
66
}
67
68
69
Int_t
FairGeoCons::readPoints
(std::fstream* pFile,
FairGeoVolume
* volu)
70
{
71
// reads the 5 'points' decribed above from ascii file
72
// if the array of points is not existing in the volume it is created and
73
// the values are stored inside
74
// returns the number of points
75
if
(!pFile) {
return
0; }
76
if
(volu->
getNumPoints
()!=
nPoints
) { volu->
createPoints
(
nPoints
); }
77
Double_t
x
,
y
,
z
;
78
const
Int_t maxbuf=155;
79
Text_t buf[maxbuf];
80
for
(Int_t i=0; i<
nPoints
; i++) {
81
pFile->getline(buf,maxbuf);
82
if
(i==0 || i==2) {
83
sscanf(buf,
"%lf%lf%lf"
,&x,&y,&z);
84
volu->
setPoint
(i,x,y,z);
85
}
else
{
86
sscanf(buf,
"%lf%lf"
,&x,&y);
87
volu->
setPoint
(i,x,y,0.0);
88
}
89
}
90
return
nPoints
;
91
}
92
93
94
Bool_t
FairGeoCons::writePoints
(std::fstream* pFile,
FairGeoVolume
* volu)
95
{
96
// writes the 5 'points' decribed above to ascii file
97
if
(!pFile) {
return
kFALSE; }
98
Text_t buf[155];
99
for
(Int_t i=0; i<
nPoints
; i++) {
100
FairGeoVector
&
v
=*(volu->
getPoint
(i));
101
if
(i==0 || i==2) { sprintf(buf,
"%9.3f%10.3f%10.3f\n"
,
v
(0),
v
(1),
v
(2)); }
102
else
{ sprintf(buf,
"%9.3f%10.3f\n"
,
v
(0),
v
(1)); }
103
pFile->write(buf,strlen(buf));
104
}
105
return
kTRUE;
106
}
107
108
109
void
FairGeoCons::printPoints
(
FairGeoVolume
* volu)
110
{
111
// prints volume points to screen
112
for
(Int_t i=0; i<
nPoints
; i++) {
113
FairGeoVector
&
v
=*(volu->
getPoint
(i));
114
if
(i==0 || i==2) {
printf
(
"%9.3f%10.3f%10.3f\n"
,
v
(0),
v
(1),
v
(2)); }
115
else
{
printf
(
"%9.3f%10.3f\n"
,
v
(0),
v
(1)); }
116
}
117
}
118
119
120
TArrayD*
FairGeoCons::calcVoluParam
(
FairGeoVolume
* volu)
121
{
122
// calculates the parameters needed to create the shape CONS
123
Double_t fac=10.;
124
FairGeoVector
v
=*(volu->
getPoint
(2)) - *(volu->
getPoint
(0));
125
param
->AddAt(TMath::Abs(
v
(2))/fac/2.,0);
126
FairGeoVector
&
v1
=*(volu->
getPoint
(1));
127
param
->AddAt(
v1
(0)/fac,1);
128
param
->AddAt(
v1
(1)/fac,2);
129
FairGeoVector
&
v3
=*(volu->
getPoint
(3));
130
param
->AddAt(
v3
(0)/fac,3);
131
param
->AddAt(
v3
(1)/fac,4);
132
FairGeoVector
&
v4
=*(volu->
getPoint
(4));
133
param
->AddAt(
v4
(0),5);
134
param
->AddAt(
v4
(1),6);
135
return
param
;
136
}
137
138
139
void
FairGeoCons::calcVoluPosition
(
FairGeoVolume
* volu,
140
const
FairGeoTransform
& dTC,
const
FairGeoTransform
& mTR)
141
{
142
// calculates the position of the center of the volume in the intrinsic
143
// coordinate system and stores it in the data element 'center'
144
// calls the function posInMother(...) to calculate the position of the
145
// volume in its mother
146
Double_t
t
[3]= {0.,0.,0.};
147
FairGeoVector
v
=*(volu->
getPoint
(2)) + *(volu->
getPoint
(0));
148
t[2]=
v
(2)/2.;
149
center
->
clear
();
150
center
->
setTransVector
(t);
151
posInMother
(dTC,mTR);
152
}
EicRoot
blob
master
geobase
FairGeoCons.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:36
using
1.8.2 with
EIC GitHub integration