Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AssemblyVolume.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: G4AssemblyVolume.hh 66872 2013-01-15 01:25:57Z japost $
28 //
29 //
30 // Class G4AssemblyVolume
31 //
32 // Class description:
33 //
34 // G4AssemblyVolume is a helper class to make the build process of geometry
35 // easier. It allows to combine several volumes together in an arbitrary way
36 // in 3D space and then work with the result as with a single logical volume
37 // for placement.
38 // The resulting objects are independent copies of each of the assembled
39 // logical volumes. The placements are not, however, bound one to each other
40 // when placement is done. They are seen as independent physical volumes in
41 // space.
42 
43 // Author: Radovan Chytracek, John Apostolakis, Gabriele Cosmo
44 // Date: November 2000
45 //
46 // History:
47 // March 2006, I.Hrivnacova - Extended to support assembly of assemblies
48 // of volumes and reflections
49 // ----------------------------------------------------------------------
50 #ifndef G4_ASSEMBLYVOLUME_H
51 #define G4_ASSEMBLYVOLUME_H
52 
53 #include <vector>
54 
55 #include "G4Transform3D.hh"
56 #include "G4AssemblyTriplet.hh"
57 
58 class G4VPhysicalVolume;
59 
61 {
62  public: // with description
63 
66  G4ThreeVector& translation,
67  G4RotationMatrix* rotation);
69  //
70  // Constructors & destructor.
71  // At destruction all the generated physical volumes and associated
72  // rotation matrices of the imprints will be destroyed.
73  //
74  // The rotation matrix passed as argument can be 0 (identity) or an address
75  // even of an object on the upper stack frame. During assembly imprint, a
76  // new matrix is created anyway and it is kept track of it so it can be
77  // automatically deleted later at the end of the application.
78  // This policy is adopted since user has no control on the way the
79  // rotations are combined.
80 
81  void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
82  G4ThreeVector& translation,
83  G4RotationMatrix* rotation);
84  //
85  // Place the given volume 'pPlacedVolume' inside the assembly.
86  //
87  // The adopted approach:
88  //
89  // - Place it w.r.t. the assembly coordinate system.
90  // This step is applied to each of the participating volumes.
91  //
92  // The other possible approaches:
93  //
94  // - Place w.r.t. the firstly added volume.
95  // When placed the first, the virtual coordinate system becomes
96  // the coordinate system of the first one.
97  // Every next volume being added into the assembly will be placed
98  // w.r.t to the first one.
99  //
100  // - Place w.r.t the last placed volume.
101  // When placed the first, the virtual coordinate system becomes
102  // the coordinate system of the first one.
103  // Every next volume being added into the assembly will be placed
104  // w.r.t to the previous one.
105  //
106  // The rotation matrix passed as argument can be 0 (identity) or an address
107  // even of an object on the upper stack frame. During assembly imprint, a
108  // new matrix is created anyway and it is kept track of it so it can be
109  // automatically deleted later at the end of the application.
110  // This policy is adopted since user has no control on the way the
111  // rotations are combined.
112 
113  void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
114  G4Transform3D& transformation);
115  //
116  // The same as previous, but takes complete 3D transformation in space
117  // as its argument.
118 
119  void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
120  G4Transform3D& transformation);
121  //
122  // The same as previous AddPlacedVolume(), but takes an assembly volume
123  // as its argument.
124 
125  void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
126  G4ThreeVector& translation,
127  G4RotationMatrix* rotation);
128  //
129  // The same as above AddPlacedVolume(), but takes an assembly volume
130  // as its argument with translation and rotation.
131 
132  void MakeImprint( G4LogicalVolume* pMotherLV,
133  G4ThreeVector& translationInMother,
134  G4RotationMatrix* pRotationInMother,
135  G4int copyNumBase = 0,
136  G4bool surfCheck = false );
137  //
138  // Creates instance of an assembly volume inside the given mother volume.
139 
140  void MakeImprint( G4LogicalVolume* pMotherLV,
141  G4Transform3D& transformation,
142  G4int copyNumBase = 0,
143  G4bool surfCheck = false );
144  //
145  // The same as previous Imprint() method, but takes complete 3D
146  // transformation in space as its argument.
147 
148  inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
149  inline unsigned int TotalImprintedVolumes() const;
150  //
151  // Methods to access the physical volumes imprinted with the assembly.
152 
153  unsigned int GetImprintsCount() const;
154  //
155  // Return the number of made imprints.
156 
157  unsigned int GetInstanceCount() const;
158  //
159  // Return the number of existing instance of G4AssemblyVolume class.
160 
161  unsigned int GetAssemblyID() const;
162  //
163  // Return instance number of this concrete object.
164 
165  protected:
166 
167  void SetInstanceCount( unsigned int value );
168  void SetAssemblyID( unsigned int value );
169 
170  void InstanceCountPlus();
171  void InstanceCountMinus();
172 
173  void SetImprintsCount( unsigned int value );
174  void ImprintsCountPlus();
175  void ImprintsCountMinus();
176  //
177  // Internal counting mechanism, used to compute unique the names of
178  // physical volumes created by MakeImprint() methods.
179 
180  private:
181 
182  void MakeImprint( G4AssemblyVolume* pAssembly,
183  G4LogicalVolume* pMotherLV,
184  G4Transform3D& transformation,
185  G4int copyNumBase = 0,
186  G4bool surfCheck = false );
187  //
188  // Function for placement of the given assembly in the given mother
189  // (called recursively if the assembly contains an assembly).
190 
191  private:
192 
193  std::vector<G4AssemblyTriplet> fTriplets;
194  //
195  // Participating volumes represented as a vector of
196  // <logical volume, translation, rotation>.
197 
198  std::vector<G4VPhysicalVolume*> fPVStore;
199  //
200  // We need to keep list of physical volumes created by MakeImprint() method
201  // in order to be able to cleanup the objects when not needed anymore.
202  // This requires the user to keep assembly objects in memory during the
203  // whole job or during the life-time of G4Navigator, logical volume store
204  // and physical volume store keep pointers to physical volumes generated by
205  // the assembly volume.
206  // When an assembly object is about to die it will destroy all its
207  // generated physical volumes and rotation matrices as well !
208 
209  unsigned int fImprintsCounter;
210  //
211  // Number of imprints of the given assembly volume.
212 
213  static G4ThreadLocal unsigned int fsInstanceCounter;
214  //
215  // Class instance counter.
216 
217  unsigned int fAssemblyID;
218  //
219  // Assembly object ID derived from instance counter at construction time.
220 
221 };
222 
223 #include "G4AssemblyVolume.icc"
224 
225 #endif // G4_ASSEMBLYVOLUME_H
unsigned int GetInstanceCount() const
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
void SetImprintsCount(unsigned int value)
void SetAssemblyID(unsigned int value)
void ImprintsCountMinus()
std::vector< G4VPhysicalVolume * >::iterator GetVolumesIterator()
#define G4ThreadLocal
Definition: tls.hh:89
void SetInstanceCount(unsigned int value)
unsigned int GetAssemblyID() const
int G4int
Definition: G4Types.hh:78
unsigned int GetImprintsCount() const
const XML_Char int const XML_Char * value
Definition: expat.h:331
bool G4bool
Definition: G4Types.hh:79
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
void ImprintsCountPlus()
unsigned int TotalImprintedVolumes() const
void AddPlacedAssembly(G4AssemblyVolume *pAssembly, G4Transform3D &transformation)