Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ReflectionFactory Class Reference

G4ReflectionFactory provides functions for volumes placements with a general transfomation that can contain a reflection. Reflection is then applied to a solid: a new G4ReflectedSolid instance is created and is placed with a transformation containing pure rotation and translation only. The pair of constituent and reflected logical volumes is considered as a generalised logical volume that is addressed by user specifying the constituent logical volume. More...

#include <G4ReflectionFactory.hh>

Public Member Functions

 ~G4ReflectionFactory ()
 G4ReflectionFactory (const G4ReflectionFactory &)=delete
G4ReflectionFactoryoperator= (const G4ReflectionFactory &)=delete
G4PhysicalVolumesPair Place (const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4PhysicalVolumesPair Replicate (const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0.)
G4PhysicalVolumesPair Divide (const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double width, G4double offset)
G4PhysicalVolumesPair Divide (const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double offset)
G4PhysicalVolumesPair Divide (const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4double width, G4double offset)
void SetVerboseLevel (G4int verboseLevel)
G4int GetVerboseLevel () const
void SetVolumesNameExtension (const G4String &nameExtension)
const G4StringGetVolumesNameExtension () const
void SetScalePrecision (G4double scaleValue)
G4double GetScalePrecision () const
G4LogicalVolumeGetConstituentLV (G4LogicalVolume *reflLV) const
G4LogicalVolumeGetReflectedLV (G4LogicalVolume *lv) const
G4bool IsConstituent (G4LogicalVolume *lv) const
G4bool IsReflected (G4LogicalVolume *lv) const
const G4ReflectedVolumesMapGetReflectedVolumesMap () const
void Clean ()

Static Public Member Functions

static G4ReflectionFactoryInstance ()

Detailed Description

G4ReflectionFactory provides functions for volumes placements with a general transfomation that can contain a reflection. Reflection is then applied to a solid: a new G4ReflectedSolid instance is created and is placed with a transformation containing pure rotation and translation only. The pair of constituent and reflected logical volumes is considered as a generalised logical volume that is addressed by user specifying the constituent logical volume.

Decomposition of a general transformation that can include reflection in a "reflection-free" transformation:

x(inM') = TG*x(inM) TG - general transformation = T*(R*x(inM)) T - "reflection-free" transformation = T* x(inReflM)

Daughters transformation: When a volume V containing daughter D with transformation TD is placed in mother M with a general tranformation TGV, the TGV is decomposed. New reflected volume ReflV containing a new daughter ReflD with reflected transformation ReflTD is created:

x(inV) = TD * x(inD); x(inM) = TGV * x(inV) = TV * R * x(inV) = TV * R * TD * x(inD) = TV * R*TD*R-1 * R*x(inD) = TV * ReflTD * x(inReflD)

Definition at line 89 of file G4ReflectionFactory.hh.

Constructor & Destructor Documentation

◆ ~G4ReflectionFactory()

G4ReflectionFactory::~G4ReflectionFactory ( )

Destructor.

Definition at line 92 of file G4ReflectionFactory.cc.

93{
94 delete fInstance;
95}

◆ G4ReflectionFactory()

G4ReflectionFactory::G4ReflectionFactory ( const G4ReflectionFactory & )
delete

Copy constructor and assignment operator not allowed.

Referenced by G4ReflectionFactory(), Instance(), and operator=().

Member Function Documentation

◆ Clean()

void G4ReflectionFactory::Clean ( )

Clears the maps of constituent and reflected volumes.

Note
To be used exclusively when volumes are removed from the stores.

Definition at line 743 of file G4ReflectionFactory.cc.

744{
745 fConstituentLVMap.clear();
746 fReflectedLVMap.clear();
747}

◆ Divide() [1/3]

G4PhysicalVolumesPair G4ReflectionFactory::Divide ( const G4String & name,
G4LogicalVolume * LV,
G4LogicalVolume * motherLV,
EAxis axis,
G4double width,
G4double offset )

Definition at line 319 of file G4ReflectionFactory.cc.

325{
326 // Creates division in the given mother.
327 // The result is a pair of physical volumes;
328 // the second physical volume is a division in a reflected mother
329 // or nullptr if mother LV was not reflected.
330 // ---
331
332 if (fVerboseLevel>0)
333 {
334 G4cout << "Divide " << name << " lv " << LV << " "
335 << LV->GetName() << G4endl;
336 }
337
338 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
339
340 G4VPhysicalVolume* pv1 = divisionFactory
341 -> CreatePVDivision(name, LV, motherLV, axis, width, offset);
342
343 G4VPhysicalVolume* pv2 = nullptr;
344 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
345 {
346 // if mother was reflected
347 // reflect the LV and replicate it in reflected mother
348
349 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
350 axis, width, offset);
351 }
352
353 return {pv1, pv2};
354}
G4ThreadLocal T * G4GeomSplitter< T >::offset
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
G4LogicalVolume * GetReflectedLV(G4LogicalVolume *lv) const
virtual G4VPhysicalVolume * CreatePVDivision(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset)=0
const char * name(G4int ptype)
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668

◆ Divide() [2/3]

G4PhysicalVolumesPair G4ReflectionFactory::Divide ( const G4String & name,
G4LogicalVolume * LV,
G4LogicalVolume * motherLV,
EAxis axis,
G4int nofDivisions,
G4double offset )

Definition at line 278 of file G4ReflectionFactory.cc.

284{
285 // Creates division in the given mother.
286 // The result is a pair of physical volumes;
287 // the second physical volume is a division in a reflected mother
288 // or nullptr if mother LV was not reflected.
289 // ---
290
291 if (fVerboseLevel>0)
292 {
293 G4cout << "Divide " << name << " lv " << LV << " "
294 << LV->GetName() << G4endl;
295 }
296
297 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
298
299 G4VPhysicalVolume* pv1 = divisionFactory
300 ->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, offset);
301
302 G4VPhysicalVolume* pv2 = nullptr;
303 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
304 {
305 // if mother was reflected
306 // reflect the LV and replicate it in reflected mother
307
308 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
309 axis, nofDivisions, offset);
310 }
311
312 return {pv1, pv2};
313}

