EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicMagneticFieldMap.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicMagneticFieldMap.h
1 //
2 // AYK (ayk@bnl.gov), 2014/09/03
3 //
4 // EIC magnetic field map;
5 //
6 
7 #include <TString.h>
8 #include <TGeoShape.h>
9 #include <TGeoTube.h>
10 #include <TGeoMatrix.h>
11 
12 #ifndef _EIC_MAGNETIC_FIELD_MAP_
13 #define _EIC_MAGNETIC_FIELD_MAP_
14 
15 // Go green :-)
16 #define _DEFAULT_YOKE_COLOR_ (kGreen)
17 
19 {
20  public:
21  EicMagneticFieldMap(const char *fileName = 0, TGeoMatrix *transformation = 0,
22  TGeoShape *shape = 0, int color = _DEFAULT_YOKE_COLOR_);
24 
25  // A complementary call: ideally should define transformation right in the constructor;
26  //void SetTransformation(TGeoMatrix *transformation) { mTransformation = transformation; };
27 
28  // Import field map and set up internal structures if needed; can in principle
29  // be empty call for simple map types;
30  virtual int Initialize();
31  bool Initialized() const { return mInitialized; };
32 
33  // The actual routine indeed is different for different field map implementations;
34  // do not see much sense in providing (even empty) default call here;
35  virtual int GetFieldValue(const double xx[], double B[]) const = 0;
36 
37  TGeoShape *GetShape() const { return mShape; };
38 
39  // The default implementation assumes that mShape is available;
40  virtual bool Contains(const double xx[]) const;
41 
42  const TString &GetFileName() const { return mFileName; };
43 
44  // Incapable per default;
45  virtual bool CapableToBuildYoke() const { return false; };
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  // Another clear hack in order to avoid basename() call modifying 'const char *' under Mac OS;
58  protected:
59  const char *BasenameWrapper(const char *fname) const;
60 
61  private:
62  // NB: format is arbitrary, but Initialize() should be able to interpret it;
63  TString mFileName; // input file name
64 
65  protected:
66  UInt_t mMD5BufferSize; // basically it is MD5_DIGEST_LENGTH constant from openssl/md5.h
67  UChar_t *mMD5Signature; //[mMD5BufferSize] input file MD5 signature
68  Bool_t mInitialized;
69 
70  TGeoMatrix *mTransformation; // transformation to the world coordinate system
71 
72  // This is needed either to precisely determine simple constant field maps (box/tube, etc)
73  // or to facilitate voxelization in case several field maps need to be imported at once
74  // like for beam line elements;
75  TGeoShape *mShape; // optional bounding shape of this field map
76 
77  Int_t mColor; // yoke color in event display
78 
79  int GetMD5Signature(unsigned char output[]);
80 
81  ClassDef(EicMagneticFieldMap,14)
82 };
83 
84 #endif