CMS 3D CMS Logo

Public Member Functions | Private Attributes

sim::Field Class Reference

#include <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.

    : G4MagneticField(), theCMSMagneticField(f),theDelta(d)
{
}
Field::~Field ( ) [virtual]

Definition at line 22 of file Field.cc.

{}

Member Function Documentation

G4Mag_UsualEqRhs * Field::fieldEquation ( )

Definition at line 15 of file Field.cc.

References theFieldEquation.

{ return theFieldEquation; }
void Field::fieldEquation ( G4Mag_UsualEqRhs *  e)

Definition at line 67 of file Field.cc.

References 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::detail::isnan(), theCMSMagneticField, theDelta, v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

{ 

    //
    // this is another trick to check on a NaN, maybe it's even CPU-faster...
    // but ler's stick to system function isnan(...) for now
    //
    // if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) )
    if ( std::isnan(xyz[0]+xyz[1]+xyz[2]) != 0 )
    {
       throw SimG4Exception( "SimG4CoreMagneticField: Corrupted Event - NaN detected (position)" ) ;
    }
    
    static float oldx[3] = {1.0e12,1.0e12,1.0e12};
    static double b[3];

    if (theDelta>0. &&
        fabs(oldx[0]-xyz[0])<theDelta &&
        fabs(oldx[1]-xyz[1])<theDelta &&
        fabs(oldx[2]-xyz[2])<theDelta) 
    {
        // old b good enough
        bfield[0] = b[0]; 
        bfield[1] = b[1]; 
        bfield[2] = b[2];
        return;
    }

    const GlobalPoint g(xyz[0]/cm,xyz[1]/cm,xyz[2]/cm);
    GlobalVector v = theCMSMagneticField->inTesla(g);
    b[0] = v.x()*tesla;
    b[1] = v.y()*tesla;
    b[2] = v.z()*tesla;

    oldx[0] = xyz[0]; 
    oldx[1] = xyz[1]; 
    oldx[2] = xyz[2];

    bfield[0] = b[0]; 
    bfield[1] = b[1]; 
    bfield[2] = b[2];
}

Member Data Documentation

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().