REST-for-Physics
v2.3
Rare Event Searches ToolKit for Physics
|
A class to load magnetic field maps and evaluate the field on those maps including interpolation.
TRestAxionMagneticField is a class that allows to load externally defined magnetic fields, and create magnetic volume regions associated to those pre-generated definitions. Once the field maps have been loaded this class will be able to evaluate the field vector at any coordinate (x,y,z). If the coordinate (x,y,z) is ourside any defined region, the returned field will be (0,0,0).
TODO Description of magnetic field interpolation
We can add any number of magnetic volumes inside the RML definition as shown in the following piece of code,
where we produce 2 magnetic regions, using the same magnetic map provided in file magnetic.file
and shifted by x=-30cm and x=30cm. The following parameters might be defined at each addMagneticVolume
entry.
data/magneticField
. They all contain 3 columns for the position in the volume and 3 columns to define the magnetic field vector. It is not the full path but only the name of the file. The default value is "none", that identifies when no input field map is given. If no magnetic field map is provided the field will be constant in the volume definition, and fixed by the field
parameter.position
field. The default value is (0,0,0).(xMax,yMax,zMax)
that defines the bounding box size. The box size will be bounded by the vertex (xMin,yMin,zMin)
and (xMax,yMax,zMax)
. This parameter is required if no field map file is given. If a field map file is provided, the bounding box will be extracted from the field map. In that case, this parameter will be only used for validation.All parameters are optional, and if not provided they will take their default values.
boundMax
and meshSize
parameters. We still have the possibility to define a constant magnetic field vector for that volume using the field
parameter. In that case the method TRestMagneticField::IsFieldConstant will return true.There are two possible formats to provide a magnetic field map.
(-xMax, -yMax, -zMax)
and (xMax,yMax,zMax)
. The field (Bx,By,Bz)
must be given for all the points in a regular grid. The default units are T
for the field and mm
for distances. The size of the grid cells will be deduced from the data. Each row in the text file should provide 6-tabulated values x
, y
, z
, Bx
, By
, Bz
.x
, y
, z
and the 3-field Bx
, By
, Bz
values expressed in 4-bytes size, Float_t.The following example shows different allowed volume definition entries.
Once we have created an instance of this class we will be able to access the magnetic field directly, at any point by using trilinear interpolation.
For example, the following code will retrieve the field at a position found at a distance z=-2m at the magnet axis,
or in a similar way,
where the second argument, true
will enable the warning message system.
The following code evaluates the transversal field component at 1m distance along the Z-axis, for a vector pointing in the direction (0,1,1).
There are also geometric functions that allow to identify the boundaries of the magnetic volume. A test particle will penetrate in the bounding box and identify the moment where the field changes to a value different from (0,0,0) in order("fields.rml", "babyIAXO_2024"); to identify the entrance and exit point.
The following code will return two TVector3 with the magnetic volume entrance and exit coordinates, for a test particle being placed at x=10cm, y=10cm and z=-4m, pointing towards the magnetic field with a slight direction deviation from the magnet axis.
In the other hand, TRestAxionMagneticField::GetVolumeBoundaries will return the bounding box containing that magnetic field.
It is possible to remap the magnetic field in order to increase the size of the grid cells in order to gain in performance. We may only increase the size of the cells by a multiple of the original mesh size.
Given the original mesh granularity by 10mmx10mmx50mm
, we might increase the granularity of the first volume, index 0
to 50mmx50mmx200mm
as follows:
You may visualize the magnetic field profile along tracks towards a vanishing point by using the TRestAxionMagneticField::DrawTracks method, using:
That will produce the following plot:
TODO Review and validate DrawHistogram drawing method and describe its use here.
RESTsoft - Software for Rare Event Searches with TPCs
History of developments:
2019-June: First concept and implementation of TRestAxionMagneticField class. Eve Pachoud
2020-April: Reviewing and validating TRestAxionMagneticField class. Javier Galan and Krešimir Jakovčić
Definition at line 50 of file TRestAxionMagneticField.h.
#include <TRestAxionMagneticField.h>
Public Member Functions | |
Bool_t | CheckOverlaps () |
It will return true if the magnetic the regions overlap. More... | |
TCanvas * | DrawComponents (Int_t volId=0) |
A method that creates a canvas where tracks traversing the magnetic volume are drawm together with their corresponding field intensity profile along the Z-axis. More... | |
TCanvas * | DrawHistogram (TString projection, TString Bcomp, Int_t volIndex=-1, Double_t step=-1, TString style="COLZ0", Double_t depth=-100010.0) |
A method that creates a canvas where magnetic field map is drawn. More... | |
TCanvas * | DrawTracks (TVector3 vanishingPoint, Int_t divisions, Int_t volId=0) |
A method that creates a canvas where tracks traversing the magnetic volume are drawm together with their corresponding field intensity profile along the Z-axis. More... | |
std::vector< Double_t > | GetComponentAlongPath (Int_t axis, TVector3 from, TVector3 to, Double_t dl=1., Int_t Nmax=0) |
It returns a vector describing the magnetic field profile component requested using the axis argument which may take values 0,1,2 for X,Y,Z components. The field profile will be constructed in the track defined between from and to positions given by argument. More... | |
TVector3 | GetFieldAverageTransverseVector (TVector3 from, TVector3 to, Double_t dl=10., Int_t Nmax=0) |
It returns the transverse component of the average magnetic field vector calculated along the line that connects the 3-d coordinates from and to with respect to that line. More... | |
std::vector< TVector3 > | GetFieldBoundaries (TVector3 pos, TVector3 dir, Double_t precision=0, Int_t id=0) |
Finds the in/out particle trajectory boundaries for a particular magnetic region, similar to the method TRestAxionMagneticField::GetVolumeBoudaries, but requiring that the in/out points are the first/last points where the transversal field intensity is not zero. More... | |
TVector3 | GetMagneticField (Double_t x, Double_t y, Double_t z) |
It returns the magnetic field vector at x,y,z. More... | |
TVector3 | GetMagneticField (TVector3 pos, Bool_t showWarning=true) |
It returns the magnetic field vector at TVector3(pos) using trilinear interpolation that is implemented following instructions given at https://en.wikipedia.org/wiki/Trilinear_interpolation. More... | |
unsigned int | GetNumberOfVolumes () |
The number of magnetic volumes loaded into the object. More... | |
Double_t | GetPhotonAbsorptionLength (Double_t x, Double_t y, Double_t z, Double_t en) |
Double_t | GetPhotonAbsorptionLength (Int_t id, Double_t en) |
Double_t | GetPhotonAbsorptionLength (TVector3 pos, Double_t en) |
Double_t | GetPhotonMass (Double_t x, Double_t y, Double_t z, Double_t en) |
Double_t | GetPhotonMass (Int_t id, Double_t en) |
Double_t | GetPhotonMass (TVector3 pos, Double_t en) |
TVector3 | GetTrackDirection () const |
Double_t | GetTrackLength () const |
TVector3 | GetTrackStart () const |
Double_t | GetTransversalComponent (TVector3 position, TVector3 direction) |
It returns the intensity of the transversal magnetic field component for the defined propagation direction and position given by argument. More... | |
std::vector< Double_t > | GetTransversalComponentAlongPath (TVector3 from, TVector3 to, Double_t dl=1., Int_t Nmax=0) |
It returns a vector describing the transversal magnetic field component between from and to positions given by argument. More... | |
Double_t | GetTransversalComponentInParametricTrack (Double_t x) |
It will return the transversal magnetic field component evaluated at a parametric distance x (given by argument) for the track defined inside the class. The track will be defined by the data members fStartTrack and fEndTrack which should be initialized by external means by invoking the method SetTrack( position, direction );. More... | |
Double_t | GetTransversalFieldAverage (TVector3 from, TVector3 to, Double_t dl=1., Int_t Nmax=0) |
It returns the average of the transversal magnetic field intensity between the 3-d coordinates from and to . More... | |
std::vector< TVector3 > | GetVolumeBoundaries (TVector3 pos, TVector3 dir, Int_t id=0) |
Finds the in/out particle trajectory boundaries for a particular magnetic region bounding box. More... | |
TVector3 | GetVolumeCenter (Int_t id) |
it returns the volume position (or center) for the given volume id . More... | |
Int_t | GetVolumeIndex (TVector3 pos) |
It returns the corresponding volume index at the given position. If not found it will return -1. More... | |
TVector3 | GetVolumePosition (Int_t id) |
it returns the volume position (or center) for the given volume id . More... | |
Bool_t | IsFieldConstant (Int_t id) |
It returns true if no magnetic field map was loaded for that volume. More... | |
Bool_t | IsInside (TVector3 pos) |
It returns true if the given position is found inside a magnetic volume. False otherwise. More... | |
void | LoadMagneticVolumes () |
It will load the magnetic field data from the data filenames specified at the RML definition. More... | |
void | PrintMetadata () |
Prints on screen the information about the metadata members of TRestAxionMagneticField. More... | |
void | ReMap (const size_t &n, const TVector3 &newMapSize) |
It allows to remap the magnetic field to a larger mesh size. The new mesh size granularity must be provided by argument, and each dimension must be a factor of the present mesh size. More... | |
void | SetTrack (const TVector3 &position, const TVector3 &direction) |
It initializes the field track boundaries data members of this class using a track position and direction so that these values can be used later on in parameterization. More... | |
TRestAxionMagneticField () | |
Default constructor. More... | |
TRestAxionMagneticField (const char *cfgFileName, std::string name="") | |
Constructor loading data from a config file. More... | |
~TRestAxionMagneticField () | |
Default destructor. More... | |
Public Member Functions inherited from TRestMetadata | |
void | AddLog (std::string log="", bool print=true) |
Add logs to messageBuffer. More... | |
void | DoNotStore () |
If this method is called the metadata information will not be stored in disk. More... | |
TVector2 | Get2DVectorParameterWithUnits (std::string parName, TVector2 defaultValue=TVector2(-1, -1)) |
TVector3 | Get3DVectorParameterWithUnits (std::string parName, TVector3 defaultValue=TVector3(-1, -1, -1)) |
TString | GetCommit () |
Returns the REST commit value stored in fCommit. More... | |
std::string | GetConfigBuffer () |
Returns the config section of this class. More... | |
std::string | GetDataMemberValue (std::string memberName) |
Get the value of data member as string. More... | |
std::vector< std::string > | GetDataMemberValues (std::string memberName, Int_t precision=0) |
Get the value of datamember as a vector of strings. More... | |
TString | GetDataPath () |
Returns a std::string with the path used for data storage. More... | |
Double_t | GetDblParameterWithUnits (std::string parName, Double_t defaultValue=PARAMETER_NOT_FOUND_DBL) |
Gets the value of the parameter name parName, after applying unit conversion. More... | |
Bool_t | GetError () const |
It returns true if an error was identified by a derived metadata class. More... | |
TString | GetErrorMessage () |
Returns a std::string containing the error message. More... | |
TString | GetLibraryVersion () |
Returns the REST libraty version stored in fLibraryVersion. More... | |
TString | GetMainDataPath () |
Gets a std::string with the path used for data storage. More... | |
Int_t | GetNumberOfErrors () const |
Int_t | GetNumberOfWarnings () const |
std::string | GetParameter (std::string parName, TString defaultValue=PARAMETER_NOT_FOUND_STR) |
Returns corresponding REST Metadata parameter from multiple sources. More... | |
std::string | GetSectionName () |
Returns the section name of this class, defined at the beginning of fSectionName. More... | |
TRestStringOutput::REST_Verbose_Level | GetVerboseLevel () |
returns the verboselevel in type of REST_Verbose_Level enumerator More... | |
TString | GetVerboseLevelString () |
returns the verbose level in type of TString More... | |
TString | GetVersion () |
Returns the REST version stored in fVersion. More... | |
Int_t | GetVersionCode () |
UInt_t | GetVersionMajor () const |
UInt_t | GetVersionMinor () const |
UInt_t | GetVersionPatch () const |
Bool_t | GetWarning () const |
It returns true if an error was identified by a derived metadata class. More... | |
TString | GetWarningMessage () |
Returns a std::string containing the warning message. More... | |
virtual void | Initialize () |
Making default settings. More... | |
TRestMetadata * | InstantiateChildMetadata (int index, std::string pattern="") |
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadata instance based on the index given by argument, which defines the element order to be retrieved, 0 for first element found, 1 for the second element found, etc. More... | |
TRestMetadata * | InstantiateChildMetadata (std::string pattern="", std::string name="") |
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadata instance based on the name given by argument. More... | |
Bool_t | isCleanState () const |
Bool_t | isOfficialRelease () const |
Int_t | LoadConfigFromBuffer () |
Initialize data from a string element buffer. More... | |
Int_t | LoadConfigFromElement (TiXmlElement *eSectional, TiXmlElement *eGlobal, std::map< std::string, std::string > envs={}) |
Main starter method. More... | |
Int_t | LoadConfigFromFile (const std::string &configFilename, const std::string §ionName="") |
Give the file name, find out the corresponding section. Then call the main starter. More... | |
virtual void | Merge (const TRestMetadata &) |
TRestMetadata & | operator= (const TRestMetadata &) |
void | Print () |
Implementing TObject::Print() method. More... | |
void | PrintConfigBuffer () |
Print the config xml section stored in the class. More... | |
void | PrintMessageBuffer () |
Print the buffered message. More... | |
virtual void | PrintMetadata () |
Implemented it in the derived metadata class to print out specific metadata information. More... | |
void | PrintTimeStamp (Double_t timeStamp) |
Print the current time on local machine. More... | |
void | SetConfigFile (std::string configFilename) |
set config file path from external More... | |
void | SetError (std::string message="", bool print=true, int maxPrint=5) |
A metadata class may use this method to signal that something went wrong. More... | |
void | SetHostmgr (TRestManager *m) |
Set the host manager for this class. More... | |
void | SetSectionName (std::string sName) |
set the section name, clear the section content More... | |
void | SetVerboseLevel (TRestStringOutput::REST_Verbose_Level v) |
sets the verbose level More... | |
void | SetWarning (std::string message="", bool print=true, int maxPrint=5) |
A metadata class may use this method to signal that something went wrong. More... | |
void | Store () |
If this method is called the metadata information will be stored in disk. More... | |
TRestMetadata (const TRestMetadata &) | |
virtual void | UpdateMetadataMembers () |
Method to allow implementation of specific metadata members updates at inherited classes. More... | |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) |
overwriting the write() method with fStore considered More... | |
void | WriteConfigBuffer (std::string fName) |
Writes the config buffer to a file in append mode. More... | |
~TRestMetadata () | |
TRestMetadata default destructor. More... | |
Private Member Functions | |
Bool_t | FieldLoaded () |
This private method returns true if the magnetic field volumes loaded are the same as the volumes defined. More... | |
MagneticFieldVolume * | GetMagneticVolume (Int_t id) |
It returns a pointer to the corresponding magnetic volume id. More... | |
TVector3 | GetMagneticVolumeNode (size_t id, TVector3 pos) |
It returns the corresponding mesh node in the magnetic volume. More... | |
void | InitFromConfigFile () |
Initialization of TRestAxionMagnetic field members through a RML file. More... | |
void | Initialize () |
Initialization of TRestAxionMagneticField members. More... | |
void | LoadMagneticFieldData (MagneticFieldVolume &mVol, std::vector< std::vector< Float_t > > data) |
A method to help loading magnetic field data, as x,y,z,Bx,By,Bz into a magnetic volume definition using its corresponding mesh. More... | |
Private Attributes | |
std::vector< TVector3 > | fBoundMax |
A vector to store the maximum bounding box values. More... | |
TCanvas * | fCanvas |
A canvas to insert the histogram drawing. More... | |
std::vector< TVector3 > | fConstantField |
A constant field component that will be added to the field map. More... | |
std::vector< std::string > | fFileNames |
The name of the filenames containing the field data. More... | |
TH2D * | fHisto |
A helper histogram to plot the field. More... | |
std::vector< MagneticFieldVolume > | fMagneticFieldVolumes |
A magnetic field volume structure to store field data and mesh. More... | |
std::vector< TVector3 > | fMeshSize |
std::vector< TString > | fMeshType |
The type of the mesh used (default is cylindrical) More... | |
std::vector< TVector3 > | fPositions |
The absolute position of each of the magnetic volumes defined in this class. More... | |
TVector3 | fReMap = TVector3(0, 0, 0) |
A vector that defines the new mesh cell volume. It will re-scale the original fMeshSize. More... | |
TVector3 | fTrackDirection = TVector3(0, 0, 0) |
The track direction used to parameterize the field along a track. More... | |
Double_t | fTrackLength = 0 |
The total length of the track which defines the limit for field parameterization. More... | |
TVector3 | fTrackStart = TVector3(0, 0, 0) |
The start track position used to parameterize the field along a track. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from TRestMetadata | |
std::string | ElementToString (TiXmlElement *ele) |
Convert an TiXmlElement object to string. More... | |
TVector2 | Get2DVectorParameterWithUnits (std::string parName, TiXmlElement *e, TVector2 defaultValue=TVector2(-1, -1)) |
TVector3 | Get3DVectorParameterWithUnits (std::string parName, TiXmlElement *e, TVector3 defaultValue=TVector3(-1, -1, -1)) |
Double_t | GetDblParameterWithUnits (std::string parName, TiXmlElement *e, Double_t defaultVal=PARAMETER_NOT_FOUND_DBL) |
TiXmlElement * | GetElement (std::string eleDeclare, TiXmlElement *e=nullptr) |
Get an xml element from a given parent element, according to its declaration. More... | |
TiXmlElement * | GetElementFromFile (std::string configFilename, std::string NameOrDecalre="") |
Open an xml encoded file and find its element. More... | |
TiXmlElement * | GetElementWithName (std::string eleDeclare, std::string eleName) |
Get an xml element from the default location, according to its declaration and its field "name". More... | |
TiXmlElement * | GetElementWithName (std::string eleDeclare, std::string eleName, TiXmlElement *e) |
Get an xml element from a given parent element, according to its declaration and its field "name". More... | |
std::string | GetFieldValue (std::string fieldName, std::string definition, size_t fromPosition=0) |
Gets field value in an xml element string by parsing it as TiXmlElement. More... | |
std::string | GetFieldValue (std::string parName, TiXmlElement *e) |
Returns the field value of an xml element which has the specified name. More... | |
std::string | GetKEYDefinition (std::string keyName) |
Gets the first key definition for keyName found inside buffer starting at fromPosition. More... | |
std::string | GetKEYDefinition (std::string keyName, size_t &Position) |
std::string | GetKEYDefinition (std::string keyName, size_t &Position, std::string buffer) |
std::string | GetKEYDefinition (std::string keyName, std::string buffer) |
std::string | GetKEYStructure (std::string keyName) |
Gets the first key structure for keyName found inside buffer after fromPosition. More... | |
std::string | GetKEYStructure (std::string keyName, size_t &Position) |
std::string | GetKEYStructure (std::string keyName, size_t &Position, std::string buffer) |
std::string | GetKEYStructure (std::string keyName, size_t &Position, TiXmlElement *ele) |
std::string | GetKEYStructure (std::string keyName, std::string buffer) |
TiXmlElement * | GetNextElement (TiXmlElement *e) |
Get the next sibling xml element of this element, with same eleDeclare. More... | |
std::string | GetParameter (std::string parName, size_t &pos, std::string inputString) |
Returns the value for the parameter name parName found in inputString. More... | |
std::string | GetParameter (std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR) |
Returns the value for the parameter named parName in the given section. More... | |
std::pair< std::string, std::string > | GetParameterAndUnits (std::string parname, TiXmlElement *e=nullptr) |
Returns the unit string of the given parameter of the given xml section. More... | |
std::map< std::string, std::string > | GetParametersList () |
It retrieves a map of all parameter:value found in the metadata class. More... | |
TString | GetSearchPath () |
virtual void | InitFromConfigFile () |
To make settings from rml file. This method must be implemented in the derived class. More... | |
virtual void | InitFromRootFile () |
Method called after the object is retrieved from root file. More... | |
virtual Int_t | LoadSectionMetadata () |
This method does some preparation of xml section. More... | |
void | ReadAllParameters () |
Reflection methods, Set value of a datamember in class according to TRestMetadata::fElement. More... | |
void | ReadParametersList (std::map< std::string, std::string > &list) |
It reads a parameter list and associates it to its corresponding metadata member. par0 --> fPar0. More... | |
std::string | ReplaceConstants (const std::string buffer) |
Identifies "constants" in the input buffer, and replace them with corresponding value. More... | |
std::string | ReplaceVariables (const std::string buffer) |
Identifies environmental variable replacing marks in the input buffer, and replace them with corresponding value. More... | |
void | ReSetVersion () |
Resets the version of TRestRun to REST_RELEASE. Only TRestRun is allowed to update version. More... | |
std::string | SearchFile (std::string filename) |
Search files in current directory and directories specified in "searchPath" section. More... | |
void | SetLibraryVersion (TString version) |
Set the library version of this metadata class. More... | |
TiXmlElement * | StringToElement (std::string definition) |
Parsing a string into TiXmlElement object. More... | |
TRestMetadata () | |
TRestMetadata default constructor. More... | |
TRestMetadata (const char *configFilename) | |
constructor More... | |
void | UnSetVersion () |
Resets the version of TRestRun to -1, in case the file is old REST file. Only TRestRun is allowed to update version. More... | |
Protected Attributes inherited from TRestMetadata | |
std::string | configBuffer |
The buffer where the corresponding metadata section is stored. Filled only during Write() More... | |
std::string | fConfigFileName |
Full name of the rml file. More... | |
std::map< std::string, std::string > | fConstants |
Saving a list of rml constants. name-value std::pair. Constants are temporary for this class only. More... | |
TiXmlElement * | fElement |
Saving the sectional element together with global element. More... | |
TiXmlElement * | fElementGlobal |
Saving the global element, to be passed to the resident class, if necessary. More... | |
Bool_t | fError = false |
It can be used as a way to identify that something went wrong using SetError method. More... | |
TString | fErrorMessage = "" |
A std::string to store an optional error message through method SetError. More... | |
TRestManager * | fHostmgr |
All metadata classes can be initialized and managed by TRestManager. More... | |
Int_t | fNErrors = 0 |
It counts the number of errors notified. More... | |
Int_t | fNWarnings = 0 |
It counts the number of warnings notified. More... | |
std::string | fSectionName |
Section name given in the constructor of the derived metadata class. More... | |
Bool_t | fStore |
This variable is used to determine if the metadata structure should be stored in the ROOT file. More... | |
std::map< std::string, std::string > | fVariables |
Saving a list of rml variables. name-value std::pair. More... | |
TRestStringOutput::REST_Verbose_Level | fVerboseLevel |
Verbose level used to print debug info. More... | |
Bool_t | fWarning = false |
It can be used as a way to identify that something went wrong using SetWarning method. More... | |
TString | fWarningMessage = "" |
It can be used as a way to identify that something went wrong using SetWarning method. More... | |
std::string | messageBuffer |
The buffer to store the output message through TRestStringOutput in this class. More... | |
endl_t | RESTendl |
Termination flag object for TRestStringOutput. More... | |
TRestAxionMagneticField::TRestAxionMagneticField | ( | ) |
Default constructor.
Definition at line 248 of file TRestAxionMagneticField.cxx.
TRestAxionMagneticField::TRestAxionMagneticField | ( | const char * | cfgFileName, |
std::string | name = "" |
||
) |
Constructor loading data from a config file.
If no configuration path is defined using TRestMetadata::SetConfigFilePath the path to the config file must be specified using full path, absolute or relative.
The default behaviour is that the config file must be specified with full path, absolute or relative.
cfgFileName | A const char* giving the path to an RML file. |
name | The name of the specific metadata. It will be used to find the corresponding TRestAxionMagneticField section inside the RML. |
Definition at line 264 of file TRestAxionMagneticField.cxx.
TRestAxionMagneticField::~TRestAxionMagneticField | ( | ) |
Default destructor.
Definition at line 278 of file TRestAxionMagneticField.cxx.
Bool_t TRestAxionMagneticField::CheckOverlaps | ( | ) |
It will return true if the magnetic the regions overlap.
Definition at line 1443 of file TRestAxionMagneticField.cxx.
TCanvas * TRestAxionMagneticField::DrawComponents | ( | Int_t | volId = 0 | ) |
A method that creates a canvas where tracks traversing the magnetic volume are drawm together with their corresponding field intensity profile along the Z-axis.
Definition at line 591 of file TRestAxionMagneticField.cxx.
TCanvas * TRestAxionMagneticField::DrawHistogram | ( | TString | projection, |
TString | Bcomp, | ||
Int_t | volIndex = -1 , |
||
Double_t | step = -1 , |
||
TString | style = "COLZ0" , |
||
Double_t | depth = -100010.0 |
||
) |
A method that creates a canvas where magnetic field map is drawn.
This method is used to create various 2D visualisations of the Bx
, By
and Bz
magnetic field components for a given magnetic field region.
The following input parameters can be specified :
X-Y
, X-Z
and Y-Z
plane, respectively.Bx
, By
and Bz
components, respectively.fMeshSize
.The following example will plot the values of the Bx
component of the magnetic field taken in the X-Y plane positioned at z=5000mm in the magnetic field region with index 0. The step/bin size is 50mm, and the plotting style is "SURF3Z".
where field
is a pointer to the TRestAxionMagneticField object that describes the magnetic field.
Definition at line 337 of file TRestAxionMagneticField.cxx.
TCanvas * TRestAxionMagneticField::DrawTracks | ( | TVector3 | vanishingPoint, |
Int_t | divisions, | ||
Int_t | volId = 0 |
||
) |
A method that creates a canvas where tracks traversing the magnetic volume are drawm together with their corresponding field intensity profile along the Z-axis.
Definition at line 650 of file TRestAxionMagneticField.cxx.
|
inlineprivate |
This private method returns true if the magnetic field volumes loaded are the same as the volumes defined.
Definition at line 102 of file TRestAxionMagneticField.h.
std::vector< Double_t > TRestAxionMagneticField::GetComponentAlongPath | ( | Int_t | axis, |
TVector3 | from, | ||
TVector3 | to, | ||
Double_t | dl = 1. , |
||
Int_t | Nmax = 0 |
||
) |
It returns a vector describing the magnetic field profile component requested using the axis
argument which may take values 0,1,2 for X,Y,Z components. The field profile will be constructed in the track defined between from
and to
positions given by argument.
The differential element dl
is by default 1mm, but it can be modified through the third argument of this function.
The maximum number of divisions (unlimited by default) of the output vector can be fixed by the forth argument. In that case, the differential element dl
length might be increased to fullfil such condition.
Definition at line 1288 of file TRestAxionMagneticField.cxx.
TVector3 TRestAxionMagneticField::GetFieldAverageTransverseVector | ( | TVector3 | from, |
TVector3 | to, | ||
Double_t | dl = 10. , |
||
Int_t | Nmax = 0 |
||
) |
It returns the transverse component of the average magnetic field vector calculated along the line that connects the 3-d coordinates from
and to
with respect to that line.
The differential element dl
defines the step, and it is by default 10mm, but it can be modified through the third argument of this function.
The maximum number of divisions (unlimited by default) can be fixed by the forth argument. In that case, the differential element dl
length might be increased to fullfil such condition.
Definition at line 1385 of file TRestAxionMagneticField.cxx.
std::vector< TVector3 > TRestAxionMagneticField::GetFieldBoundaries | ( | TVector3 | pos, |
TVector3 | dir, | ||
Double_t | precision = 0 , |
||
Int_t | id = 0 |
||
) |
Finds the in/out particle trajectory boundaries for a particular magnetic region, similar to the method TRestAxionMagneticField::GetVolumeBoudaries, but requiring that the in/out points are the first/last points where the transversal field intensity is not zero.
If no precision is given, the mesh size of the corresponding volume will be used as reference. The precision will be meshSize/2.
If no intersection is found the returned std::vector will be empty.
Definition at line 1497 of file TRestAxionMagneticField.cxx.
TVector3 TRestAxionMagneticField::GetMagneticField | ( | Double_t | x, |
Double_t | y, | ||
Double_t | z | ||
) |
It returns the magnetic field vector at x,y,z.
Definition at line 1006 of file TRestAxionMagneticField.cxx.
TVector3 TRestAxionMagneticField::GetMagneticField | ( | TVector3 | pos, |
Bool_t | showWarning = true |
||
) |
It returns the magnetic field vector at TVector3(pos) using trilinear interpolation that is implemented following instructions given at https://en.wikipedia.org/wiki/Trilinear_interpolation.
The warning in case the evaluated point is found outside any volume might be disabled using the showWarning
argument.
Definition at line 1018 of file TRestAxionMagneticField.cxx.
|
inlineprivate |
It returns a pointer to the corresponding magnetic volume id.
Definition at line 105 of file TRestAxionMagneticField.h.
|
private |
It returns the corresponding mesh node in the magnetic volume.
The corresponging node to x,y,z is the bottom, down, left node in the cell volume defined by 8-nodes.
This method will be made private, no reason to use it outside this class.
Definition at line 1433 of file TRestAxionMagneticField.cxx.
|
inline |
The number of magnetic volumes loaded into the object.
Definition at line 133 of file TRestAxionMagneticField.h.
|
inline |
Definition at line 124 of file TRestAxionMagneticField.h.
|
inline |
Definition at line 122 of file TRestAxionMagneticField.h.
|
inline |
Definition at line 123 of file TRestAxionMagneticField.h.
Double_t TRestAxionMagneticField::GetTransversalComponent | ( | TVector3 | position, |
TVector3 | direction | ||
) |
It returns the intensity of the transversal magnetic field component for the defined propagation direction
and position
given by argument.
Definition at line 1236 of file TRestAxionMagneticField.cxx.
std::vector< Double_t > TRestAxionMagneticField::GetTransversalComponentAlongPath | ( | TVector3 | from, |
TVector3 | to, | ||
Double_t | dl = 1. , |
||
Int_t | Nmax = 0 |
||
) |
It returns a vector describing the transversal magnetic field component between from
and to
positions given by argument.
The differential element dl
is by default 1mm, but it can be modified through the third argument of this function.
The maximum number of divisions (unlimited by default) of the output vector can be fixed by the forth argument. In that case, the differential element dl
length might be increased to fullfil such condition.
Definition at line 1251 of file TRestAxionMagneticField.cxx.
Double_t TRestAxionMagneticField::GetTransversalComponentInParametricTrack | ( | Double_t | x | ) |
It will return the transversal magnetic field component evaluated at a parametric distance x
(given by argument) for the track defined inside the class. The track will be defined by the data members fStartTrack and fEndTrack which should be initialized by external means by invoking the method SetTrack( position, direction );.
This method will be used by the integration method
Definition at line 1346 of file TRestAxionMagneticField.cxx.
Double_t TRestAxionMagneticField::GetTransversalFieldAverage | ( | TVector3 | from, |
TVector3 | to, | ||
Double_t | dl = 1. , |
||
Int_t | Nmax = 0 |
||
) |
It returns the average of the transversal magnetic field intensity between the 3-d coordinates from
and to
.
The differential element dl
defines the integration step, and it is by default 1mm, but it can be modified through the third argument of this function.
The maximum number of divisions of the output vector can be fixed by the forth argument. In that case, the differential element dl
length might be increased to fullfil such condition.
Definition at line 1362 of file TRestAxionMagneticField.cxx.
std::vector< TVector3 > TRestAxionMagneticField::GetVolumeBoundaries | ( | TVector3 | pos, |
TVector3 | dir, | ||
Int_t | id = 0 |
||
) |
Finds the in/out particle trajectory boundaries for a particular magnetic region bounding box.
This method checks if the trajectory defined by the position pos
and direction dir
passes through the magnetic field region/volume id
given. If two such points (entry point and exit point) are found, their coordinates are returned. In the example shown in Fig. 1 from TRestAxionFieldPropagationProcess these points are: IN 1 and OUT 1 for the region #1 and IN2 and OUT 2 for the region #2.
If no intersection is found, or the particle is not moving towards the volume, the returned std::vector will be empty.
Definition at line 1477 of file TRestAxionMagneticField.cxx.
TVector3 TRestAxionMagneticField::GetVolumeCenter | ( | Int_t | id | ) |
it returns the volume position (or center) for the given volume id
.
Definition at line 1216 of file TRestAxionMagneticField.cxx.
Int_t TRestAxionMagneticField::GetVolumeIndex | ( | TVector3 | pos | ) |
It returns the corresponding volume index at the given position. If not found it will return -1.
Definition at line 1196 of file TRestAxionMagneticField.cxx.
TVector3 TRestAxionMagneticField::GetVolumePosition | ( | Int_t | id | ) |
it returns the volume position (or center) for the given volume id
.
Definition at line 1221 of file TRestAxionMagneticField.cxx.
|
privatevirtual |
Initialization of TRestAxionMagnetic field members through a RML file.
Reimplemented from TRestMetadata.
Definition at line 1535 of file TRestAxionMagneticField.cxx.
|
privatevirtual |
Initialization of TRestAxionMagneticField members.
Reimplemented from TRestMetadata.
Definition at line 285 of file TRestAxionMagneticField.cxx.
|
inline |
It returns true if no magnetic field map was loaded for that volume.
Definition at line 127 of file TRestAxionMagneticField.h.
Bool_t TRestAxionMagneticField::IsInside | ( | TVector3 | pos | ) |
It returns true if the given position is found inside a magnetic volume. False otherwise.
Definition at line 1208 of file TRestAxionMagneticField.cxx.
|
private |
A method to help loading magnetic field data, as x,y,z,Bx,By,Bz into a magnetic volume definition using its corresponding mesh.
This method will be made private since it will only be used internally.
Definition at line 780 of file TRestAxionMagneticField.cxx.
void TRestAxionMagneticField::LoadMagneticVolumes | ( | ) |
It will load the magnetic field data from the data filenames specified at the RML definition.
This method will be made private since it will only be used internally.
Definition at line 834 of file TRestAxionMagneticField.cxx.
|
virtual |
Prints on screen the information about the metadata members of TRestAxionMagneticField.
Reimplemented from TRestMetadata.
Definition at line 1606 of file TRestAxionMagneticField.cxx.
void TRestAxionMagneticField::ReMap | ( | const size_t & | n, |
const TVector3 & | newMapSize | ||
) |
It allows to remap the magnetic field to a larger mesh size. The new mesh size granularity must be provided by argument, and each dimension must be a factor of the present mesh size.
Definition at line 1146 of file TRestAxionMagneticField.cxx.
void TRestAxionMagneticField::SetTrack | ( | const TVector3 & | position, |
const TVector3 & | direction | ||
) |
It initializes the field track boundaries data members of this class using a track position and direction so that these values can be used later on in parameterization.
Definition at line 1323 of file TRestAxionMagneticField.cxx.
|
private |
A vector to store the maximum bounding box values.
Definition at line 69 of file TRestAxionMagneticField.h.
|
private |
A canvas to insert the histogram drawing.
Definition at line 90 of file TRestAxionMagneticField.h.
|
private |
A constant field component that will be added to the field map.
Definition at line 59 of file TRestAxionMagneticField.h.
|
private |
The name of the filenames containing the field data.
Definition at line 53 of file TRestAxionMagneticField.h.
|
private |
A helper histogram to plot the field.
Definition at line 87 of file TRestAxionMagneticField.h.
|
private |
A magnetic field volume structure to store field data and mesh.
Definition at line 75 of file TRestAxionMagneticField.h.
|
private |
The size of a grid element from the mesh in mm. Initially, it must be the same as the binary input data
Definition at line 63 of file TRestAxionMagneticField.h.
|
private |
The type of the mesh used (default is cylindrical)
Definition at line 66 of file TRestAxionMagneticField.h.
|
private |
The absolute position of each of the magnetic volumes defined in this class.
Definition at line 56 of file TRestAxionMagneticField.h.
|
private |
A vector that defines the new mesh cell volume. It will re-scale the original fMeshSize.
Definition at line 72 of file TRestAxionMagneticField.h.
|
private |
The track direction used to parameterize the field along a track.
Definition at line 81 of file TRestAxionMagneticField.h.
|
private |
The total length of the track which defines the limit for field parameterization.
Definition at line 84 of file TRestAxionMagneticField.h.
|
private |
The start track position used to parameterize the field along a track.
Definition at line 78 of file TRestAxionMagneticField.h.