CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
magneticfield::AutoMagneticFieldESProducer Class Reference

#include <AutoMagneticFieldESProducer.h>

Inheritance diagram for magneticfield::AutoMagneticFieldESProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 AutoMagneticFieldESProducer (const edm::ParameterSet &)
 
std::unique_ptr< MagneticFieldproduce (const IdealMagneticFieldRecord &)
 
 ~AutoMagneticFieldESProducer ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Public Attributes

edm::ParameterSet pset
 

Private Member Functions

std::string closerModel (float current)
 

Private Attributes

std::vector< std::string > maps
 
std::vector< int > nominalCurrents
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- 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 eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Detailed Description

Definition at line 22 of file AutoMagneticFieldESProducer.h.

Constructor & Destructor Documentation

AutoMagneticFieldESProducer::AutoMagneticFieldESProducer ( const edm::ParameterSet iConfig)

Definition at line 30 of file AutoMagneticFieldESProducer.cc.

References Exception, edm::ParameterSet::getUntrackedParameter(), maps, nominalCurrents, pset, edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

30  : pset(iConfig) {
32  nominalCurrents = pset.getUntrackedParameter<vector<int> >("nominalCurrents");
33  maps = pset.getUntrackedParameter<vector<string> >("mapLabels");
34 
35  if (maps.size()==0 || (maps.size() != nominalCurrents.size())) {
36  throw cms::Exception("InvalidParameter") << "Invalid values for parameters \"nominalCurrents\" and \"maps\"";
37  }
38 }
T getUntrackedParameter(std::string const &, T const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
AutoMagneticFieldESProducer::~AutoMagneticFieldESProducer ( )

Definition at line 41 of file AutoMagneticFieldESProducer.cc.

42 {
43 }

Member Function Documentation

std::string AutoMagneticFieldESProducer::closerModel ( float  current)
private

Definition at line 77 of file AutoMagneticFieldESProducer.cc.

References DEFINE_FWK_EVENTSETUP_MODULE, mps_fire::i, createfilelist::int, maps, and nominalCurrents.

Referenced by produce().

77  {
78  int i=0;
79  for(;i<(int)maps.size()-1;i++) {
80  if(2*current < nominalCurrents[i]+nominalCurrents[i+1] )
81  return maps[i];
82  }
83  return maps[i];
84 }
std::unique_ptr< MagneticField > AutoMagneticFieldESProducer::produce ( const IdealMagneticFieldRecord iRecord)

Definition at line 47 of file AutoMagneticFieldESProducer.cc.

References MagneticField::clone(), closerModel(), edm::eventsetup::EventSetupRecord::get(), edm::ParameterSet::getParameter(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), RunInfo::m_avg_current, genParticles_cff::map, python.rootplot.argparse::message, edm::ESHandle< T >::product(), pset, and mps_fire::result.

48 {
49  float current = pset.getParameter<int>("valueOverride");
50 
51  string message;
52 
53  if (current < 0) {
54  ESHandle<RunInfo> rInfo;
55  iRecord.getRecord<RunInfoRcd>().get(rInfo);
56  current = rInfo->m_avg_current;
57  message = " (from RunInfo DB)";
58  } else {
59  message = " (from valueOverride card)";
60  }
61 
62  string model = closerModel(current);
63 
64  edm::LogInfo("MagneticField|AutoMagneticField") << "Current: " << current << message << "; using map with label: " << model;
65 
66 
68 
69  iRecord.get(model,map);
70 
71  MagneticField* result = map.product()->clone();
72 
73  return std::unique_ptr<MagneticField>(result);
74 }
T getParameter(std::string const &) const
void get(HolderT &iHolder) const
float m_avg_current
Definition: RunInfo.h:29
T const * product() const
Definition: ESHandle.h:86
virtual MagneticField * clone() const
Definition: MagneticField.h:26

Member Data Documentation

std::vector<std::string> magneticfield::AutoMagneticFieldESProducer::maps
private

Definition at line 33 of file AutoMagneticFieldESProducer.h.

Referenced by AutoMagneticFieldESProducer(), and closerModel().

std::vector<int> magneticfield::AutoMagneticFieldESProducer::nominalCurrents
private

Definition at line 32 of file AutoMagneticFieldESProducer.h.

Referenced by AutoMagneticFieldESProducer(), and closerModel().

edm::ParameterSet magneticfield::AutoMagneticFieldESProducer::pset

Definition at line 29 of file AutoMagneticFieldESProducer.h.

Referenced by AutoMagneticFieldESProducer(), and produce().