Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions
CCalMagneticField Class Reference

#include <CCalMagneticField.hh>

Inheritance diagram for CCalMagneticField:
G4MagneticField G4ElectroMagneticField G4Field

Public Member Functions

 CCalMagneticField (const G4String &name)
 
 ~CCalMagneticField ()
 
void MagneticField (const double Point[3], double Bfield[3]) const
 
CLHEP::Hep3Vector MagneticField (const CLHEP::Hep3Vector Point) const
 
virtual void GetFieldValue (const double Point[3], double *Bfield) const
 
G4double GetConstantFieldvalue () const
 
- Public Member Functions inherited from G4MagneticField
 G4MagneticField ()
 
virtual ~G4MagneticField ()
 
 G4MagneticField (const G4MagneticField &r)
 
G4MagneticFieldoperator= (const G4MagneticField &p)
 
G4bool DoesFieldChangeEnergy () const
 
virtual void GetFieldValue (const G4double Point[4], G4double *Bfield) const =0
 
- Public Member Functions inherited from G4ElectroMagneticField
 G4ElectroMagneticField ()
 
virtual ~G4ElectroMagneticField ()
 
 G4ElectroMagneticField (const G4ElectroMagneticField &r)
 
G4ElectroMagneticFieldoperator= (const G4ElectroMagneticField &p)
 
- Public Member Functions inherited from G4Field
 G4Field (G4bool gravityOn=false)
 
 G4Field (const G4Field &)
 
virtual ~G4Field ()
 
G4Fieldoperator= (const G4Field &p)
 
G4bool IsGravityActive () const
 
void SetGravityActive (G4bool OnOffFlag)
 
virtual G4FieldClone () const
 

Protected Member Functions

G4FieldManagerGetGlobalFieldManager ()
 

Detailed Description

Definition at line 38 of file CCalMagneticField.hh.

Constructor & Destructor Documentation

CCalMagneticField::CCalMagneticField ( const G4String name)

Definition at line 42 of file CCalMagneticField.cc.

References findDO(), G4cout, G4endl, python.hepunit::mm, openGeomFile(), and tab().

42  :
43  fval(0), pos(0), slope(0), intercept(0) {
44 
45  //Let's open the file
46  G4cout << " ==> Opening file " << filename << " to read magnetic field..."
47  << G4endl;
48  G4String pathName = getenv("CCAL_GLOBALPATH");
49  std::ifstream is;
50  bool ok = openGeomFile(is, pathName, filename);
51 
52  if (ok) {
53  findDO(is, G4String("FLDM"));
54  is >> fval >> npts >> xoff;
55 #ifdef debug
56  G4cout << "Field value " << fval << " # points " << npts << " offset in x "
57  << xoff*mm << G4endl;
58 #endif
59 
60  if (npts > 0) {
61  pos = new G4double[npts];
62  slope = new G4double[npts];
63  intercept = new G4double[npts];
64 
65  for (G4int i = 0; i < npts; i++) {
66  is >> pos[i] >> slope[i] >> intercept[i];
67 #ifdef debug
68  G4cout << tab << "Position " << i << " " << pos[i] << " Slope "
69  << slope[i] << " Intercept " << intercept[i] << G4endl;
70 #endif
71  }
72  }
73 
74  ///////////////////////////////////////////////////////////////
75  // Close the file
76  G4cout << " ==> Closing file " << filename << G4endl;
77  is.close();
78  }
79 }
bool openGeomFile(std::ifstream &is, const G4String &pathname, const G4String &filename)
Definition: CCalutils.cc:116
std::ifstream & findDO(std::ifstream &, const G4String &)
Definition: CCalutils.cc:72
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
std::ostream & tab(std::ostream &)
Definition: CCalutils.cc:89
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
CCalMagneticField::~CCalMagneticField ( )

Definition at line 82 of file CCalMagneticField.cc.

82  {
83  if (pos)
84  delete[] pos;
85  if (slope)
86  delete[] slope;
87  if (intercept)
88  delete[] intercept;
89 }

Member Function Documentation

G4double CCalMagneticField::GetConstantFieldvalue ( ) const
inline

Definition at line 47 of file CCalMagneticField.hh.

Referenced by CCalDetectorConstruction::Construct().

47 {return fval;}
void CCalMagneticField::GetFieldValue ( const double  Point[3],
double *  Bfield 
) const
virtual

Definition at line 141 of file CCalMagneticField.cc.

References MagneticField().

141  {
143 }
void MagneticField(const double Point[3], double Bfield[3]) const
G4FieldManager* CCalMagneticField::GetGlobalFieldManager ( )
protected
void CCalMagneticField::MagneticField ( const double  Point[3],
double  Bfield[3] 
) const

Definition at line 94 of file CCalMagneticField.cc.

References plottest35::c1, G4cout, G4endl, python.hepunit::kilogauss, python.hepunit::m, python.hepunit::mm, and python.hepunit::tesla.

Referenced by GetFieldValue(), and MagneticField().

94  {
95 
96  G4int i=0;
97  for (i=0; i<2; i++) {
98  B[i] = 0*kilogauss;
99  }
100 
101  G4double m1=0, c1=0;
102  G4double xnew = x[0]/mm + xoff;
103  if (npts > 0) {
104  for (i=0; i<npts; i++) {
105  if (xnew > pos[i]*mm) {
106  m1 = slope[i];
107  c1 = intercept[i];
108  }
109  }
110  }
111  G4double scor = c1 + m*xnew;
112  if (scor < 0.) scor = 0.;
113  if (scor > 1.) scor = 1.0;
114 
115  B[2] = scor*fval*kilogauss;
116 #ifdef ddebug
117  G4cout << "Field at x: " << x[0]/mm << "mm (" << xnew << ") = " << B[2]/tesla
118  << "T (m = " << m1 << ", c = " << c1 << ", scale = " << scor << ")"
119  << G4endl;
120 #endif
121 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
tuple c1
Definition: plottest35.py:14
CLHEP::Hep3Vector CCalMagneticField::MagneticField ( const CLHEP::Hep3Vector  Point) const

Definition at line 125 of file CCalMagneticField.cc.

References MagneticField(), CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), test::v, test::x, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

125  {
126 
127  G4double x[3],B[3];
129 
130  x[0] = point.x();
131  x[1] = point.y();
132  x[2] = point.z();
134  v.setX(B[0]);
135  v.setY(B[1]);
136  v.setZ(B[2]);
137  return v;
138 }
void setY(double)
void setZ(double)
void setX(double)
void MagneticField(const double Point[3], double Bfield[3]) const
double G4double
Definition: G4Types.hh:76

The documentation for this class was generated from the following files: