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;
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
ConfigurationDescriptions.h
DQMEDHarvester.h
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
min
T min(T a, T b)
Definition: MathUtil.h:58
printsummarytable.folder
folder
Definition: printsummarytable.py:7
LuminosityBlock.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:678
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:478
dqmdumpme.first
first
Definition: dqmdumpme.py:55
folders
*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
ThroughputServiceClient::fillSummaryPlots
void fillSummaryPlots(DQMStore::IBooker &booker, DQMStore::IGetter &getter)
Definition: ThroughputServiceClient.cc:61
config
Definition: config.py:1
ThroughputServiceClient::ThroughputServiceClient
ThroughputServiceClient(edm::ParameterSet const &)
Definition: ThroughputServiceClient.cc:46
MakerMacros.h
dqmdumpme.last
last
Definition: dqmdumpme.py:56
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
ProcessHistory.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Service.h
Run.h
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
ThroughputServiceClient::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &booker, DQMStore::IGetter &getter, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: ThroughputServiceClient.cc:54
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
ThroughputServiceClient::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ThroughputServiceClient.cc:143
ThroughputServiceClient::m_dqm_path
const std::string m_dqm_path
Definition: ThroughputServiceClient.cc:33
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
ThroughputServiceClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
Definition: ThroughputServiceClient.cc:50
ThroughputServiceClient::m_dqm_merge
const bool m_dqm_merge
Definition: ThroughputServiceClient.cc:34
ThroughputServiceClient::~ThroughputServiceClient
~ThroughputServiceClient() override=default
average
Definition: average.py:1
edm::EventSetup
Definition: EventSetup.h:57
Registry.h
DQMEDHarvester
Definition: DQMEDHarvester.py:1
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
dqm::implementation::IBooker
Definition: DQMStore.h:43
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
ParameterSet.h
ThroughputServiceClient
Definition: ThroughputServiceClient.cc:25
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98