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

#include <G4ReflectionFactory.hh>

Public Member Functions

virtual ~G4ReflectionFactory ()
 
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 ()
 
 G4ReflectionFactory (const G4ReflectionFactory &)=delete
 
G4ReflectionFactoryoperator= (const G4ReflectionFactory &)=delete
 

Static Public Member Functions

static G4ReflectionFactoryInstance ()
 

Protected Member Functions

 G4ReflectionFactory ()
 

Detailed Description

Definition at line 78 of file G4ReflectionFactory.hh.

Constructor & Destructor Documentation

◆ ~G4ReflectionFactory()

G4ReflectionFactory::~G4ReflectionFactory ( )
virtual

Definition at line 92 of file G4ReflectionFactory.cc.

93{
94 delete fInstance;
95}

◆ G4ReflectionFactory() [1/2]

G4ReflectionFactory::G4ReflectionFactory ( const G4ReflectionFactory & )
delete

◆ G4ReflectionFactory() [2/2]

G4ReflectionFactory::G4ReflectionFactory ( )
protected

Definition at line 79 of file G4ReflectionFactory.cc.

80 : fNameExtension(fDefaultNameExtension)
81{
82 // Protected singleton constructor.
83 // ---
84
85 fScalePrecision = 10.
87 fInstance = this;
88}
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()

Referenced by Instance().

Member Function Documentation

◆ Clean()

void G4ReflectionFactory::Clean ( )

Definition at line 751 of file G4ReflectionFactory.cc.

752{
753 fConstituentLVMap.clear();
754 fReflectedLVMap.clear();
755}

◆ Divide() [1/3]

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

Definition at line 321 of file G4ReflectionFactory.cc.

327{
328 // Creates division in the given mother.
329 // The result is a pair of physical volumes;
330 // the second physical volume is a division in a reflected mother
331 // or nullptr if mother LV was not reflected.
332 // ---
333
334 if (fVerboseLevel>0)
335 {
336 G4cout << "Divide " << name << " lv " << LV << " "
337 << LV->GetName() << G4endl;
338 }
339
340 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
341
342 G4VPhysicalVolume* pv1 = divisionFactory
343 -> CreatePVDivision(name, LV, motherLV, axis, width, offset);
344
345 G4VPhysicalVolume* pv2 = nullptr;
346 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
347 {
348 // if mother was reflected
349 // reflect the LV and replicate it in reflected mother
350
351 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
352 axis, width, offset);
353 }
354
355 return {pv1, pv2};
356}
#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)

◆ Divide() [2/3]

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

Definition at line 280 of file G4ReflectionFactory.cc.

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

◆ Divide() [3/3]

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

Definition at line 238 of file G4ReflectionFactory.cc.

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

Referenced by G4GDMLReadStructure::DivisionvolRead().

◆ GetConstituentLV()

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

Definition at line 680 of file G4ReflectionFactory.cc.

681{
682 // Returns the consituent volume of the given reflected volume,
683 // nullptr if the given reflected volume was not found.
684 // ---
685
686 auto it = fReflectedLVMap.find(reflLV);
687
688 if (it == fReflectedLVMap.end()) return nullptr;
689
690 return (*it).second;
691}

Referenced by G4GDMLWriteStructure::PhysvolWrite(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ GetReflectedLV()

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

Definition at line 696 of file G4ReflectionFactory.cc.

697{
698 // Returns the reflected volume of the given consituent volume,
699 // nullptr if the given volume was not reflected.
700 // ---
701
702 auto it = fConstituentLVMap.find(lv);
703
704 if (it == fConstituentLVMap.end()) return nullptr;
705
706 return (*it).second;
707}

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

◆ GetReflectedVolumesMap()

const G4ReflectedVolumesMap & G4ReflectionFactory::GetReflectedVolumesMap ( ) const

Definition at line 744 of file G4ReflectionFactory.cc.

745{
746 return fReflectedLVMap;
747}

◆ GetScalePrecision()

G4double G4ReflectionFactory::GetScalePrecision ( ) const

Definition at line 834 of file G4ReflectionFactory.cc.

835{
836 return fScalePrecision;
837}

◆ GetVerboseLevel()

G4int G4ReflectionFactory::GetVerboseLevel ( ) const

Definition at line 848 of file G4ReflectionFactory.cc.

849{
850 return fVerboseLevel;
851}

◆ GetVolumesNameExtension()

const G4String & G4ReflectionFactory::GetVolumesNameExtension ( ) const

Definition at line 862 of file G4ReflectionFactory.cc.

863{
864 return fNameExtension;
865}

◆ Instance()

◆ IsConstituent()

G4bool G4ReflectionFactory::IsConstituent ( G4LogicalVolume * lv) const

Definition at line 711 of file G4ReflectionFactory.cc.

712{
713 // Returns true if the given volume has been already reflected
714 // (is in the map of constituent volumes).
715 // ---
716
717 return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
718}

◆ IsReflected()

G4bool G4ReflectionFactory::IsReflected ( G4LogicalVolume * lv) const

Definition at line 722 of file G4ReflectionFactory.cc.

723{
724 // Returns true if the given volume is a reflected volume
725 // (is in the map reflected volumes).
726 // ---
727
728 return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
729}

Referenced by G4tgbGeometryDumper::DumpPhysVol(), G4tgbGeometryDumper::DumpPVPlacement(), G4GDMLWriteStructure::PhysvolWrite(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ 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 )

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)
150 G4cout << "Scale positive" << G4endl;
151
153 = new G4PVPlacement(pureTransform3D, LV, name,
154 motherLV, isMany, copyNo, surfCheck);
155
156 G4VPhysicalVolume* pv2 = nullptr;
157 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
158 {
159 // if mother was reflected
160 // reflect this LV and place it in reflected mother
161
162 pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
163 ReflectLV(LV, surfCheck), name, reflMotherLV,
164 isMany, copyNo, surfCheck);
165 }
166
167 return {pv1, pv2};
168 }
169
170 //
171 // reflection IS present in transform3D
172 //
173
174 if (fVerboseLevel>0)
175 G4cout << "scale negative" << G4endl;
176
178 = new G4PVPlacement(pureTransform3D, ReflectLV(LV, surfCheck), name,
179 motherLV, isMany, copyNo, surfCheck);
180
181 G4VPhysicalVolume* pv2 = nullptr;
182 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
183 {
184
185 // if mother was reflected
186 // place the refLV consituent in reflected mother
187
188 pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
189 LV, name, reflMotherLV, isMany, copyNo, surfCheck);
190 }
191
192 return {pv1, pv2};
193}
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
Transform3D inverse() 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. )

Definition at line 199 of file G4ReflectionFactory.cc.

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

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

◆ SetScalePrecision()

void G4ReflectionFactory::SetScalePrecision ( G4double scaleValue)

Definition at line 827 of file G4ReflectionFactory.cc.

828{
829 fScalePrecision = scaleValue;
830}

Referenced by G4tgbVolumeMgr::G4tgbVolumeMgr().

◆ SetVerboseLevel()

void G4ReflectionFactory::SetVerboseLevel ( G4int verboseLevel)

Definition at line 841 of file G4ReflectionFactory.cc.

842{
843 fVerboseLevel = verboseLevel;
844}

◆ SetVolumesNameExtension()

void G4ReflectionFactory::SetVolumesNameExtension ( const G4String & nameExtension)

Definition at line 855 of file G4ReflectionFactory.cc.

856{
857 fNameExtension = nameExtension;
858}

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