◆ Divide() [3/3]

G4PhysicalVolumesPair G4ReflectionFactory::Divide ( const G4String & name,
G4LogicalVolume * LV,
G4LogicalVolume * motherLV,
EAxis axis,
G4int nofDivisions,
G4double width,
G4double offset )

Methods to create a division in the given mother, along with the possible specifications for creating a division.

Returns
A pair of physical volumes; the second physical volume is a division in a reflected mother or nullptr if mother logical volume was not reflected.

Definition at line 236 of file G4ReflectionFactory.cc.

243{
244 // Creates division in the given mother.
245 // The result is a pair of physical volumes;
246 // the second physical volume is a division in a reflected mother
247 // or nullptr if mother LV was not reflected.
248 // ---
249
250 if (fVerboseLevel>0)
251 {
252 G4cout << "Divide " << name << " lv " << LV << " "
253 << LV->GetName() << G4endl;
254 }
255
256 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
257
258 G4VPhysicalVolume* pv1 = divisionFactory
259 ->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, width, offset);
260
261 G4VPhysicalVolume* pv2 = nullptr;
262 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
263 {
264 // if mother was reflected
265 // reflect the LV and replicate it in reflected mother
266
267 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
268 axis, nofDivisions, width, offset);
269 }
270
271 return {pv1, pv2};
272}

Referenced by G4GDMLReadStructure::DivisionvolRead().

◆ GetConstituentLV()

G4LogicalVolume * G4ReflectionFactory::GetConstituentLV ( G4LogicalVolume * reflLV) const

Returns the consituent volume of the given reflected volume. Returns nullptr if the given reflected volume was not found.

Definition at line 672 of file G4ReflectionFactory.cc.

673{
674 // Returns the consituent volume of the given reflected volume,
675 // nullptr if the given reflected volume was not found.
676 // ---
677
678 auto it = fReflectedLVMap.find(reflLV);
679
680 if (it == fReflectedLVMap.cend()) { return nullptr; }
681
682 return (*it).second;
683}

◆ GetReflectedLV()

G4LogicalVolume * G4ReflectionFactory::GetReflectedLV ( G4LogicalVolume * lv) const

Returns the reflected volume of the given consituent volume. Returns nullptr if the given volume was not reflected.

Definition at line 688 of file G4ReflectionFactory.cc.

689{
690 // Returns the reflected volume of the given consituent volume,
691 // nullptr if the given volume was not reflected.
692 // ---
693
694 auto it = fConstituentLVMap.find(lv);
695
696 if (it == fConstituentLVMap.cend()) { return nullptr; }
697
698 return (*it).second;
699}

Referenced by Divide(), Divide(), Divide(), Place(), and Replicate().

◆ GetReflectedVolumesMap()

const G4ReflectedVolumesMap & G4ReflectionFactory::GetReflectedVolumesMap ( ) const

Returns a handle to the internal map of volumes which have been reflected, after that placement or replication is performed.

Definition at line 736 of file G4ReflectionFactory.cc.

737{
738 return fReflectedLVMap;
739}

◆ GetScalePrecision()

G4double G4ReflectionFactory::GetScalePrecision ( ) const

