Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:56

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4AssemblyVolume
0027 //
0028 // Class description:
0029 //
0030 // G4AssemblyVolume is a helper class to make the build process of geometry
0031 // easier. It allows one to combine several volumes together in an arbitrary way
0032 // in 3D space and then work with the result as with a single logical volume
0033 // for placement.
0034 // The resulting objects are independent copies of each of the assembled
0035 // logical volumes. The placements are not, however, bound one to each other
0036 // when placement is done. They are seen as independent physical volumes in
0037 // space.
0038 
0039 // Radovan Chytracek, John Apostolakis, Gabriele Cosmo: created - November 2000
0040 // Ivana Hrivnacova: extended to support assembly of assemblies
0041 //                   of volumes and reflections - March 2006
0042 // ----------------------------------------------------------------------
0043 #ifndef G4_ASSEMBLYVOLUME_HH
0044 #define G4_ASSEMBLYVOLUME_HH
0045 
0046 #include <vector>
0047 
0048 #include "G4Transform3D.hh"
0049 #include "G4AssemblyTriplet.hh"
0050 
0051 class G4VPhysicalVolume;
0052 
0053 class G4AssemblyVolume
0054 {
0055   public:
0056 
0057     G4AssemblyVolume();    
0058     G4AssemblyVolume( G4LogicalVolume* volume,
0059                       G4ThreeVector& translation,
0060                       G4RotationMatrix* rotation);
0061     ~G4AssemblyVolume();
0062       //
0063       // Constructors & destructor.
0064       // At destruction all the generated physical volumes and associated
0065       // rotation matrices of the imprints will be destroyed.
0066       //
0067       // The rotation matrix passed as argument can be nullptr (identity) or an
0068       // address even of an object on the upper stack frame. During assembly
0069       // imprint, a new matrix is created anyway and it is kept track of it so
0070       // it can be automatically deleted later at the end of the application.
0071       // This policy is adopted since user has no control on the way the
0072       // rotations are combined.
0073 
0074     void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
0075                           G4ThreeVector& translation,
0076                           G4RotationMatrix* rotation);
0077       //
0078       // Place the given volume 'pPlacedVolume' inside the assembly.
0079       //
0080       // The adopted approach:
0081       //
0082       // - Place it w.r.t. the assembly coordinate system.
0083       //   This step is applied to each of the participating volumes.
0084       //
0085       // The other possible approaches:
0086       //
0087       // - Place w.r.t. the firstly added volume.
0088       //   When placed the first, the virtual coordinate system becomes
0089       //   the coordinate system of the first one.
0090       //   Every next volume being added into the assembly will be placed
0091       //   w.r.t to the first one.
0092       //
0093       // - Place w.r.t the last placed volume.
0094       //   When placed the first, the virtual coordinate system becomes
0095       //   the coordinate system of the first one.
0096       //   Every next volume being added into the assembly will be placed
0097       //   w.r.t to the previous one.
0098       //
0099       // The rotation matrix passed as argument can be nullptr (identity) or an
0100       // address even of an object on the upper stack frame. During assembly
0101       // imprint, a new matrix is created anyway and it is kept track of it so
0102       // it can be automatically deleted later at the end of the application.
0103       // This policy is adopted since user has no control on the way the
0104       // rotations are combined.
0105 
0106     void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
0107                           G4Transform3D&   transformation);
0108       //
0109       // The same as previous, but takes complete 3D transformation in space
0110       // as its argument.
0111 
0112     void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
0113                             G4Transform3D&    transformation);
0114       //
0115       // The same as previous AddPlacedVolume(), but takes an assembly volume 
0116       // as its argument.
0117 
0118     void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
0119                             G4ThreeVector& translation,
0120                             G4RotationMatrix* rotation);
0121       //
0122       // The same as above AddPlacedVolume(), but takes an assembly volume 
0123       // as its argument with translation and rotation.
0124 
0125     void MakeImprint( G4LogicalVolume* pMotherLV,
0126                       G4ThreeVector& translationInMother,
0127                       G4RotationMatrix* pRotationInMother,
0128                       G4int copyNumBase = 0,
0129                       G4bool surfCheck = false );
0130       //
0131       // Creates instance of an assembly volume inside the given mother volume.
0132 
0133     void MakeImprint( G4LogicalVolume* pMotherLV,
0134                       G4Transform3D&   transformation,
0135                       G4int copyNumBase = 0,
0136                       G4bool surfCheck = false );
0137       //
0138       // The same as previous Imprint() method, but takes complete 3D
0139       // transformation in space as its argument.
0140 
0141     inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
0142     inline std::size_t TotalImprintedVolumes() const;
0143       //
0144       // Methods to access the physical volumes imprinted with the assembly.
0145     inline G4Transform3D& GetImprintTransformation(unsigned int imprintID);
0146       // Method to access transformation for each imprint
0147 
0148     inline std::vector<G4AssemblyTriplet>::iterator GetTripletsIterator();
0149     inline std::size_t TotalTriplets() const;
0150       //
0151       // Methods to access the triplets which are part of the assembly
0152   
0153     inline unsigned int GetImprintsCount() const;
0154       //
0155       // Return the number of made imprints.
0156 
0157     unsigned int GetInstanceCount() const;
0158       //
0159       // Return the number of existing instance of G4AssemblyVolume class.
0160 
0161     inline unsigned int GetAssemblyID()    const;
0162       //
0163       // Return instance number of this concrete object.
0164   
0165   protected:
0166 
0167     inline void SetInstanceCount( unsigned int value );
0168     inline void SetAssemblyID( unsigned int value );
0169  
0170     void InstanceCountPlus();
0171     void InstanceCountMinus();
0172 
0173     inline void SetImprintsCount( unsigned int value );
0174     inline void ImprintsCountPlus();
0175     inline void ImprintsCountMinus();
0176       //
0177       // Internal counting mechanism, used to compute unique the names of
0178       // physical volumes created by MakeImprint() methods.
0179 
0180   private:    
0181 
0182     void MakeImprint( G4AssemblyVolume* pAssembly,
0183                       G4LogicalVolume*  pMotherLV,
0184                       G4Transform3D&    transformation,
0185                       G4int copyNumBase = 0,
0186                       G4bool surfCheck = false );
0187       //    
0188       // Function for placement of the given assembly in the given mother
0189       // (called recursively if the assembly contains an assembly).
0190 
0191   private:
0192 
0193     std::vector<G4AssemblyTriplet> fTriplets;
0194       //
0195       // Participating volumes represented as a vector of
0196       // <logical volume, translation, rotation>.
0197 
0198     std::vector<G4VPhysicalVolume*> fPVStore;
0199       //
0200       // We need to keep list of physical volumes created by MakeImprint()
0201       // in order to be able to cleanup the objects when not needed anymore.
0202       // This requires the user to keep assembly objects in memory during the
0203       // whole job or during the life-time of G4Navigator, logical volume store
0204       // and physical volume store keep pointers to physical volumes generated
0205       // by the assembly volume.
0206       // When an assembly object is about to die it will destroy all its
0207       // generated physical volumes and rotation matrices as well !
0208 
0209     unsigned int fImprintsCounter;
0210       //
0211       // Number of imprints of the given assembly volume.
0212 
0213     static G4ThreadLocal unsigned int fsInstanceCounter;
0214       //
0215       // Class instance counter.
0216 
0217     unsigned int fAssemblyID = 0;
0218       //
0219       // Assembly object ID derived from instance counter at construction time.
0220 
0221     std::map<unsigned int, G4Transform3D> fImprintsTransf;
0222       //
0223       // Container of transformations for each imprint (used in GDML)
0224 };
0225 
0226 #include "G4AssemblyVolume.icc"
0227 
0228 #endif // G4_ASSEMBLYVOLUME_HH