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
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename Record >
void updateFromMayConsumes (unsigned int iIndex, const Record &iRecord)
 
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 char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &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 >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- 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 47 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

Constructor & Destructor Documentation

◆ VolumeBasedMagneticFieldESProducerFromDB() [1/2]

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

Definition at line 76 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

77  : debug_(iConfig.getUntrackedParameter<bool>("debugBuilder")) {
78  std::string const myConfigLabel = "VBMFESChoice";
79 
80  //Based on configuration, pick algorithm to produce the proper MagFieldConfig with a specific label
81  const int current = iConfig.getParameter<int>("valueOverride");
82  if (current < 0) {
83  //We do not know what to get until we first read RunInfo
86  .setMayConsume(
88  [](auto const& iGet, edm::ESTransientHandle<RunInfo> iHandle) {
89  auto const label = closerNominalLabel(iHandle->m_avg_current);
90  edm::LogInfo("MagneticField") << "Current :" << iHandle->m_avg_current
91  << " (from RunInfo DB); using map configuration with label: " << label;
92  return iGet("", label);
93  },
95 
96  } else {
97  //we know exactly what we are going to get
98  auto const label = closerNominalLabel(current);
99  edm::LogInfo("MagneticField") << "Current :" << current
100  << " (from valueOverride card); using map configuration with label: " << label;
104  }
105 
106  auto const label = iConfig.getUntrackedParameter<std::string>("label");
107  auto const myConfigTag = edm::ESInputTag(iConfig.getParameter<std::string>("@module_label"), myConfigLabel);
108 
109  //We use the MagFieldConfig created above to decide which FileBlob to use
110  setWhatProduced(this, label)
111  .setMayConsume(
113  [](auto const& iGet, edm::ESTransientHandle<MagFieldConfig> iConfig) {
114  if (iConfig->version == "parametrizedMagneticField") {
115  return iGet.nothing();
116  }
117  return iGet("", std::to_string(iConfig->geometryVersion));
118  },
120  .setConsumes(chosenConfigToken_, myConfigTag); //Use same tag as the choice
121 }

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

◆ 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 123 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

124  {
126 
127  //just forward what we just got but do not take ownership
128  return std::shared_ptr<MagFieldConfig const>(config.product(), [](auto*) {});
129 }

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

Referenced by VolumeBasedMagneticFieldESProducerFromDB().

◆ chooseConfigViaParameter()

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

Definition at line 131 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

132  {
134 
135  //just forward what we just got but do not take ownership
136  return std::shared_ptr<MagFieldConfig const>(config.product(), [](auto*) {});
137 }

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

Referenced by VolumeBasedMagneticFieldESProducerFromDB().

◆ closerNominalLabel()

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

Definition at line 195 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

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

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

Referenced by VolumeBasedMagneticFieldESProducerFromDB().

◆ fillDescriptions()

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

Definition at line 207 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

207  {
209  desc.addUntracked<bool>("debugBuilder", false);
210  desc.add<int>("valueOverride", -1)->setComment("Force value of current (in A); take the value from DB if < 0.");
211  desc.addUntracked<std::string>("label", "");
212 
213  descriptions.addDefault(desc);
214 }

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ operator=()

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

◆ produce()

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

Definition at line 140 of file VolumeBasedMagneticFieldESProducerFromDB.cc.

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

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().

Member Data Documentation

◆ chosenConfigToken_

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

◆ debug_

const bool magneticfield::VolumeBasedMagneticFieldESProducerFromDB::debug_
private

Definition at line 72 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
mps_fire.i
i
Definition: mps_fire.py:355
edm::ESProductTag
Definition: ESProductTag.h:29
edm::ESInputTag
Definition: ESInputTag.h:87
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
RunInfoPI::nominalCurrents
constexpr std::array< int, 7 > nominalCurrents
Definition: RunInfoPayloadInspectoHelper.h:16
ParametrizedMagneticFieldFactory::get
static std::unique_ptr< MagneticField > get(std::string version, const edm::ParameterSet &parameters)
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::mayGetConfigToken_
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > mayGetConfigToken_
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:64
MagGeoBuilderFromDDD
Definition: MagGeoBuilderFromDDD.h:32
edm::eventsetup::DependentRecordImplementation::getHandle
ESHandle< ProductT > getHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:86
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::chooseConfigAtRuntime
std::shared_ptr< MagFieldConfig const > chooseConfigAtRuntime(const IdealMagneticFieldRecord &iRecord)
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:123
edm::LogInfo
Definition: MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MagFieldConfig::version
std::string version
Version of the data tables to be used.
Definition: MagFieldConfig.h:41
MagFieldConfig::geometryVersion
int geometryVersion
Version of the geometry to be used.
Definition: MagFieldConfig.h:38
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
config
Definition: config.py:1
alignCSCRings.s
s
Definition: alignCSCRings.py:92
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::closerNominalLabel
static std::string_view closerNominalLabel(float current)
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:195
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:99
edm::ESHandle
Definition: DTSurvey.h:22
edm::es::Label
Definition: es_Label.h:54
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::mayConsumeBlobToken_
edm::ESGetToken< FileBlob, MFGeometryFileRcd > mayConsumeBlobToken_
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:71
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::chooseConfigViaParameter
std::shared_ptr< MagFieldConfig const > chooseConfigViaParameter(const IdealMagneticFieldRecord &iRecord)
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:131
DDLParser
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
createfilelist.int
int
Definition: createfilelist.py:10
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::chosenConfigToken_
edm::ESGetToken< MagFieldConfig, IdealMagneticFieldRecord > chosenConfigToken_
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:69
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::debug_
const bool debug_
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:72
magneticfield::VolumeBasedMagneticFieldESProducerFromDB::knownFromParamConfigToken_
edm::ESGetToken< MagFieldConfig, MagFieldConfigRcd > knownFromParamConfigToken_
Definition: VolumeBasedMagneticFieldESProducerFromDB.cc:65
RunInfo::m_avg_current
float m_avg_current
Definition: RunInfo.h:28
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
label
const char * label
Definition: PFTauDecayModeTools.cc:11