DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4Field.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DDG4/Geant4Field.h>
16 #include <DD4hep/DD4hepUnits.h>
17 #include <CLHEP/Units/SystemOfUnits.h>
18 namespace units = dd4hep;
19 
20 using namespace dd4hep::sim;
21 
23  return m_field.changesEnergy();
24 }
25 
26 void Geant4Field::GetFieldValue(const double pos[4], double *field) const {
27  static const double fac1 = units::mm/CLHEP::mm;
28  static const double fac2 = CLHEP::tesla/units::tesla;
29  double p[3] = {pos[0]*fac1, pos[1]*fac1, pos[2]*fac1}; // Convert from CLHEP units to tgeo units
30  field[0] = field[1] = field[2] = 0.0; // Reset field vector
31  m_field.magneticField(p, field);
32  field[0] *= fac2; // Convert from tgeo units to CLHEP units
33  field[1] *= fac2;
34  field[2] *= fac2;
35  //::printf("Pos: %7.4f %7.4f %7.4f --> %9g %9g %9g\n",p[0],p[1],p[2],field[0],field[1],field[2]);
36 }
Geant4Field.h
dd4hep::sim::Geant4Field::DoesFieldChangeEnergy
virtual G4bool DoesFieldChangeEnergy() const override
Does field change energy ?
Definition: Geant4Field.cpp:22
dd4hep::sim::Geant4Field::m_field
OverlayedField m_field
Reference to the detector description field.
Definition: Geant4Field.h:42
dd4hep::sim::Geant4Field::GetFieldValue
virtual void GetFieldValue(const double pos[4], double *arr) const override
Access field values at a given point.
Definition: Geant4Field.cpp:26
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::OverlayedField::changesEnergy
bool changesEnergy() const
Does the field change the energy of charged particles?
Definition: Fields.cpp:104
dd4hep::OverlayedField::magneticField
void magneticField(const Position &pos, double *field) const
Returns the 3 magnetic field components (x, y, z).
Definition: Fields.cpp:140
DD4hepUnits.h