ECCE @ EIC Software
Reference for
ECCE @ 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
G4VPhysicalVolume.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4VPhysicalVolume.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
// class G4VPhysicalVolume Implementation
27
//
28
// 15.01.13, G.Cosmo, A.Dotti: Modified for thread-safety for MT
29
// 28.08.96, P.Kent: Replaced transform by rotmat + vector
30
// 25.07.96, P.Kent: Modified interface for new `Replica' capable geometry
31
// 24.07.95, P.Kent: First non-stub version
32
// --------------------------------------------------------------------
33
34
#include "
G4VPhysicalVolume.hh
"
35
36
#include "
G4PhysicalVolumeStore.hh
"
37
#include "
G4LogicalVolume.hh
"
38
39
// This new field helps to use the class G4PVManager
40
//
41
G4PVManager
G4VPhysicalVolume::subInstanceManager
;
42
43
// These macros change the references to fields that are now encapsulated
44
// in the class G4PVData.
45
//
46
#define G4MT_rot ((subInstanceManager.offset[instanceID]).frot)
47
#define G4MT_tx ((subInstanceManager.offset[instanceID]).tx)
48
#define G4MT_ty ((subInstanceManager.offset[instanceID]).ty)
49
#define G4MT_tz ((subInstanceManager.offset[instanceID]).tz)
50
#define G4MT_pvdata (subInstanceManager.offset[instanceID])
51
52
// Constructor: init parameters and register in Store
53
//
54
G4VPhysicalVolume::G4VPhysicalVolume
(
G4RotationMatrix
* pRot,
55
const
G4ThreeVector
& tlate,
56
const
G4String
& pName,
57
G4LogicalVolume
* pLogical,
58
G4VPhysicalVolume
* )
59
: flogical(pLogical),
fname
(pName)
60
{
61
instanceID
=
subInstanceManager
.
CreateSubInstance
();
62
63
this->
SetRotation
( pRot );
// G4MT_rot = pRot;
64
this->
SetTranslation
( tlate );
// G4MT_trans = tlate;
65
66
// Initialize 'Shadow' data structure - for use by object persistency
67
pvdata
=
new
G4PVData
();
68
pvdata
->
frot
= pRot;
69
pvdata
->
tx
= tlate.
x
();
70
pvdata
->
ty
= tlate.
y
();
71
pvdata
->
tz
= tlate.
z
();
72
73
G4PhysicalVolumeStore::Register
(
this
);
74
}
75
76
// Fake default constructor - sets only member data and allocates memory
77
// for usage restricted to object persistency.
78
//
79
G4VPhysicalVolume::G4VPhysicalVolume
( __void__& )
80
:
fname
(
""
)
81
{
82
// Register to store
83
//
84
instanceID
=
subInstanceManager
.
CreateSubInstance
();
85
86
G4PhysicalVolumeStore::Register
(
this
);
87
}
88
89
// Destructor - remove from Store
90
//
91
G4VPhysicalVolume::~G4VPhysicalVolume
()
92
{
93
delete
pvdata
;
94
G4PhysicalVolumeStore::DeRegister
(
this
);
95
}
96
97
// This method is similar to the constructor. It is used by each worker
98
// thread to achieve the same effect as that of the master thread exept
99
// to register the new created instance. This method is invoked explicitly.
100
// It does not create a new G4VPhysicalVolume instance.
101
// It only assign the value for the fields encapsulated by the class G4PVData.
102
//
103
void
G4VPhysicalVolume::
104
InitialiseWorker
(
G4VPhysicalVolume
*
/*pMasterObject*/
,
105
G4RotationMatrix
*pRot,
106
const
G4ThreeVector
&tlate)
107
{
108
subInstanceManager
.
SlaveCopySubInstanceArray
();
109
110
this->
SetRotation
( pRot );
// G4MT_rot = pRot;
111
this->
SetTranslation
( tlate );
// G4MT_trans = tlate;
112
// G4PhysicalVolumeStore::Register(this);
113
}
114
115
// Release memory allocated for offset
116
//
117
void
G4VPhysicalVolume::Clean
()
118
{
119
subInstanceManager
.
FreeSlave
();
120
}
121
122
// This method is similar to the destructor. It is used by each worker
123
// thread to achieve the partial effect as that of the master thread.
124
// For G4VPhysicalVolume instances, nothing more to do here.
125
//
126
void
G4VPhysicalVolume::TerminateWorker
(
G4VPhysicalVolume
*
/*pMasterObject*/
)
127
{
128
}
129
130
// Returns the private data instance manager.
131
//
132
const
G4PVManager
&
G4VPhysicalVolume::GetSubInstanceManager
()
133
{
134
return
subInstanceManager
;
135
}
136
137
G4int
G4VPhysicalVolume::GetMultiplicity
()
const
138
{
139
return
1;
140
}
141
142
const
G4ThreeVector
G4VPhysicalVolume::GetTranslation
()
const
143
{
144
return
G4ThreeVector
(
G4MT_tx
,
G4MT_ty
,
G4MT_tz
);
145
}
146
147
void
G4VPhysicalVolume::SetTranslation
(
const
G4ThreeVector
&vec)
148
{
149
G4MT_tx
=vec.
x
();
G4MT_ty
=vec.
y
();
G4MT_tz
=vec.
z
();
150
}
151
152
const
G4RotationMatrix
*
G4VPhysicalVolume::GetRotation
()
const
153
{
154
return
G4MT_rot
;
155
}
156
157
G4RotationMatrix
*
G4VPhysicalVolume::GetRotation
()
158
{
159
return
G4MT_rot
;
160
}
161
162
void
G4VPhysicalVolume::SetRotation
(
G4RotationMatrix
*pRot)
163
{
164
G4MT_rot
= pRot;
165
}
166
167
G4RotationMatrix
*
G4VPhysicalVolume::GetObjectRotation
()
const
168
{
169
static
G4RotationMatrix
aRotM;
170
static
G4RotationMatrix
IdentityRM;
171
172
G4RotationMatrix
* retval = &IdentityRM;
173
174
// Insure against frot being a null pointer
175
if
(this->
GetRotation
())
176
{
177
aRotM =
GetRotation
()->
inverse
();
178
retval= &aRotM;
179
}
180
return
retval;
181
}
182
183
G4RotationMatrix
G4VPhysicalVolume::GetObjectRotationValue
()
const
184
{
185
G4RotationMatrix
aRotM;
// Initialised to identity
186
187
// Insure against G4MT_rot being a null pointer
188
if
(
G4MT_rot
)
189
{
190
aRotM =
G4MT_rot
->inverse();
191
}
192
return
aRotM;
193
}
194
195
G4ThreeVector
G4VPhysicalVolume::GetObjectTranslation
()
const
196
{
197
return
G4ThreeVector
(
G4MT_tx
,
G4MT_ty
,
G4MT_tz
);
198
}
199
200
const
G4RotationMatrix
*
G4VPhysicalVolume::GetFrameRotation
()
const
201
{
202
return
G4MT_rot
;
203
}
204
205
G4ThreeVector
G4VPhysicalVolume::GetFrameTranslation
()
const
206
{
207
return
-
G4ThreeVector
(
G4MT_tx
,
G4MT_ty
,
G4MT_tz
);
208
}
209
210
// Only implemented for placed and parameterised volumes.
211
// Not required for replicas.
212
//
213
G4bool
G4VPhysicalVolume::CheckOverlaps
(
G4int
,
G4double
,
G4bool
,
G4int
)
214
{
215
return
false
;
216
}
geant4
tree
geant4-10.6-release
source
geometry
management
src
G4VPhysicalVolume.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:17
using
1.8.2 with
ECCE GitHub integration