DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4Field.cpp
Go to the documentation of this file.
1 // $Id$
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DDG4/Geant4Field.h"
17 #include "DD4hep/DD4hepUnits.h"
18 #include "CLHEP/Units/SystemOfUnits.h"
19 
20 using namespace DD4hep::Simulation;
21 
23  return m_field.changesEnergy();
24 }
25 
26 void Geant4Field::GetFieldValue(const double pos[4], double *field) const {
27  static const double fac1 = dd4hep::mm/CLHEP::mm;
28  static const double fac2 = CLHEP::tesla/dd4hep::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 }
virtual G4bool DoesFieldChangeEnergy() const
Does field change energy ?
Definition: Geant4Field.cpp:22
bool changesEnergy() const
Does the field change the energy of charged particles?
Definition: Fields.cpp:99
void magneticField(const Position &pos, Direction &field) const
Returns the 3 magnetic field components (x, y, z).
Definition: Fields.h:213
virtual void GetFieldValue(const double pos[4], double *arr) const
Access field values at a given point.
Definition: Geant4Field.cpp:26
static const double tesla
Definition: DD4hepUnits.h:220
Geometry::OverlayedField m_field
Reference to the detector description field.
Definition: Geant4Field.h:43
static const double mm
Definition: DD4hepUnits.h:69