CMS 3D CMS Logo

HistDefinition.cc
Go to the documentation of this file.
3 #include <algorithm>
4 
5 namespace dqmoffline {
6  namespace l1t {
7 
8  typedef std::vector<double> vdouble;
9 
11  : name("name"), title("title"), nbinsX(0), nbinsY(0), xmin(0), xmax(0), ymin(0), ymax(0), binsX(), binsY() {}
12 
14  : name(ps.getUntrackedParameter<std::string>("name")),
15  title(ps.getUntrackedParameter<std::string>("title")),
16  nbinsX(ps.getUntrackedParameter<unsigned int>("nbinsX", 0)),
17  nbinsY(ps.getUntrackedParameter<unsigned int>("nbinsY", 0)),
18  xmin(ps.getUntrackedParameter<double>("xmin", 0)),
19  xmax(ps.getUntrackedParameter<double>("xmax", 0)),
20  ymin(ps.getUntrackedParameter<double>("ymin", 0)),
21  ymax(ps.getUntrackedParameter<double>("ymax", 0)),
22  binsXtmp(ps.getUntrackedParameter<vdouble>("binsX", vdouble())),
23  binsYtmp(ps.getUntrackedParameter<vdouble>("binsY", vdouble())),
24  binsX(binsXtmp.begin(), binsXtmp.end()),
25  binsY(binsYtmp.begin(), binsYtmp.end()) {}
26 
28 
30  const std::map<std::string, unsigned int> &mapping) {
32  std::vector<std::string> names = ps.getParameterNames();
33  std::vector<unsigned int> map_values;
34 
35  map_values.reserve(mapping.size());
36  for (auto const &imap : mapping) {
37  map_values.push_back(imap.second);
38  }
39  unsigned int max_size = *std::max_element(map_values.begin(), map_values.end());
40  max_size = std::max(max_size, (unsigned int)mapping.size());
41  definitions.resize(max_size);
42 
43  for (const auto &name : names) {
44  if (mapping.find(name) != mapping.end()) {
47  } else {
48  edm::LogError("HistDefinition::readHistDefinitions")
49  << "Could not find histogram definition for '" << name << "'" << std::endl;
50  }
51  }
52  return definitions;
53  }
54  } // namespace l1t
55 } // namespace dqmoffline
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< HistDefinition > HistDefinitions
delete x;
Definition: CaloConfig.h:22
Log< level::Error, false > LogError
const std::string names[nVars_]
std::vector< double > vdouble
HistDefinitions readHistDefinitions(const edm::ParameterSet &ps, const std::map< std::string, unsigned int > &mapping)
std::vector< std::string > getParameterNames() const