CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes
magneticfield::VolumeBasedMagneticFieldESProducerFromDB Class Reference
Inheritance diagram for magneticfield::VolumeBasedMagneticFieldESProducerFromDB:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

std::shared_ptr< MagFieldConfig const > chooseConfigAtRuntime (const IdealMagneticFieldRecord &iRecord)
 
std::shared_ptr< MagFieldConfig const > chooseConfigViaParameter (const IdealMagneticFieldRecord &iRecord)
 
const VolumeBasedMagneticFieldESProducerFromDBoperator= (const VolumeBasedMagneticFieldESProducerFromDB &)=delete
 
std::unique_ptr< MagneticFieldproduce (const IdealMagneticFieldRecord &iRecord)
 
 VolumeBasedMagneticFieldESProducerFromDB (const edm::ParameterSet &iConfig)
 
 VolumeBasedMagneticFieldESProducerFromDB (const VolumeBasedMagneticFieldESProducerFromDB &)=delete
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Static Private Member Functions

static std::string_view closerNominalLabel (float current)
 

Private Attributes

edm::ESGetToken< MagFieldConfig, IdealMagneticFieldRecordchosenConfigToken_
 
const bool debug_
 
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcdknownFromParamConfigToken_
 
edm::ESGetToken< FileBlob, MFGeometryFileRcdmayConsumeBlobToken_
 
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcdmayGetConfigToken_
 

Additional Inherited Members

- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Detailed Description

Definition at line 49 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

Constructor & Destructor Documentation

◆ VolumeBasedMagneticFieldESProducerFromDB() [1/2]

VolumeBasedMagneticFieldESProducerFromDB::VolumeBasedMagneticFieldESProducerFromDB ( const edm::ParameterSet iConfig)

Definition at line 78 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

References chooseConfigAtRuntime(), chooseConfigViaParameter(), chosenConfigToken_, closerNominalLabel(), MagFieldConfig::geometryVersion, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), edm::ESSharedResourceNames::kDDGeometry, knownFromParamConfigToken_, label, RunInfo::m_avg_current, mayConsumeBlobToken_, mayGetConfigToken_, alignCSCRings::s, edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), edm::ESProducer::usesResources(), and MagFieldConfig::version.

