Geant4 9.6.0
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 Reset ()
 

Static Public Member Functions

static G4ReflectionFactoryInstance ()
 

Protected Member Functions

 G4ReflectionFactory ()
 
 G4ReflectionFactory (const G4ReflectionFactory &)
 
G4ReflectionFactoryoperator= (const G4ReflectionFactory &)
 

Detailed Description

Definition at line 84 of file G4ReflectionFactory.hh.

Constructor & Destructor Documentation

◆ ~G4ReflectionFactory()

G4ReflectionFactory::~G4ReflectionFactory ( )
virtual

Definition at line 97 of file G4ReflectionFactory.cc.

98{
99 delete fInstance;
100}

◆ G4ReflectionFactory() [1/2]

G4ReflectionFactory::G4ReflectionFactory ( )
protected

Definition at line 83 of file G4ReflectionFactory.cc.

84 : fVerboseLevel(0),
85 fNameExtension(fDefaultNameExtension)
86{
87 // Protected singleton constructor.
88 // ---
89
90 fScalePrecision = 10.
92 fInstance = this;
93}
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()

Referenced by Instance().

◆ G4ReflectionFactory() [2/2]

G4ReflectionFactory::G4ReflectionFactory ( const G4ReflectionFactory )
protected

Member Function Documentation

◆ Divide() [1/3]

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

Definition at line 326 of file G4ReflectionFactory.cc.

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

◆ Divide() [2/3]

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

Definition at line 285 of file G4ReflectionFactory.cc.

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

◆ Divide() [3/3]

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

Definition at line 243 of file G4ReflectionFactory.cc.

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

Referenced by G4GDMLReadStructure::DivisionvolRead().

◆ GetConstituentLV()

G4LogicalVolume * G4ReflectionFactory::GetConstituentLV ( G4LogicalVolume reflLV) const

Definition at line 685 of file G4ReflectionFactory.cc.

686{
687 // Returns the consituent volume of the given reflected volume,
688 // 0 if the given reflected volume was not found.
689 // ---
690
691 LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
692
693 if (it == fReflectedLVMap.end()) return 0;
694
695 return (*it).second;
696}

◆ GetReflectedLV()

G4LogicalVolume * G4ReflectionFactory::GetReflectedLV ( G4LogicalVolume lv) const

Definition at line 701 of file G4ReflectionFactory.cc.

702{
703 // Returns the reflected volume of the given consituent volume,
704 // 0 if the given volume was not reflected.
705 // ---
706
707 LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
708
709 if (it == fConstituentLVMap.end()) return 0;
710
711 return (*it).second;
712}

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

◆ GetReflectedVolumesMap()

const G4ReflectedVolumesMap & G4ReflectionFactory::GetReflectedVolumesMap ( ) const

Definition at line 752 of file G4ReflectionFactory.cc.

753{
754 return fReflectedLVMap;
755}

◆ GetScalePrecision()

G4double G4ReflectionFactory::GetScalePrecision ( ) const

Definition at line 843 of file G4ReflectionFactory.cc.

844{
845 return fScalePrecision;
846}

◆ GetVerboseLevel()

G4int G4ReflectionFactory::GetVerboseLevel ( ) const

Definition at line 857 of file G4ReflectionFactory.cc.

858{
859 return fVerboseLevel;
860}

◆ GetVolumesNameExtension()

const G4String & G4ReflectionFactory::GetVolumesNameExtension ( ) const

Definition at line 871 of file G4ReflectionFactory.cc.

872{
873 return fNameExtension;
874}

◆ Instance()

◆ IsConstituent()

G4bool G4ReflectionFactory::IsConstituent ( G4LogicalVolume lv) const

Definition at line 716 of file G4ReflectionFactory.cc.

717{
718 // Returns true if the given volume has been already reflected
719 // (is in the map of constituent volumes).
720 // ---
721
722 return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
723}

◆ IsReflected()

G4bool G4ReflectionFactory::IsReflected ( G4LogicalVolume lv) const

Definition at line 727 of file G4ReflectionFactory.cc.

728{
729 // Returns true if the given volume is a reflected volume
730 // (is in the map reflected volumes).
731 // ---
732
733 return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
734}

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

◆ operator=()

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

◆ Place()

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

Definition at line 109 of file G4ReflectionFactory.cc.

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

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 204 of file G4ReflectionFactory.cc.

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

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

◆ Reset()

void G4ReflectionFactory::Reset ( )

Definition at line 760 of file G4ReflectionFactory.cc.

761{
762 fConstituentLVMap.~map();
763 fReflectedLVMap.~map();
764}

◆ SetScalePrecision()

void G4ReflectionFactory::SetScalePrecision ( G4double  scaleValue)

Definition at line 836 of file G4ReflectionFactory.cc.

837{
838 fScalePrecision = scaleValue;
839}

Referenced by G4tgbVolumeMgr::G4tgbVolumeMgr().

◆ SetVerboseLevel()

void G4ReflectionFactory::SetVerboseLevel ( G4int  verboseLevel)

Definition at line 850 of file G4ReflectionFactory.cc.

851{
852 fVerboseLevel = verboseLevel;
853}

◆ SetVolumesNameExtension()

void G4ReflectionFactory::SetVolumesNameExtension ( const G4String nameExtension)

Definition at line 864 of file G4ReflectionFactory.cc.

865{
866 fNameExtension = nameExtension;
867}

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