|
FairShip
|
Creates various magnetic fields and assigns them to geometry regions. More...
#include <ShipFieldMaker.h>


Classes | |
| struct | fieldInfo |
| Structure to hold volume name, field name and field scaling factor. More... | |
| struct | transformInfo |
| Structure to hold transformation information. More... | |
Public Types | |
| typedef std::map< TString, TVirtualMagField * > | SFMap |
| Typedef for a TString-TVirtualMagField* map. | |
| typedef std::vector< std::string > | stringVect |
| Typedef of a vector of strings. | |
Public Member Functions | |
| ShipFieldMaker (Bool_t verbose=kFALSE) | |
| Constructor. | |
| virtual | ~ShipFieldMaker () |
| Destructor. | |
| virtual void | Construct () |
| Set-up all local and regional fields and assign them to volumes. | |
| void | readInputFile (const std::string &inputFile) |
| Read an input file to define fields and associated volumes. | |
| void | defineUniform (const TString &name, const TVector3 &BVector) |
| Define a uniform field. | |
| void | defineConstant (const TString &name, const TVector2 &xRange, const TVector2 &yRange, const TVector2 &zRange, const TVector3 &BVector) |
| Define a constant field. | |
| void | defineBell (const TString &name, Double_t BPeak, Double_t zMiddle, Int_t orient=1, Double_t tubeR=500.0, Double_t xy=0.0, Double_t z=0.0, Double_t L=0.0) |
| Define a Bell field. | |
| void | defineFieldMap (const TString &name, const TString &mapFileName, const TVector3 &localCentre=TVector3(0.0, 0.0, 0.0), const TVector3 &localAngles=TVector3(0.0, 0.0, 0.0), Bool_t useSymmetry=kFALSE) |
| void | defineFieldMapCopy (const TString &name, const TString &mapNameToCopy, const TVector3 &translation, const TVector3 &eulerAngles=TVector3(0.0, 0.0, 0.0)) |
| void | defineComposite (const TString &name, const TString &field1Name, const TString &field2Name, const TString &field3Name="", const TString &field4Name="") |
| Define a composite field from up to four fields. | |
| void | defineComposite (const TString &name, std::vector< TString > fieldNames) |
| Define a composite field from a vector of field names. | |
| void | defineGlobalField (const TString &field1Name, const TString &field2Name="", const TString &field3Name="", const TString &field4Name="") |
| Define a composite field from up to four fields. | |
| void | defineGlobalField (std::vector< TString > fieldNames) |
| Define the Global field using a vector of field names. | |
| void | defineRegionField (const TString &volName, const TString &fieldName, Double_t scale=1.0) |
| Define a regional (local + global) field and volume pairing. | |
| void | defineLocalField (const TString &volName, const TString &fieldName, Double_t scale=1.0) |
| Define a localised field and volume pairing. | |
| ShipCompField * | getGlobalField () const |
| Get the global magnetic field. | |
| SFMap | getAllFields () const |
| TVirtualMagField * | getVolumeField (const TString &volName) const |
| Get the magnetic field for the given volume. | |
| Bool_t | gotField (const TString &name) const |
| Check if we have a field stored with the given name name. | |
| TVirtualMagField * | getField (const TString &name) const |
| Get the field stored with the given name name. | |
| void | plotXYField (const TVector3 &xAxis, const TVector3 &yAxis, const std::string &plotFile) const |
| Plot the magnetic field in x-y plane. | |
| void | plotZXField (const TVector3 &zAxis, const TVector3 &xAxis, const std::string &plotFile) const |
| Plot the magnetic field in z-x plane. | |
| void | plotZYField (const TVector3 &zAxis, const TVector3 &yAxis, const std::string &plotFile) const |
| Plot the magnetic field in z-y plane. | |
| void | plotField (Int_t type, const TVector3 &xAxis, const TVector3 &yAxis, const std::string &plotFile) const |
| Plot the magnetic field in "x-y" plane. | |
| void | generateFieldMap (TString fileName, const float step=2.5, const float xRange=179, const float yRange=317, const float zRange=1515.5, const float zShift=-4996) |
| ClassDef (ShipFieldMaker, 1) | |
| Generate fieldMap csv file in the given region. | |
Protected Member Functions | |
| void | defineUniform (const stringVect &inputLine) |
| Define a uniform field based on information from the inputLine. | |
| void | defineConstant (const stringVect &inputLine) |
| Define a constant field based on information from the inputLine. | |
| void | defineBell (const stringVect &inputLine) |
| Define a Bell field based on information from the inputLine. | |
| void | defineFieldMap (const stringVect &inputLine, Bool_t useSymmetry=kFALSE) |
| Define a field map based on information from the inputLine. | |
| void | defineFieldMapCopy (const stringVect &inputLine) |
| void | defineComposite (const stringVect &inputLine) |
| Define a composite field based on information from the inputLine. | |
| void | defineGlobalField (const stringVect &inputLine) |
| Define the global field based on information from the inputLine. | |
| void | defineRegionField (const stringVect &inputLine) |
| void | setAllRegionFields () |
| void | defineLocalField (const stringVect &inputLine) |
| Define a local field only based on information from the inputLine. | |
| void | checkLocalFieldMap (TVirtualMagField *&localField, const TString &volName, Double_t scale) |
| void | setAllLocalFields () |
| void | getTransformation (const TString &volName, transformInfo &theInfo) |
| Get the transformation matrix for the volume position and orientation. | |
| void | findNode (TGeoVolume *aVolume, const TString &volName) |
Private Member Functions | |
| stringVect | splitString (std::string &theString, std::string &splitter) const |
| Split a string. | |
Private Attributes | |
| ShipCompField * | globalField_ |
| The global magnetic field. | |
| SFMap | theFields_ |
| The map storing all created magnetic fields. | |
| std::vector< fieldInfo > | regionInfo_ |
| Vector of fieldInfo for regional fields. | |
| std::vector< fieldInfo > | localInfo_ |
| Vector of fieldInfo for local fields. | |
| Bool_t | verbose_ |
| Verbose boolean. | |
| Double_t | Tesla_ |
| Double converting Tesla to kiloGauss (for VMC/FairRoot B field units) | |
| TGeoNode * | theNode_ |
| The current volume node: used for finding volume transformations. | |
| Bool_t | gotNode_ |
| Boolean to specify if we have found the volume node we need. | |
Creates various magnetic fields and assigns them to geometry regions.
The internal units here are cm for distances and Tesla for fields. Geant4 units for distance are mm, B fields = 0.001 megaVolt*ns/mm^2 (1 Tesla). VMC units require cm and kGauss (0.1 Tesla). Internally, use cm and Tesla, so keep distances unchanged but multiply B fields by 10 (1 Tesla = 10 kGauss)
This inherits from TG4VUserPostDetConstruction and overloads the Construct() function so that the VMC (re)assigns the G4 magnetic fields to volumes using the input configuration file defined in this class constructor, together with the code below used in the addVMCFields function in python/geomGeant4.py:
geom = ROOT.TG4GeometryManager.Instance() geom.SetUserPostDetConstruction(fieldMaker) geom.ConstructSDandField()
Definition at line 38 of file ShipFieldMaker.h.
| typedef std::map<TString, TVirtualMagField*> ShipFieldMaker::SFMap |
Typedef for a TString-TVirtualMagField* map.
Definition at line 47 of file ShipFieldMaker.h.
| typedef std::vector<std::string> ShipFieldMaker::stringVect |
Typedef of a vector of strings.
Definition at line 50 of file ShipFieldMaker.h.
|
explicit |
Constructor.
Definition at line 43 of file ShipFieldMaker.cxx.
|
virtual |
Destructor.
Definition at line 54 of file ShipFieldMaker.cxx.
|
protected |
Check if we have a local field map and store the volume global transformation
| [in] | localField | The pointer (reference) to the field map (which may be updated) |
| [in] | volName | The name of the volume (which is used to find the transformation) |
| [in] | scale | The B field magnitude scaling factor |
Definition at line 876 of file ShipFieldMaker.cxx.
| ShipFieldMaker::ClassDef | ( | ShipFieldMaker | , |
| 1 | |||
| ) |
Generate fieldMap csv file in the given region.
ClassDef for ROOT
|
virtual |
Set-up all local and regional fields and assign them to volumes.
Definition at line 64 of file ShipFieldMaker.cxx.
|
protected |
Define a Bell field based on information from the inputLine.
| [in] | inputLine | The space separated input line |
Definition at line 293 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineBell | ( | const TString & | name, |
| Double_t | BPeak, | ||
| Double_t | zMiddle, | ||
| Int_t | orient = 1, |
||
| Double_t | tubeR = 500.0, |
||
| Double_t | xy = 0.0, |
||
| Double_t | z = 0.0, |
||
| Double_t | L = 0.0 |
||
| ) |
Define a Bell field.
| [in] | name | The name of the field |
| [in] | BPeak | The peak B field magnitude (Tesla) |
| [in] | zMiddle | The middle z global position of the magnet (cm) |
| [in] | orient | Orientation flag: 1 => Bx = 0 (default), 0 => By = 0 |
| [in] | tubeR | The largest inner radius of the tube ellipse (cm); default = 500 cm |
| [in] | xy | Optional target xy radius region (cm) |
| [in] | z | Optional target start z global position (cm) |
| [in] | L | Optional target region length (cm) |
Definition at line 327 of file ShipFieldMaker.cxx.
|
protected |
Define a composite field based on information from the inputLine.
| [in] | inputLine | The space separated input line |
Definition at line 517 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineComposite | ( | const TString & | name, |
| const TString & | field1Name, | ||
| const TString & | field2Name, | ||
| const TString & | field3Name = "", |
||
| const TString & | field4Name = "" |
||
| ) |
Define a composite field from up to four fields.
| [in] | name | The name of the composite field |
| [in] | field1Name | The name of the first field |
| [in] | field2Name | The name of the second field |
| [in] | field3Name | The name of the third field (optional) |
| [in] | field4Name | The name of the fourth field (optional) |
Definition at line 540 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineComposite | ( | const TString & | name, |
| std::vector< TString > | fieldNames | ||
| ) |
Define a composite field from a vector of field names.
| [in] | name | The name of the composite field |
| [in] | fieldNames | Vector of all of the field names to be combined |
Definition at line 559 of file ShipFieldMaker.cxx.
|
protected |
Define a constant field based on information from the inputLine.
| [in] | inputLine | The space separated input line |
Definition at line 227 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineConstant | ( | const TString & | name, |
| const TVector2 & | xRange, | ||
| const TVector2 & | yRange, | ||
| const TVector2 & | zRange, | ||
| const TVector3 & | BVector | ||
| ) |
Define a constant field.
| [in] | name | The name of the field |
| [in] | xRange | The x range as a TVector2(xMin, xMax) |
| [in] | yRange | The y range as a TVector2(yMin, yMax) |
| [in] | zRange | The z range as a TVector2(zMin, zMax) |
| [in] | BVector | The vector of B field components (Bx, By, Bz) in Tesla |
Definition at line 264 of file ShipFieldMaker.cxx.
|
protected |
Define a field map based on information from the inputLine.
| [in] | inputLine | The space separated input line |
| [in] | useSymmetry | Boolean to specify if we have x-y quadrant symmetry |
Definition at line 349 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineFieldMap | ( | const TString & | name, |
| const TString & | mapFileName, | ||
| const TVector3 & | localCentre = TVector3(0.0, 0.0, 0.0), |
||
| const TVector3 & | localAngles = TVector3(0.0, 0.0, 0.0), |
||
| Bool_t | useSymmetry = kFALSE |
||
| ) |
| [in] | name | The name of the field |
| [in] | mapFileName | The location of the field map ROOT file relative to VMCWORKDIR |
| [in] | localCentre | The TVector3(x,y,z) offset shift applied to all field map coordinates |
| [in] | localAngles | The TVector3(phi, theta, psi) Euler rotation applied to all map coords |
| [in] | useSymmetry | Boolean to specify if the map has quadrant symmetry (default = false) |
Definition at line 389 of file ShipFieldMaker.cxx.
|
protected |
Define a (translated) copy of a field map based on information from the inputLine
| [in] | inputLine | The space separated input line |
Definition at line 441 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineFieldMapCopy | ( | const TString & | name, |
| const TString & | mapNameToCopy, | ||
| const TVector3 & | translation, | ||
| const TVector3 & | eulerAngles = TVector3(0.0, 0.0, 0.0) |
||
| ) |
Define a copy of a field map with a coordinate translation and optional rotation
| [in] | name | The name of the field |
| [in] | mapNameToCopy | The name of the field map that is to be copied |
| [in] | translation | The TVector3(x,y,z) coordinate translation |
| [in] | eulerAngles | The TVector3(phi, theta, psi) Euler angle rotation |
Definition at line 479 of file ShipFieldMaker.cxx.
|
protected |
Define the global field based on information from the inputLine.
| [in] | inputLine | The space separated input line |
Definition at line 587 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineGlobalField | ( | const TString & | field1Name, |
| const TString & | field2Name = "", |
||
| const TString & | field3Name = "", |
||
| const TString & | field4Name = "" |
||
| ) |
Define a composite field from up to four fields.
| [in] | field1Name | The name of the first field |
| [in] | field2Name | The name of the second field (optional) |
| [in] | field3Name | The name of the third field (optional) |
| [in] | field4Name | The name of the fourth field (optional) |
Definition at line 613 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineGlobalField | ( | std::vector< TString > | fieldNames | ) |
Define the Global field using a vector of field names.
| [in] | fieldNames | Vector of all of the field names to be combined |
Definition at line 633 of file ShipFieldMaker.cxx.
|
protected |
Define a local field only based on information from the inputLine.
| [in] | inputLine | The space separated input line |
Definition at line 798 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineLocalField | ( | const TString & | volName, |
| const TString & | fieldName, | ||
| Double_t | scale = 1.0 |
||
| ) |
Define a localised field and volume pairing.
| [in] | volName | The name of the volume |
| [in] | fieldName | The name of the local field for the volume |
| [in] | scale | Optional scale factor for field maps (default = 1.0) |
Definition at line 822 of file ShipFieldMaker.cxx.
|
protected |
Define a regional (local+global) field based on the info from the inputLine
| [in] | inputLine | The space separated input line |
Definition at line 676 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineRegionField | ( | const TString & | volName, |
| const TString & | fieldName, | ||
| Double_t | scale = 1.0 |
||
| ) |
Define a regional (local + global) field and volume pairing.
| [in] | volName | The name of the volume |
| [in] | fieldName | The name of the field for the volume |
| [in] | scale | Optional scale factor for field maps (default = 1.0) |
Definition at line 702 of file ShipFieldMaker.cxx.
|
protected |
Define a uniform field based on information from the inputLine.
| [in] | inputLine | The space separated input line |
Definition at line 182 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::defineUniform | ( | const TString & | name, |
| const TVector3 & | BVector | ||
| ) |
Define a uniform field.
| [in] | name | The name of the field |
| [in] | BVector | The vector of B field components (Bx, By, Bz) in Tesla |
Definition at line 204 of file ShipFieldMaker.cxx.
|
protected |
Update the current geometry node pointer that matches the required volume name
| [in] | aVolume | The current volume, whose nodes are looked at |
| [in] | volName | The required volume name we want to find |
Definition at line 1047 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::generateFieldMap | ( | TString | fileName, |
| const float | step = 2.5, |
||
| const float | xRange = 179, |
||
| const float | yRange = 317, |
||
| const float | zRange = 1515.5, |
||
| const float | zShift = -4996 |
||
| ) |
Definition at line 1290 of file ShipFieldMaker.cxx.
|
inline |
Get the map storing volume names and their associated local magnetic fields
Definition at line 212 of file ShipFieldMaker.h.
| TVirtualMagField * ShipFieldMaker::getField | ( | const TString & | name | ) | const |
Get the field stored with the given name name.
| [in] | name | The name of the field |
Definition at line 1116 of file ShipFieldMaker.cxx.
|
inline |
Get the global magnetic field.
Definition at line 204 of file ShipFieldMaker.h.
|
protected |
Get the transformation matrix for the volume position and orientation.
| [in] | volName | The name of the volume |
| [in] | theInfo | The transformation information structure |
Definition at line 983 of file ShipFieldMaker.cxx.
| TVirtualMagField * ShipFieldMaker::getVolumeField | ( | const TString & | volName | ) | const |
Get the magnetic field for the given volume.
| [in] | volName | The name of the TGeo volume |
Definition at line 1082 of file ShipFieldMaker.cxx.
| Bool_t ShipFieldMaker::gotField | ( | const TString & | name | ) | const |
Check if we have a field stored with the given name name.
| [in] | name | The name of the field |
Definition at line 1097 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::plotField | ( | Int_t | type, |
| const TVector3 & | xAxis, | ||
| const TVector3 & | yAxis, | ||
| const std::string & | plotFile | ||
| ) | const |
Plot the magnetic field in "x-y" plane.
| [in] | type | The coordinate type: 0 = x-y, 1 = z-x and 2 = z-y |
| [in] | xAxis | Three vector specifying the min, max and bin width of the x axis |
| [in] | yAxis | Three vector specifying the min, max and bin width of the y axis |
| [in] | plotFile | The name of the output file containing the plot of the magnetic field |
Definition at line 1150 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::plotXYField | ( | const TVector3 & | xAxis, |
| const TVector3 & | yAxis, | ||
| const std::string & | plotFile | ||
| ) | const |
Plot the magnetic field in x-y plane.
| [in] | xAxis | Three vector specifying the min, max and bin width of the x axis |
| [in] | yAxis | Three vector specifying the min, max and bin width of the y axis |
| [in] | plotFile | The name of the output file containing the plot of the magnetic field |
Definition at line 1135 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::plotZXField | ( | const TVector3 & | zAxis, |
| const TVector3 & | xAxis, | ||
| const std::string & | plotFile | ||
| ) | const |
Plot the magnetic field in z-x plane.
| [in] | zAxis | Three vector specifying the min, max and bin width of the z axis |
| [in] | xAxis | Three vector specifying the min, max and bin width of the x axis |
| [in] | plotFile | The name of the output file containing the plot of the magnetic field |
Definition at line 1140 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::plotZYField | ( | const TVector3 & | zAxis, |
| const TVector3 & | yAxis, | ||
| const std::string & | plotFile | ||
| ) | const |
Plot the magnetic field in z-y plane.
| [in] | zAxis | Three vector specifying the min, max and bin width of the z axis |
| [in] | yAxis | Three vector specifying the min, max and bin width of the y axis |
| [in] | plotFile | The name of the output file containing the plot of the magnetic field |
Definition at line 1145 of file ShipFieldMaker.cxx.
| void ShipFieldMaker::readInputFile | ( | const std::string & | inputFile | ) |
Read an input file to define fields and associated volumes.
| [in] | inputFile | The input text file |
Definition at line 70 of file ShipFieldMaker.cxx.
|
protected |
Definition at line 835 of file ShipFieldMaker.cxx.
|
protected |
Definition at line 715 of file ShipFieldMaker.cxx.
|
private |
Split a string.
| [in] | theString | The string to be split up |
| [in] | splitter | The delimiter that will be used to split up the string |
Definition at line 1338 of file ShipFieldMaker.cxx.
|
private |
The global magnetic field.
Definition at line 404 of file ShipFieldMaker.h.
|
private |
Boolean to specify if we have found the volume node we need.
Definition at line 425 of file ShipFieldMaker.h.
|
private |
Vector of fieldInfo for local fields.
Definition at line 413 of file ShipFieldMaker.h.
|
private |
Vector of fieldInfo for regional fields.
Definition at line 410 of file ShipFieldMaker.h.
|
private |
Double converting Tesla to kiloGauss (for VMC/FairRoot B field units)
Definition at line 419 of file ShipFieldMaker.h.
|
private |
The map storing all created magnetic fields.
Definition at line 407 of file ShipFieldMaker.h.
|
private |
The current volume node: used for finding volume transformations.
Definition at line 422 of file ShipFieldMaker.h.
|
private |
Verbose boolean.
Definition at line 416 of file ShipFieldMaker.h.