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
25 
27 public:
29  ~ThroughputServiceClient() override = default;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
32 
33 private:
35 
36  void dqmEndLuminosityBlock(DQMStore::IBooker & booker, DQMStore::IGetter & getter, edm::LuminosityBlock const &, edm::EventSetup const&) override;
37  void dqmEndJob(DQMStore::IBooker & booker, DQMStore::IGetter & getter) override;
38 
39 private:
40  void fillSummaryPlots( DQMStore::IBooker & booker, DQMStore::IGetter & getter);
41 };
42 
43 
45  m_dqm_path( config.getUntrackedParameter<std::string>( "dqmPath" ) )
46 {
47 }
48 
49 void
51 {
52  fillSummaryPlots(booker, getter);
53 }
54 
55 void
57 {
58  fillSummaryPlots(booker, getter);
59 }
60 
61 void
63 {
64  // find whether the plots are in the main folder, or in per-number-of-processess subfolders
65  std::vector<std::string> folders;
66  if (getter.get(m_dqm_path + "/throughput_sourced")) {
67  // the plots are in the main folder
68  folders.push_back(m_dqm_path);
69  } else {
70  static const boost::regex running_n_processes(".*/Running [0-9]+ processes");
72  std::vector<std::string> subdirs = getter.getSubdirs();
73  for (auto const & subdir: subdirs) {
74  if (boost::regex_match(subdir, running_n_processes)) {
75  if (getter.get(subdir + "/throughput_sourced"))
76  // the plots are in a per-number-of-processes subfolder
77  folders.push_back(subdir + "/throughput_sourced");
78  }
79  }
80  }
81  for (auto const & folder: folders) {
82  TH1F * sourced = getter.get( folder + "/throughput_sourced" )->getTH1F();
83  TH1F * retired = getter.get( folder + "/throughput_retired" )->getTH1F();
84  booker.setCurrentFolder(folder);
85  unsigned int nbins = sourced->GetXaxis()->GetNbins();
86  double range = sourced->GetXaxis()->GetXmax();
87 
88  // drop .../concurrent, if it exists
89  if (getter.get(folder + "/concurrent"))
90  getter.removeElement(folder, "concurrent", true);
91  // (re)book and fill .../concurrent
92  TH1F* concurrent = booker.book1D("concurrent", "Concurrent events being processed", nbins, 0., range)->getTH1F();
93  double sum = 0;
94  // from bin=0 (underflow) to bin=nbins+1 (overflow)
95  for (unsigned int i = 0; i <= nbins+1; ++i) {
96  sum += sourced->GetBinContent(i) - retired->GetBinContent(i);
97  concurrent->Fill( concurrent->GetXaxis()->GetBinCenter(i), sum );
98  }
99 
100  TH1F* average = nullptr;
101  double avg_min = std::min(sourced->GetMinimum(0.), retired->GetMinimum(0.));
102  double avg_max = std::max(sourced->GetMaximum(), retired->GetMaximum());
103  double width = avg_max - avg_min;
104  avg_min = std::floor( avg_min - width * 0.2 );
105  if (avg_min < 0.) avg_min = 0.;
106  avg_max = std::ceil( avg_max + width * 0.2 );
107  width = avg_max - avg_min;
108 
109  // drop .../average_sourced, if it exists
110  if (getter.get(folder + "/average_sourced"))
111  getter.removeElement(folder, "average_sourced", true);
112  // define the range for .../average_sourced
113  uint64_t first = sourced->FindFirstBinAbove(0.);
114  uint64_t last = sourced->FindLastBinAbove(0.);
115  booker.setCurrentFolder(folder);
116  // (re)book and fill .../average_sourced
117  average = booker.book1D("average_sourced", "Throughput (sourced events)", (int) width, avg_min, avg_max)->getTH1F();
118  for (unsigned int i = first; i <= last; ++i)
119  average->Fill(sourced->GetBinContent(i));
120 
121  // drop .../average_retired, if it exists
122  if (getter.get(folder + "/average_retired"))
123  getter.removeElement(folder, "average_retired", true);
124  // define the range for .../average_retired
125  first = retired->FindFirstBinAbove(0.);
126  last = retired->FindLastBinAbove(0.);
127  booker.setCurrentFolder(folder);
128  // (re)book and fill .../average_retired
129  average = booker.book1D("average_retired", "Throughput (retired events)", (int) width, avg_min, avg_max)->getTH1F();
130  for (unsigned int i = first; i <= last; ++i)
131  average->Fill(retired->GetBinContent(i));
132  }
133 }
134 
135 void
138  desc.addUntracked<std::string>( "dqmPath", "HLT/Throughput" );
139  descriptions.add("throughputServiceClient", desc);
140 }
141 
142 //define this as a plug-in
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
T min(T a, T b)
Definition: MathUtil.h:58
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
unsigned long long uint64_t
Definition: Time.h:15
TH1F * getTH1F(void) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~ThroughputServiceClient() override=default
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:323
void removeElement(Args &&...args)
Definition: DQMStore.h:202