62const G4String G4ReflectionFactory::fDefaultNameExtension =
"_refl";
80 : fNameExtension(fDefaultNameExtension)
124 G4cout <<
"Place " << name <<
" lv " << LV <<
" "
147 if (!IsReflection(scale))
154 motherLV, isMany, copyNo, surfCheck);
163 ReflectLV(LV, surfCheck), name, reflMotherLV,
164 isMany, copyNo, surfCheck);
178 =
new G4PVPlacement(pureTransform3D, ReflectLV(LV, surfCheck), name,
179 motherLV, isMany, copyNo, surfCheck);
189 LV, name, reflMotherLV, isMany, copyNo, surfCheck);
215 G4cout <<
"Replicate " << name <<
" lv " << LV <<
" "
220 =
new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
228 pv2 =
new G4PVReplica(name, ReflectLV(LV), reflMotherLV,
229 axis, nofReplicas, width, offset);
254 G4cout <<
"Divide " << name <<
" lv " << LV <<
" "
270 axis, nofDivisions, width, offset);
295 G4cout <<
"Divide " << name <<
" lv " << LV <<
" "
311 axis, nofDivisions, offset);
336 G4cout <<
"Divide " << name <<
" lv " << LV <<
" "
343 -> CreatePVDivision(name, LV, motherLV, axis, width, offset);
352 axis, width, offset);
379 refLV = CreateReflectedLV(LV);
383 ReflectDaughters(LV, refLV, surfCheck);
406 if (fReflectedLVMap.find(LV) != fReflectedLVMap.end())
408 std::ostringstream message;
409 message <<
"Invalid reflection for volume: "
411 <<
"Cannot be applied to a volume already reflected !";
412 G4Exception(
"G4ReflectionFactory::CreateReflectedLV()",
423 LV->
GetName() + fNameExtension,
434 fConstituentLVMap[LV] = refLV;
435 fReflectedLVMap[refLV] = LV;
451 G4cout <<
"G4ReflectionFactory::ReflectDaughters(): "
461 ReflectPVPlacement(dPV, refLV, surfCheck);
465 ReflectPVReplica(dPV, refLV);
470 ReflectPVDivision(dPV, refLV);
474 ReflectPVParameterised(dPV, refLV, surfCheck);
494 dt = fScale * (dt * fScale.
inverse());
510 if (refDLV ==
nullptr)
514 refDLV = CreateReflectedLV(dLV);
518 ReflectDaughters(dLV, refDLV, surfCheck);
575 if (refDLV ==
nullptr)
579 refDLV = CreateReflectedLV(dLV);
583 ReflectDaughters(dLV, refDLV);
589 axis, nofReplicas, width, offset);
599 axis, nofReplicas, width, offset);
634 if (refDLV ==
nullptr)
638 refDLV = CreateReflectedLV(dLV);
642 ReflectDaughters(dLV, refDLV);
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()",
686 LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
688 if (it == fReflectedLVMap.end())
return nullptr;
702 LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
704 if (it == fConstituentLVMap.end())
return nullptr;
717 return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
728 return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
738 if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
749 return fReflectedLVMap;
756 fConstituentLVMap.clear();
757 fReflectedLVMap.clear();
762void G4ReflectionFactory::PrintConstituentLVMap()
767 LogicalVolumesMapIterator it;
768 for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); ++it)
770 G4cout <<
"lv: " << (*it).first <<
" lv_refl: " << (*it).second <<
G4endl;
777void G4ReflectionFactory::CheckScale(
const G4Scale3D& scale)
const
783 if (!IsReflection(scale))
return;
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));
790 if (diff > fScalePrecision)
792 std::ostringstream message;
793 message <<
"Unexpected scale in input !" <<
G4endl
794 <<
" Difference: " << diff;
809 if (!divisionFactory)
811 std::ostringstream message;
812 message <<
"A concrete G4PVDivisionFactory instantiated is required !"
814 <<
" It has been requested to reflect divided volumes."
816 <<
" In this case, it is required to instantiate a concrete"
818 <<
" factory G4PVDivisionFactory in your program -before-"
820 <<
" executing the reflection !";
821 G4Exception(
"G4ReflectionFactory::GetPVDivisionFactory()",
825 return divisionFactory;
832 fScalePrecision = scaleValue;
839 return fScalePrecision;
846 fVerboseLevel = verboseLevel;
853 return fVerboseLevel;
860 fNameExtension = nameExtension;
867 return fNameExtension;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
std::map< G4LogicalVolume *, G4LogicalVolume *, std::less< G4LogicalVolume * > > G4ReflectedVolumesMap
G4GLOB_DLL std::ostream G4cout
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4VSolid * GetSolid() const
const G4VisAttributes * GetVisAttributes() const
G4VSensitiveDetector * GetSensitiveDetector() const
std::size_t GetNoDaughters() const
void SetRegion(G4Region *reg)
G4bool IsRootRegion() const
G4Region * GetRegion() const
G4double GetBiasWeight() const
G4Material * GetMaterial() const
G4VPhysicalVolume * GetDaughter(const std::size_t i) const
G4UserLimits * GetUserLimits() const
G4FieldManager * GetFieldManager() const
void SetVisAttributes(const G4VisAttributes *pVA)
void SetBiasWeight(G4double w)
const G4String & GetName() const
G4int GetVerboseLevel() const
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)
virtual ~G4ReflectionFactory()
G4double GetScalePrecision() const
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4bool IsConstituent(G4LogicalVolume *lv) const
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)
void AddRootLogicalVolume(G4LogicalVolume *lv, G4bool search=true)
static G4VPVDivisionFactory * Instance()
virtual G4VPhysicalVolume * CreatePVDivision(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset)=0
virtual G4bool IsReplicated() const =0
G4LogicalVolume * GetLogicalVolume() const
G4RotationMatrix GetObjectRotationValue() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
virtual G4VPVParameterisation * GetParameterisation() const =0
virtual G4bool IsMany() const =0
G4ThreeVector GetObjectTranslation() const