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 {
13  setWhatProduced(this);
14  findingRecord<HBHEDarkeningRecord>();
15 }
16 
18 {}
19 
22 }
23 
26  desc.add<int>("ieta_shift");
27  desc.add<double>("drdA");
28  desc.add<double>("drdB");
29  edm::ParameterSetDescription desc_dosemaps;
30  desc_dosemaps.add<int>("energy");
31  desc_dosemaps.add<edm::FileInPath>("file");
32  std::vector<edm::ParameterSet> default_dosemap(1);
33  desc.addVPSet("dosemaps",desc_dosemaps,default_dosemap);
35  desc_years.add<std::string>("year");
36  desc_years.add<double>("intlumi");
37  desc_years.add<double>("lumirate");
38  desc_years.add<int>("energy");
39  std::vector<edm::ParameterSet> default_year(1);
40  desc.addVPSet("years",desc_years,default_year);
41 
42  descriptions.addDefault(desc);
43 }
44 
45 // ------------ method called to produce the data ------------
48  //initialize dose maps
49  std::vector<edm::ParameterSet> p_dosemaps = pset_.getParameter<std::vector<edm::ParameterSet>>("dosemaps");
50  std::map<int,std::vector<std::vector<float>>> dosemaps;
51  for(const auto& p_dosemap : p_dosemaps){
52  edm::FileInPath fp = p_dosemap.getParameter<edm::FileInPath>("file");
53  int file_energy = p_dosemap.getParameter<int>("energy");
54  dosemaps.emplace(file_energy,HBHEDarkening::readDoseMap(fp.fullPath()));
55  }
56 
57  //initialize years
58  std::vector<edm::ParameterSet> p_years = pset_.getParameter<std::vector<edm::ParameterSet>>("years");
59  std::vector<HBHEDarkening::LumiYear> years;
60  years.reserve(p_years.size());
61  for(const auto& p_year : p_years){
62  years.emplace_back(
63  p_year.getParameter<std::string>("year"),
64  p_year.getParameter<double>("intlumi"),
65  p_year.getParameter<double>("lumirate"),
66  p_year.getParameter<int>("energy")
67  );
68  }
69 
70  ReturnType myResult(
71  new HBHEDarkening(
72  pset_.getParameter<int>("ieta_shift"),
73  pset_.getParameter<double>("drdA"),
74  pset_.getParameter<double>("drdB"),
75  dosemaps,
76  years
77  )
78  );
79 
80  return myResult;
81 }
82 
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
ReturnType produce(const HBHEDarkeningRecord &)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::shared_ptr< HBHEDarkening > ReturnType
~HBHEDarkeningEP() override
void addDefault(ParameterSetDescription const &psetDescription)
static const IOVSyncValue & beginOfTime()
const edm::ParameterSet & pset_
static std::vector< std::vector< float > > readDoseMap(const std::string &fullpath)
HBHEDarkeningEP(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
std::string fullPath() const
Definition: FileInPath.cc:184