Geant4-11
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
G4ReflectionFactory Class Reference

#include <G4ReflectionFactory.hh>

Public Member Functions

void Clean ()
 
G4PhysicalVolumesPair Divide (const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, 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, G4int nofDivisions, G4double width, G4double offset)
 
 G4ReflectionFactory (const G4ReflectionFactory &)=delete
 
G4LogicalVolumeGetConstituentLV (G4LogicalVolume *reflLV) const
 
G4LogicalVolumeGetReflectedLV (G4LogicalVolume *lv) const
 
const G4ReflectedVolumesMapGetReflectedVolumesMap () const
 
G4double GetScalePrecision () const
 
G4int GetVerboseLevel () const
 
const G4StringGetVolumesNameExtension () const
 
G4bool IsConstituent (G4LogicalVolume *lv) const
 
G4bool IsReflected (G4LogicalVolume *lv) const
 
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.)
 
void SetScalePrecision (G4double scaleValue)
 
void SetVerboseLevel (G4int verboseLevel)
 
void SetVolumesNameExtension (const G4String &nameExtension)
 
virtual ~G4ReflectionFactory ()
 

Static Public Member Functions

static G4ReflectionFactoryInstance ()
 

Protected Member Functions

 G4ReflectionFactory ()
 

Private Types

using LogicalVolumesMapIterator = G4ReflectedVolumesMap::const_iterator
 

Private Member Functions

void CheckScale (const G4Scale3D &scale) const
 
G4LogicalVolumeCreateReflectedLV (G4LogicalVolume *LV)
 
G4VPVDivisionFactoryGetPVDivisionFactory () const
 
G4bool IsReflection (const G4Scale3D &scale) const
 
void PrintConstituentLVMap ()
 
void ReflectDaughters (G4LogicalVolume *LV, G4LogicalVolume *refLV, G4bool surfCheck=false)
 
G4LogicalVolumeReflectLV (G4LogicalVolume *LV, G4bool surfCheck=false)
 
void ReflectPVDivision (G4VPhysicalVolume *PV, G4LogicalVolume *refLV)
 
void ReflectPVParameterised (G4VPhysicalVolume *PV, G4LogicalVolume *refLV, G4bool surfChk=false)
 
void ReflectPVPlacement (G4VPhysicalVolume *PV, G4LogicalVolume *refLV, G4bool surfCheck=false)
 
void ReflectPVReplica (G4VPhysicalVolume *PV, G4LogicalVolume *refLV)
 

Private Attributes

G4ReflectedVolumesMap fConstituentLVMap
 
G4String fNameExtension
 
G4ReflectedVolumesMap fReflectedLVMap
 
G4double fScalePrecision
 
G4int fVerboseLevel = 0
 

Static Private Attributes

static const G4String fDefaultNameExtension = "_refl"
 
static G4ThreadLocal G4ReflectionFactoryfInstance = nullptr
 
static const G4Scale3D fScale = G4ScaleZ3D(-1.0)
 

Detailed Description

Definition at line 78 of file G4ReflectionFactory.hh.

Member Typedef Documentation

◆ LogicalVolumesMapIterator

using G4ReflectionFactory::LogicalVolumesMapIterator = G4ReflectedVolumesMap::const_iterator
private

Definition at line 80 of file G4ReflectionFactory.hh.

Constructor & Destructor Documentation

◆ ~G4ReflectionFactory()

G4ReflectionFactory::~G4ReflectionFactory ( )
virtual

Definition at line 92 of file G4ReflectionFactory.cc.

93{
94 delete fInstance;
95}
static G4ThreadLocal G4ReflectionFactory * fInstance

References fInstance.

◆ G4ReflectionFactory() [1/2]

G4ReflectionFactory::G4ReflectionFactory ( const G4ReflectionFactory )
delete

◆ G4ReflectionFactory() [2/2]

G4ReflectionFactory::G4ReflectionFactory ( )
protected

Definition at line 79 of file G4ReflectionFactory.cc.

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

References fInstance, fScalePrecision, G4GeometryTolerance::GetInstance(), and G4GeometryTolerance::GetSurfaceTolerance().

