Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ReflectionFactory.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// G4ReflectionFactory
27//
28// Class description:
29//
30// Class providing functions for volumes placements with a general
31// transfomation that can contain a reflection.
32// Reflection is then applied to a solid: a new G4ReflectedSolid
33// instance is created and is placed with a transformation containing
34// pure rotation and translation only.
35// The pair of constituent and reflected logical volumes is
36// considered as a generalised logical volume that is addressed
37// by user specifying the constituent logical volume.
38
39// Author: Ivana Hrivnacova (IN2P3/IJCLab Orsay), 16.10.2001
40// --------------------------------------------------------------------
41#ifndef G4_REFLECTION_FACTORY_HH
42#define G4_REFLECTION_FACTORY_HH
43
44#include "G4Types.hh"
45#include "G4Transform3D.hh"
46#include "geomdefs.hh"
47
48#include <map>
49
51class G4LogicalVolume;
52class G4VSolid;
54
55using G4PhysicalVolumesPair = std::pair<G4VPhysicalVolume*, G4VPhysicalVolume*>;
57 std::less<G4LogicalVolume*> >;
58/**
59 * @brief G4ReflectionFactory provides functions for volumes placements with
60 * a general transfomation that can contain a reflection.
61 * Reflection is then applied to a solid: a new G4ReflectedSolid instance is
62 * created and is placed with a transformation containing pure rotation and
63 * translation only.
64 * The pair of constituent and reflected logical volumes is considered as a
65 * generalised logical volume that is addressed by user specifying the
66 * constituent logical volume.
67 *
68 * Decomposition of a general transformation that can include reflection
69 * in a "reflection-free" transformation:
70 *
71 * x(inM') = TG*x(inM) TG - general transformation
72 * = T*(R*x(inM)) T - "reflection-free" transformation
73 * = T* x(inReflM)
74 *
75 * Daughters transformation:
76 * When a volume V containing daughter D with transformation TD
77 * is placed in mother M with a general tranformation TGV,
78 * the TGV is decomposed. New reflected volume ReflV containing
79 * a new daughter ReflD with reflected transformation ReflTD is created:
80 *
81 * x(inV) = TD * x(inD);
82 * x(inM) = TGV * x(inV)
83 * = TV * R * x(inV)
84 * = TV * R * TD * x(inD)
85 * = TV * R*TD*R-1 * R*x(inD)
86 * = TV * ReflTD * x(inReflD)
87 */
88
90{
91 using LogicalVolumesMapIterator = G4ReflectedVolumesMap::const_iterator;
92
93 public:
94
95 /**
96 * Destructor.
97 */
99
100 /**
101 * Copy constructor and assignment operator not allowed.
102 */
105
106 /**
107 * Gets pointer to the instance of the singleton.
108 */
110
111 /**
112 * Evaluates the passed transformation; if it contains reflection
113 * it performs its decomposition, creates new reflected solid and
114 * logical volume (or retrieves them from a map if the reflected
115 * objects were already created), transforms the daughters (if present)
116 * and places it in the given mother.
117 * @param[in] transform3D The transformation in 3D space that can contain
118 * a reflection.
119 * @param[in] pName The volume name.
120 * @param[in] LV Pointer to the logical volume to be placed.
121 * @param[in] motherLV Pointer to the logical volume of the mother.
122 * @param[in] isMany Not used.
123 * @param[in] copyNo The optional custom copy number.
124 * @param[in] surfCheck Boolean flag, if true activates check for overlaps
125 * with existing volumes (false by default).
126 * @returns A pair of physical volumes; the second physical volume
127 * is a placement in a reflected mother or nullptr if mother
128 * logical volume was not reflected.
129 */
130 G4PhysicalVolumesPair Place(const G4Transform3D& transform3D,
131 const G4String& name,
132 G4LogicalVolume* LV,
133 G4LogicalVolume* motherLV,
134 G4bool isMany,
135 G4int copyNo,
136 G4bool surfCheck = false);
137
138 /**
139 * Creates a replica in the given mother.
140 * @param[in] name The volume name.
141 * @param[in] LV Pointer to the logical volume to be replicated.
142 * @param[in] motherLV Pointer to the logical volume of the mother.
143 * @param[in] axis The axis along which do the replication.
144 * @param[in] nofReplicas The number of copies to replicate.
145 * @param[in] width The witdh of the replicated object along the axis.
146 * @param[in] offset The optional offset distance from mother's border.
147 * @returns A pair of physical volumes; the second physical volume is
148 * a replica in a reflected mother or nullptr if the mother
149 * logical volume was not reflected.
150 */
152 G4LogicalVolume* LV,
153 G4LogicalVolume* motherLV,
154 EAxis axis,
155 G4int nofReplicas,
156 G4double width,
157 G4double offset = 0.);
158
159 /**
160 * Methods to create a division in the given mother, along with the
161 * possible specifications for creating a division.
162 * @returns A pair of physical volumes; the second physical volume is
163 * a division in a reflected mother or nullptr if mother
164 * logical volume was not reflected.
165 */
167 G4LogicalVolume* LV,
168 G4LogicalVolume* motherLV,
169 EAxis axis,
170 G4int nofDivisions,
171 G4double width,
174 G4LogicalVolume* LV,
175 G4LogicalVolume* motherLV,
176 EAxis axis,
177 G4int nofDivisions,
180 G4LogicalVolume* LV,
181 G4LogicalVolume* motherLV,
182 EAxis axis,
183 G4double width,
185
186 /**
187 * Verbosity control.
188 */
189 void SetVerboseLevel(G4int verboseLevel);
190 G4int GetVerboseLevel() const;
191
192 /**
193 * Sets/returns the name extension for the reflected solids and
194 * logical volumes.
195 */
196 void SetVolumesNameExtension(const G4String& nameExtension);
197 const G4String& GetVolumesNameExtension() const;
198
199 /**
200 * Sets/gets the precision factor for the scale consistency check.
201 * The default value is set to 10*kCarTolerance.
202 */
203 void SetScalePrecision(G4double scaleValue);
205
206 /**
207 * Returns the consituent volume of the given reflected volume.
208 * Returns nullptr if the given reflected volume was not found.
209 */
211
212 /**
213 * Returns the reflected volume of the given consituent volume.
214 * Returns nullptr if the given volume was not reflected.
215 */
217
218 /**
219 * Returns true if the given volume has been already reflected
220 * (i.e. is in the map of constituent volumes).
221 */
223
224 /**
225 * Returns true if the given volume is a reflected volume
226 * (i.e. is in the map reflected volumes).
227 */
229
230 /**
231 * Returns a handle to the internal map of volumes which have
232 * been reflected, after that placement or replication is performed.
233 */
235
236 /**
237 * Clears the maps of constituent and reflected volumes.
238 * @note To be used exclusively when volumes are removed from the stores.
239 */
240 void Clean();
241
242 private:
243
244 /**
245 * Private singleton constructor.
246 */
248
249 /**
250 * Gets/creates the reflected solid and logical volume
251 * and copies + transforms logical volumes of daughters.
252 */
253 G4LogicalVolume* ReflectLV(G4LogicalVolume* LV, G4bool surfCheck = false);
254
255 /**
256 * Creates the reflected solid and logical volume
257 * and adds the logical volumes pair in the maps.
258 */
259 G4LogicalVolume* CreateReflectedLV(G4LogicalVolume* LV);
260
261 /**
262 * Reflects daughters recursively.
263 */
264 void ReflectDaughters(G4LogicalVolume* LV,
265 G4LogicalVolume* refLV, G4bool surfCheck = false);
266
267 /**
268 * Copies and transforms daughter of G4PVPlacement type of
269 * a constituent volume into a reflected volume.
270 */
271 void ReflectPVPlacement(G4VPhysicalVolume* PV,
272 G4LogicalVolume* refLV, G4bool surfCheck = false);
273
274 /**
275 * Copies and transforms daughter of G4PVReplica type of
276 * a constituent volume into a reflected volume.
277 */
278 void ReflectPVReplica(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
279
280 /**
281 * Copies and transforms daughter of G4PVDivision type of
282 * a constituent volume into a reflected volume.
283 */
284 void ReflectPVDivision(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
285
286 /**
287 * Not yet implemented.
288 * Should copy and transform daughter of G4PVParameterised type of
289 * a constituent volume into a reflected volume.
290 */
291 void ReflectPVParameterised(G4VPhysicalVolume* PV,
292 G4LogicalVolume* refLV, G4bool surfChk = false);
293
294 /**
295 * Returns true if the scale is negative, false otherwise.
296 */
297 G4bool IsReflection(const G4Scale3D& scale) const;
298
299 /**
300 * Checks if scale correspond to fScale, if not gives exception.
301 */
302 void CheckScale(const G4Scale3D& scale) const;
303
304 /**
305 * Checks if the division factory is instanciated, if not gives exception.
306 */
307 G4VPVDivisionFactory* GetPVDivisionFactory() const;
308
309 /**
310 * Dump method, for debugging purpose.
311 */
312 void PrintConstituentLVMap() const;
313
314 private:
315
316 static G4ThreadLocal G4ReflectionFactory* fInstance;
317 static const G4String fDefaultNameExtension;
318 static const G4Scale3D fScale;
319 G4double fScalePrecision;
320
321 G4int fVerboseLevel = 0;
322 G4String fNameExtension;
323 G4ReflectedVolumesMap fConstituentLVMap;
324 G4ReflectedVolumesMap fReflectedLVMap;
325};
326
327#endif
G4ThreadLocal T * G4GeomSplitter< T >::offset
std::map< G4LogicalVolume *, G4LogicalVolume *, std::less< G4LogicalVolume * > > G4ReflectedVolumesMap
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
HepGeom::Transform3D G4Transform3D
HepGeom::Scale3D G4Scale3D
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
const G4String & GetVolumesNameExtension() const
G4bool IsReflected(G4LogicalVolume *lv) const
G4PhysicalVolumesPair Divide(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double width, G4double offset)
G4LogicalVolume * GetReflectedLV(G4LogicalVolume *lv) const
static G4ReflectionFactory * Instance()
void SetVerboseLevel(G4int verboseLevel)
G4double GetScalePrecision() const
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4ReflectionFactory(const G4ReflectionFactory &)=delete
G4bool IsConstituent(G4LogicalVolume *lv) const
G4ReflectionFactory & operator=(const G4ReflectionFactory &)=delete
void SetScalePrecision(G4double scaleValue)
const G4ReflectedVolumesMap & GetReflectedVolumesMap() const
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const
G4PhysicalVolumesPair Replicate(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0.)
void SetVolumesNameExtension(const G4String &nameExtension)
G4VPVDivisionFactory is an abstract factory that defines the interfaces for creating volume divisions...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
Definition G4VSolid.hh:80
EAxis
Definition geomdefs.hh:54
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668
#define G4ThreadLocal
Definition tls.hh:77