67 static std::string_view closerNominalLabel(
float current);
83 DD4hep_VolumeBasedMagneticFieldESProducerFromDB::DD4hep_VolumeBasedMagneticFieldESProducerFromDB(
85 : debug_(iConfig.getUntrackedParameter<
bool>(
"debugBuilder")) {
90 const int current = iConfig.
getParameter<
int>(
"valueOverride");
100 <<
" (from RunInfo DB); using map configuration with label: " <<
label;
101 return iGet(
"",
label);
109 <<
" (from valueOverride card); using map configuration with label: " <<
label;
125 if (iConfig->
version ==
"parametrizedMagneticField") {
126 return iGet.nothing();
143 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
151 return std::shared_ptr<MagFieldConfig const>(
config.product(), [](
auto*) {});
159 std::unique_ptr<MagneticField> paramField =
162 edm::LogInfo(
"MagneticField") <<
"(DD4hep) Version: " << conf->version
163 <<
" geometryVersion: " << conf->geometryVersion
164 <<
" slaveFieldVersion: " << conf->slaveFieldVersion;
166 if (conf->version ==
"parametrizedMagneticField") {
175 if (!conf->keys.empty()) {
180 if (!conf->gridFiles.empty()) {
187 std::unique_ptr<std::vector<unsigned char> > tb = blob->getUncompressedBlob();
189 string sblob(tb->begin(), tb->end());
191 sblob.rfind(
"</DDDefinition>"),
192 "<MaterialSection label=\"materials.xml\"><ElementaryMaterial name=\"materials:Vacuum\" density=\"1e-13*mg/cm3\" " 193 "symbol=\" \" atomicWeight=\"1*g/mole\" atomicNumber=\"1\"/></MaterialSection>");
201 return std::make_unique<VolumeBasedMagneticField>(conf->geometryVersion,
208 paramField.release(),
213 constexpr std::array<int, 7>
nominalCurrents = {{-1, 0, 9558, 14416, 16819, 18268, 19262}};
214 constexpr std::array<std::string_view, 7> nominalLabels = {{
"3.8T",
"0T",
"2T",
"3T",
"3.5T",
"3.8T",
"4T"}};
217 for (;
i < (
int)nominalLabels.size() - 1;
i++) {
219 return nominalLabels[
i];
221 return nominalLabels[
i];
226 desc.addUntracked<
bool>(
"debugBuilder",
false);
227 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_
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)
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
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.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
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)
cms::DDDetector * detector_
constexpr std::array< int, 7 > nominalCurrents
std::vector< MagVolume6Faces * > endcapVolumes() const