Referenced by Instance().

Member Function Documentation

◆ CheckScale()

void G4ReflectionFactory::CheckScale ( const G4Scale3D scale) const
private

Definition at line 777 of file G4ReflectionFactory.cc.

778{
779 // Check if scale correspond to fScale,
780 // if not give exception.
781 // ---
782
783 if (!IsReflection(scale)) return;
784
785 G4double diff = 0.;
786 for (auto i=0; i<4; ++i)
787 for (auto j=0; j<4; ++j)
788 diff += std::abs(scale(i,j) - fScale(i,j));
789
790 if (diff > fScalePrecision)
791 {
792 std::ostringstream message;
793 message << "Unexpected scale in input !" << G4endl
794 << " Difference: " << diff;
795 G4Exception("G4ReflectionFactory::CheckScale()",
796 "GeomVol0002", FatalException, message);
797 }
798}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4bool IsReflection(const G4Scale3D &scale) const
static const G4Scale3D fScale

References FatalException, fScale, fScalePrecision, G4endl, G4Exception(), and IsReflection().

Referenced by Place().

◆ Clean()

void G4ReflectionFactory::Clean ( )

Definition at line 754 of file G4ReflectionFactory.cc.

755{
756 fConstituentLVMap.clear();
757 fReflectedLVMap.clear();
758}
G4ReflectedVolumesMap fConstituentLVMap
G4ReflectedVolumesMap fReflectedLVMap

References fConstituentLVMap, and fReflectedLVMap.

◆ CreateReflectedLV()

G4LogicalVolume * G4ReflectionFactory::CreateReflectedLV ( G4LogicalVolume LV)
private

Definition at line 398 of file G4ReflectionFactory.cc.

399{
400 // Creates the reflected solid and logical volume
401 // and add the logical volumes pair in the maps.
402 // ---
403
404 // consistency check
405 //
406 if (fReflectedLVMap.find(LV) != fReflectedLVMap.end())
407 {
408 std::ostringstream message;
409 message << "Invalid reflection for volume: "
410 << LV->GetName() << G4endl
411 << "Cannot be applied to a volume already reflected !";
412 G4Exception("G4ReflectionFactory::CreateReflectedLV()",
413 "GeomVol0002", FatalException, message);
414 }
415
416 G4VSolid* refSolid
418 LV->GetSolid(), fScale);
419
420 G4LogicalVolume* refLV
421 = new G4LogicalVolume(refSolid,
422 LV->GetMaterial(),
423 LV->GetName() + fNameExtension,
424 LV->GetFieldManager(),
426 LV->GetUserLimits());
427 refLV->SetVisAttributes(LV->GetVisAttributes()); // vis-attributes
428 refLV->SetBiasWeight(LV->GetBiasWeight()); // biasing weight
429 if (LV->IsRegion())
430 {
431 refLV->SetRegion(LV->GetRegion()); // set a region in case
432 }
433
434 fConstituentLVMap[LV] = refLV;
435 fReflectedLVMap[refLV] = LV;
436
437 return refLV;
438}
G4VSolid * GetSolid() const
const G4VisAttributes * GetVisAttributes() const
G4VSensitiveDetector * GetSensitiveDetector() const
void SetRegion(G4Region *reg)
G4Region * GetRegion() const
G4double GetBiasWeight() const
G4bool IsRegion() const
G4Material * GetMaterial() const
G4UserLimits * GetUserLimits() const
G4FieldManager * GetFieldManager() const
void SetVisAttributes(const G4VisAttributes *pVA)
void SetBiasWeight(G4double w)
const G4String & GetName() const
G4String GetName() const

References FatalException, fConstituentLVMap, fNameExtension, fReflectedLVMap, fScale, G4endl, G4Exception(), G4LogicalVolume::GetBiasWeight(), G4LogicalVolume::GetFieldManager(), G4LogicalVolume::GetMaterial(), G4LogicalVolume::GetName(), G4VSolid::GetName(), G4LogicalVolume::GetRegion(), G4LogicalVolume::GetSensitiveDetector(), G4LogicalVolume::GetSolid(), G4LogicalVolume::GetUserLimits(), G4LogicalVolume::GetVisAttributes(), G4LogicalVolume::IsRegion(), G4LogicalVolume::SetBiasWeight(), G4LogicalVolume::SetRegion(), and G4LogicalVolume::SetVisAttributes().

