65 static std::string_view closerNominalLabel(
float current);
79 DD4hep_VolumeBasedMagneticFieldESProducerFromDB::DD4hep_VolumeBasedMagneticFieldESProducerFromDB(
81 : debug_(iConfig.getUntrackedParameter<
bool>(
"debugBuilder")) {
85 const int current = iConfig.
getParameter<
int>(
"valueOverride");
95 <<
" (from RunInfo DB); using map configuration with label: " <<
label;
96 return iGet(
"",
label);
104 <<
" (from valueOverride card); using map configuration with label: " <<
label;
120 if (iConfig->
version ==
"parametrizedMagneticField") {
121 return iGet.nothing();
134 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
142 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
150 std::unique_ptr<MagneticField> paramField =
153 edm::LogInfo(
"MagneticField") <<
"Version: " << conf->version <<
" geometryVersion: " << conf->geometryVersion
154 <<
" slaveFieldVersion: " << conf->slaveFieldVersion;
156 if (conf->version ==
"parametrizedMagneticField") {
165 if (!conf->keys.empty()) {
170 if (!conf->gridFiles.empty()) {
177 std::unique_ptr<std::vector<unsigned char> > tb = blob->getUncompressedBlob();
179 string sblob(tb->begin(), tb->end());
181 sblob.rfind(
"</DDDefinition>"),
182 "<MaterialSection label=\"materials.xml\"><ElementaryMaterial name=\"materials:Vacuum\" density=\"1e-13*mg/cm3\" "
183 "symbol=\" \" atomicWeight=\"1*g/mole\" atomicNumber=\"1\"/></MaterialSection>");
185 auto ddet = make_unique<cms::DDDetector>(
"", sblob,
true);
187 builder.
build(ddet.get());
190 return std::make_unique<VolumeBasedMagneticField>(conf->geometryVersion,
197 paramField.release(),
202 constexpr std::array<int, 7>
nominalCurrents = {{-1, 0, 9558, 14416, 16819, 18268, 19262}};
203 constexpr std::array<std::string_view, 7> nominalLabels = {{
"3.8T",
"0T",
"2T",
"3T",
"3.5T",
"3.8T",
"4T"}};
206 for (;
i < (
int)nominalLabels.size() - 1;
i++) {
208 return nominalLabels[
i];
210 return nominalLabels[
i];
215 desc.addUntracked<
bool>(
"debugBuilder",
false);
216 desc.add<
int>(
"valueOverride", -1)->setComment(
"Force value of current (in A); take the value from DB if < 0.");