Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:26

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 // Framework include files
0015 #include <DDG4/Geant4HitHandler.h>
0016 #include <DD4hep/DD4hepUnits.h>
0017 #include <CLHEP/Units/SystemOfUnits.h>
0018 
0019 // Geant4 include files
0020 #include <G4NavigationHistory.hh>
0021 
0022 using namespace dd4hep::sim;
0023 
0024 /// Coordinate transformation to global coordinate.
0025 dd4hep::Position Geant4HitHandler::localToGlobal(const DDSegmentation::Vector3D& local)  const   {
0026   return localToGlobal(G4ThreeVector(local.X / dd4hep::mm,local.Y / dd4hep::mm,local.Z / dd4hep::mm));
0027 }
0028 
0029 /// Coordinate transformation to global coordinates.
0030 dd4hep::Position Geant4HitHandler::localToGlobal(const Position& local)  const   {
0031   return localToGlobal(G4ThreeVector(local.X(),local.Y(),local.Z()));
0032 }
0033 
0034 /// Coordinate transformation to global coordinates
0035 dd4hep::Position Geant4HitHandler::localToGlobal(double x, double y, double z)  const    {
0036   return localToGlobal(G4ThreeVector(x,y,z));
0037 }
0038 
0039 /// Coordinate transformation to global coordinates
0040 dd4hep::Position Geant4HitHandler::localToGlobal(const G4ThreeVector& loc)  const    {
0041   G4ThreeVector p = touchable_ptr->GetHistory()->GetTopTransform().Inverse().TransformPoint(loc);
0042   return Position(p.x(),p.y(),p.z());
0043 }
0044 
0045 /// Coordinate transformation to local coordinates
0046 dd4hep::Position Geant4HitHandler::globalToLocal(double x, double y, double z)  const    {
0047   G4ThreeVector p = globalToLocalG4(G4ThreeVector(x,y,z));
0048   return Position(p.x(),p.y(),p.z());
0049 }
0050 
0051 /// Coordinate transformation to local coordinates
0052 dd4hep::Position Geant4HitHandler::globalToLocal(const Position& global)  const    {
0053   G4ThreeVector p = globalToLocalG4(G4ThreeVector(global.X(),global.Y(),global.Z()));
0054   return Position(p.x(),p.y(),p.z());
0055 }
0056 
0057 /// Coordinate transformation to local coordinates
0058 dd4hep::Position Geant4HitHandler::globalToLocal(const G4ThreeVector& global)  const    {
0059   G4ThreeVector p = globalToLocalG4(global);
0060   return Position(p.x(),p.y(),p.z());
0061 }
0062 
0063 /// Coordinate transformation to local coordinates
0064 G4ThreeVector Geant4HitHandler::globalToLocalG4(double x, double y, double z)  const    {
0065   return globalToLocalG4(G4ThreeVector(x,y,z));
0066 }
0067 
0068 /// Coordinate transformation to local coordinates
0069 G4ThreeVector Geant4HitHandler::globalToLocalG4(const G4ThreeVector& global)  const    {
0070   return touchable_ptr->GetHistory()->GetTopTransform().TransformPoint(global);
0071 }