Referenced by ReflectLV(), ReflectPVDivision(), ReflectPVPlacement(), and ReflectPVReplica().

◆ 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 G4PhysicalVolumesPair(pv1, pv2);
356}
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
G4GLOB_DLL std::ostream G4cout
G4LogicalVolume * ReflectLV(G4LogicalVolume *LV, G4bool surfCheck=false)
G4LogicalVolume * GetReflectedLV(G4LogicalVolume *lv) const
G4VPVDivisionFactory * GetPVDivisionFactory() 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)

References G4VPVDivisionFactory::CreatePVDivision(), fVerboseLevel, G4cout, G4endl, G4LogicalVolume::GetName(), GetPVDivisionFactory(), GetReflectedLV(), G4InuclParticleNames::name(), and ReflectLV().

◆ 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 G4PhysicalVolumesPair(pv1, pv2);
315}

References G4VPVDivisionFactory::CreatePVDivision(), fVerboseLevel, G4cout, G4endl, G4LogicalVolume::GetName(), GetPVDivisionFactory(), GetReflectedLV(), G4InuclParticleNames::name(), and ReflectLV().

◆ 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 G4PhysicalVolumesPair(pv1, pv2);
274}

References G4VPVDivisionFactory::CreatePVDivision(), fVerboseLevel, G4cout, G4endl, G4LogicalVolume::GetName(), GetPVDivisionFactory(), GetReflectedLV(), G4InuclParticleNames::name(), and ReflectLV().

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
687
688 if (it == fReflectedLVMap.end()) return nullptr;
689
690 return (*it).second;
691}
G4ReflectedVolumesMap::const_iterator LogicalVolumesMapIterator

References fReflectedLVMap.

Referenced by G4GDMLWriteStructure::PhysvolWrite(), ReflectPVDivision(), ReflectPVPlacement(), ReflectPVReplica(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ GetPVDivisionFactory()

G4VPVDivisionFactory * G4ReflectionFactory::GetPVDivisionFactory ( ) const
private

Definition at line 802 of file G4ReflectionFactory.cc.

803{
804 // Returns the G4PVDivisionFactory instance if it exists,
805 // otherwise gives exception
806 // ---
807
809 if (!divisionFactory)
810 {
811 std::ostringstream message;
812 message << "A concrete G4PVDivisionFactory instantiated is required !"
813 << G4endl
814 << " It has been requested to reflect divided volumes."
815 << G4endl
816 << " In this case, it is required to instantiate a concrete"
817 << G4endl
818 << " factory G4PVDivisionFactory in your program -before-"
819 << G4endl
820 << " executing the reflection !";
821 G4Exception("G4ReflectionFactory::GetPVDivisionFactory()",
822 "GeomVol0002", FatalException, message);
823 }
824
825 return divisionFactory;
826}
static G4VPVDivisionFactory * Instance()

References FatalException, G4endl, G4Exception(), and G4VPVDivisionFactory::Instance().

Referenced by Divide(), and ReflectPVDivision().

◆ 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
703
704 if (it == fConstituentLVMap.end()) return nullptr;
705
706 return (*it).second;
707}

References fConstituentLVMap.

Referenced by Divide(), G4GDMLParser::ImportRegions(), Place(), ReflectLV(), ReflectPVDivision(), ReflectPVPlacement(), ReflectPVReplica(), and Replicate().

◆ GetReflectedVolumesMap()

const G4ReflectedVolumesMap & G4ReflectionFactory::GetReflectedVolumesMap ( ) const

Definition at line 747 of file G4ReflectionFactory.cc.

748{
749 return fReflectedLVMap;
750}

References fReflectedLVMap.

◆ GetScalePrecision()

G4double G4ReflectionFactory::GetScalePrecision ( ) const