79  : debug_(iConfig.getUntrackedParameter<bool>("debugBuilder")) {
80  std::string const myConfigLabel = "VBMFESChoice";
81 
83  //Based on configuration, pick algorithm to produce the proper MagFieldConfig with a specific label
84  const int current = iConfig.getParameter<int>("valueOverride");
85  if (current < 0) {
86  //We do not know what to get until we first read RunInfo
89  .setMayConsume(
91  [](auto const& iGet, edm::ESTransientHandle<RunInfo> iHandle) {
92  auto const label = closerNominalLabel(iHandle->m_avg_current);
93  edm::LogInfo("MagneticField") << "Current :" << iHandle->m_avg_current
94  << " (from RunInfo DB); using map configuration with label: " << label;
95  return iGet("", label);
96  },
98 
99  } else {
100  //we know exactly what we are going to get
101  auto const label = closerNominalLabel(current);
102  edm::LogInfo("MagneticField") << "Current :" << current
103  << " (from valueOverride card); using map configuration with label: " << label;
104  auto cc = setWhatProduced(
107  }
108 
109  auto const label = iConfig.getUntrackedParameter<std::string>("label");
110  auto const myConfigTag = edm::ESInputTag(iConfig.getParameter<std::string>("@module_label"), myConfigLabel);
111 
112  //We use the MagFieldConfig created above to decide which FileBlob to use
113  auto cc = setWhatProduced(this, label);
114  cc.setMayConsume(
116  [](auto const& iGet, edm::ESTransientHandle<MagFieldConfig> iConfig) {
117  if (iConfig->version == "parametrizedMagneticField") {
118  return iGet.nothing();
119  }
120  return iGet("", std::to_string(iConfig->geometryVersion));
121  },
123  chosenConfigToken_ = cc.consumes(myConfigTag); //Use same tag as the choice
124 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string to_string(const V &value)
Definition: OMSAccess.h:71
T getUntrackedParameter(std::string const &, T const &) const
void usesResources(std::vector< std::string > const &)
Definition: ESProducer.cc:117
char const * label
static const std::string kDDGeometry
std::shared_ptr< MagFieldConfig const > chooseConfigAtRuntime(const IdealMagneticFieldRecord &iRecord)
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > mayGetConfigToken_
Log< level::Info, false > LogInfo
edm::ESGetToken< MagFieldConfig, IdealMagneticFieldRecord > chosenConfigToken_
std::string version
Version of the data tables to be used.
std::shared_ptr< MagFieldConfig const > chooseConfigViaParameter(const IdealMagneticFieldRecord &iRecord)
float m_avg_current
Definition: RunInfo.h:28
int geometryVersion
Version of the geometry to be used.
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > knownFromParamConfigToken_

◆ VolumeBasedMagneticFieldESProducerFromDB() [2/2]

magneticfield::VolumeBasedMagneticFieldESProducerFromDB::VolumeBasedMagneticFieldESProducerFromDB ( const VolumeBasedMagneticFieldESProducerFromDB )
delete

Member Function Documentation

◆ chooseConfigAtRuntime()

std::shared_ptr< MagFieldConfig const > VolumeBasedMagneticFieldESProducerFromDB::chooseConfigAtRuntime ( const IdealMagneticFieldRecord iRecord)

Definition at line 126 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

References edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getHandle(), and mayGetConfigToken_.

Referenced by VolumeBasedMagneticFieldESProducerFromDB().

127  {
129 
130  //just forward what we just got but do not take ownership
131  return std::shared_ptr<MagFieldConfig const>(config.product(), [](auto*) {});
132 }
Definition: config.py:1
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > mayGetConfigToken_

◆ chooseConfigViaParameter()

std::shared_ptr< MagFieldConfig const > VolumeBasedMagneticFieldESProducerFromDB::chooseConfigViaParameter ( const IdealMagneticFieldRecord iRecord)

Definition at line 134 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

References edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getHandle(), and knownFromParamConfigToken_.

Referenced by VolumeBasedMagneticFieldESProducerFromDB().

135  {
137 
138  //just forward what we just got but do not take ownership
139  return std::shared_ptr<MagFieldConfig const>(config.product(), [](auto*) {});
140 }
Definition: config.py:1
ESHandle< ProductT > getHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > knownFromParamConfigToken_

◆ closerNominalLabel()

std::string_view VolumeBasedMagneticFieldESProducerFromDB::closerNominalLabel ( float  current)
staticprivate

Definition at line 198 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

References mps_fire::i, createfilelist::int, and RunInfoPI::nominalCurrents.

Referenced by VolumeBasedMagneticFieldESProducerFromDB().

198  {
199  constexpr std::array<int, 7> nominalCurrents = {{-1, 0, 9558, 14416, 16819, 18268, 19262}};
200  constexpr std::array<std::string_view, 7> nominalLabels = {{"3.8T", "0T", "2T", "3T", "3.5T", "3.8T", "4T"}};
201 
202  int i = 0;
203  for (; i < (int)nominalLabels.size() - 1; i++) {
204  if (2 * current < nominalCurrents[i] + nominalCurrents[i + 1])
205  return nominalLabels[i];
206  }
207  return nominalLabels[i];
208 }
constexpr std::array< int, 7 > nominalCurrents

◆ fillDescriptions()

void VolumeBasedMagneticFieldESProducerFromDB::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 210 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

210  {
212  desc.addUntracked<bool>("debugBuilder", false);
213  desc.add<int>("valueOverride", -1)->setComment("Force value of current (in A); take the value from DB if < 0.");
214  desc.addUntracked<std::string>("label", "");
215 
216  descriptions.addDefault(desc);
217 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ operator=()

const VolumeBasedMagneticFieldESProducerFromDB& magneticfield::VolumeBasedMagneticFieldESProducerFromDB::operator= ( const VolumeBasedMagneticFieldESProducerFromDB )
delete

◆ produce()

std::unique_ptr< MagneticField > VolumeBasedMagneticFieldESProducerFromDB::produce ( const IdealMagneticFieldRecord iRecord)

Definition at line 143 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

References MagGeoBuilderFromDDD::barrelLayers(), MagGeoBuilderFromDDD::barrelVolumes(), MagGeoBuilderFromDDD::build(), chosenConfigToken_, debug_, MagGeoBuilderFromDDD::endcapSectors(), MagGeoBuilderFromDDD::endcapVolumes(), ParametrizedMagneticFieldFactory::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getTransientHandle(), MagGeoBuilderFromDDD::maxR(), MagGeoBuilderFromDDD::maxZ(), mayConsumeBlobToken_, writedatasetfile::parser, MagGeoBuilderFromDDD::setGridFiles(), and MagGeoBuilderFromDDD::setScaling().

144  {
145  auto const& conf = iRecord.getTransientHandle(chosenConfigToken_);
146 
147  std::unique_ptr<MagneticField> paramField =
148  ParametrizedMagneticFieldFactory::get(conf->slaveFieldVersion, conf->slaveFieldParameters);
149 
150  edm::LogInfo("MagneticField") << "Version: " << conf->version << " geometryVersion: " << conf->geometryVersion
151  << " slaveFieldVersion: " << conf->slaveFieldVersion;
152 
153  if (conf->version == "parametrizedMagneticField") {
154  // The map consist of only the parametrization in this case
155  return paramField;
156  }
157 
158  // Full VolumeBased map + parametrization
159  MagGeoBuilderFromDDD builder(conf->version, conf->geometryVersion, debug_);
160 
161  // Set scaling factors
162  if (!conf->keys.empty()) {
163  builder.setScaling(conf->keys, conf->values);
164  }
165 
166  // Set specification for the grid tables to be used.
167  if (!conf->gridFiles.empty()) {
168  builder.setGridFiles(conf->gridFiles);
169  }
170 
171  // Build the geometry (DDDCompactView) from the DB blob
172  // (code taken from GeometryReaders/XMLIdealGeometryESSource/src/XMLIdealMagneticFieldGeometryESProducer.cc)
173 
174  auto const& blob = iRecord.getTransientHandle(mayConsumeBlobToken_);
175 
176  DDCompactView cpv{DDName("cmsMagneticField:MAGF")};
177  DDLParser parser(cpv);
178  parser.getDDLSAX2FileHandler()->setUserNS(true);
179  parser.clearFiles();
180  std::unique_ptr<std::vector<unsigned char> > tb = blob->getUncompressedBlob();
181  parser.parse(*tb, tb->size());
182  cpv.lockdown();
183 
184  builder.build(cpv);
185 
186  // Build the VB map. Ownership of the parametrization is transferred to it
187  return std::make_unique<VolumeBasedMagneticField>(conf->geometryVersion,
188  builder.barrelLayers(),
189  builder.endcapSectors(),
190  builder.barrelVolumes(),
191  builder.endcapVolumes(),
192  builder.maxR(),
193  builder.maxZ(),
194  paramField.release(),
195  true);
196 }
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
static std::unique_ptr< MagneticField > get(std::string version, const edm::ParameterSet &parameters)
Log< level::Info, false > LogInfo
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
edm::ESGetToken< MagFieldConfig, IdealMagneticFieldRecord > chosenConfigToken_

Member Data Documentation

◆ chosenConfigToken_

edm::ESGetToken<MagFieldConfig, IdealMagneticFieldRecord> magneticfield::VolumeBasedMagneticFieldESProducerFromDB::chosenConfigToken_
private

◆ debug_

const bool magneticfield::VolumeBasedMagneticFieldESProducerFromDB::debug_
private

Definition at line 74 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

Referenced by produce().

◆ knownFromParamConfigToken_

edm::ESGetToken<MagFieldConfig, MagFieldConfigRcd> magneticfield::VolumeBasedMagneticFieldESProducerFromDB::knownFromParamConfigToken_
private

◆ mayConsumeBlobToken_

edm::ESGetToken<FileBlob, MFGeometryFileRcd> magneticfield::VolumeBasedMagneticFieldESProducerFromDB::mayConsumeBlobToken_
private

◆ mayGetConfigToken_

edm::ESGetToken<MagFieldConfig, MagFieldConfigRcd> magneticfield::VolumeBasedMagneticFieldESProducerFromDB::mayGetConfigToken_
private