23 #ifndef _TRestAxionMagneticField 24 #define _TRestAxionMagneticField 26 #include <TRestMetadata.h> 34 #include "TRestMesh.h" 38 struct MagneticFieldVolume {
46 std::vector<std::vector<std::vector<TVector3>>> field;
81 void InitFromConfigFile();
83 void LoadMagneticFieldData(MagneticFieldVolume& mVol, std::vector<std::vector<Float_t>> data);
85 TVector3 GetMagneticVolumeNode(MagneticFieldVolume mVol, TVector3 pos);
89 Bool_t
FieldLoaded() {
return GetNumberOfVolumes() == fMagneticFieldVolumes.size(); }
93 if (!FieldLoaded()) LoadMagneticVolumes();
94 if (fMagneticFieldVolumes.size() > id)
95 return &fMagneticFieldVolumes[
id];
97 RESTError <<
"TRestAxionMagneticField::GetMagneticVolume. Id outside limits!" << RESTendl;
103 void LoadMagneticVolumes();
107 if (GetMagneticVolume(
id))
return GetMagneticVolume(
id)->field.size() == 0;
114 Bool_t CheckOverlaps();
116 std::vector<TVector3> GetVolumeBoundaries(TVector3 pos, TVector3 dir, Int_t
id = 0);
117 std::vector<TVector3> GetFieldBoundaries(TVector3 pos, TVector3 dir, Double_t precision = 0,
120 TVector3 GetMagneticField(Double_t x, Double_t y, Double_t z);
121 TVector3 GetMagneticField(TVector3 pos, Bool_t showWarning =
true);
123 Double_t GetPhotonMass(Double_t x, Double_t y, Double_t z, Double_t en);
124 Double_t GetPhotonMass(TVector3 pos, Double_t en);
125 Double_t GetPhotonMass(Int_t
id, Double_t en);
127 Double_t GetPhotonAbsorptionLength(Double_t x, Double_t y, Double_t z, Double_t en);
128 Double_t GetPhotonAbsorptionLength(TVector3 pos, Double_t en);
129 Double_t GetPhotonAbsorptionLength(Int_t
id, Double_t en);
131 Int_t GetVolumeIndex(TVector3 pos);
132 Bool_t IsInside(TVector3 pos);
134 TVector3 GetVolumePosition(Int_t
id);
135 TVector3 GetVolumeCenter(Int_t
id);
137 Double_t GetTransversalComponent(TVector3 position, TVector3 direction);
139 std::vector<Double_t> GetTransversalComponentAlongPath(TVector3 from, TVector3 to, Double_t dl = 1.,
142 Double_t GetTransversalFieldAverage(TVector3 from, TVector3 to, Double_t dl = 1., Int_t Nmax = 0);
144 TVector3 GetFieldAverageTransverseVector(TVector3 from, TVector3 to, Double_t dl = 10., Int_t Nmax = 0);
146 TCanvas* DrawHistogram(TString projection, TString Bcomp, Int_t volIndex = -1, Double_t step = -1,
147 TString style =
"COLZ0", Double_t depth = -100010.0);
149 TCanvas* DrawTracks(TVector3 vanishingPoint, Int_t divisions, Int_t volId = 0);
151 void PrintMetadata();
std::vector< TVector3 > fMeshSize
The size of a grid element from the mesh in mm.
std::vector< TVector3 > fBoundMax
A vector to store the maximum bounding box values.
A class to load magnetic field maps and evaluate the field on those maps including interpolation...
std::vector< TString > fMeshType
The type of the mesh used (default is cylindrical)
std::vector< TVector3 > fConstantField
A constant field component that will be added to the field map.
Int_t GetNumberOfVolumes()
The number of magnetic volumes loaded into the object.
TCanvas * fCanvas
A canvas to insert the histogram drawing.
std::vector< TVector3 > fPositions
The absolute position of each of the magnetic volumes defined in this class.
std::vector< std::string > fFileNames
The name of the filenames containing the field data.
Bool_t IsFieldConstant(Int_t id)
It returns true if no magnetic field map was loaded for that volume.
Bool_t FieldLoaded()
This private method returns true if the magnetic field volumes loaded are the same as the volumes def...
std::vector< MagneticFieldVolume > fMagneticFieldVolumes
A magnetic field volume structure to store field data and mesh.
TH2D * fHisto
A helper histogram to plot the field.
A basic class inheriting from TObject to help creating a node grid definition.
MagneticFieldVolume * GetMagneticVolume(Int_t id)
It returns a pointer to the corresponding magnetic volume id.