Geant4 10.7.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// 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
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
87// The type G4PVRManager is introduced to encapsulate the methods used by
88// both the master thread and worker threads to allocate memory space for
89// the fields encapsulated by the class G4ReplicaData. When each thread
90// initializes the value for these fields, it refers to them using a macro
91// definition defined below. For every G4PVReplica instance, there is
92// a corresponding G4ReplicaData instance. All G4ReplicaData instances are
93// organized by the class G4PVRManager as an array.
94// The field "int instanceID" is added to the class G4PVReplica.
95// The value of this field in each G4LogicalVolume instance is the subscript
96// of the corresponding G4ReplicaData instance.
97// In order to use the class G4PVRManager, we add a static member in the
98// class G4LogicalVolume as follows: "static G4PVRManager subInstanceManager".
99// For the master thread, the array for G4ReplicaData instances grows
100// dynamically along with G4PVReplica instances arecreated.
101// For each worker thread, it copies the array of G4ReplicaData instances
102// from the master thread.
103// In addition, it invokes a method similiar to the constructor explicitly
104// to achieve the partial effect for each instance in the array.
105//
107
108// This macro changes the references to fields that are now encapsulated
109// in the class G4ReplicaData.
110//
111#define G4MT_copyNo ((subInstanceManager.offset[instanceID]).fcopyNo)
112
114{
115 public: // with description
116
117 G4PVReplica(const G4String& pName,
118 G4LogicalVolume* pLogical,
119 G4LogicalVolume* pMother,
120 const EAxis pAxis,
121 const G4int nReplicas,
122 const G4double width,
123 const G4double offset = 0.);
124
125 G4PVReplica(const G4String& pName,
126 G4LogicalVolume* pLogical,
127 G4VPhysicalVolume* pMother,
128 const EAxis pAxis,
129 const G4int nReplicas,
130 const G4double width,
131 const G4double offset = 0.);
132
133 G4PVReplica(__void__&);
134 // Fake default constructor for usage restricted to direct object
135 // persistency for clients requiring preallocation of memory for
136 // persistifiable objects.
137
138 G4PVReplica(const G4PVReplica&) = delete;
140 // Copy constructor and assignment operator not allowed
141
142 virtual ~G4PVReplica();
143
144 virtual EVolume VolumeType() const;
145
146 G4bool IsMany() const;
147 G4bool IsReplicated() const;
148
149 virtual G4int GetCopyNo() const;
150 virtual void SetCopyNo(G4int CopyNo);
151 virtual G4bool IsParameterised() const;
153 virtual G4int GetMultiplicity() const;
154 virtual void GetReplicationData(EAxis& axis,
155 G4int& nReplicas,
156 G4double& width,
157 G4double& offset,
158 G4bool& consuming) const;
159
160 virtual void SetRegularStructureId( G4int code );
161 // This method must set a unique code for each type of regular structure.
162 // - It must be called only during detector construction.
163 // - It can also be used to prepare any corresponding special
164 // navigation 'conditions'.
165
166 G4bool IsRegularStructure() const;
168 // Accessors for specialised geometries
169
170 public: // without description
171
172 inline G4int GetInstanceID() const { return instanceID; }
173 // Returns the instance ID.
174
175 static const G4PVRManager& GetSubInstanceManager();
176 // Returns the private data instance manager.
177
178 void InitialiseWorker(G4PVReplica* pMasterObject);
179 // This method is similar to the constructor. It is used by each worker
180 // thread to achieve the partial effect as that of the master thread.
181
182 void TerminateWorker(G4PVReplica* pMasterObject);
183 // This method is similar to the destructor. It is used by each worker
184 // thread to achieve the partial effect as that of the master thread.
185
186 private:
187
188 void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
189 const G4double width, const G4double offset);
190
191 void CheckOnlyDaughter(G4LogicalVolume* pMotherLogical);
192 // Check that this volume is the only daughter of its proposed mother volume
193
194 protected:
195 G4PVReplica(const G4String& pName,
196 G4int nReplicas,
197 EAxis pAxis,
198 G4LogicalVolume* pLogical,
199 G4LogicalVolume* pMotherLogical
200 );
201 // Constructor for derived type(s): PVParameterised
202 // - does not set mother or register in mother volume -- leaves it to derived type
203
204 protected:
205
209
210 private:
211
212 G4int fRegularVolsId = 0;
213
214 G4int instanceID;
215 // This new field is used as instance ID.
216 G4GEOM_DLL static G4PVRManager subInstanceManager;
217 // This new field helps to use the class G4PVRManager introduced above.
218};
219
220#endif
G4GeomSplitter< G4ReplicaData > G4PVRManager
Definition: G4PVReplica.hh:106
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4int GetRegularStructureId() const
Definition: G4PVReplica.cc:315
virtual void SetRegularStructureId(G4int code)
Definition: G4PVReplica.cc:320
G4bool IsMany() const
Definition: G4PVReplica.cc:257
G4double fwidth
Definition: G4PVReplica.hh:208
virtual void SetCopyNo(G4int CopyNo)
Definition: G4PVReplica.cc:267
G4bool IsReplicated() const
Definition: G4PVReplica.cc:272
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:287
static const G4PVRManager & GetSubInstanceManager()
Definition: G4PVReplica.cc:327
G4int fnReplicas
Definition: G4PVReplica.hh:207
G4double foffset
Definition: G4PVReplica.hh:208
virtual G4VPVParameterisation * GetParameterisation() const
Definition: G4PVReplica.cc:282
void TerminateWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:383
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
Definition: G4PVReplica.cc:297
virtual G4bool IsParameterised() const
Definition: G4PVReplica.cc:277
G4bool IsRegularStructure() const
Definition: G4PVReplica.cc:310
void InitialiseWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:338
virtual G4int GetCopyNo() const
Definition: G4PVReplica.cc:262
G4PVReplica & operator=(const G4PVReplica &)=delete
virtual EVolume VolumeType() const
Definition: G4PVReplica.cc:292
G4int GetInstanceID() const
Definition: G4PVReplica.hh:172
virtual ~G4PVReplica()
Definition: G4PVReplica.cc:249
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