66 static std::string_view closerNominalLabel(
float current);
80 DD4hep_VolumeBasedMagneticFieldESProducerFromDB::DD4hep_VolumeBasedMagneticFieldESProducerFromDB(
82 : debug_(iConfig.getUntrackedParameter<
bool>(
"debugBuilder")) {
87 const int current = iConfig.
getParameter<
int>(
"valueOverride");
97 <<
" (from RunInfo DB); using map configuration with label: " <<
label;
98 return iGet(
"",
label);
106 <<
" (from valueOverride card); using map configuration with label: " <<
label;
122 if (iConfig->
version ==
"parametrizedMagneticField") {
123 return iGet.nothing();
136 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
144 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
152 std::unique_ptr<MagneticField> paramField =
155 edm::LogInfo(
"MagneticField") <<
"(DD4hep) Version: " << conf->version
156 <<
" geometryVersion: " << conf->geometryVersion
157 <<
" slaveFieldVersion: " << conf->slaveFieldVersion;
159 if (conf->version ==
"parametrizedMagneticField") {
168 if (!conf->keys.empty()) {
173 if (!conf->gridFiles.empty()) {
180 std::unique_ptr<std::vector<unsigned char> > tb = blob->getUncompressedBlob();
182 string sblob(tb->begin(), tb->end());
184 sblob.rfind(
"</DDDefinition>"),
185 "<MaterialSection label=\"materials.xml\"><ElementaryMaterial name=\"materials:Vacuum\" density=\"1e-13*mg/cm3\" "
186 "symbol=\" \" atomicWeight=\"1*g/mole\" atomicNumber=\"1\"/></MaterialSection>");
188 auto ddet = make_unique<cms::DDDetector>(
"cmsMagneticField:MAGF", sblob,
true);
190 builder.
build(ddet.get());
193 return std::make_unique<VolumeBasedMagneticField>(conf->geometryVersion,
200 paramField.release(),
205 constexpr std::array<int, 7>
nominalCurrents = {{-1, 0, 9558, 14416, 16819, 18268, 19262}};
206 constexpr std::array<std::string_view, 7> nominalLabels = {{
"3.8T",
"0T",
"2T",
"3T",
"3.5T",
"3.8T",
"4T"}};
209 for (;
i < (
int)nominalLabels.size() - 1;
i++) {
211 return nominalLabels[
i];
213 return nominalLabels[
i];
218 desc.addUntracked<
bool>(
"debugBuilder",
false);
219 desc.add<
int>(
"valueOverride", -1)->setComment(
"Force value of current (in A); take the value from DB if < 0.");