Definition at line 830 of file G4ReflectionFactory.cc.

831{
832 return fScalePrecision;
833}

◆ GetVerboseLevel()

G4int G4ReflectionFactory::GetVerboseLevel ( ) const

Definition at line 844 of file G4ReflectionFactory.cc.

845{
846 return fVerboseLevel;
847}

◆ GetVolumesNameExtension()

const G4String & G4ReflectionFactory::GetVolumesNameExtension ( ) const

Definition at line 858 of file G4ReflectionFactory.cc.

859{
860 return fNameExtension;
861}

◆ Instance()

G4ReflectionFactory * G4ReflectionFactory::Instance ( )
static

Gets pointer to the instance of the singleton.

Definition at line 67 of file G4ReflectionFactory.cc.

68{
69 // Static singleton access method.
70 // ---
71
72 if (fInstance == nullptr) { fInstance = new G4ReflectionFactory(); }
73
74 return fInstance;
75}
G4ReflectionFactory(const G4ReflectionFactory &)=delete

Referenced by G4tgbVolume::ConstructG4PhysVol(), G3Division::CreatePVReplica(), G4GDMLReadStructure::DivisionvolRead(), G4tgbGeometryDumper::DumpPhysVol(), G4tgbGeometryDumper::DumpPVPlacement(), G3toG4BuildPVTree(), G4GDMLWriteStructure::G4GDMLWriteStructure(), G4tgbVolumeMgr::G4tgbVolumeMgr(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadStructure::ReplicaRead().

◆ IsConstituent()

G4bool G4ReflectionFactory::IsConstituent ( G4LogicalVolume * lv) const

Returns true if the given volume has been already reflected (i.e. is in the map of constituent volumes).

Definition at line 703 of file G4ReflectionFactory.cc.

704{
705 // Returns true if the given volume has been already reflected
706 // (is in the map of constituent volumes).
707 // ---
708
709 return (fConstituentLVMap.find(lv) != fConstituentLVMap.cend());
710}

◆ IsReflected()

G4bool G4ReflectionFactory::IsReflected ( G4LogicalVolume * lv) const

Returns true if the given volume is a reflected volume (i.e. is in the map reflected volumes).

Definition at line 714 of file G4ReflectionFactory.cc.

715{
716 // Returns true if the given volume is a reflected volume
717 // (is in the map reflected volumes).
718 // ---
719
720 return (fReflectedLVMap.find(lv) != fReflectedLVMap.cend());
721}

Referenced by G4tgbGeometryDumper::DumpPhysVol(), and G4tgbGeometryDumper::DumpPVPlacement().

◆ operator=()

G4ReflectionFactory & G4ReflectionFactory::operator= ( const G4ReflectionFactory & )
delete

◆ Place()

G4PhysicalVolumesPair G4ReflectionFactory::Place ( const G4Transform3D & transform3D,
const G4String & name,
G4LogicalVolume * LV,
G4LogicalVolume * motherLV,
G4bool isMany,
G4int copyNo,
G4bool surfCheck = false )

Evaluates the passed transformation; if it contains reflection it performs its decomposition, creates new reflected solid and logical volume (or retrieves them from a map if the reflected objects were already created), transforms the daughters (if present) and places it in the given mother.

Parameters
[in]transform3DThe transformation in 3D space that can contain a reflection.
[in]pNameThe volume name.
[in]LVPointer to the logical volume to be placed.
[in]motherLVPointer to the logical volume of the mother.
[in]isManyNot used.
[in]copyNoThe optional custom copy number.
[in]surfCheckBoolean flag, if true activates check for overlaps with existing volumes (false by default).
Returns
A pair of physical volumes; the second physical volume is a placement in a reflected mother or nullptr if mother logical volume was not reflected.

Definition at line 104 of file G4ReflectionFactory.cc.

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 place it in the given mother.
117 // The result is a pair of physical volumes;
118 // the second physical volume is a placement in a reflected mother
119 // - or nullptr if mother LV was not reflected.
120 // ---
121
122 if (fVerboseLevel>0)
123 {
124 G4cout << "Place " << name << " lv " << LV << " "
125 << LV->GetName() << G4endl;
126 }
127
128 // decompose transformation
129 G4Scale3D scale;
130 G4Rotate3D rotation;
131 G4Translate3D translation;
132
133 transform3D.getDecomposition(scale, rotation, translation);
134 G4Transform3D pureTransform3D = translation * rotation;
135
136 //PrintTransform(transform3D);
137 //PrintTransform(pureTransform3D);
138
139 // check that scale correspond to fScale
140 //
141 CheckScale(scale);
142
143 //
144 // reflection IS NOT present in transform3D
145 //
146
147 if (!IsReflection(scale))
148 {
149 if (fVerboseLevel>0) { G4cout << "Scale positive" << G4endl; }
150
151 G4VPhysicalVolume* pv1
152 = new G4PVPlacement(pureTransform3D, LV, name,
153 motherLV, isMany, copyNo, surfCheck);
154
155 G4VPhysicalVolume* pv2 = nullptr;
156 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
157 {
158 // if mother was reflected
159 // reflect this LV and place it in reflected mother
160
161 pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
162 ReflectLV(LV, surfCheck), name, reflMotherLV,
163 isMany, copyNo, surfCheck);
164 }
165
166 return {pv1, pv2};
167 }
168
169 //
170 // reflection IS present in transform3D
171 //
172
173 if (fVerboseLevel>0) { G4cout << "scale negative" << G4endl; }
174
175 G4VPhysicalVolume* pv1
176 = new G4PVPlacement(pureTransform3D, ReflectLV(LV, surfCheck), name,
177 motherLV, isMany, copyNo, surfCheck);
178
179 G4VPhysicalVolume* pv2 = nullptr;
180 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
181 {
182
183 // if mother was reflected
184 // place the refLV consituent in reflected mother
185
186 pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
187 LV, name, reflMotherLV, isMany, copyNo, surfCheck);
188 }
189
190 return {pv1, pv2};
191}
HepGeom::Transform3D G4Transform3D
HepGeom::Translate3D G4Translate3D
HepGeom::Scale3D G4Scale3D
HepGeom::Rotate3D G4Rotate3D
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const