Definition at line 837 of file G4ReflectionFactory.cc.

838{
839 return fScalePrecision;
840}

References fScalePrecision.

◆ GetVerboseLevel()

G4int G4ReflectionFactory::GetVerboseLevel ( ) const

Definition at line 851 of file G4ReflectionFactory.cc.

852{
853 return fVerboseLevel;
854}

References fVerboseLevel.

◆ GetVolumesNameExtension()

const G4String & G4ReflectionFactory::GetVolumesNameExtension ( ) const

Definition at line 865 of file G4ReflectionFactory.cc.

866{
867 return fNameExtension;
868}

References fNameExtension.

◆ Instance()

G4ReflectionFactory * G4ReflectionFactory::Instance ( )
static

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

References fConstituentLVMap.

Referenced by G4GDMLParser::ImportRegions().

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

References fReflectedLVMap.

Referenced by G4tgbGeometryDumper::DumpPhysVol(), G4tgbGeometryDumper::DumpPVPlacement(), G4GDMLParser::ExportRegions(), G4GDMLWriteStructure::PhysvolWrite(), ReflectPVDivision(), ReflectPVPlacement(), ReflectPVReplica(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ IsReflection()

G4bool G4ReflectionFactory::IsReflection ( const G4Scale3D scale) const
private

Definition at line 733 of file G4ReflectionFactory.cc.

734{
735 // Returns true if the scale is negative, false otherwise.
736 // ---
737
738 if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
739 return true;
740 else
741 return false;
742}

Referenced by CheckScale(), and Place().

◆ 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 G4PhysicalVolumesPair(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 G4PhysicalVolumesPair(pv1, pv2);
193}
void CheckScale(const G4Scale3D &scale) const
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
Definition: Transform3D.cc:173
Transform3D inverse() const
Definition: Transform3D.cc:141

References CheckScale(), fScale, fVerboseLevel, G4cout, G4endl, HepGeom::Transform3D::getDecomposition(), G4LogicalVolume::GetName(), GetReflectedLV(), HepGeom::Transform3D::inverse(), IsReflection(), G4InuclParticleNames::name(), and ReflectLV().

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

◆ PrintConstituentLVMap()

void G4ReflectionFactory::PrintConstituentLVMap ( )
private

Definition at line 762 of file G4ReflectionFactory.cc.

763{
764 // temporary - for debugging purpose
765 // ---
766
768 for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); ++it)
769 {
770 G4cout << "lv: " << (*it).first << " lv_refl: " << (*it).second << G4endl;
771 }
772 G4cout << G4endl;
773}

References fConstituentLVMap, G4cout, and G4endl.

◆ ReflectDaughters()

void G4ReflectionFactory::ReflectDaughters ( G4LogicalVolume LV,
G4LogicalVolume refLV,
G4bool  surfCheck = false 
)
private

Definition at line 442 of file G4ReflectionFactory.cc.

445{
446 // Reflects daughters recursively.
447 // ---
448
449 if (fVerboseLevel>0)
450 {
451 G4cout << "G4ReflectionFactory::ReflectDaughters(): "
452 << LV->GetNoDaughters() << " of " << LV->GetName() << G4endl;
453 }
454
455 for (size_t i=0; i<LV->GetNoDaughters(); ++i)
456 {
457 G4VPhysicalVolume* dPV = LV->GetDaughter(i);
458
459 if (!dPV->IsReplicated())
460 {
461 ReflectPVPlacement(dPV, refLV, surfCheck);
462 }
463 else if (!dPV->GetParameterisation())
464 {
465 ReflectPVReplica(dPV, refLV);
466 }
468 G4VPVDivisionFactory::Instance()->IsPVDivision(dPV))
469 {
470 ReflectPVDivision(dPV, refLV);
471 }
472 else
473 {
474 ReflectPVParameterised(dPV, refLV, surfCheck);
475 }
476 }
477}
size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
void ReflectPVPlacement(G4VPhysicalVolume *PV, G4LogicalVolume *refLV, G4bool surfCheck=false)
void ReflectPVReplica(G4VPhysicalVolume *PV, G4LogicalVolume *refLV)
void ReflectPVParameterised(G4VPhysicalVolume *PV, G4LogicalVolume *refLV, G4bool surfChk=false)
void ReflectPVDivision(G4VPhysicalVolume *PV, G4LogicalVolume *refLV)
virtual G4bool IsReplicated() const =0
virtual G4VPVParameterisation * GetParameterisation() const =0

