CMS 3D CMS Logo

SiStripDelayESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripDelayESProducer
4 // Class: SiStripDelayESProducer
5 //
13 //
14 // Original Author: M. De Mattia
15 // Created: 26/10/2010
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
26 
29 
33 
35 public:
38 
39  std::unique_ptr<SiStripDelay> produce(const SiStripDelayRcd&);
40 
41 private:
42  struct TokenSign {
46  label_{label},
47  sumSign_{sumSign} {}
51  int sumSign_;
52  };
53  std::vector<TokenSign> tokens_;
54 };
55 
57  auto cc = setWhatProduced(this);
58 
59  edm::LogInfo("SiStripDelayESProducer") << "ctor" << std::endl;
60 
61  for (const auto& pset : iConfig.getParameter<std::vector<edm::ParameterSet>>("ListOfRecordToMerge")) {
62  auto recordName = pset.getParameter<std::string>("Record");
63  auto label = pset.getParameter<std::string>("Label");
64 
65  edm::LogInfo("SiStripDelayESProducer")
66  << "[SiStripDelayESProducer::ctor] Going to get data from record " << recordName << " with label " << label;
67 
68  // Is the "recordName" parameter really useful?
69  if (recordName == "SiStripBaseDelayRcd") {
70  tokens_.emplace_back(cc, recordName, label, pset.getParameter<int>("SumSign"));
71  } else {
72  // Would an exception make sense?
73  edm::LogError("SiStripDelayESProducer")
74  << "[SiStripDelayESProducer::ctor] Skipping the requested data for unexisting record " << recordName
75  << " with tag " << label << std::endl;
76  }
77  }
78 }
79 
80 std::unique_ptr<SiStripDelay> SiStripDelayESProducer::produce(const SiStripDelayRcd& iRecord) {
81  edm::LogInfo("SiStripDelayESProducer") << "produce called" << std::endl;
82  auto delay = std::make_unique<SiStripDelay>();
83 
84  for (const auto& tokenSign : tokens_) {
85  const auto& baseDelay = iRecord.get(tokenSign.token_);
86  delay->fillNewDelay(baseDelay, tokenSign.sumSign_, std::make_pair(tokenSign.recordName_, tokenSign.label_));
87  }
88 
89  delay->makeDelay();
90 
91  return delay;
92 }
93 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
auto consumesFrom(ESInputTag const &tag)
SiStripDelayESProducer(const edm::ParameterSet &)
Log< level::Error, false > LogError
char const * label
TokenSign(edm::ESConsumesCollector &cc, const std::string &recordName, const std::string &label, int sumSign)
Log< level::Info, false > LogInfo
std::unique_ptr< SiStripDelay > produce(const SiStripDelayRcd &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::vector< TokenSign > tokens_
edm::ESGetToken< SiStripBaseDelay, SiStripBaseDelayRcd > token_