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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // G4AssemblyVolume
 27 //
 28 // Class description:
 29 //
 30 // G4AssemblyVolume is a helper class to make the build process of geometry
 31 // easier. It allows one to combine several volumes together in an arbitrary way
 32 // in 3D space and then work with the result as with a single logical volume
 33 // for placement.
 34 // The resulting objects are independent copies of each of the assembled
 35 // logical volumes. The placements are not, however, bound one to each other
 36 // when placement is done. They are seen as independent physical volumes in
 37 // space.
 38 
 39 // Radovan Chytracek, John Apostolakis, Gabriele Cosmo: created - November 2000
 40 // Ivana Hrivnacova: extended to support assembly of assemblies
 41 //                   of volumes and reflections - March 2006
 42 // ----------------------------------------------------------------------
 43 #ifndef G4_ASSEMBLYVOLUME_HH
 44 #define G4_ASSEMBLYVOLUME_HH
 45 
 46 #include <vector>
 47 
 48 #include "G4Transform3D.hh"
 49 #include "G4AssemblyTriplet.hh"
 50 
 51 class G4VPhysicalVolume;
 52 
 53 class G4AssemblyVolume
 54 {
 55   public:
 56 
 57     G4AssemblyVolume();    
 58     G4AssemblyVolume( G4LogicalVolume* volume,
 59                       G4ThreeVector& translation,
 60                       G4RotationMatrix* rotation);
 61     ~G4AssemblyVolume();
 62       //
 63       // Constructors & destructor.
 64       // At destruction all the generated physical volumes and associated
 65       // rotation matrices of the imprints will be destroyed.
 66       //
 67       // The rotation matrix passed as argument can be nullptr (identity) or an
 68       // address even of an object on the upper stack frame. During assembly
 69       // imprint, a new matrix is created anyway and it is kept track of it so
 70       // it can be automatically deleted later at the end of the application.
 71       // This policy is adopted since user has no control on the way the
 72       // rotations are combined.
 73 
 74     void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
 75                           G4ThreeVector& translation,
 76                           G4RotationMatrix* rotation);
 77       //
 78       // Place the given volume 'pPlacedVolume' inside the assembly.
 79       //
 80       // The adopted approach:
 81       //
 82       // - Place it w.r.t. the assembly coordinate system.
 83       //   This step is applied to each of the participating volumes.
 84       //
 85       // The other possible approaches:
 86       //
 87       // - Place w.r.t. the firstly added volume.
 88       //   When placed the first, the virtual coordinate system becomes
 89       //   the coordinate system of the first one.
 90       //   Every next volume being added into the assembly will be placed
 91       //   w.r.t to the first one.
 92       //
 93       // - Place w.r.t the last placed volume.
 94       //   When placed the first, the virtual coordinate system becomes
 95       //   the coordinate system of the first one.
 96       //   Every next volume being added into the assembly will be placed
 97       //   w.r.t to the previous one.
 98       //
 99       // The rotation matrix passed as argument can be nullptr (identity) or an
100       // address even of an object on the upper stack frame. During assembly
101       // imprint, a new matrix is created anyway and it is kept track of it so
102       // it can be automatically deleted later at the end of the application.
103       // This policy is adopted since user has no control on the way the
104       // rotations are combined.
105 
106     void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
107                           G4Transform3D&   transformation);
108       //
109       // The same as previous, but takes complete 3D transformation in space
110       // as its argument.
111 
112     void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
113                             G4Transform3D&    transformation);
114       //
115       // The same as previous AddPlacedVolume(), but takes an assembly volume 
116       // as its argument.
117 
118     void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
119                             G4ThreeVector& translation,
120                             G4RotationMatrix* rotation);
121       //
122       // The same as above AddPlacedVolume(), but takes an assembly volume 
123       // as its argument with translation and rotation.
124 
125     void MakeImprint( G4LogicalVolume* pMotherLV,
126                       G4ThreeVector& translationInMother,
127                       G4RotationMatrix* pRotationInMother,
128                       G4int copyNumBase = 0,
129                       G4bool surfCheck = false );
130       //
131       // Creates instance of an assembly volume inside the given mother volume.
132 
133     void MakeImprint( G4LogicalVolume* pMotherLV,
134                       G4Transform3D&   transformation,
135                       G4int copyNumBase = 0,
136                       G4bool surfCheck = false );
137       //
138       // The same as previous Imprint() method, but takes complete 3D
139       // transformation in space as its argument.
140 
141     inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
142     inline std::size_t TotalImprintedVolumes() const;
143       //
144       // Methods to access the physical volumes imprinted with the assembly.
145     inline G4Transform3D& GetImprintTransformation(unsigned int imprintID);
146       // Method to access transformation for each imprint
147 
148     inline std::vector<G4AssemblyTriplet>::iterator GetTripletsIterator();
149     inline std::size_t TotalTriplets() const;
150       //
151       // Methods to access the triplets which are part of the assembly
152   
153     inline 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     inline unsigned int GetAssemblyID()    const;
162       //
163       // Return instance number of this concrete object.
164   
165   protected:
166 
167     inline void SetInstanceCount( unsigned int value );
168     inline void SetAssemblyID( unsigned int value );
169  
170     void InstanceCountPlus();
171     void InstanceCountMinus();
172 
173     inline void SetImprintsCount( unsigned int value );
174     inline void ImprintsCountPlus();
175     inline 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()
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
205       // by 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 = 0;
218       //
219       // Assembly object ID derived from instance counter at construction time.
220 
221     std::map<unsigned int, G4Transform3D> fImprintsTransf;
222       //
223       // Container of transformations for each imprint (used in GDML)
224 };
225 
226 #include "G4AssemblyVolume.icc"
227 
228 #endif // G4_ASSEMBLYVOLUME_HH
229