References fVerboseLevel, G4cout, G4endl, G4LogicalVolume::GetDaughter(), G4LogicalVolume::GetName(), G4LogicalVolume::GetNoDaughters(), G4VPhysicalVolume::GetParameterisation(), G4VPVDivisionFactory::Instance(), G4VPhysicalVolume::IsReplicated(), ReflectPVDivision(), ReflectPVParameterised(), ReflectPVPlacement(), and ReflectPVReplica().

Referenced by ReflectLV(), ReflectPVDivision(), ReflectPVPlacement(), and ReflectPVReplica().

◆ ReflectLV()

G4LogicalVolume * G4ReflectionFactory::ReflectLV ( G4LogicalVolume LV,
G4bool  surfCheck = false 
)
private

Definition at line 365 of file G4ReflectionFactory.cc.

367{
368 // Gets/creates the reflected solid and logical volume
369 // and copies + transforms LV daughters.
370 // ---
371
372 G4LogicalVolume* refLV = GetReflectedLV(LV);
373
374 if (!refLV)
375 {
376
377 // create new (reflected) objects
378 //
379 refLV = CreateReflectedLV(LV);
380
381 // process daughters
382 //
383 ReflectDaughters(LV, refLV, surfCheck);
384
385 // check if to be set as root region
386 //
387 if (LV->IsRootRegion())
388 {
389 LV->GetRegion()->AddRootLogicalVolume(refLV);
390 }
391 }
392
393 return refLV;
394}
G4bool IsRootRegion() const
void ReflectDaughters(G4LogicalVolume *LV, G4LogicalVolume *refLV, G4bool surfCheck=false)
G4LogicalVolume * CreateReflectedLV(G4LogicalVolume *LV)
void AddRootLogicalVolume(G4LogicalVolume *lv, G4bool search=true)
Definition: G4Region.cc:293

References G4Region::AddRootLogicalVolume(), CreateReflectedLV(), GetReflectedLV(), G4LogicalVolume::GetRegion(), G4LogicalVolume::IsRootRegion(), and ReflectDaughters().

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

◆ ReflectPVDivision()

void G4ReflectionFactory::ReflectPVDivision ( G4VPhysicalVolume PV,
G4LogicalVolume refLV 
)
private

Definition at line 605 of file G4ReflectionFactory.cc.

607{
608 // Copies and transforms daughter of PVDivision type of
609 // a constituent volume into a reflected volume.
610 // ---
611
612 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
613
614 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
615
616 // get parameterisation data
617 //
618 G4VPVParameterisation* param = dPV->GetParameterisation();
619
620 G4LogicalVolume* refDLV;
621
622 if (fVerboseLevel>0)
623 G4cout << "Daughter: " << dPV << " " << dLV->GetName();
624
625 if (!IsReflected(dLV))
626 {
627 if (fVerboseLevel>0)
628 G4cout << " will be reflected." << G4endl;
629
630 // get reflected volume if already created
631 //
632 refDLV = GetReflectedLV(dLV);
633
634 if (refDLV == nullptr)
635 {
636 // create new daughter solid and logical volume
637 //
638 refDLV = CreateReflectedLV(dLV);
639
640 // recursive call
641 //
642 ReflectDaughters(dLV, refDLV);
643 }
644
645 // create new daughter replica
646 //
647 divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
648 }
649 else
650 {
651 if (fVerboseLevel>0)
652 G4cout << " will be reconstitued." << G4endl;
653
654 refDLV = GetConstituentLV(dLV);
655
656 divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
657 }
658}
G4bool IsReflected(G4LogicalVolume *lv) const
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const

