67 static std::string_view closerNominalLabel(
float current);
78 int cachedGeometryVersion_{-1};
85 DD4hep_VolumeBasedMagneticFieldESProducerFromDB::DD4hep_VolumeBasedMagneticFieldESProducerFromDB(
87 : debug_(iConfig.getUntrackedParameter<
bool>(
"debugBuilder")),
88 useMergeFileIfAvailable_(iConfig.getParameter<
bool>(
"useMergeFileIfAvailable")) {
93 const int current = iConfig.
getParameter<
int>(
"valueOverride");
103 <<
" (from RunInfo DB); using map configuration with label: " <<
label;
104 return iGet(
"",
label);
112 <<
" (from valueOverride card); using map configuration with label: " <<
label;
128 if (iConfig->
version ==
"parametrizedMagneticField") {
129 return iGet.nothing();
146 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
154 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
162 std::unique_ptr<MagneticField> paramField =
165 edm::LogInfo(
"MagneticField") <<
"(DD4hep) Version: " << conf->version
166 <<
" geometryVersion: " << conf->geometryVersion
167 <<
" slaveFieldVersion: " << conf->slaveFieldVersion;
169 if (conf->version ==
"parametrizedMagneticField") {
178 if (!conf->keys.empty()) {
183 if (!conf->gridFiles.empty()) {
190 edm::LogError(
"MagneticField") <<
"MF Geometry needs to be re-created since current changed (cached: " 192 <<
"), which is not supported by dd4hep" << endl;
196 std::unique_ptr<std::vector<unsigned char> > tb = blob->getUncompressedBlob();
198 string sblob(tb->begin(), tb->end());
199 sblob.insert(sblob.rfind(
"</DDDefinition>"),
200 "<MaterialSection label=\"materials.xml\"><ElementaryMaterial name=\"materials:Vacuum\" " 201 "density=\"1e-13*mg/cm3\" " 202 "symbol=\" \" atomicWeight=\"1*g/mole\" atomicNumber=\"1\"/></MaterialSection>");
211 return std::make_unique<VolumeBasedMagneticField>(conf->geometryVersion,
218 paramField.release(),
223 constexpr std::array<int, 7>
nominalCurrents = {{-1, 0, 9558, 14416, 16819, 18268, 19262}};
224 constexpr std::array<std::string_view, 7> nominalLabels = {{
"3.8T",
"0T",
"2T",
"3T",
"3.5T",
"3.8T",
"4T"}};
227 for (;
i < (
int)nominalLabels.size() - 1;
i++) {
229 return nominalLabels[
i];
231 return nominalLabels[
i];
236 desc.addUntracked<
bool>(
"debugBuilder",
false);
237 desc.add<
bool>(
"useMergeFileIfAvailable",
true);
238 desc.add<
int>(
"valueOverride", -1)->setComment(
"Force value of current (in A); take the value from DB if < 0.");
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
edm::ESGetToken< MagFieldConfig, IdealMagneticFieldRecord > chosenConfigToken_
static const std::string kDD4hep
T getParameter(std::string const &) const
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > mayGetConfigToken_
std::unique_ptr< MagneticField > produce(const IdealMagneticFieldRecord &iRecord)
~DD4hep_VolumeBasedMagneticFieldESProducerFromDB() override
std::string to_string(const V &value)
edm::ESGetToken< FileBlob, MFGeometryFileRcd > mayConsumeBlobToken_
Log< level::Error, false > LogError
std::shared_ptr< MagFieldConfig const > chooseConfigAtRuntime(const IdealMagneticFieldRecord &iRecord)
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > knownFromParamConfigToken_
T getUntrackedParameter(std::string const &, T const &) const
void usesResources(std::vector< std::string > const &)
static std::unique_ptr< MagneticField > get(std::string version, const edm::ParameterSet ¶meters)
int cachedGeometryVersion_
void addDefault(ParameterSetDescription const &psetDescription)
static std::string_view closerNominalLabel(float current)
std::shared_ptr< MagFieldConfig const > chooseConfigViaParameter(const IdealMagneticFieldRecord &iRecord)
ESHandle< ProductT > getHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Log< level::Info, false > LogInfo
void setGridFiles(const TableFileMap &gridFiles)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string version
Version of the data tables to be used.
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
std::vector< MagVolume6Faces * > barrelVolumes() const
void build(const cms::DDDetector *det)
int geometryVersion
Version of the geometry to be used.
void setScaling(const std::vector< int > &keys, const std::vector< double > &values)
const bool useMergeFileIfAvailable_
cms::DDDetector * detector_
constexpr std::array< int, 7 > nominalCurrents
std::vector< MagVolume6Faces * > endcapVolumes() const