G4AssemblyVolume.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // Class G4AssemblyVolume
00031 //
00032 // Class description:
00033 //
00034 // G4AssemblyVolume is a helper class to make the build process of geometry
00035 // easier. It allows to combine several volumes together in an arbitrary way
00036 // in 3D space and then work with the result as with a single logical volume
00037 // for placement.
00038 // The resulting objects are independent copies of each of the assembled
00039 // logical volumes. The placements are not, however, bound one to each other
00040 // when placement is done. They are seen as independent physical volumes in
00041 // space.
00042 
00043 // Author:      Radovan Chytracek, John Apostolakis, Gabriele Cosmo
00044 // Date:        November 2000
00045 //
00046 // History:
00047 // March 2006, I.Hrivnacova - Extended to support assembly of assemblies
00048 //             of volumes and reflections
00049 // ----------------------------------------------------------------------
00050 #ifndef G4_ASSEMBLYVOLUME_H
00051 #define G4_ASSEMBLYVOLUME_H 
00052 
00053 #include <vector>
00054 
00055 #include "G4Transform3D.hh"
00056 #include "G4AssemblyTriplet.hh"
00057 
00058 class G4VPhysicalVolume;
00059 
00060 class G4AssemblyVolume
00061 {
00062  public:  // with description
00063 
00064   G4AssemblyVolume();    
00065   G4AssemblyVolume( G4LogicalVolume* volume,
00066                     G4ThreeVector& translation,
00067                     G4RotationMatrix* rotation);
00068   ~G4AssemblyVolume();
00069     //
00070     // Constructors & destructor.
00071     // At destruction all the generated physical volumes and associated
00072     // rotation matrices of the imprints will be destroyed.
00073     //
00074     // The rotation matrix passed as argument can be 0 (identity) or an address
00075     // even of an object on the upper stack frame. During assembly imprint, a
00076     // new matrix is created anyway and it is kept track of it so it can be
00077     // automatically deleted later at the end of the application.
00078     // This policy is adopted since user has no control on the way the
00079     // rotations are combined.
00080 
00081   void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
00082                         G4ThreeVector& translation,
00083                         G4RotationMatrix* rotation);
00084     //
00085     // Place the given volume 'pPlacedVolume' inside the assembly.
00086     //
00087     // The adopted approach:
00088     //
00089     // - Place it w.r.t. the assembly coordinate system.
00090     //   This step is applied to each of the participating volumes.
00091     //
00092     // The other possible approaches:
00093     //
00094     // - Place w.r.t. the firstly added volume.
00095     //   When placed the first, the virtual coordinate system becomes
00096     //   the coordinate system of the first one.
00097     //   Every next volume being added into the assembly will be placed
00098     //   w.r.t to the first one.
00099     //
00100     // - Place w.r.t the last placed volume.
00101     //   When placed the first, the virtual coordinate system becomes
00102     //   the coordinate system of the first one.
00103     //   Every next volume being added into the assembly will be placed
00104     //   w.r.t to the previous one.
00105     //
00106     // The rotation matrix passed as argument can be 0 (identity) or an address
00107     // even of an object on the upper stack frame. During assembly imprint, a
00108     // new matrix is created anyway and it is kept track of it so it can be
00109     // automatically deleted later at the end of the application.
00110     // This policy is adopted since user has no control on the way the
00111     // rotations are combined.
00112 
00113   void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
00114                         G4Transform3D&   transformation);
00115     //
00116     // The same as previous, but takes complete 3D transformation in space
00117     // as its argument.
00118 
00119   void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
00120                           G4Transform3D&    transformation);
00121     //
00122     // The same as previous AddPlacedVolume(), but takes an assembly volume 
00123     // as its argument.
00124 
00125   void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
00126                           G4ThreeVector& translation,
00127                           G4RotationMatrix* rotation);
00128     //
00129     // The same as above AddPlacedVolume(), but takes an assembly volume 
00130     // as its argument with translation and rotation.
00131 
00132   void MakeImprint( G4LogicalVolume* pMotherLV,
00133                     G4ThreeVector& translationInMother,
00134                     G4RotationMatrix* pRotationInMother,
00135                     G4int copyNumBase = 0,
00136                     G4bool surfCheck = false );
00137     //
00138     // Creates instance of an assembly volume inside the given mother volume.
00139 
00140   void MakeImprint( G4LogicalVolume* pMotherLV,
00141                     G4Transform3D&   transformation,
00142                     G4int copyNumBase = 0,
00143                     G4bool surfCheck = false );
00144     //
00145     // The same as previous Imprint() method, but takes complete 3D
00146     // transformation in space as its argument.
00147 
00148   inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
00149   inline unsigned int TotalImprintedVolumes() const;
00150     //
00151     // Methods to access the physical volumes imprinted with the assembly.
00152 
00153   unsigned int GetImprintsCount() const;
00154     //
00155     // Return the number of made imprints.
00156 
00157   unsigned int GetInstanceCount() const;
00158     //
00159     // Return the number of existing instance of G4AssemblyVolume class.
00160 
00161   unsigned int GetAssemblyID()    const;
00162     //
00163     // Return instance number of this concrete object.
00164   
00165  protected:
00166      
00167   void SetInstanceCount( unsigned int value );
00168   void SetAssemblyID( unsigned int value );
00169  
00170   void InstanceCountPlus();
00171   void InstanceCountMinus();
00172 
00173   void SetImprintsCount( unsigned int value );
00174   void ImprintsCountPlus();
00175   void ImprintsCountMinus();
00176     //
00177     // Internal counting mechanism, used to compute unique the names of
00178     // physical volumes created by MakeImprint() methods.
00179 
00180  private:    
00181 
00182   void MakeImprint( G4AssemblyVolume* pAssembly,
00183                     G4LogicalVolume*  pMotherLV,
00184                     G4Transform3D&    transformation,
00185                     G4int copyNumBase = 0,
00186                     G4bool surfCheck = false );
00187     //    
00188     // Function for placement of the given assembly in the given mother
00189     // (called recursively if the assembly contains an assembly).
00190 
00191  private:
00192 
00193   std::vector<G4AssemblyTriplet> fTriplets;
00194     //
00195     // Participating volumes represented as a vector of
00196     // <logical volume, translation, rotation>.
00197 
00198   std::vector<G4VPhysicalVolume*> fPVStore;
00199     //
00200     // We need to keep list of physical volumes created by MakeImprint() method
00201     // in order to be able to cleanup the objects when not needed anymore.
00202     // This requires the user to keep assembly objects in memory during the
00203     // whole job or during the life-time of G4Navigator, logical volume store
00204     // and physical volume store keep pointers to physical volumes generated by
00205     // the assembly volume.
00206     // When an assembly object is about to die it will destroy all its
00207     // generated physical volumes and rotation matrices as well !
00208 
00209   unsigned int fImprintsCounter;
00210     //
00211     // Number of imprints of the given assembly volume.
00212 
00213   static unsigned int fsInstanceCounter;
00214     //
00215     // Class instance counter.
00216 
00217   unsigned int fAssemblyID;
00218     //
00219     // Assembly object ID derived from instance counter at construction time.
00220 
00221 };
00222 
00223 #include "G4AssemblyVolume.icc"
00224 
00225 #endif // G4_ASSEMBLYVOLUME_H

Generated on Mon May 27 17:47:41 2013 for Geant4 by  doxygen 1.4.7