References G4VPVDivisionFactory::CreatePVDivision(), CreateReflectedLV(), fVerboseLevel, G4cout, G4endl, GetConstituentLV(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetName(), G4VPhysicalVolume::GetName(), G4VPhysicalVolume::GetParameterisation(), GetPVDivisionFactory(), GetReflectedLV(), IsReflected(), and ReflectDaughters().

Referenced by ReflectDaughters().

◆ ReflectPVParameterised()

void G4ReflectionFactory::ReflectPVParameterised ( G4VPhysicalVolume PV,
G4LogicalVolume refLV,
G4bool  surfChk = false 
)
private

Definition at line 662 of file G4ReflectionFactory.cc.

664{
665 // Not implemented.
666 // Should copy and transform daughter of PVReplica type of
667 // a constituent volume into a reflected volume.
668 // ---
669
670 std::ostringstream message;
671 message << "Not yet implemented. Volume: " << dPV->GetName() << G4endl
672 << "Reflection of parameterised volumes is not yet implemented.";
673 G4Exception("G4ReflectionFactory::ReflectPVParameterised()",
674 "GeomVol0001", FatalException, message);
675}

References FatalException, G4endl, G4Exception(), and G4VPhysicalVolume::GetName().

Referenced by ReflectDaughters().

◆ ReflectPVPlacement()

void G4ReflectionFactory::ReflectPVPlacement ( G4VPhysicalVolume PV,
G4LogicalVolume refLV,
G4bool  surfCheck = false 
)
private

Definition at line 481 of file G4ReflectionFactory.cc.

484{
485 // Copies and transforms daughter of PVPlacement type of
486 // a constituent volume into a reflected volume.
487 // ---
488
489 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
490
491 // update daughter transformation
492 //
493 G4Transform3D dt(dPV->GetObjectRotationValue(), dPV->GetObjectTranslation());
494 dt = fScale * (dt * fScale.inverse());
495
496 G4LogicalVolume* refDLV;
497
498 if (fVerboseLevel>0)
499 G4cout << "Daughter: " << dPV << " " << dLV->GetName();
500
501 if (!IsReflected(dLV))
502 {
503
504 if (fVerboseLevel>0)
505 G4cout << " will be reflected." << G4endl;
506
507 // get reflected volume if already created
508 refDLV = GetReflectedLV(dLV);
509
510 if (refDLV == nullptr)
511 {
512 // create new daughter solid and logical volume
513 //
514 refDLV = CreateReflectedLV(dLV);
515
516 // recursive call
517 //
518 ReflectDaughters(dLV, refDLV, surfCheck);
519 }
520
521 // create new daughter physical volume
522 // with updated transformation
523
524 new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
525 dPV->IsMany(), dPV->GetCopyNo(), surfCheck);
526
527 }
528 else
529 {
530 if (fVerboseLevel>0)
531 G4cout << " will be reconstitued." << G4endl;
532
533 refDLV = GetConstituentLV(dLV);
534
535 new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
536 dPV->IsMany(), dPV->GetCopyNo(), surfCheck);
537 }
538}

