20#ifndef FIELD_SHIPFIELDMAKER_H_
21#define FIELD_SHIPFIELDMAKER_H_
28#include "TG4VUserPostDetConstruction.h"
32#include "TVirtualMagField.h"
47 typedef std::map<TString, TVirtualMagField*>
SFMap;
65 fieldInfo(
const TString& volName,
const TString& fieldName,
84 void defineUniform(
const TString& name,
const TVector3& BVector);
95 const TVector2& yRange,
const TVector2& zRange,
96 const TVector3& BVector);
110 void defineBell(
const TString& name, Double_t BPeak, Double_t zMiddle,
111 Int_t orient = 1, Double_t tubeR = 500.0, Double_t xy = 0.0,
112 Double_t z = 0.0, Double_t L = 0.0);
126 void defineFieldMap(
const TString& name,
const TString& mapFileName,
127 const TVector3& localCentre = TVector3(0.0, 0.0, 0.0),
128 const TVector3& localAngles = TVector3(0.0, 0.0, 0.0),
129 Bool_t useSymmetry = kFALSE);
140 const TVector3& translation,
141 const TVector3& eulerAngles = TVector3(0.0, 0.0,
153 const TString& field2Name,
154 const TString& field3Name =
"",
155 const TString& field4Name =
"");
162 void defineComposite(
const TString& name, std::vector<TString> fieldNames);
172 const TString& field2Name =
"",
173 const TString& field3Name =
"",
174 const TString& field4Name =
"");
189 Double_t scale = 1.0);
198 Double_t scale = 1.0);
227 Bool_t
gotField(
const TString& name)
const;
234 TVirtualMagField*
getField(
const TString& name)
const;
245 void plotXYField(
const TVector3& xAxis,
const TVector3& yAxis,
246 const std::string& plotFile)
const;
257 void plotZXField(
const TVector3& zAxis,
const TVector3& xAxis,
258 const std::string& plotFile)
const;
269 void plotZYField(
const TVector3& zAxis,
const TVector3& yAxis,
270 const std::string& plotFile)
const;
282 void plotField(Int_t type,
const TVector3& xAxis,
const TVector3& yAxis,
283 const std::string& plotFile)
const;
286 const float xRange = 179,
const float yRange = 317,
287 const float zRange = 1515.5,
288 const float zShift = -4996);
400 void findNode(TGeoVolume* aVolume,
const TString& volName);
Class that defines a magnetic field composed from many fields.
Creates various magnetic fields and assigns them to geometry regions.
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)
std::vector< fieldInfo > localInfo_
Vector of fieldInfo for local fields.
Bool_t gotField(const TString &name) const
Check if we have a field stored with the given name name.
void findNode(TGeoVolume *aVolume, const TString &volName)
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.
ClassDef(ShipFieldMaker, 1)
Generate fieldMap csv file in the given region.
void plotField(Int_t type, const TVector3 &xAxis, const TVector3 &yAxis, const std::string &plotFile) const
Plot the magnetic field in "x-y" plane.
Bool_t gotNode_
Boolean to specify if we have found the volume node we need.
SFMap theFields_
The map storing all created magnetic fields.
TVirtualMagField * getField(const TString &name) const
Get the field stored with the given name name.
void plotZYField(const TVector3 &zAxis, const TVector3 &yAxis, const std::string &plotFile) const
Plot the magnetic field in z-y plane.
ShipCompField * globalField_
The global magnetic field.
std::vector< fieldInfo > regionInfo_
Vector of fieldInfo for regional fields.
std::vector< std::string > stringVect
Typedef of a vector of strings.
void getTransformation(const TString &volName, transformInfo &theInfo)
Get the transformation matrix for the volume position and orientation.
void readInputFile(const std::string &inputFile)
Read an input file to define fields and associated volumes.
TGeoNode * theNode_
The current volume node: used for finding volume transformations.
void plotXYField(const TVector3 &xAxis, const TVector3 &yAxis, const std::string &plotFile) const
Plot the magnetic field in x-y plane.
Double_t Tesla_
Double converting Tesla to kiloGauss (for VMC/FairRoot B field units)
TVirtualMagField * getVolumeField(const TString &volName) const
Get the magnetic field for the given volume.
ShipCompField * getGlobalField() const
Get the global magnetic field.
void defineGlobalField(const TString &field1Name, const TString &field2Name="", const TString &field3Name="", const TString &field4Name="")
Define a composite field from up to four fields.
void defineLocalField(const TString &volName, const TString &fieldName, Double_t scale=1.0)
Define a localised field and volume pairing.
std::map< TString, TVirtualMagField * > SFMap
Typedef for a TString-TVirtualMagField* map.
Bool_t verbose_
Verbose boolean.
void setAllRegionFields()
void defineUniform(const TString &name, const TVector3 &BVector)
Define a uniform field.
virtual void Construct()
Set-up all local and regional fields and assign them to volumes.
virtual ~ShipFieldMaker()
Destructor.
SFMap getAllFields() const
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 defineFieldMapCopy(const TString &name, const TString &mapNameToCopy, const TVector3 &translation, const TVector3 &eulerAngles=TVector3(0.0, 0.0, 0.0))
void defineConstant(const TString &name, const TVector2 &xRange, const TVector2 &yRange, const TVector2 &zRange, const TVector3 &BVector)
Define a constant field.
stringVect splitString(std::string &theString, std::string &splitter) const
Split a string.
void checkLocalFieldMap(TVirtualMagField *&localField, const TString &volName, Double_t scale)
void plotZXField(const TVector3 &zAxis, const TVector3 &xAxis, const std::string &plotFile) const
Plot the magnetic field in z-x plane.
void defineRegionField(const TString &volName, const TString &fieldName, Double_t scale=1.0)
Define a regional (local + global) field and volume pairing.
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)
Structure to hold volume name, field name and field scaling factor.
TString fieldName_
The name of the field.
Double_t scale_
The field scaling factor.
fieldInfo()
Default constructor.
fieldInfo(const TString &volName, const TString &fieldName, Double_t scale=1.0)
Constructor.
TString volName_
The name of the volume.