Geant4  10.03
G4ReflectionFactory.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ReflectionFactory.hh 66872 2013-01-15 01:25:57Z japost $
28 //
29 //
30 // class G4ReflectionFactory
31 //
32 // Class description:
33 //
34 // Class providing functions for volumes placements with a general
35 // transfomation that can contain reflection.
36 // Reflection is then applied to a solid: a new G4ReflectedSolid
37 // instance is created and is placed with a transformation containing
38 // pure rotation and translation only.
39 // The pair of constituent and reflected logical volumes is
40 // considered as a generalized logical volume that is addressed
41 // by user specifying the constituent logical volume.
42 //
43 // Decomposition of a general transformation that can include reflection
44 // in a "reflection-free" transformation:
45 //
46 // x(inM') = TG*x(inM) TG - general transformation
47 // = T*(R*x(inM)) T - "reflection-free" transformation
48 // = T* x(inReflM)
49 //
50 // Daughters transformation:
51 // When a volume V containing daughter D with transformation TD
52 // is placed in mother M with a general tranformation TGV,
53 // the TGV is decomposed. New reflected volume ReflV containing
54 // a new daughter ReflD with reflected transformation ReflTD is created:
55 //
56 // x(inV) = TD * x(inD);
57 // x(inM) = TGV * x(inV)
58 // = TV * R * x(inV)
59 // = TV * R * TD * x(inD)
60 // = TV * R*TD*R-1 * R*x(inD)
61 // = TV * ReflTD * x(inReflD)
62 
63 // Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
64 // --------------------------------------------------------------------
65 #ifndef G4_REFLECTION_FACTORY_HH
66 #define G4_REFLECTION_FACTORY_HH
67 
68 #include "G4Types.hh"
69 #include "G4Transform3D.hh"
70 #include "geomdefs.hh"
71 
72 #include <map>
73 
74 class G4VPhysicalVolume;
75 class G4LogicalVolume;
76 class G4VSolid;
78 
79 typedef std::pair<G4VPhysicalVolume*,
81 typedef std::map<G4LogicalVolume*, G4LogicalVolume*,
82  std::less<G4LogicalVolume*> > G4ReflectedVolumesMap;
83 
85 {
86  typedef G4ReflectedVolumesMap::const_iterator LogicalVolumesMapIterator;
87 
88  public: // with description
89 
90  virtual ~G4ReflectionFactory();
91  // Virtual destructor.
92 
93  static G4ReflectionFactory* Instance();
94  // Gets pointer to the instance of the singleton.
95 
96  G4PhysicalVolumesPair Place(const G4Transform3D& transform3D,
97  const G4String& name,
98  G4LogicalVolume* LV,
99  G4LogicalVolume* motherLV,
100  G4bool isMany,
101  G4int copyNo,
102  G4bool surfCheck=false);
103  // Evaluates the passed transformation; if it contains reflection
104  // it performs its decomposition, creates new reflected solid and
105  // logical volume (or retrieves them from a map if the reflected
106  // objects were already created), transforms the daughters (if present)
107  // and place it in the given mother.
108  // The result is a pair of physical volumes;
109  // the second physical volume is a placement in a reflected mother
110  // or 0 if mother LV was not reflected.
111 
113  G4LogicalVolume* LV,
114  G4LogicalVolume* motherLV,
115  EAxis axis,
116  G4int nofReplicas,
117  G4double width,
118  G4double offset=0);
119  // Creates replica in the given mother.
120  // The result is a pair of physical volumes;
121  // the second physical volume is a replica in a reflected mother
122  // or 0 if mother LV was not reflected.
123 
125  G4LogicalVolume* LV,
126  G4LogicalVolume* motherLV,
127  EAxis axis,
128  G4int nofDivisions,
129  G4double width,
130  G4double offset);
132  G4LogicalVolume* LV,
133  G4LogicalVolume* motherLV,
134  EAxis axis,
135  G4int nofDivisions,
136  G4double offset);
138  G4LogicalVolume* LV,
139  G4LogicalVolume* motherLV,
140  EAxis axis,
141  G4double width,
142  G4double offset);
143  // Creates division in the given mother.
144  // The result is a pair of physical volumes;
145  // the second physical volume is a division in a reflected mother
146  // or 0 if mother LV was not reflected.
147 
148  void SetVerboseLevel(G4int verboseLevel);
149  G4int GetVerboseLevel() const;
150  // Sets/gets verbosity level.
151 
152  void SetVolumesNameExtension(const G4String& nameExtension);
153  const G4String& GetVolumesNameExtension() const;
154  // Returns the name extension for the reflected solids
155  // and logical volumes.
156 
157  void SetScalePrecision(G4double scaleValue);
158  G4double GetScalePrecision() const;
159  // Sets/gets precision factor for the scale consistency check
160  // The default value is set to 10*kCarTolerance.
161 
163  // Returns the consituent volume of the given reflected volume,
164  // 0 if the given reflected volume was not found.
165 
167  // Returns the reflected volume of the given consituent volume,
168  // 0 if the given volume was not reflected.
169 
171  // Returns true if the given volume has been already reflected
172  // (is in the map of constituent volumes).
173 
175  // Returns true if the given volume is a reflected volume
176  // (is in the map reflected volumes).
177 
179  // Returns a handle to the internal map of volumes which have
180  // been reflected, after that placement or replication is performed.
181 
182  void Reset();
183  // Resets maps of constituent and reflected volumes.
184  // To be used exclusively when volumes are removed from the stores.
185 
186  protected:
187 
189  // Protected singleton constructor.
190 
193  // Disabled copy constructor and assignment operator.
194 
195  private:
196 
197  G4LogicalVolume* ReflectLV(G4LogicalVolume* LV, G4bool surfCheck=false);
198  // Gets/creates the reflected solid and logical volume
199  // and copies + transforms LV daughters.
200 
202  // Creates the reflected solid and logical volume
203  // and add the logical volumes pair in the maps.
204 
206  G4LogicalVolume* refLV, G4bool surfCheck=false);
207  // Reflects daughters recursively.
208 
210  G4LogicalVolume* refLV, G4bool surfCheck=false);
211  // Copies and transforms daughter of PVPlacement type of
212  // a constituent volume into a reflected volume.
213 
215  // Copies and transforms daughter of PVReplica type of
216  // a constituent volume into a reflected volume.
217 
219  // Copies and transforms daughter of PVDivision type of
220  // a constituent volume into a reflected volume.
221 
223  G4LogicalVolume* refLV, G4bool surfCheck=false);
224  // Not implemented yet.
225  // Should copy and transform daughter of PVReplica type of
226  // a constituent volume into a reflected volume.
227 
228  G4bool IsReflection(const G4Scale3D& scale) const;
229  // Returns true if the scale is negative, false otherwise.
230 
231  void CheckScale(const G4Scale3D& scale) const;
232  // Checks if scale correspond to fScale, if not gives exception.
233 
235  // Checks if the division factory is instanciated,
236  // if not gives exception.
237 
238  void PrintConstituentLVMap();
239  // Temporary - for debugging purpose.
240 
241  private:
242 
245  static const G4Scale3D fScale;
247 
252 };
253 
254 #endif
G4PhysicalVolumesPair Divide(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double width, G4double offset)
G4ReflectedVolumesMap fReflectedLVMap
void ReflectPVParameterised(G4VPhysicalVolume *PV, G4LogicalVolume *refLV, G4bool surfCheck=false)
const G4String & GetVolumesNameExtension() const
void SetScalePrecision(G4double scaleValue)
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const
#define width
G4PhysicalVolumesPair Replicate(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0)
const char * name(G4int ptype)
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
void CheckScale(const G4Scale3D &scale) const
G4bool IsReflected(G4LogicalVolume *lv) const
static G4ReflectionFactory * Instance()
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4ReflectedVolumesMap fConstituentLVMap
G4ReflectedVolumesMap::const_iterator LogicalVolumesMapIterator
const G4ReflectedVolumesMap & GetReflectedVolumesMap() const
bool G4bool
Definition: G4Types.hh:79
G4VPVDivisionFactory * GetPVDivisionFactory() const
std::map< G4LogicalVolume *, G4LogicalVolume *, std::less< G4LogicalVolume * > > G4ReflectedVolumesMap
static const G4Scale3D fScale
void SetVolumesNameExtension(const G4String &nameExtension)
HepGeom::Transform3D G4Transform3D
HepGeom::Scale3D G4Scale3D
static const G4String fDefaultNameExtension
void SetVerboseLevel(G4int verboseLevel)
G4double GetScalePrecision() const
G4int GetVerboseLevel() const
EAxis
Definition: geomdefs.hh:54
G4bool IsReflection(const G4Scale3D &scale) const
G4LogicalVolume * GetReflectedLV(G4LogicalVolume *lv) const
G4LogicalVolume * ReflectLV(G4LogicalVolume *LV, G4bool surfCheck=false)
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
static G4ThreadLocal G4ReflectionFactory * fInstance
void ReflectPVPlacement(G4VPhysicalVolume *PV, G4LogicalVolume *refLV, G4bool surfCheck=false)
double G4double
Definition: G4Types.hh:76
void ReflectDaughters(G4LogicalVolume *LV, G4LogicalVolume *refLV, G4bool surfCheck=false)
void ReflectPVDivision(G4VPhysicalVolume *PV, G4LogicalVolume *refLV)
G4LogicalVolume * CreateReflectedLV(G4LogicalVolume *LV)
G4bool IsConstituent(G4LogicalVolume *lv) const
G4ReflectionFactory & operator=(const G4ReflectionFactory &)
void ReflectPVReplica(G4VPhysicalVolume *PV, G4LogicalVolume *refLV)