56 auto fieldDescriptions = pset.get<std::vector<fhicl::ParameterSet>>(
"FieldDescriptions");
58 MagneticFieldDescription fieldDescription;
59 for(
auto itr : fieldDescriptions)
61 fieldDescription.fMode = (mag::MagFieldMode_t)(itr.get<
int>(
"UseField"));
68 if(fieldDescription.fMode == mag::kNoBFieldMode)
71 fieldDescription.fScaleFactor = itr.get<
float>(
"ScaleFactor", 1.0);
72 fieldDescription.fVolume = itr.get<
std::string>(
"MagnetizedVolume");
73 fieldDescription.fGeoVol = gGeoManager->FindVolumeFast(fieldDescription.fVolume.c_str());
76 if(fieldDescription.fGeoVol ==
nullptr)
79 <<
"cannot locate volume " << fieldDescription.fVolume <<
" in gGeoManager, bail";
84 std::vector<double> defaultField = {0, 0, 0};
85 std::vector<double> field = itr.get<std::vector<double>>(
"ConstantField", defaultField);
89 for(
size_t i = 0; i < 3; ++i)
90 fieldDescription.fField[i] = field[i];
92 if(fieldDescription.fMode == mag::kFieldRZMapMode)
94 fieldDescription.fFieldMapFilename = itr.get<
std::string>(
"FieldMapFilename");
96 std::string fn2 = fieldDescription.fFieldMapFilename;
98 sp.find_file(fn2, fullname);
101 if(fullname.empty() ||
stat(fullname.c_str(), &sb) != 0)
104 <<
"Input magnetic field file " << fn2 <<
" not found in FW_SEARCH_PATH!\n";
108 struct RZFieldMap rzmap;
112 std::vector<double> ZAxis = itr.get<std::vector<double>>(
"ZAxis");
113 rzmap.ZAxis.SetXYZ(ZAxis[0], ZAxis[1], ZAxis[2]);
115 std::vector<double> CoordOffset = itr.get<std::vector<double>>(
"CoordOffset");
116 rzmap.CoordOffset.SetXYZ(CoordOffset[0], CoordOffset[1], CoordOffset[2]);
118 std::chrono::duration<double> elapsed_seconds =
end - start;
119 std::cout <<
"GArMagneticField: Finished reading RZ map in " << elapsed_seconds.count() <<
"s, now setting it: " << rzmap.dr
121 std::cout <<
"Array sizes (R, Z): " << rzmap.br.size() <<
" " << rzmap.br[0].size()
123 fieldDescription.fRZFieldMap = rzmap;
126 if(fieldDescription.fMode == mag::kFieldXYZMapMode)
128 fieldDescription.fFieldMapFilename = itr.get<
std::string>(
"FieldMapFilename");
130 std::string fn2 = fieldDescription.fFieldMapFilename;
132 sp.find_file(fn2, fullname);
135 if(fullname.empty() ||
stat(fullname.c_str(), &sb) != 0)
138 <<
"Input magnetic field file " << fn2 <<
" not found in FW_SEARCH_PATH!\n";
142 struct XYZFieldMap xyzmap;
146 std::vector<double> ZAxis
147 = itr.get<std::vector<double>>(
"ZAxis", std::vector<double>{0.0, 0.0, 1.0});
148 xyzmap.ZAxis.SetXYZ(ZAxis[0], ZAxis[1], ZAxis[2]);
150 xyzmap.CoordOffset.SetXYZ(xyzmap.xo, xyzmap.yo, xyzmap.zo);
151 std::chrono::duration<double> elapsed_seconds =
end - start;
152 std::cout <<
"GArMagneticField: Finished reading XYZ map in " << elapsed_seconds.count()
155 xyzmap.UseSymmetry = itr.get<
bool>(
"UseSymmetry",
false);
156 std::cout <<
"GArMagneticField: Is map symmetric - " << std::boolalpha
158 fieldDescription.fXYZFieldMap = xyzmap;
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void ReadXYZFile(const std::string &filename, XYZFieldMap &xyzmap, const float unitFactor)
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
void ReadRZFile(const std::string &filename, RZFieldMap &rzmap)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)