References CreateReflectedLV(), fScale, fVerboseLevel, G4cout, G4endl, GetConstituentLV(), G4VPhysicalVolume::GetCopyNo(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetName(), G4VPhysicalVolume::GetName(), G4VPhysicalVolume::GetObjectRotationValue(), G4VPhysicalVolume::GetObjectTranslation(), GetReflectedLV(), HepGeom::Transform3D::inverse(), G4VPhysicalVolume::IsMany(), IsReflected(), and ReflectDaughters().

Referenced by ReflectDaughters().

◆ ReflectPVReplica()

void G4ReflectionFactory::ReflectPVReplica ( G4VPhysicalVolume PV,
G4LogicalVolume refLV 
)
private

Definition at line 542 of file G4ReflectionFactory.cc.

544{
545 // Copies and transforms daughter of PVReplica type of
546 // a constituent volume into a reflected volume.
547 // ---
548
549 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
550
551 // get replication data
552 //
553 EAxis axis;
554 G4int nofReplicas;
555 G4double width;
556 G4double offset;
557 G4bool consuming;
558
559 dPV->GetReplicationData(axis, nofReplicas, width, offset, consuming);
560
561 G4LogicalVolume* refDLV;
562
563 if (fVerboseLevel>0)
564 G4cout << "Daughter: " << dPV << " " << dLV->GetName();
565
566 if (!IsReflected(dLV))
567 {
568 if (fVerboseLevel>0)
569 G4cout << " will be reflected." << G4endl;
570
571 // get reflected volume if already created
572 //
573 refDLV = GetReflectedLV(dLV);
574
575 if (refDLV == nullptr)
576 {
577 // create new daughter solid and logical volume
578 //
579 refDLV = CreateReflectedLV(dLV);
580
581 // recursive call
582 //
583 ReflectDaughters(dLV, refDLV);
584 }
585
586 // create new daughter replica
587 //
588 new G4PVReplica(dPV->GetName(), refDLV, refLV,
589 axis, nofReplicas, width, offset);
590 }
591 else
592 {
593 if (fVerboseLevel>0)
594 G4cout << " will be reconstitued." << G4endl;
595
596 refDLV = GetConstituentLV(dLV);
597
598 new G4PVReplica(dPV->GetName(), refDLV, refLV,
599 axis, nofReplicas, width, offset);
600 }
601}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
EAxis
Definition: geomdefs.hh:54

References CreateReflectedLV(), fVerboseLevel, G4cout, G4endl, GetConstituentLV(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetName(), G4VPhysicalVolume::GetName(), GetReflectedLV(), G4VPhysicalVolume::GetReplicationData(), IsReflected(), and ReflectDaughters().

Referenced by ReflectDaughters().

◆ 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 G4PhysicalVolumesPair(pv1, pv2);
233}

References fVerboseLevel, G4cout, G4endl, G4LogicalVolume::GetName(), GetReflectedLV(), G4InuclParticleNames::name(), and ReflectLV().

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

◆ SetScalePrecision()

void G4ReflectionFactory::SetScalePrecision ( G4double  scaleValue)

Definition at line 830 of file G4ReflectionFactory.cc.

831{
832 fScalePrecision = scaleValue;
833}

References fScalePrecision.

Referenced by G4tgbVolumeMgr::G4tgbVolumeMgr().

◆ SetVerboseLevel()

void G4ReflectionFactory::SetVerboseLevel ( G4int  verboseLevel)

Definition at line 844 of file G4ReflectionFactory.cc.

845{
846 fVerboseLevel = verboseLevel;
847}

References fVerboseLevel.

◆ SetVolumesNameExtension()

void G4ReflectionFactory::SetVolumesNameExtension ( const G4String nameExtension)

Definition at line 858 of file G4ReflectionFactory.cc.

859{
860 fNameExtension = nameExtension;
861}

References fNameExtension.

Field Documentation

◆ fConstituentLVMap

G4ReflectedVolumesMap G4ReflectionFactory::fConstituentLVMap
private

◆ fDefaultNameExtension

const G4String G4ReflectionFactory::fDefaultNameExtension = "_refl"
staticprivate

Definition at line 238 of file G4ReflectionFactory.hh.

◆ fInstance

G4ThreadLocal G4ReflectionFactory * G4ReflectionFactory::fInstance = nullptr
staticprivate

Definition at line 237 of file G4ReflectionFactory.hh.

Referenced by G4ReflectionFactory(), Instance(), and ~G4ReflectionFactory().

◆ fNameExtension

G4String G4ReflectionFactory::fNameExtension
private

◆ fReflectedLVMap

G4ReflectedVolumesMap G4ReflectionFactory::fReflectedLVMap
private

◆ fScale

const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0)
staticprivate

Definition at line 239 of file G4ReflectionFactory.hh.

Referenced by CheckScale(), CreateReflectedLV(), Place(), and ReflectPVPlacement().

◆ fScalePrecision

G4double G4ReflectionFactory::fScalePrecision
private

◆ fVerboseLevel

G4int G4ReflectionFactory::fVerboseLevel = 0
private

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