Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0014 #ifndef DDG4_GEANT4HELPERS_H
0015 #define DDG4_GEANT4HELPERS_H
0016 
0017 /// Framework include files
0018 #include <DD4hep/Objects.h>
0019 
0020 /// Geant4 include files
0021 #include <G4ThreeVector.hh>
0022 #include <G4Transform3D.hh>
0023 #include <G4RotationMatrix.hh>
0024 #include <geomdefs.hh>
0025 
0026 /// C/C++ include files
0027 #include <functional>
0028 
0029 /// Namespace for the AIDA detector description toolkit
0030 namespace dd4hep {
0031 
0032   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0033   namespace sim {
0034 
0035     /// Extract G4 rotation matrix from ROOT matrices
0036     G4RotationMatrix g4Rotation(const TGeoMatrix* matrix);
0037     G4RotationMatrix g4Rotation(const TGeoMatrix& matrix);
0038     G4RotationMatrix g4Rotation(const TGeoRotation* rot);
0039     G4RotationMatrix g4Rotation(const TGeoRotation& rot);
0040     G4RotationMatrix g4Rotation(const Rotation3D& rot);
0041     G4RotationMatrix g4Rotation(const RotationZYX& rot);
0042 
0043     /// Generate parameterised placements in 1 dimension according to transformation delta
0044     G4Transform3D
0045     generate_placements(const G4Transform3D& start,
0046             const G4Transform3D& delta,
0047             std::size_t count,
0048             const std::function<void(const G4Transform3D& delta)>& callback);
0049 
0050     /// Generate parameterised placements in 2 dimensions according to transformation delta
0051     G4Transform3D
0052     generate_placements(const G4Transform3D& start,
0053             const G4Transform3D& delta1,
0054             std::size_t count1,
0055             const G4Transform3D& delta2,
0056             std::size_t count2,
0057             const std::function<void(const G4Transform3D& delta)>& callback);
0058 
0059     /// Generate parameterised placements in 3 dimensions according to transformation delta
0060     G4Transform3D
0061     generate_placements(const G4Transform3D& start,
0062             const G4Transform3D& delta1,
0063             std::size_t count1,
0064             const G4Transform3D& delta2,
0065             std::size_t count2,
0066             const G4Transform3D& delta3,
0067             std::size_t count3,
0068             const std::function<void(const G4Transform3D& delta)>& callback);
0069     
0070     /// These conversions automatically apply the conversion from CM to MM!
0071 
0072     void          g4Transform(const double* translation, const double* rotation, G4Transform3D& transform);
0073     void          g4Transform(const Position& pos, const Rotation3D& rot, G4Transform3D& transform);
0074     void          g4Transform(const double* translation, G4Transform3D& transform);
0075     void          g4Transform(const Transform3D& matrix, G4Transform3D& transform);
0076     void          g4Transform(const TGeoMatrix* matrix, G4Transform3D& transform);
0077     void          g4Transform(const TGeoMatrix& matrix, G4Transform3D& transform);
0078 
0079     G4Transform3D g4Transform(const double* translation);
0080     G4Transform3D g4Transform(const double* translation, const double* rotation);
0081 
0082     G4Transform3D g4Transform(const Transform3D& matrix);
0083     G4Transform3D g4Transform(const Position& pos, const Rotation3D& rot);
0084     G4Transform3D g4Transform(const Position& pos, const RotationZYX& rot);
0085 
0086     G4Transform3D g4Transform(const TGeoMatrix* matrix);
0087     G4Transform3D g4Transform(const TGeoMatrix& matrix);
0088     G4Transform3D g4Transform(const TGeoTranslation* translation, const TGeoRotation* rotation);
0089     G4Transform3D g4Transform(const TGeoTranslation& translation, const TGeoRotation& rotation);
0090 
0091     std::pair<double, EAxis> extract_axis(const Transform3D& trafo);
0092 
0093   }    // End namespace sim
0094 }      // End namespace dd4hep
0095 #endif // DDG4_GEANT4HELPERS_H