Geant4  10.00.p02
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 //
27 // $Id: G4PVReplica.hh 81646 2014-06-04 09:28:37Z gcosmo $
28 //
29 //
30 // class G4PVReplica
31 //
32 // Class description:
33 //
34 // Represents many touchable detector elements differing only in their
35 // positioning. The elements' positions are calculated by means of a simple
36 // linear formula, and the elements completely fill the containing mother
37 // volume.
38 //
39 // G4PVReplica(const G4String& pName,
40 // G4LogicalVolume *pLogical,
41 // G4LogicalVolume *pMother,
42 // const EAxis pAxis,
43 // const G4int nReplicas,
44 // const G4double width,
45 // const G4double offset=0);
46 //
47 // Replication may occur along:
48 //
49 // o Cartesian axes (kXAxis,kYAxis,kZAxis)
50 //
51 // The replications, of specified width have coordinates of
52 // form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
53 // for the case of kXAxis, and are unrotated.
54 //
55 // o Radial axis (cylindrical polar) (kRho)
56 //
57 // The replications are cons/tubs sections, centred on the origin
58 // and are unrotated.
59 // They have radii of width*n+offset to width*(n+1)+offset
60 // where n=0..nReplicas-1
61 //
62 // o Phi axis (cylindrical polar) (kPhi)
63 // The replications are `phi sections' or wedges, and of cons/tubs form
64 // They have phi of offset+n*width to offset+(n+1)*width where
65 // n=0..nReplicas-1
66 
67 // History:
68 // 29.07.95 P.Kent - First non-stub version
69 // 26.10.97 J.Apostolakis - Added constructor that takes mother LV
70 // 16.02.98 J.Apostolakis - Added copy number
71 // 13.01.13 G.Cosmo, A.Dotti - Modified for thread-safety for MT
72 // ----------------------------------------------------------------------
73 #ifndef G4PVREPLICA_HH
74 #define G4PVREPLICA_HH
75 
76 #include "G4VPhysicalVolume.hh"
77 #include "G4GeomSplitter.hh"
78 
80 {
81  // Encapsulates the fields of the class G4PVReplica that may not be
82  // read-only. G4PVReplica inherits from the class G4VPhysicalVolume.
83  // The fields from the ancestor that may not be read-only are handled
84  // by the ancestor class.
85 
86 public:
87 
88  void initialize() {}
89 
91 };
92 
93 // The type G4PVRManager is introduced to encapsulate the methods used by
94 // both the master thread and worker threads to allocate memory space for
95 // the fields encapsulated by the class G4ReplicaData. When each thread
96 // initializes the value for these fields, it refers to them using a macro
97 // definition defined below. For every G4PVReplica instance, there is
98 // a corresponding G4ReplicaData instance. All G4ReplicaData instances are
99 // organized by the class G4PVRManager as an array.
100 // The field "int instanceID" is added to the class G4PVReplica.
101 // The value of this field in each G4LogicalVolume instance is the subscript
102 // of the corresponding G4ReplicaData instance.
103 // In order to use the class G4PVRManager, we add a static member in the
104 // class G4LogicalVolume as follows: "static G4PVRManager subInstanceManager".
105 // For the master thread, the array for G4ReplicaData instances grows
106 // dynamically along with G4PVReplica instances arecreated.
107 // For each worker thread, it copies the array of G4ReplicaData instances
108 // from the master thread.
109 // In addition, it invokes a method similiar to the constructor explicitly
110 // to achieve the partial effect for each instance in the array.
111 //
113 
114 // This macro changes the references to fields that are now encapsulated
115 // in the class G4ReplicaData.
116 //
117 #define G4MT_copyNo ((subInstanceManager.offset[instanceID]).fcopyNo)
118 
120 {
121  public: // with description
122 
123  G4PVReplica(const G4String& pName,
124  G4LogicalVolume* pLogical,
125  G4LogicalVolume* pMother,
126  const EAxis pAxis,
127  const G4int nReplicas,
128  const G4double width,
129  const G4double offset=0);
130 
131  public: // without description
132 
133  G4PVReplica(const G4String& pName,
134  G4LogicalVolume* pLogical,
135  G4VPhysicalVolume* pMother,
136  const EAxis pAxis,
137  const G4int nReplicas,
138  const G4double width,
139  const G4double offset=0);
140 
141  G4PVReplica(__void__&);
142  // Fake default constructor for usage restricted to direct object
143  // persistency for clients requiring preallocation of memory for
144  // persistifiable objects.
145 
146  public: // with description
147 
148  virtual ~G4PVReplica();
149 
150  G4bool IsMany() const;
151  G4bool IsReplicated() const;
152 
153  virtual G4int GetCopyNo() const;
154  virtual void SetCopyNo(G4int CopyNo);
155  virtual G4bool IsParameterised() const;
157  virtual G4int GetMultiplicity() const;
158  virtual void GetReplicationData(EAxis& axis,
159  G4int& nReplicas,
160  G4double& width,
161  G4double& offset,
162  G4bool& consuming) const;
163 
164  virtual void SetRegularStructureId( G4int Code );
165  // This method must set a unique code for each type of regular structure.
166  // - It must be called only during detector construction.
167  // - It can also be used to prepare any corresponding special
168  // navigation 'conditions'.
169 
170  G4bool IsRegularStructure() const;
172  // Accessors for specialised geometries
173 
174  public: // without description
175 
176  inline G4int GetInstanceID() const { return instanceID; }
177  // Returns the instance ID.
178 
179  static const G4PVRManager& GetSubInstanceManager();
180  // Returns the private data instance manager.
181 
182  void InitialiseWorker(G4PVReplica *pMasterObject);
183  // This method is similar to the constructor. It is used by each worker
184  // thread to achieve the partial effect as that of the master thread.
185 
186  void TerminateWorker(G4PVReplica *pMasterObject);
187  // This method is similar to the destructor. It is used by each worker
188  // thread to achieve the partial effect as that of the master thread.
189 
190  protected:
191 
195 
196  private:
197 
198  void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
199  const G4double width, const G4double offset);
200  G4PVReplica(const G4PVReplica&);
202 
203  private:
204 
207 
209  // This new field is used as instance ID.
211  // This new field helps to use the class G4PVRManager introduced above.
212 };
213 
214 #endif
void TerminateWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:300
G4PVReplica(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0)
Definition: G4PVReplica.cc:91
virtual ~G4PVReplica()
Definition: G4PVReplica.cc:191
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
Definition: G4PVReplica.cc:236
G4PVReplica & operator=(const G4PVReplica &)
virtual void SetRegularStructureId(G4int Code)
Definition: G4PVReplica.cc:259
#define width
G4double fwidth
Definition: G4PVReplica.hh:194
G4bool IsRegularStructure() const
Definition: G4PVReplica.cc:249
static G4GEOM_DLL G4PVRManager subInstanceManager
Definition: G4PVReplica.hh:210
int G4int
Definition: G4Types.hh:78
virtual G4int GetCopyNo() const
Definition: G4PVReplica.cc:204
G4bool IsReplicated() const
Definition: G4PVReplica.cc:214
G4int GetInstanceID() const
Definition: G4PVReplica.hh:176
static const G4PVRManager & GetSubInstanceManager()
Definition: G4PVReplica.cc:275
virtual G4bool IsParameterised() const
Definition: G4PVReplica.cc:219
G4double foffset
Definition: G4PVReplica.hh:194
G4int fRegularVolsId
Definition: G4PVReplica.hh:206
void InitialiseWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:287
virtual G4VPVParameterisation * GetParameterisation() const
Definition: G4PVReplica.cc:224
G4int fnReplicas
Definition: G4PVReplica.hh:193
bool G4bool
Definition: G4Types.hh:79
G4bool IsMany() const
Definition: G4PVReplica.cc:199
G4int fRegularStructureCode
Definition: G4PVReplica.hh:205
G4int instanceID
Definition: G4PVReplica.hh:208
EAxis
Definition: geomdefs.hh:54
void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset)
Definition: G4PVReplica.cc:136
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:229
virtual void SetCopyNo(G4int CopyNo)
Definition: G4PVReplica.cc:209
void initialize()
Definition: G4PVReplica.hh:88
double G4double
Definition: G4Types.hh:76
G4GeomSplitter< G4ReplicaData > G4PVRManager
Definition: G4PVReplica.hh:112
#define G4GEOM_DLL
Definition: geomwdefs.hh:48
G4int GetRegularStructureId() const
Definition: G4PVReplica.cc:254