Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:24

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDG4_GEANT4PLACEMENTPARAMETERISATION_H
0014 #define DDG4_GEANT4PLACEMENTPARAMETERISATION_H
0015 
0016 /// Framework include files
0017 #include <DD4hep/Volumes.h>
0018 
0019 /// Geant4 include files
0020 #include <G4Transform3D.hh>
0021 #include <G4PVParameterised.hh>
0022 #include <G4VPVParameterisation.hh>
0023 
0024 /// C/C++ include files
0025 #include <vector>
0026 
0027 /// Namespace for the AIDA detector description toolkit
0028 namespace dd4hep {
0029 
0030   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0031   namespace sim {
0032 
0033     /// Class to dump the records of the intrinsic Geant4 event model.
0034     /**
0035      *  \author  M.Frank
0036      *  \version 1.0
0037      *  \ingroup DD4HEP_SIMULATION
0038      */
0039     class Geant4PlacementParameterisation : public G4VPVParameterisation  {
0040     public:
0041 
0042       /// Helper structure to cache dimension variabled from setup parameters
0043       struct Dimension  {
0044     G4Transform3D delta        {   };
0045     G4ThreeVector translation  {   };
0046     std::size_t   count        { 0 };
0047 
0048       public:
0049     /// Initializing constructor
0050     Dimension(const G4Transform3D& d, std::size_t c)
0051       : delta(d), translation(d.getTranslation()), count(c) {}
0052     /// Default constructor
0053     Dimension() = default;
0054     /// Move Constructor
0055     Dimension(Dimension&&) = default;
0056     /// Copy Constructor
0057     Dimension(const Dimension&) = default;
0058     /// Assignment operator
0059     Dimension& operator=(Dimension&&) = default;
0060     /// Assignment operator
0061     Dimension& operator=(const Dimension&) = default;
0062       };
0063 
0064       using Parameters   = PlacedVolume::Object::Parameterisation;
0065       using Rotations    = std::vector<G4RotationMatrix>;
0066       using Translations = std::vector<G4ThreeVector>;
0067       using Dimensions   = std::vector<Dimension>;
0068 
0069       /// Setup parameters: Reference to the DD4hep placement handle
0070       PlacedVolume         m_placement;
0071       /// Setup parameters: Reference to the DD4hep placement parameters
0072       const Parameters&    m_params;
0073       /// Setup parameters: Initial parameterisation position
0074       Dimension            m_start          {  };
0075       /// Setup parameters: Dimensional parameter setup
0076       Dimensions           m_dimensions     {  };
0077 
0078       /// Axis definition
0079       EAxis                m_axis           { kUndefined };
0080       /// Total number of parameterized cells
0081       size_t               m_num_cells      { 0UL };
0082       /// Optimization flag for simple parameteristions
0083       bool                 m_have_rotation  { false };
0084 
0085       /// Cached rotations and translations for complex parameterisations
0086       mutable Rotations    m_rotations;
0087       mutable Translations m_translations;
0088 
0089       /// Callback to store resulting rotation
0090       void operator()(const G4Transform3D& transform);
0091 
0092     public:
0093       /// Initializing constructor
0094       Geant4PlacementParameterisation(PlacedVolume pv);
0095       /// Standard destructor
0096       virtual ~Geant4PlacementParameterisation() = default;
0097       /// Access Axis direction
0098       EAxis axis()  const     {   return m_axis;  }
0099       /// Access number of replicas
0100       std::size_t count()  const;
0101       /// G4VPVParameterisation overload: Compute copy transformation
0102       virtual void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* vol) const override;
0103     };
0104   }    // End namespace sim
0105 }      // End namespace dd4hep
0106 #endif // DDG4_GEANT4PLACEMENTPARAMETERISATION_H