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);
374 if (refLV ==
nullptr)
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 auto it = fReflectedLVMap.find(reflLV);
688 if (it == fReflectedLVMap.end())
return nullptr;
702 auto 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 return scale(0,0)*scale(1,1)*scale(2,2) < 0.;
746 return fReflectedLVMap;
753 fConstituentLVMap.clear();
754 fReflectedLVMap.clear();
759void G4ReflectionFactory::PrintConstituentLVMap()
764 LogicalVolumesMapIterator it;
765 for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); ++it)
767 G4cout <<
"lv: " << (*it).first <<
" lv_refl: " << (*it).second <<
G4endl;
774void G4ReflectionFactory::CheckScale(
const G4Scale3D& scale)
const
780 if (!IsReflection(scale))
return;
783 for (
auto i=0; i<4; ++i)
784 for (
auto j=0; j<4; ++j)
785 diff += std::abs(scale(i,j) - fScale(i,j));
787 if (diff > fScalePrecision)
789 std::ostringstream message;
790 message <<
"Unexpected scale in input !" <<
G4endl
791 <<
" Difference: " << diff;
806 if (divisionFactory ==
nullptr)
808 std::ostringstream message;
809 message <<
"A concrete G4PVDivisionFactory instantiated is required !"
811 <<
" It has been requested to reflect divided volumes."
813 <<
" In this case, it is required to instantiate a concrete"
815 <<
" factory G4PVDivisionFactory in your program -before-"
817 <<
" executing the reflection !";
818 G4Exception(
"G4ReflectionFactory::GetPVDivisionFactory()",
822 return divisionFactory;
829 fScalePrecision = scaleValue;
836 return fScalePrecision;
843 fVerboseLevel = verboseLevel;
850 return fVerboseLevel;
857 fNameExtension = nameExtension;
864 return fNameExtension;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::map< G4LogicalVolume *, G4LogicalVolume *, std::less< G4LogicalVolume * > > G4ReflectedVolumesMap
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
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