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 
17 
18 #include "SiStripGainFactor.h"
19 
21 public:
24 
25  std::unique_ptr<SiStripGain> produce(const SiStripGainSimRcd&);
26 
27 private:
28  struct TokenLabel {
33  std::pair<std::string, std::string> recordLabel_;
34  };
35 
36  std::vector<TokenLabel> tokenLabels_;
38 };
39 
41  auto cc = setWhatProduced(this);
42 
43  auto apvGainLabels = iConfig.getParameter<std::vector<edm::ParameterSet> >("APVGain");
44  if (apvGainLabels.empty()) {
45  throw cms::Exception("Configuration") << "Got empty APVGain vector, but need at least one entry";
46  }
47 
48  // Fill the vector of apv labels
49  for (const auto& gainPSet : apvGainLabels) {
50  // Shouldn't all these parameters be tracked?
51  tokenLabels_.emplace_back(
52  cc, gainPSet.getParameter<std::string>("Record"), gainPSet.getUntrackedParameter<std::string>("Label", ""));
53  factor_.push_back_norm(gainPSet.getUntrackedParameter<double>("NormalizationFactor", 1.));
54  }
55 
56  factor_.resetIfBadNorm();
57 }
58 
59 std::unique_ptr<SiStripGain> SiStripGainSimESProducer::produce(const SiStripGainSimRcd& iRecord) {
60  const auto detInfo =
62 
63  const auto& apvGain = iRecord.get(tokenLabels_[0].token_);
64  auto gain = std::make_unique<SiStripGain>(apvGain, factor_.get(apvGain, 0), tokenLabels_[0].recordLabel_, detInfo);
65 
66  for (unsigned int i = 1; i < tokenLabels_.size(); ++i) {
67  const auto& apvGain = iRecord.get(tokenLabels_[i].token_);
68  gain->multiply(apvGain, factor_.get(apvGain, i), tokenLabels_[i].recordLabel_, detInfo);
69  }
70  return gain;
71 }
72 
74 
std::unique_ptr< SiStripGain > produce(const SiStripGainSimRcd &)
edm::ESGetToken< SiStripApvGain, SiStripApvGainSimRcd > token_
std::vector< TokenLabel > tokenLabels_
auto consumesFrom(ESInputTag const &tag)
TokenLabel(edm::ESConsumesCollector &cc, std::string record, std::string label)
std::pair< std::string, std::string > recordLabel_
char const * label
SiStripDetInfo read(std::string filePath)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
double get(const SiStripApvGain &gain, const int apvGainIndex) const
static constexpr char const *const kDefaultFile
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
def move(src, dest)
Definition: eostools.py:511
SiStripGainSimESProducer(const edm::ParameterSet &)