CMS 3D CMS Logo

HBHEDarkeningEP.cc
Go to the documentation of this file.
1 #include "HBHEDarkeningEP.h"
6 
7 #include <string>
8 #include <vector>
9 #include <map>
10 
12  : drdA_(pset.getParameter<double>("drdA")),
13  drdB_(pset.getParameter<double>("drdB")),
14  ieta_shift_(pset.getParameter<int>("ieta_shift")) {
15  setWhatProduced(this);
16  findingRecord<HBHEDarkeningRecord>();
17 
18  const std::vector<edm::ParameterSet>& p_dosemaps = pset.getParameter<std::vector<edm::ParameterSet>>("dosemaps");
19  dosemaps_.reserve(p_dosemaps.size());
20  for (const auto& p_dosemap : p_dosemaps) {
21  dosemaps_.push_back({p_dosemap.getParameter<edm::FileInPath>("file"), p_dosemap.getParameter<int>("energy")});
22  }
23 
24  //initialize years
25  const std::vector<edm::ParameterSet>& p_years = pset.getParameter<std::vector<edm::ParameterSet>>("years");
26  years_.reserve(p_years.size());
27  for (const auto& p_year : p_years) {
28  years_.emplace_back(p_year.getParameter<std::string>("year"),
29  p_year.getParameter<double>("intlumi"),
30  p_year.getParameter<double>("lumirate"),
31  p_year.getParameter<int>("energy"));
32  }
33 }
34 
36 
38  const edm::IOVSyncValue& iTime,
39  edm::ValidityInterval& oInterval) {
41 }
42 
45  desc.add<int>("ieta_shift");
46  desc.add<double>("drdA");
47  desc.add<double>("drdB");
48  edm::ParameterSetDescription desc_dosemaps;
49  desc_dosemaps.add<int>("energy");
50  desc_dosemaps.add<edm::FileInPath>("file");
51  std::vector<edm::ParameterSet> default_dosemap(1);
52  desc.addVPSet("dosemaps", desc_dosemaps, default_dosemap);
54  desc_years.add<std::string>("year");
55  desc_years.add<double>("intlumi");
56  desc_years.add<double>("lumirate");
57  desc_years.add<int>("energy");
58  std::vector<edm::ParameterSet> default_year(1);
59  desc.addVPSet("years", desc_years, default_year);
60 
61  descriptions.addDefault(desc);
62 }
63 
64 // ------------ method called to produce the data ------------
66  //initialize dose maps
67  std::map<int, std::vector<std::vector<float>>> dosemaps;
68  for (const auto& p_dosemap : dosemaps_) {
69  dosemaps.emplace(p_dosemap.file_energy, HBHEDarkening::readDoseMap(p_dosemap.fp.fullPath()));
70  }
71 
72  return std::make_unique<HBHEDarkening>(ieta_shift_, drdA_, drdB_, std::move(dosemaps), years_);
73 }
74 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ReturnType produce(const HBHEDarkeningRecord &)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std::vector< HBHEDarkening::LumiYear > years_
~HBHEDarkeningEP() override
void addDefault(ParameterSetDescription const &psetDescription)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
static std::vector< std::vector< float > > readDoseMap(const std::string &fullpath)
std::vector< Dosemap > dosemaps_
std::unique_ptr< HBHEDarkening > ReturnType
HBHEDarkeningEP(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const int ieta_shift_
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
const double drdB_
def move(src, dest)
Definition: eostools.py:511
const double drdA_