CMS 3D CMS Logo

sim::Field Class Reference

#include <SimG4Core/MagneticField/interface/Field.h>

List of all members.

Public Member Functions

 Field (const MagneticField *f, double d)
void fieldEquation (G4Mag_UsualEqRhs *e)
G4Mag_UsualEqRhs * fieldEquation ()
virtual void GetFieldValue (const double p[3], double b[3]) const
virtual ~Field ()

Private Attributes

const MagneticFieldtheCMSMagneticField
double theDelta
G4Mag_UsualEqRhs * theFieldEquation


Detailed Description

Definition at line 10 of file Field.h.


Constructor & Destructor Documentation

Field::Field ( const MagneticField f,
double  d 
)

Definition at line 17 of file Field.cc.

00018     : G4MagneticField(), theCMSMagneticField(f),theDelta(d)
00019 {
00020 }

Field::~Field (  )  [virtual]

Definition at line 22 of file Field.cc.

00022 {}


Member Function Documentation

void Field::fieldEquation ( G4Mag_UsualEqRhs *  e  ) 

Definition at line 67 of file Field.cc.

References theFieldEquation.

00067 { theFieldEquation = e; }

G4Mag_UsualEqRhs * Field::fieldEquation (  ) 

Definition at line 15 of file Field.cc.

References theFieldEquation.

00015 { return theFieldEquation; }

void Field::GetFieldValue ( const double  p[3],
double  b[3] 
) const [virtual]

Definition at line 24 of file Field.cc.

References b, g, MagneticField::inTesla(), edm::isnan(), theCMSMagneticField, theDelta, v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

00025 { 
00026 
00027     //
00028     // this is another trick to check on a NaN, maybe it's even CPU-faster...
00029     // but ler's stick to system function isnan(...) for now
00030     //
00031     // if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) )
00032     if ( isnan(xyz[0]+xyz[1]+xyz[2]) != 0 )
00033     {
00034        throw SimG4Exception( "SimG4CoreMagneticField: Corrupted Event - NaN detected (position)" ) ;
00035     }
00036     
00037     static float oldx[3] = {1.0e12,1.0e12,1.0e12};
00038     static double b[3];
00039 
00040     if (theDelta>0. &&
00041         fabs(oldx[0]-xyz[0])<theDelta &&
00042         fabs(oldx[1]-xyz[1])<theDelta &&
00043         fabs(oldx[2]-xyz[2])<theDelta) 
00044     {
00045         // old b good enough
00046         bfield[0] = b[0]; 
00047         bfield[1] = b[1]; 
00048         bfield[2] = b[2];
00049         return;
00050     }
00051 
00052     const GlobalPoint g(xyz[0]/cm,xyz[1]/cm,xyz[2]/cm);
00053     GlobalVector v = theCMSMagneticField->inTesla(g);
00054     b[0] = v.x()*tesla;
00055     b[1] = v.y()*tesla;
00056     b[2] = v.z()*tesla;
00057 
00058     oldx[0] = xyz[0]; 
00059     oldx[1] = xyz[1]; 
00060     oldx[2] = xyz[2];
00061 
00062     bfield[0] = b[0]; 
00063     bfield[1] = b[1]; 
00064     bfield[2] = b[2];
00065 }


Member Data Documentation

const MagneticField* sim::Field::theCMSMagneticField [private]

Definition at line 19 of file Field.h.

Referenced by GetFieldValue().

double sim::Field::theDelta [private]

Definition at line 21 of file Field.h.

Referenced by GetFieldValue().

G4Mag_UsualEqRhs* sim::Field::theFieldEquation [private]

Definition at line 20 of file Field.h.

Referenced by fieldEquation().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:52:32 2009 for CMSSW by  doxygen 1.5.4