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  const edm::IOVSyncValue& iov,
32  edm::ValidityInterval& iValidity) override;
33 
34  typedef std::unique_ptr<SiStripConfObject> ReturnType;
36 
37 private:
38  std::vector<edm::ParameterSet> m_parameters;
39 };
40 
42 
44  setWhatProduced(this);
45  findingRecord<SiStripConfObjectRcd>();
46 
47  m_parameters = iConfig.getParameter<std::vector<edm::ParameterSet>>("Parameters");
48 }
49 
51 
53  const edm::IOVSyncValue& iov,
54  edm::ValidityInterval& iValidity) {
55  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
56 }
57 
58 // ------------ method called to produce the data ------------
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  } else if (paramType == "double") {
70  confObject->put(paramName, param.getParameter<double>("ParameterValue"));
71  } else if (paramType == "string") {
72  confObject->put(paramName, param.getParameter<std::string>("ParameterValue"));
73  } else if (paramType == "bool") {
74  confObject->put(paramName, param.getParameter<bool>("ParameterValue"));
75  } else if (paramType == "vint32") {
76  confObject->put(paramName, param.getParameter<std::vector<int>>("ParameterValue"));
77  } else if (paramType == "vstring") {
78  confObject->put(paramName, param.getParameter<std::vector<std::string>>("ParameterValue"));
79  }
80  }
81 
82  return confObject;
83 }
84 
85 //define this as a plug-in
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:165
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
SiStripConfObjectFakeESSource(const edm::ParameterSet &)
std::unique_ptr< SiStripConfObject > ReturnType
std::vector< edm::ParameterSet > m_parameters
ReturnType produce(const SiStripConfObjectRcd &)