56 file.write(
reinterpret_cast<char*
>(&numberOfParametrization),
sizeof(std::int32_t));
58 file.write(
reinterpret_cast<char*
>(
param.BOffsets), DIMENSIONS * numberOfParametrization *
sizeof(
float));
59 file.write(
reinterpret_cast<char*
>(
param.BScales), DIMENSIONS * numberOfParametrization *
sizeof(
float));
60 file.write(
reinterpret_cast<char*
>(
param.BMin), DIMENSIONS * numberOfParametrization *
sizeof(
float));
61 file.write(
reinterpret_cast<char*
>(
param.BMax), DIMENSIONS * numberOfParametrization *
sizeof(
float));
63 file.write(
reinterpret_cast<char*
>(
param.NRows), DIMENSIONS * numberOfParametrization *
sizeof(
float));
64 file.write(
reinterpret_cast<char*
>(
param.ColsAtRowOffset), DIMENSIONS * numberOfParametrization *
sizeof(
float));
65 file.write(
reinterpret_cast<char*
>(
param.CofsAtRowOffset), DIMENSIONS * numberOfParametrization *
sizeof(
float));
67 file.write(
reinterpret_cast<char*
>(&Nrows),
sizeof(std::int32_t));
69 file.write(
reinterpret_cast<char*
>(
param.NColsAtRow), Nrows *
sizeof(int32_t));
70 file.write(
reinterpret_cast<char*
>(
param.CofsAtColOffset), Nrows *
sizeof(int32_t));
72 file.write(
reinterpret_cast<char*
>(&Ncolums),
sizeof(int32_t));
74 file.write(
reinterpret_cast<char*
>(
param.NCofsAtCol), Ncolums *
sizeof(int32_t));
75 file.write(
reinterpret_cast<char*
>(
param.AtColCoefOffset), Ncolums *
sizeof(int32_t));
77 file.write(
reinterpret_cast<char*
>(&Ncoeffs),
sizeof(int32_t));
79 file.write(
reinterpret_cast<char*
>(
param.Coeffs), Ncoeffs *
sizeof(
float));
82int32_t
main(
int argc,
char** argv)
84 bpo::options_description options(
"Field Uniform exporter options");
86 float l3Cur, diCur, beamenergy;
90 options.add_options()(
91 "help,h",
"produce help message")(
92 "l3current,l", bpo::value<
decltype(l3Cur)>()->default_value(30000.f),
"current of the L3 magnet")(
93 "dipolecurrent,d", bpo::value<
decltype(diCur)>()->default_value(6000.f),
"current of the Dipole magnet")(
94 "beamenergy,b", bpo::value<
decltype(beamenergy)>()->default_value(7000.f),
"beam energy")(
95 "beamtype,t", bpo::value<
decltype(beamtype)>()->default_value(
"pp"),
"beam type")(
96 "uniform,u", bpo::value<
decltype(uniform)>()->default_value(
false),
"uniform")(
97 "filename,f", bpo::value<
decltype(beamtype)>()->default_value(
"field.uniform"),
"output filename");
99 using namespace bpo::command_line_style;
100 auto style = (allow_short | short_allow_adjacent | short_allow_next | allow_long | long_allow_adjacent | long_allow_next | allow_sticky | allow_dash_for_short);
101 bpo::variables_map varmap;
104 bpo::command_line_parser(argc, argv)
109 }
catch (std::exception
const& e) {
110 LOGP(error,
"error parsing options of {}: {}", argv[0], e.what());
114 if (varmap.count(
"help")) {
115 LOG(info) << options << std::endl;
119 l3Cur = varmap[
"l3current"].as<
decltype(l3Cur)>();
120 diCur = varmap[
"dipolecurrent"].as<
decltype(diCur)>();
121 beamenergy = varmap[
"beamenergy"].as<
decltype(beamenergy)>();
122 beamtype = varmap[
"beamtype"].as<
decltype(beamtype)>();
123 uniform = varmap[
"uniform"].as<
decltype(uniform)>();
127 const auto gpufield = std::make_unique<GPUDisplayMagneticField>(field.get());
129 auto file = std::ofstream(
filename, std::ios::out | std::ios::binary);
131 saveSegments(
file, gpufield->mSolSegDim1, gpufield->mSolSegDim2, gpufield->mSolSegDim3, *gpufield->mSolenoidSegments);
132 saveSegments(
file, gpufield->mDipSegDim1, gpufield->mDipSegDim2, gpufield->mDipSegDim3, *gpufield->mDipoleSegments);
133 saveParams<o2::gpu::GPUDisplayMagneticField::DIMENSIONS>(
file, gpufield->mSolParametrizations, gpufield->mSolRows, gpufield->mSolColumns, gpufield->mSolCoefficients, *gpufield->mSolenoidParameterization);
134 saveParams<o2::gpu::GPUDisplayMagneticField::DIMENSIONS>(
file, gpufield->mDipParametrizations, gpufield->mDipRows, gpufield->mDipColumns, gpufield->mDipCoefficients, *gpufield->mDipoleParameterization);
static MagneticField * createFieldMap(float l3Current=-30000., float diCurrent=-6000., Int_t convention=0, Bool_t uniform=kFALSE, float beamenergy=7000, const Char_t *btype="pp", const std::string path=std::string(gSystem->Getenv("VMCWORKDIR"))+std::string("/Common/maps/mfchebKGI_sym.root"))