Referenced by G4tgbVolume::ConstructG4PhysVol(), G3Division::CreatePVReplica(), G3toG4BuildPVTree(), and G4GDMLReadStructure::PhysvolRead().

◆ Replicate()

G4PhysicalVolumesPair G4ReflectionFactory::Replicate ( const G4String & name,
G4LogicalVolume * LV,
G4LogicalVolume * motherLV,
EAxis axis,
G4int nofReplicas,
G4double width,
G4double offset = 0. )

Creates a replica in the given mother.

Parameters
[in]nameThe volume name.
[in]LVPointer to the logical volume to be replicated.
[in]motherLVPointer to the logical volume of the mother.
[in]axisThe axis along which do the replication.
[in]nofReplicasThe number of copies to replicate.
[in]widthThe witdh of the replicated object along the axis.
[in]offsetThe optional offset distance from mother's border.
Returns
A pair of physical volumes; the second physical volume is a replica in a reflected mother or nullptr if the mother logical volume was not reflected.

Definition at line 197 of file G4ReflectionFactory.cc.

204{
205 // Creates replica in given mother.
206 // The result is a pair of physical volumes;
207 // the second physical volume is a replica in a reflected mother
208 // - or nullptr if mother LV was not reflected.
209 // ---
210
211 if (fVerboseLevel>0)
212 {
213 G4cout << "Replicate " << name << " lv " << LV << " "
214 << LV->GetName() << G4endl;
215 }
216
217 G4VPhysicalVolume* pv1
218 = new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
219
220 G4VPhysicalVolume* pv2 = nullptr;
221 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
222 {
223 // if mother was reflected
224 // reflect the LV and replicate it in reflected mother
225
226 pv2 = new G4PVReplica(name, ReflectLV(LV), reflMotherLV,
227 axis, nofReplicas, width, offset);
228 }
229
230 return {pv1, pv2};
231}
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....

Referenced by G3Division::CreatePVReplica(), and G4GDMLReadStructure::ReplicaRead().

◆ SetScalePrecision()

void G4ReflectionFactory::SetScalePrecision ( G4double scaleValue)

Sets/gets the precision factor for the scale consistency check. The default value is set to 10*kCarTolerance.

Definition at line 823 of file G4ReflectionFactory.cc.

824{
825 fScalePrecision = scaleValue;
826}

Referenced by G4tgbVolumeMgr::G4tgbVolumeMgr().

◆ SetVerboseLevel()

void G4ReflectionFactory::SetVerboseLevel ( G4int verboseLevel)

Verbosity control.

Definition at line 837 of file G4ReflectionFactory.cc.

838{
839 fVerboseLevel = verboseLevel;
840}

◆ SetVolumesNameExtension()

void G4ReflectionFactory::SetVolumesNameExtension ( const G4String & nameExtension)

Sets/returns the name extension for the reflected solids and logical volumes.

Definition at line 851 of file G4ReflectionFactory.cc.

852{
853 fNameExtension = nameExtension;
854}

The documentation for this class was generated from the following files: