Geant4 11.1.1
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// G4PVReplica(const G4String& pName,
36// G4LogicalVolume *pLogical,
37// G4LogicalVolume *pMother,
38// const EAxis pAxis,
39// const G4int nReplicas,
40// const G4double width,
41// const G4double offset=0);
42//
43// Replication may occur along:
44//
45// o Cartesian axes (kXAxis,kYAxis,kZAxis)
46//
47// The replications, of specified width have coordinates of
48// form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
49// for the case of kXAxis, and are unrotated.
50//
51// o Radial axis (cylindrical polar) (kRho)
52//
53// The replications are cons/tubs sections, centred on the origin
54// and are unrotated.
55// They have radii of width*n+offset to width*(n+1)+offset
56// where n=0..nReplicas-1
57//
58// o Phi axis (cylindrical polar) (kPhi)
59// The replications are `phi sections' or wedges, and of cons/tubs form
60// They have phi of offset+n*width to offset+(n+1)*width where
61// n=0..nReplicas-1
62
63// 29.07.95 P.Kent - First non-stub version
64// 26.10.97 J.Apostolakis - Added constructor that takes mother LV
65// 13.01.13 G.Cosmo, A.Dotti - Modified for thread-safety for MT
66// ----------------------------------------------------------------------
67#ifndef G4PVREPLICA_HH
68#define G4PVREPLICA_HH 1
69
70#include "G4VPhysicalVolume.hh"
71#include "G4GeomSplitter.hh"
72
74{
75 // Encapsulates the fields of the class G4PVReplica that may not be
76 // read-only. G4PVReplica inherits from the class G4VPhysicalVolume.
77 // The fields from the ancestor that may not be read-only are handled
78 // by the ancestor class.
79
80public:
81
82 void initialize() {}
83
85};
86
88// Implementation detail for use of G4ReplicaData objects
89
91{
92 public:
93
94 G4PVReplica(const G4String& pName,
95 G4LogicalVolume* pLogical,
96 G4LogicalVolume* pMother,
97 const EAxis pAxis,
98 const G4int nReplicas,
99 const G4double width,
100 const G4double offset = 0.);
101
102 G4PVReplica(const G4String& pName,
103 G4LogicalVolume* pLogical,
104 G4VPhysicalVolume* pMother,
105 const EAxis pAxis,
106 const G4int nReplicas,
107 const G4double width,
108 const G4double offset = 0.);
109
110 G4PVReplica(__void__&);
111 // Fake default constructor for usage restricted to direct object
112 // persistency for clients requiring preallocation of memory for
113 // persistifiable objects.
114
115 G4PVReplica(const G4PVReplica&) = delete;
117 // Copy constructor and assignment operator not allowed
118
119 virtual ~G4PVReplica();
120
121 virtual EVolume VolumeType() const;
122
123 G4bool IsMany() const;
124 G4bool IsReplicated() const;
125
126 virtual G4int GetCopyNo() const;
127 virtual void SetCopyNo(G4int CopyNo);
128 virtual G4bool IsParameterised() const;
130 virtual G4int GetMultiplicity() const;
131 virtual void GetReplicationData(EAxis& axis,
132 G4int& nReplicas,
133 G4double& width,
134 G4double& offset,
135 G4bool& consuming) const;
136
137 virtual void SetRegularStructureId( G4int code );
138 // This method must set a unique code for each type of regular structure.
139 // - It must be called only during detector construction.
140 // - It can also be used to prepare any corresponding special
141 // navigation 'conditions'.
142
143 G4bool IsRegularStructure() const;
145 // Accessors for specialised geometries
146
147 // Methods for handling of MT instances
148
149 inline G4int GetInstanceID() const { return instanceID; }
150 // Returns the instance ID.
151
152 static const G4PVRManager& GetSubInstanceManager();
153 // Returns the private data instance manager.
154
155 void InitialiseWorker(G4PVReplica* pMasterObject);
156 // This method is similar to the constructor. It is used by each worker
157 // thread to achieve the partial effect as that of the master thread.
158
159 void TerminateWorker(G4PVReplica* pMasterObject);
160 // This method is similar to the destructor. It is used by each worker
161 // thread to achieve the partial effect as that of the master thread.
162
163 protected:
164
165 G4PVReplica(const G4String& pName,
166 G4int nReplicas,
167 EAxis pAxis,
168 G4LogicalVolume* pLogical,
169 G4LogicalVolume* pMotherLogical);
170 // Constructor for derived type(s): PVParameterised, PVDivision, ...
171 // Does not set mother or register in mother volume -- leaves it to
172 // derived type
173
174 private:
175
176 void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
177 const G4double width, const G4double offset);
178
179 void CheckOnlyDaughter(G4LogicalVolume* pMotherLogical);
180 // Check that this volume is the only daughter of its proposed mother
181 // volume
182
183 protected:
184
188
189 private:
190
191 G4int fRegularVolsId = 0;
192
193 G4int instanceID;
194 // This new field is used as instance ID.
195 G4GEOM_DLL static G4PVRManager subInstanceManager;
196 // This new field helps to use the class G4PVRManager introduced above.
197};
198
199// NOTE:
200// The type G4PVRManager is introduced to encapsulate the methods used by
201// both the master thread and worker threads to allocate memory space for
202// the fields encapsulated by the class G4ReplicaData. When each thread
203// initializes the value for these fields, it refers to them using a macro
204// definition defined below. For every G4PVReplica instance, there is
205// a corresponding G4ReplicaData instance. All G4ReplicaData instances are
206// organized by the class G4PVRManager as an array.
207// The field "int instanceID" is added to the class G4PVReplica.
208// The value of this field in each G4LogicalVolume instance is the subscript
209// of the corresponding G4ReplicaData instance.
210// In order to use the class G4PVRManager, we add a static member in the
211// class G4LogicalVolume as follows: "static G4PVRManager subInstanceManager".
212// For the master thread, the array for G4ReplicaData instances grows
213// dynamically along with G4PVReplica instances arecreated.
214// For each worker thread, it copies the array of G4ReplicaData instances
215// from the master thread.
216// In addition, it invokes a method similiar to the constructor explicitly
217// to achieve the partial effect for each instance in the array.
218
219#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4int GetRegularStructureId() const
Definition: G4PVReplica.cc:329
virtual void SetRegularStructureId(G4int code)
Definition: G4PVReplica.cc:335
G4bool IsMany() const
Definition: G4PVReplica.cc:261
G4double fwidth
Definition: G4PVReplica.hh:187
virtual void SetCopyNo(G4int CopyNo)
Definition: G4PVReplica.cc:273
G4bool IsReplicated() const
Definition: G4PVReplica.cc:279
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:297
static const G4PVRManager & GetSubInstanceManager()
Definition: G4PVReplica.cc:343
G4int fnReplicas
Definition: G4PVReplica.hh:186
G4double foffset
Definition: G4PVReplica.hh:187
virtual G4VPVParameterisation * GetParameterisation() const
Definition: G4PVReplica.cc:291
void TerminateWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:400
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
Definition: G4PVReplica.cc:309
virtual G4bool IsParameterised() const
Definition: G4PVReplica.cc:285
G4bool IsRegularStructure() const
Definition: G4PVReplica.cc:323
void InitialiseWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:355
virtual G4int GetCopyNo() const
Definition: G4PVReplica.cc:267
G4PVReplica & operator=(const G4PVReplica &)=delete
virtual EVolume VolumeType() const
Definition: G4PVReplica.cc:303
G4int GetInstanceID() const
Definition: G4PVReplica.hh:149
virtual ~G4PVReplica()
Definition: G4PVReplica.cc:256
G4PVReplica(const G4PVReplica &)=delete
void initialize()
Definition: G4PVReplica.hh:82
EAxis
Definition: geomdefs.hh:54
EVolume
Definition: geomdefs.hh:83
#define G4GEOM_DLL
Definition: geomwdefs.hh:44
Definition: inftrees.h:24