EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicConstantField.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicConstantField.h
1 // AYK (ayk@bnl.gov), 2014/09/03
2 //
3 // Constant field handler;
4 //
5 
6 #include <TGeoBBox.h>
7 #include <TGeoTube.h>
8 
9 #include <EicMagneticFieldMap.h>
10 
11 #ifndef _EIC_CONSTANT_FIELD_
12 #define _EIC_CONSTANT_FIELD_
13 
14 //
15 // Assume, that 1) *full* box/tube dimensions are given, 2) units are [cm] and [kGs];
16 //
17 
19 {
20  public:
21  EicConstantField(double bX = 0.0, double bY = 0.0, double bZ = 0.0) {
22  mFieldLocal[0] = bX; mFieldLocal[1] = bY; mFieldLocal[2] = bZ;
23 
24  memset(mFieldGlobal, 0x00, sizeof(mFieldGlobal));
25  };
27 
28  // Initialize() & GetFieldValue() can in principle be the same for box/tube (and
29  // other, if needed) constant fields, optionally restricted by a TGeoShape;
30  int Initialize();
31  int GetFieldValue(const double xx[], double B[]) const;
32 
33  protected:
34  // Obviously I only need to save local field values; the global ones are transient guys;
35  Double_t mFieldLocal[3]; // constant field value in the object local coordinate system
36  mutable Double_t mFieldGlobal[3];
37 
38  ClassDef(EicConstantField,1)
39 };
40 
42 {
43  public:
45  EicConstantBoxField(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax,
46  double bX, double bY, double bZ): EicConstantField(bX, bY, bZ) {
47  mShape = dynamic_cast<TGeoShape*>(TGeoBBox((xMax - xMin)/2, (yMax - yMin)/2,
48  (zMax - zMin)/2).Clone());
49 
50  // Prefer not to use fOrigin[];
51  mTransformation = new TGeoTranslation((xMax + xMin)/2, (yMax + yMin)/2, (zMax + zMin)/2);
52  };
53  EicConstantBoxField(double xSize, double ySize, double zSize,
54  double bX, double bY, double bZ, TGeoMatrix *transformation = 0):
55  EicConstantField(bX, bY, bZ) {
56  mShape = dynamic_cast<TGeoShape*>(TGeoBBox(xSize/2, ySize/2, zSize/2).Clone());
57 
58  mTransformation = transformation;
59  };
61 
62  ClassDef(EicConstantBoxField,1)
63 };
64 
66 {
67  public:
69  EicConstantTubeField(double rMin, double rMax, double length,
70  double bX, double bY, double bZ, TGeoMatrix *transformation = 0):
71  EicConstantField(bX, bY, bZ) {
72  mShape = dynamic_cast<TGeoShape*>(TGeoTube(rMin, rMax, length/2).Clone());
73 
74  mTransformation = transformation;
75  };
77 
78  ClassDef(EicConstantTubeField,1)
79 };
80 
81 #endif