Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PVReplica.hh
Go to the documentation of this file.
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// G4PVReplica
27//
28// Class description:
29//
30// Represents many touchable detector elements differing only in their
31// positioning. The elements' positions are calculated by means of a simple
32// linear formula, and the elements completely fill the containing mother
33// volume.
34
35// Original author: Paul Kent (CERN), 29.07.1995 - First non-stub version
36// - G.Cosmo, A.Dotti (CERN), 13.01.2013 - Modified for MT thread-safety
37// ----------------------------------------------------------------------
38#ifndef G4PVREPLICA_HH
39#define G4PVREPLICA_HH
40
41#include "G4VPhysicalVolume.hh"
42#include "G4GeomSplitter.hh"
43
45{
46 /**
47 * @brief G4ReplicaData encapsulates the fields of the class G4PVReplica that
48 * may not be read-only. G4PVReplica inherits from the class G4VPhysicalVolume.
49 * The fields from the ancestor that may not be read-only are handled
50 * by the ancestor class.
51 */
52
53 public:
54
55 void initialize() {}
56
58};
59
60/** Implementation detail for use of G4ReplicaData objects. */
62
63/**
64 * @brief G4PVReplica represents many touchable detector elements differing
65 * only in their positioning. The elements' positions are calculated by means
66 * of a simple linear formula, and the elements completely fill the containing
67 * mother volume.
68 *
69 * Replication may occur along:
70 *
71 * o Cartesian axes (kXAxis,kYAxis,kZAxis)
72 *
73 * The replications, of specified width have coordinates of
74 * form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
75 * for the case of kXAxis, and are unrotated.
76 *
77 * o Radial axis (cylindrical polar) (kRho)
78 *
79 * The replications are cons/tubs sections, centred on the origin
80 * and are unrotated.
81 * They have radii of width*n+offset to width*(n+1)+offset
82 * where n=0..nReplicas-1
83 *
84 * o Phi axis (cylindrical polar) (kPhi)
85 * The replications are `phi sections' or wedges, and of cons/tubs form
86 * They have phi of offset+n*width to offset+(n+1)*width where
87 * n=0..nReplicas-1
88 */
89
90class G4PVReplica : public G4VPhysicalVolume
91{
92 public:
93
94 /**
95 * Replicates the volume 'nReplicas' times along the specified axis
96 * within the mother volume 'pMother' and filling completely the mother.
97 * @param[in] pName The volume name.
98 * @param[in] pLogical Pointer to the logical volume of the replica.
99 * @param[in] pMother Pointer to the logical volume of the mother.
100 * @param[in] pAxis The axis along which do the replication.
101 * @param[in] nReplicas The number of copies to replicate.
102 * @param[in] width The witdh of the replicated object along the axis.
103 * @param[in] offset The optional offset distance from mother's border.
104 */
105 G4PVReplica(const G4String& pName,
106 G4LogicalVolume* pLogical,
107 G4LogicalVolume* pMother,
108 const EAxis pAxis,
109 const G4int nReplicas,
110 const G4double width,
111 const G4double offset = 0.);
112
113 /**
114 * Similar to the constructor above, except for the mother pointer's type
115 * being here a G4VPhysicalVolume.
116 * @param[in] pName The volume name.
117 * @param[in] pLogical Pointer to the logical volume of the replica.
118 * @param[in] pMother Pointer to the physical volume of the mother.
119 * @param[in] pAxis The axis along which do the replication.
120 * @param[in] nReplicas The number of copies to replicate.
121 * @param[in] width The witdh of the replicated object along the axis.
122 * @param[in] offset The optional offset distance from mother's border.
123 */
124 G4PVReplica(const G4String& pName,
125 G4LogicalVolume* pLogical,
126 G4VPhysicalVolume* pMother,
127 const EAxis pAxis,
128 const G4int nReplicas,
129 const G4double width,
130 const G4double offset = 0.);
131
132 /**
133 * Fake default constructor for usage restricted to direct object
134 * persistency for clients requiring preallocation of memory for
135 * persistifiable objects.
136 */
137 G4PVReplica(__void__&);
138
139 /**
140 * Copy constructor and assignment operator not allowed.
141 */
142 G4PVReplica(const G4PVReplica&) = delete;
144
145 /**
146 * Default Destructor.
147 */
148 ~G4PVReplica() override = default;
149
150 /**
151 * Returns the volume type characterisation.
152 */
153 EVolume VolumeType() const override;
154
155 /**
156 * Not used.
157 */
158 G4bool IsMany() const override;
159
160 /**
161 * Returns true.
162 */
163 G4bool IsReplicated() const override;
164
165 /**
166 * Accessor/modifier for optional handling of the copy-number.
167 */
168 G4int GetCopyNo() const override;
169 void SetCopyNo(G4int CopyNo) override;
170
171 /**
172 * Returns false and nullptr.
173 */
174 G4bool IsParameterised() const override;
176
177 /**
178 * Returns the number of replications.
179 */
180 G4int GetMultiplicity() const override;
181
182 /**
183 * Fills arguments with the attributes from the base replica.
184 * @param[in,out] axis Axis of parameterisation returned.
185 * @param[in,out] nReplicas The number of replica copies.
186 * @param[in,out] width Width of the replica object.
187 * @param[in,out] offset Potential offset in replication.
188 * @param[in,out] consuming Flag of replica characterisation (always true
189 * for pure replicas).
190 */
192 G4int& nReplicas,
193 G4double& width,
195 G4bool& consuming) const override;
196
197 /**
198 * Sets a unique code for each type of regular structure.
199 * @note It must be called only during detector construction.
200 * It can also be used to prepare any corresponding special
201 * navigation 'conditions'.
202 */
204
205 /**
206 * Accessors for specialised geometries.
207 */
208 G4bool IsRegularStructure() const override;
209 G4int GetRegularStructureId() const override;
210
211 // Methods for handling of MT instances
212
213 /**
214 * Returns the MT instance ID.
215 */
216 inline G4int GetInstanceID() const { return instanceID; }
217
218 /**
219 * Returns the private data instance manager.
220 */
221 static const G4PVRManager& GetSubInstanceManager();
222
223 /**
224 * This method is similar to the constructor. It is used by each worker
225 * thread to achieve the partial effect as that of the master thread.
226 */
227 void InitialiseWorker(G4PVReplica* pMasterObject);
228
229 /**
230 * This method is similar to the destructor. It is used by each worker
231 * thread to achieve the partial effect as that of the master thread.
232 */
233 void TerminateWorker(G4PVReplica* pMasterObject);
234
235 protected:
236
237 /**
238 * Constructor for derived type(s): PVParameterised, PVDivision, ...
239 * Does not set mother or register in mother volume -- leaves it to
240 * derived type.
241 */
242 G4PVReplica(const G4String& pName,
243 G4int nReplicas,
244 EAxis pAxis,
245 G4LogicalVolume* pLogical,
246 G4LogicalVolume* pMotherLogical);
247
248 private:
249
250 /**
251 * Performs sanity checks on parameters and initialises data.
252 */
253 void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
254 const G4double width, const G4double offset);
255
256 /**
257 * Checks that this volume is the only daughter of its proposed mother
258 * volume.
259 */
260 void CheckOnlyDaughter(G4LogicalVolume* pMotherLogical);
261
262 protected:
263
267
268 private:
269
270 G4int fRegularVolsId = 0;
271
272 G4int instanceID; // Used as instance ID
273 G4GEOM_DLL static G4PVRManager subInstanceManager; // Uses G4PVRManager
274};
275
276/**
277 * @note:
278 *
279 * The type G4PVRManager is introduced to encapsulate the methods used by
280 * both the master thread and worker threads to allocate memory space for
281 * the fields encapsulated by the class G4ReplicaData. When each thread
282 * initializes the value for these fields, it refers to them using a macro
283 * definition defined below. For every G4PVReplica instance, there is
284 * a corresponding G4ReplicaData instance. All G4ReplicaData instances are
285 * organized by the class G4PVRManager as an array.
286 * The field "int instanceID" is added to the class G4PVReplica.
287 * The value of this field in each G4LogicalVolume instance is the subscript
288 * of the corresponding G4ReplicaData instance.
289 * In order to use the class G4PVRManager, we add a static member in the
290 * class G4LogicalVolume as follows: "static G4PVRManager subInstanceManager".
291 * For the master thread, the array for G4ReplicaData instances grows
292 * dynamically along with G4PVReplica instances arecreated.
293 * For each worker thread, it copies the array of G4ReplicaData instances
294 * from the master thread.
295 * In addition, it invokes a method similiar to the constructor explicitly
296 * to achieve the partial effect for each instance in the array.
297 */
298
299#endif
G4ThreadLocal T * G4GeomSplitter< T >::offset
G4VPVParameterisation * GetParameterisation() const override
EAxis faxis
G4int fnReplicas
G4bool IsParameterised() const override
G4double fwidth
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const override
G4bool IsMany() const override
G4double foffset
G4PVDivision & operator=(const G4PVDivision &)=delete
G4int GetRegularStructureId() const override
G4bool IsReplicated() const override
G4int GetMultiplicity() const override
G4bool IsRegularStructure() const override
EVolume VolumeType() const override
void TerminateWorker(G4PVReplica *pMasterObject)
G4PVReplica(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0.)
G4PVReplica represents many touchable detector elements differing only in their positioning....
void InitialiseWorker(G4PVReplica *pMasterObject)
G4int GetInstanceID() const
G4GeomSplitter< G4ReplicaData > G4PVRManager
void SetCopyNo(G4int CopyNo) override
virtual void SetRegularStructureId(G4int code)
G4int GetCopyNo() const override
~G4PVReplica() override=default
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4GeomSplitter is an utility class for splitting of R/W data for thread-safety from geometry classes....
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
void initialize()
G4ReplicaData encapsulates the fields of the class G4PVReplica that may not be read-only....
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
EAxis
Definition geomdefs.hh:54
EVolume
Definition geomdefs.hh:83
#define G4GEOM_DLL
Definition geomwdefs.hh:45
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668