CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Field.cc
Go to the documentation of this file.
3 
4 //#include "Geometry/Vector/interface/GlobalPoint.h"
6 
7 #include "G4Mag_UsualEqRhs.hh"
8 
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 
13 
14 using namespace sim;
15 
16 G4Mag_UsualEqRhs * Field::fieldEquation() { return theFieldEquation; }
17 
18 Field::Field(const MagneticField * f, double d)
19  : G4MagneticField(), theCMSMagneticField(f),theDelta(d)
20 {
21 }
22 
24 
25 void Field::GetFieldValue(const double xyz[3],double bfield[3]) const
26 {
27 
28  //
29  // this is another trick to check on a NaN, maybe it's even CPU-faster...
30  // but ler's stick to system function edm::isNotFinite(...) for now
31  //
32  // if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) )
33  if ( edm::isNotFinite(xyz[0]+xyz[1]+xyz[2]) != 0 )
34  {
35  throw SimG4Exception( "SimG4CoreMagneticField: Corrupted Event - NaN detected (position)" ) ;
36  }
37 
38  static float oldx[3] = {1.0e12,1.0e12,1.0e12};
39  static double b[3];
40 
41  if (theDelta>0. &&
42  fabs(oldx[0]-xyz[0])<theDelta &&
43  fabs(oldx[1]-xyz[1])<theDelta &&
44  fabs(oldx[2]-xyz[2])<theDelta)
45  {
46  // old b good enough
47  bfield[0] = b[0];
48  bfield[1] = b[1];
49  bfield[2] = b[2];
50  return;
51  }
52 
53  const GlobalPoint g(xyz[0]/cm,xyz[1]/cm,xyz[2]/cm);
55  b[0] = v.x()*tesla;
56  b[1] = v.y()*tesla;
57  b[2] = v.z()*tesla;
58 
59  oldx[0] = xyz[0];
60  oldx[1] = xyz[1];
61  oldx[2] = xyz[2];
62 
63  bfield[0] = b[0];
64  bfield[1] = b[1];
65  bfield[2] = b[2];
66 }
67 
68 void Field::fieldEquation(G4Mag_UsualEqRhs* e) { theFieldEquation = e; }
69 
const MagneticField * theCMSMagneticField
Definition: Field.h:19
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
virtual ~Field()
Definition: Field.cc:23
T y() const
Definition: PV3DBase.h:63
G4Mag_UsualEqRhs * theFieldEquation
Definition: Field.h:20
Definition: sim.h:19
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
bool isNotFinite(T x)
Definition: isFinite.h:10
G4Mag_UsualEqRhs * fieldEquation()
Definition: Field.cc:16
T z() const
Definition: PV3DBase.h:64
virtual void GetFieldValue(const double p[3], double b[3]) const
Definition: Field.cc:25
double f[11][100]
double b
Definition: hdecay.h:120
double theDelta
Definition: Field.h:21
Field(const MagneticField *f, double d)
Definition: Field.cc:18
T x() const
Definition: PV3DBase.h:62