Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 08:20:13

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/Geant4Field.h>
0016 #include <DD4hep/DD4hepUnits.h>
0017 #include <CLHEP/Units/SystemOfUnits.h>
0018 namespace units = dd4hep;
0019 
0020 using namespace dd4hep::sim;
0021 
0022 G4bool Geant4Field::DoesFieldChangeEnergy() const {
0023   return m_field.changesEnergy();
0024 }
0025 
0026 void Geant4Field::GetFieldValue(const double pos[4], double *field) const {
0027   static const double fac1 = units::mm/CLHEP::mm;
0028   static const double fac2 = CLHEP::tesla/units::tesla;
0029   double p[3] = {pos[0]*fac1, pos[1]*fac1, pos[2]*fac1}; // Convert from CLHEP units to tgeo units
0030   field[0] = field[1] = field[2] = 0.0;                  // Reset field vector
0031   m_field.magneticField(p, field);
0032   field[0] *= fac2;                                      // Convert from tgeo units to CLHEP units
0033   field[1] *= fac2;
0034   field[2] *= fac2;
0035   //::printf("Pos: %7.4f %7.4f %7.4f --> %9g %9g %9g\n",p[0],p[1],p[2],field[0],field[1],field[2]);
0036 }