CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
35 
37  DQMStore::IGetter &getter,
38  edm::LuminosityBlock const &,
39  edm::EventSetup const &) override;
40  void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override;
41 
42 private:
44 };
45 
47  : m_dqm_path(config.getUntrackedParameter<std::string>("dqmPath")),
48  m_dqm_merge(config.getUntrackedParameter<bool>("createSummary")) {}
49 
51  fillSummaryPlots(booker, getter);
52 }
53 
55  DQMStore::IGetter &getter,
56  edm::LuminosityBlock const &,
57  edm::EventSetup const &) {
58  fillSummaryPlots(booker, getter);
59 }
60 
62  // find whether the plots are in the main folder, or in per-number-of-processess subfolders
63  std::vector<std::string> folders;
64  if (getter.get(m_dqm_path + "/throughput_sourced")) {
65  // the plots are in the main folder
66  folders.push_back(m_dqm_path);
67  } else {
68  static const boost::regex running_n_processes(".*/Running .*");
70  std::vector<std::string> subdirs = getter.getSubdirs();
71  for (auto const &subdir : subdirs) {
72  if (boost::regex_match(subdir, running_n_processes)) {
73  if (getter.get(subdir + "/throughput_sourced"))
74  // the plots are in a per-number-of-processes subfolder
75  folders.push_back(subdir);
76  }
77  }
78  }
79  // create a summary folder if there are more than one
80  if (m_dqm_merge and folders.size() > 1) {
81  std::string summary_folder = m_dqm_path + "/Summary";
82  booker.setCurrentFolder(summary_folder);
83  // clone the first set of histograms
84  auto folder = folders.begin();
85  TH1F *sourced =
86  booker.book1D("throughput_sourced", getter.get(*folder + "/throughput_sourced")->getTH1F())->getTH1F();
87  TH1F *retired =
88  booker.book1D("throughput_retired", getter.get(*folder + "/throughput_retired")->getTH1F())->getTH1F();
89  // add the other sets of histograms
90  for (++folder; folder != folders.end(); ++folder) {
91  sourced->Add(getter.get(*folder + "/throughput_sourced")->getTH1F());
92  retired->Add(getter.get(*folder + "/throughput_retired")->getTH1F());
93  }
94  // move the summary folder to the list
95  folders.push_back(std::move(summary_folder));
96  }
97  for (auto const &folder : folders) {
98  TH1F *sourced = getter.get(folder + "/throughput_sourced")->getTH1F();
99  TH1F *retired = getter.get(folder + "/throughput_retired")->getTH1F();
100  booker.setCurrentFolder(folder);
101  unsigned int nbins = sourced->GetXaxis()->GetNbins();
102  double range = sourced->GetXaxis()->GetXmax();
103 
104  // (re)book and fill .../concurrent
105  TH1F *concurrent = booker.book1D("concurrent", "Concurrent events being processed", nbins, 0., range)->getTH1F();
106  double sum = 0;
107  // from bin=0 (underflow) to bin=nbins+1 (overflow)
108  for (unsigned int i = 0; i <= nbins + 1; ++i) {
109  sum += sourced->GetBinContent(i) - retired->GetBinContent(i);
110  concurrent->Fill(concurrent->GetXaxis()->GetBinCenter(i), sum);
111  }
112 
113  TH1F *average = nullptr;
114  double avg_min = std::min(sourced->GetMinimum(0.), retired->GetMinimum(0.));
115  double avg_max = std::max(sourced->GetMaximum(), retired->GetMaximum());
116  double width = avg_max - avg_min;
117  avg_min = std::floor(avg_min - width * 0.2);
118  if (avg_min < 0.)
119  avg_min = 0.;
120  avg_max = std::ceil(avg_max + width * 0.2);
121  width = avg_max - avg_min;
122 
123  // define the range for .../average_sourced
124  uint64_t first = sourced->FindFirstBinAbove(0.);
125  uint64_t last = sourced->FindLastBinAbove(0.);
126  booker.setCurrentFolder(folder);
127  // (re)book and fill .../average_sourced
128  average = booker.book1D("average_sourced", "Throughput (sourced events)", (int)width, avg_min, avg_max)->getTH1F();
129  for (unsigned int i = first; i <= last; ++i)
130  average->Fill(sourced->GetBinContent(i));
131 
132  // define the range for .../average_retired
133  first = retired->FindFirstBinAbove(0.);
134  last = retired->FindLastBinAbove(0.);
135  booker.setCurrentFolder(folder);
136  // (re)book and fill .../average_retired
137  average = booker.book1D("average_retired", "Throughput (retired events)", (int)width, avg_min, avg_max)->getTH1F();
138  for (unsigned int i = first; i <= last; ++i)
139  average->Fill(retired->GetBinContent(i));
140  }
141 }
142 
145  desc.addUntracked<std::string>("dqmPath", "HLT/Throughput");
146  desc.addUntracked<bool>("createSummary", true);
147  descriptions.add("throughputServiceClient", desc);
148 }
149 
150 // declare this class as a framework plugin
constexpr int32_t ceil(float num)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual TH1F * getTH1F() const
const uint16_t range(const Frame &aFrame)
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)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
def move
Definition: eostools.py:511
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
unsigned long long uint64_t
Definition: Time.h:13
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~ThroughputServiceClient() override=default
int average
Definition: PDRates.py:138
tuple config
parse the configuration file
tuple last
Definition: dqmdumpme.py:56
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98