EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicMagneticFieldGrad.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicMagneticFieldGrad.h
1 //
2 // EIC magnetic field map;
3 // object encoding the field directly from gradients
4 //
5 
6 #include <TString.h>
7 #include <TGeoShape.h>
8 #include <TGeoTube.h>
9 #include <TGeoMatrix.h>
10 
11 #ifndef _EIC_MAGNETIC_FIELD_GRAD_
12 #define _EIC_MAGNETIC_FIELD_GRAD_
13 
14 // Go green :-)
15 #define _DEFAULT_YOKE_COLOR_ (kGreen)
16 
18 {
19  public:
20  EicMagneticFieldGrad(const char *fileName = 0, TGeoMatrix *transformation = 0,
21  TGeoShape *shape = 0, int color = _DEFAULT_YOKE_COLOR_);
23 
24  // A complementary call: ideally should define transformation right in the constructor;
25  //void SetTransformation(TGeoMatrix *transformation) { mTransformation = transformation; };
26 
27  // Import field map and set up internal structures if needed; can in principle
28  // be empty call for simple map types;
29  virtual int Initialize();
30  bool Initialized() const { return mInitialized; };
31 
32  // The actual routine indeed is different for different field map implementations;
33  // do not see much sense in providing (even empty) default call here;
34  virtual int GetFieldValue(const double xx[], double B[]) const = 0;
35 
36  TGeoShape *GetShape() const { return mShape; };
37 
38  // The default implementation assumes that mShape is available;
39  virtual bool Contains(const double xx[]) const;
40 
41  const TString &GetFileName() const { return mFileName; };
42 
43  // Incapable per default;
44  virtual bool CapableToBuildYoke() const { return false; };
45 
46  // This is needed only if field map pretends to be able to cook a solid object like
47  // a yoke imitator; in particular EicBeamLineElementMap just strips .csv extension
48  // from the file name;
49  virtual TString GetDetectorName() const { return GetFileName(); };
50  virtual int ConstructGeometry() { return 0; };
51 
52  void SetYokeColor(int color) { mColor = color; };
53  int GetYokeColor() const { return mColor; };
54 
55  virtual TGeoVolume *GetYokeVolume() const { return 0; };
56 
57 
58  private:
59  // NB: format is arbitrary, but Initialize() should be able to interpret it;
60  TString mFileName; // input file name
61 
62  protected:
63  Bool_t mInitialized;
64 
65  TGeoMatrix *mTransformation; // transformation to the world coordinate system
66 
67  // This is needed either to precisely determine simple constant field maps (box/tube, etc)
68  // or to facilitate voxelization in case several field maps need to be imported at once
69  // like for beam line elements;
70  TGeoShape *mShape; // optional bounding shape of this field map
71 
72  Int_t mColor; // yoke color in event display
73 
74  ClassDef(EicMagneticFieldGrad,1)
75 };
76 
77 #endif