CMS 3D CMS Logo

SiStripConfObjectFakeESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiStripESProducers
4 // Class: SiStripConfObjectFakeESSource
5 //
14 // system include files
15 #include <memory>
16 
17 // user include files
20 
24 
26 public:
29 
31 
32  typedef std::unique_ptr<SiStripConfObject> ReturnType;
33  ReturnType produce(const SiStripConfObjectRcd&);
34 
35 private:
36  std::vector<edm::ParameterSet> m_parameters;
37 };
38 
40 
42 {
43  setWhatProduced(this);
44  findingRecord<SiStripConfObjectRcd>();
45 
46  m_parameters = iConfig.getParameter<std::vector<edm::ParameterSet>>("Parameters");
47 }
48 
50 
52 {
53  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
54 }
55 
56 // ------------ method called to produce the data ------------
59 {
60  using namespace edm::es;
61 
62  auto confObject = std::make_unique<SiStripConfObject>();
63 
64  for ( const auto& param : m_parameters ) {
65  const std::string paramType{param.getParameter<std::string>("ParameterType")};
66  const std::string paramName{param.getParameter<std::string>("ParameterName")};
67  if( paramType == "int" ) {
68  confObject->put(paramName, param.getParameter<int32_t>("ParameterValue"));
69  }
70  else if( paramType == "double" ) {
71  confObject->put(paramName, param.getParameter<double>("ParameterValue"));
72  }
73  else if( paramType == "string" ) {
74  confObject->put(paramName, param.getParameter<std::string>("ParameterValue"));
75  }
76  else if( paramType == "bool" ) {
77  confObject->put(paramName, param.getParameter<bool>("ParameterValue"));
78  }
79  else if( paramType == "vint32" ) {
80  confObject->put(paramName, param.getParameter<std::vector<int> >("ParameterValue"));
81  }
82  else if( paramType == "vstring" ) {
83  confObject->put(paramName, param.getParameter<std::vector<std::string> >("ParameterValue"));
84  }
85  }
86 
87  return confObject;
88 }
89 
90 //define this as a plug-in
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
SiStripConfObjectFakeESSource(const edm::ParameterSet &)
std::unique_ptr< SiStripConfObject > ReturnType
std::vector< edm::ParameterSet > m_parameters
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
ReturnType produce(const SiStripConfObjectRcd &)