CMS 3D CMS Logo

ThroughputServiceClient.cc
Go to the documentation of this file.
1 // C++ headers
2 #include <string>
3 #include <cstring>
4 
5 // boost headers
6 #include <boost/regex.hpp>
7 
8 // Root headers
9 #include <TH1F.h>
10 
11 // CMSSW headers
24 
26 public:
28  ~ThroughputServiceClient() override = default;
29 
30  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
31 
32 private:
34  const bool m_dqm_merge;
36 
38  DQMStore::IGetter &getter,
39  edm::LuminosityBlock const &,
40  edm::EventSetup const &) override;
41  void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override;
42 
43 private:
45 };
46 
48  : m_dqm_path(config.getUntrackedParameter<std::string>("dqmPath")),
49  m_dqm_merge(config.getUntrackedParameter<bool>("createSummary")),
50  m_fillEveryLumiSection(config.getParameter<bool>("fillEveryLumiSection")) {}
51 
53  fillSummaryPlots(booker, getter);
54 }
55 
57  DQMStore::IGetter &getter,
58  edm::LuminosityBlock const &,
59  edm::EventSetup const &) {
61  fillSummaryPlots(booker, getter);
62  }
63 }
64 
66  // find whether the plots are in the main folder, or in per-number-of-processess subfolders
67  std::vector<std::string> folders;
68  if (getter.get(m_dqm_path + "/throughput_sourced")) {
69  // the plots are in the main folder
70  folders.push_back(m_dqm_path);
71  } else {
72  static const boost::regex running_n_processes(".*/Running .*");
74  std::vector<std::string> subdirs = getter.getSubdirs();
75  for (auto const &subdir : subdirs) {
76  if (boost::regex_match(subdir, running_n_processes)) {
77  if (getter.get(subdir + "/throughput_sourced")) {
78  // the plots are in a per-number-of-processes subfolder
79  folders.push_back(subdir);
80  }
81  }
82  }
83  }
84  // create a summary folder if there are more than one
85  if (m_dqm_merge and folders.size() > 1) {
86  std::string summary_folder = m_dqm_path + "/Summary";
87  booker.setCurrentFolder(summary_folder);
88  // clone the first set of histograms
89  auto folder = folders.begin();
90  TH1F *sourced =
91  booker.book1D("throughput_sourced", getter.get(*folder + "/throughput_sourced")->getTH1F())->getTH1F();
92  TH1F *retired =
93  booker.book1D("throughput_retired", getter.get(*folder + "/throughput_retired")->getTH1F())->getTH1F();
94  // add the other sets of histograms
95  for (++folder; folder != folders.end(); ++folder) {
96  sourced->Add(getter.get(*folder + "/throughput_sourced")->getTH1F());
97  retired->Add(getter.get(*folder + "/throughput_retired")->getTH1F());
98  }
99  // move the summary folder to the list
100  folders.push_back(std::move(summary_folder));
101  }
102  for (auto const &folder : folders) {
103  TH1F *sourced = getter.get(folder + "/throughput_sourced")->getTH1F();
104  TH1F *retired = getter.get(folder + "/throughput_retired")->getTH1F();
105  booker.setCurrentFolder(folder);
106  unsigned int nbins = sourced->GetXaxis()->GetNbins();
107  double range = sourced->GetXaxis()->GetXmax();
108 
109  // (re)book and fill .../concurrent
110  TH1F *concurrent = booker.book1D("concurrent", "Concurrent events being processed", nbins, 0., range)->getTH1F();
111  double sum = 0;
112  // from bin=0 (underflow) to bin=nbins+1 (overflow)
113  for (unsigned int i = 0; i <= nbins + 1; ++i) {
114  sum += sourced->GetBinContent(i) - retired->GetBinContent(i);
115  concurrent->Fill(concurrent->GetXaxis()->GetBinCenter(i), sum);
116  }
117 
118  TH1F *average = nullptr;
119  double avg_min = std::min(sourced->GetMinimum(0.), retired->GetMinimum(0.));
120  double avg_max = std::max(sourced->GetMaximum(), retired->GetMaximum());
121  double width = avg_max - avg_min;
122  avg_min = std::floor(avg_min - width * 0.2);
123  if (avg_min < 0.)
124  avg_min = 0.;
125  avg_max = std::ceil(avg_max + width * 0.2);
126  width = avg_max - avg_min;
127 
128  // define the range for .../average_sourced
129  auto first = sourced->FindFirstBinAbove(0.);
130  auto last = sourced->FindLastBinAbove(0.);
131  booker.setCurrentFolder(folder);
132  // (re)book and fill .../average_sourced
133  average = booker.book1D("average_sourced", "Throughput (sourced events)", (int)width, avg_min, avg_max)->getTH1F();
134  if (first >= 0)
135  for (auto i = first; i <= last; ++i)
136  average->Fill(sourced->GetBinContent(i));
137 
138  // define the range for .../average_retired
139  first = retired->FindFirstBinAbove(0.);
140  last = retired->FindLastBinAbove(0.);
141  booker.setCurrentFolder(folder);
142  // (re)book and fill .../average_retired
143  average = booker.book1D("average_retired", "Throughput (retired events)", (int)width, avg_min, avg_max)->getTH1F();
144  if (first >= 0)
145  for (auto i = first; i <= last; ++i)
146  average->Fill(retired->GetBinContent(i));
147  }
148 }
149 
152  desc.addUntracked<std::string>("dqmPath", "HLT/Throughput");
153  desc.addUntracked<bool>("createSummary", true);
154  desc.add<bool>("fillEveryLumiSection", true);
155  descriptions.add("throughputServiceClient", desc);
156 }
157 
158 // declare this class as a framework plugin
constexpr int32_t ceil(float num)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
Definition: config.py:1
void fillSummaryPlots(DQMStore::IBooker &booker, DQMStore::IGetter &getter)
ThroughputServiceClient(edm::ParameterSet const &)
void dqmEndLuminosityBlock(DQMStore::IBooker &booker, DQMStore::IGetter &getter, edm::LuminosityBlock const &, edm::EventSetup const &) override
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle otherwise a larger ***bin number will have no effects or even make the ***precision lower than before *********************************************************************************************************it lies in three folders
Definition: invegas.h:5
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual TH1F * getTH1F() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~ThroughputServiceClient() override=default
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
def move(src, dest)
Definition: eostools.py:511
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:739