CMS 3D CMS Logo

SiStripGainSimESProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <utility>
4 
5 // user include files
8 
11 
16 
17 #include "SiStripGainFactor.h"
18 
20 public:
23 
24  std::unique_ptr<SiStripGain> produce(const SiStripGainSimRcd&);
25 
26 private:
27  struct TokenLabel {
32  std::pair<std::string, std::string> recordLabel_;
33  };
34 
35  std::vector<TokenLabel> tokenLabels_;
37 };
38 
40  auto cc = setWhatProduced(this);
41 
42  auto apvGainLabels = iConfig.getParameter<std::vector<edm::ParameterSet> >("APVGain");
43  if (apvGainLabels.empty()) {
44  throw cms::Exception("Configuration") << "Got empty APVGain vector, but need at least one entry";
45  }
46 
47  // Fill the vector of apv labels
48  for (const auto& gainPSet : apvGainLabels) {
49  // Shouldn't all these parameters be tracked?
50  tokenLabels_.emplace_back(
51  cc, gainPSet.getParameter<std::string>("Record"), gainPSet.getUntrackedParameter<std::string>("Label", ""));
52  factor_.push_back_norm(gainPSet.getUntrackedParameter<double>("NormalizationFactor", 1.));
53  }
54 
56 }
57 
58 std::unique_ptr<SiStripGain> SiStripGainSimESProducer::produce(const SiStripGainSimRcd& iRecord) {
59  const auto& apvGain = iRecord.get(tokenLabels_[0].token_);
60  auto gain = std::make_unique<SiStripGain>(apvGain, factor_.get(apvGain, 0), tokenLabels_[0].recordLabel_);
61 
62  for (unsigned int i = 1; i < tokenLabels_.size(); ++i) {
63  const auto& apvGain = iRecord.get(tokenLabels_[i].token_);
64  gain->multiply(apvGain, factor_.get(apvGain, i), tokenLabels_[i].recordLabel_);
65  }
66  return gain;
67 }
68 
70 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
std::unique_ptr< SiStripGain > produce(const SiStripGainSimRcd &)
JetCorrectorParameters::Record record
Definition: classes.h:7
edm::ESGetToken< SiStripApvGain, SiStripApvGainSimRcd > token_
std::vector< TokenLabel > tokenLabels_
auto consumesFrom(ESInputTag const &tag)
void push_back_norm(double norm)
TokenLabel(edm::ESConsumesCollector &cc, std::string record, std::string label)
std::pair< std::string, std::string > recordLabel_
char const * label
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
double get(const SiStripApvGain &gain, const int apvGainIndex) const
def move(src, dest)
Definition: eostools.py:511
SiStripGainSimESProducer(const edm::ParameterSet &)