CMS 3D CMS Logo

PayloadInspector.cc
Go to the documentation of this file.
5 
6 #include <sstream>
7 #include <iostream>
8 
9 namespace cond {
10 
11  namespace payloadInspector {
12 
14 
16  std::string ret("");
17  auto im = m.find(key);
18  if (im != m.end())
19  ret = im->second;
20  return ret;
21  }
22 
23  constexpr const char* const ModuleVersion::label;
24 
26  : m_plotAnnotations(),
27  m_inputParams(),
28  m_tagNames(),
29  m_tagBoundaries(),
30  m_tagIovs(),
31  m_inputParamValues(),
32  m_data("") {}
33 
34  void PlotBase::addInputParam(const std::string& paramName) {
35  // maybe add a check for existing params - returning an Exception when found...
36  m_inputParams.insert(paramName);
37  }
38 
40 
42 
44 
46 
47  unsigned int PlotBase::ntags() const { return m_plotAnnotations.ntags; }
48 
49  bool PlotBase::isTwoTags() const { return m_plotAnnotations.ntags == 2; }
50 
51  py::list PlotBase::inputParams() const {
52  py::list tmp;
53  for (const auto& ip : m_inputParams) {
54  tmp.append(ip);
55  }
56  return tmp;
57  }
58 
59  void PlotBase::setInputParamValues(const py::dict& values) {
60  for (auto item : values) {
61  std::string k = item.first.cast<std::string>();
62  std::string v = item.second.cast<std::string>();
63  if (m_inputParams.find(k) != m_inputParams.end()) {
64  m_inputParamValues.insert(std::make_pair(k, v));
65  }
66  }
67  }
68 
69  std::string PlotBase::data() const { return m_data; }
70 
71  bool PlotBase::process(const std::string& connectionString, const py::list& tagsWithTimeBoundaries) {
72  size_t nt = py::len(tagsWithTimeBoundaries);
73  bool ret = false;
74  if (nt) {
75  std::vector<std::tuple<std::string, cond::Time_t, cond::Time_t> > tags;
76  tags.resize(nt);
77  for (size_t i = 0; i < nt; i++) {
78  py::tuple entry = tagsWithTimeBoundaries[i].cast<py::tuple>();
79  std::string tagName = entry[0].cast<std::string>();
80  std::string time0s = entry[1].cast<std::string>();
81  std::string time1s = entry[2].cast<std::string>();
82  cond::Time_t time0 = std::stoull(time0s);
83  cond::Time_t time1 = std::stoull(time1s);
84  tags[i] = std::make_tuple(tagName, time0, time1);
85  }
86  ret = exec_process(connectionString, tags);
87  }
88  return ret;
89  }
90 
91  bool PlotBase::exec_process(
93  const std::vector<std::tuple<std::string, cond::Time_t, cond::Time_t> >& tagsWithTimeBoundaries) {
94  m_tagNames.clear();
95  m_tagBoundaries.clear();
96  m_tagIovs.clear();
97  init();
98 
99  std::vector<edm::ParameterSet> psets;
100  edm::ParameterSet pSet;
101  pSet.addParameter("@service_type", std::string("SiteLocalConfigService"));
102  psets.push_back(pSet);
103  static const edm::ServiceToken services(edm::ServiceRegistry::createSet(psets));
104  static const edm::ServiceRegistry::Operate operate(services);
105  bool ret = false;
106  size_t nt = tagsWithTimeBoundaries.size();
107  if (nt) {
111  m_tagNames.resize(nt);
112  m_tagBoundaries.resize(nt);
113  m_tagIovs.resize(nt);
114  for (size_t i = 0; i < nt; i++) {
115  const std::string& tagName = std::get<0>(tagsWithTimeBoundaries[i]);
116  cond::Time_t time0 = std::get<1>(tagsWithTimeBoundaries[i]);
117  cond::Time_t time1 = std::get<2>(tagsWithTimeBoundaries[i]);
118  m_tagNames[i] = tagName;
119  m_tagBoundaries[i] = std::make_pair(time0, time1);
120  auto proxy = m_dbSession.readIov(tagName);
121  proxy.selectRange(time0, time1, m_tagIovs[i]);
122  }
123  m_data = processData();
125  ret = true;
126  }
127  return ret;
128  }
129 
130  void PlotBase::init() {}
131 
133 
136  return info;
137  }
138 
139  const std::map<std::string, std::string>& PlotBase::inputParamValues() const { return m_inputParamValues; }
140 
142 
143  } // namespace payloadInspector
144 
145 } // namespace cond
std::map< std::string, std::string > m_inputParamValues
cond::Tag_t getTagInfo(const std::string &tag)
static const TGPicture * info(bool iBackgroundIsBlack)
const boost::posix_time::ptime time0
std::set< std::string > m_inputParams
ret
prodAgent to be discontinued
void start(bool readOnly=true)
Definition: Session.cc:18
std::vector< std::string > m_tagNames
static constexpr const char *const PAYLOAD_TYPE_K
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session dbSession()
static constexpr const char *const PLOT_TYPE_K
unsigned long long Time_t
Definition: Time.h:14
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
Session createSession(const std::string &connectionString, bool writeCapable=false)
static ServiceToken createSet(std::vector< ParameterSet > &)
cond::Tag_t tagInfo() const
Definition: IOVProxy.cc:246
int nt
Definition: AMPTWrapper.h:42
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
const std::map< std::string, std::string > & inputParamValues() const
void addInputParam(const std::string &paramName)
static constexpr const char *const label
Definition: plugin.cc:23
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cond::persistency::Session m_dbSession
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:197
std::map< std::string, std::string > m
static constexpr const char *const TITLE_K
std::vector< std::pair< cond::Time_t, cond::Time_t > > m_tagBoundaries
tmp
align.sh
Definition: createJobs.py:716
std::string get(const std::string &key) const
std::vector< std::vector< std::tuple< cond::Time_t, cond::Hash > > > m_tagIovs