CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastTimerServiceClient.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:
28  explicit FastTimerServiceClient(edm::ParameterSet const &);
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
32 
33 private:
35 
36  void analyze(const edm::Event & event, const edm::EventSetup & setup) override;
37  void endRun(edm::Run const & run, edm::EventSetup const & setup) override;
38  void endLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup) override;
39 
40 private:
41  void fillSummaryPlots();
43  void fillPathSummaryPlots(double events, std::string const & path);
44 };
45 
46 
48  m_dqm_path( config.getUntrackedParameter<std::string>( "dqmPath" ) )
49 {
50 }
51 
53 {
54 }
55 
56 void
58 {
59 }
60 
61 void
63 {
65 }
66 
67 void
69 {
71 }
72 
73 void
75 {
77  if (dqm == 0)
78  // cannot access the DQM store
79  return;
80 
81  if (dqm->get(m_dqm_path + "/event")) {
82  // the plots are directly in the configured folder
84  } else {
85  static const boost::regex running_n_processes(".*/Running [0-9]+ processes");
87  std::vector<std::string> subdirs = dqm->getSubdirs();
88  for (auto const & subdir: subdirs) {
89  if (boost::regex_match(subdir, running_n_processes)) {
90  // the plots are in a per-number-of-processes folder
91  if (dqm->get(subdir + "/event"))
93  }
94  }
95  }
96 }
97 
98 
99 
100 void
103 
104  MonitorElement * me = dqm->get(current_path + "/event");
105  if (me == 0)
106  // no FastTimerService DQM information
107  return;
108 
109  double events = me->getTH1F()->GetEntries();
110 
111  // look for per-process directories
112  static const boost::regex process_name(".*/process .*");
113  dqm->setCurrentFolder(current_path);
114  std::vector<std::string> subdirs = dqm->getSubdirs();
115  for (auto const & subdir: subdirs) {
116  if (boost::regex_match(subdir, process_name)) {
117  // look for per-path plots inside each per-process directory
118  if (dqm->dirExists(subdir + "/Paths"))
119  fillPathSummaryPlots(events, subdir);
120  }
121  }
122 
123  // look for per-path plots inside the current directory
124  if (dqm->dirExists(current_path + "/Paths"))
125  fillPathSummaryPlots(events, current_path);
126 }
127 
128 void
131 
132  // note: the following checks need to be kept separate, as any of these histograms might be missing
133  // if any of them is filled, size will have the total number of paths, and "paths" can be used to extract the list of labels
134  MonitorElement * me;
135  TProfile const * paths = nullptr;
136  uint32_t size = 0;
137 
138  // extract the list of Paths and EndPaths from the summary plots
139  if (( me = dqm->get(current_path + "/paths_active_time") )) {
140  paths = me->getTProfile();
141  size = paths->GetXaxis()->GetNbins();
142  } else
143  if (( me = dqm->get(current_path + "/paths_total_time") )) {
144  paths = me->getTProfile();
145  size = paths->GetXaxis()->GetNbins();
146  } else
147  if (( me = dqm->get(current_path + "/paths_exclusive_time") )) {
148  paths = me->getTProfile();
149  size = paths->GetXaxis()->GetNbins();
150  }
151 
152  if (paths == nullptr)
153  return;
154 
155  // for each path, fill histograms with
156  // - the average time spent in each module (total time spent in that module, averaged over all events)
157  // - the running time spent in each module (total time spent in that module, averaged over the events where that module actually ran)
158  // - the "efficiency" of each module (number of time a module succeded divided by the number of times the has run)
159  dqm->setCurrentFolder(current_path + "/Paths");
160  for (uint32_t p = 1; p <= size; ++p) {
161  // extract the list of Paths and EndPaths from the bin labels of one of the summary plots
162  std::string label = paths->GetXaxis()->GetBinLabel(p);
163  MonitorElement * me_counter = dqm->get( current_path + "/Paths/" + label + "_module_counter" );
164  MonitorElement * me_total = dqm->get( current_path + "/Paths/" + label + "_module_total" );
165  if (me_counter == 0 or me_total == 0)
166  continue;
167  TH1F * counter = me_counter->getTH1F();
168  TH1F * total = me_total ->getTH1F();
169  uint32_t bins = counter->GetXaxis()->GetNbins();
170  double min = counter->GetXaxis()->GetXmin();
171  double max = counter->GetXaxis()->GetXmax();
172  TH1F * average = dqm->book1D(label + "_module_average", label + " module average", bins, min, max)->getTH1F();
173  average ->SetYTitle("processing time [ms]");
174  TH1F * running = dqm->book1D(label + "_module_running", label + " module running", bins, min, max)->getTH1F();
175  running ->SetYTitle("processing time [ms]");
176  TH1F * efficiency = dqm->book1D(label + "_module_efficiency", label + " module efficiency", bins, min, max)->getTH1F();
177  efficiency->SetYTitle("filter efficiency");
178  efficiency->SetMaximum(1.05);
179  for (uint32_t i = 1; i <= bins; ++i) {
180  const char * module = counter->GetXaxis()->GetBinLabel(i);
181  average ->GetXaxis()->SetBinLabel(i, module);
182  running ->GetXaxis()->SetBinLabel(i, module);
183  efficiency->GetXaxis()->SetBinLabel(i, module);
184  double t = total ->GetBinContent(i);
185  double n = counter->GetBinContent(i);
186  double p = counter->GetBinContent(i+1);
187  average ->SetBinContent(i, t / events);
188  if (n) {
189  running ->SetBinContent(i, t / n);
190  efficiency->SetBinContent(i, p / n);
191  }
192  }
193  }
194 
195 }
196 
197 void
199  // The following says we do not know what parameters are allowed so do no validation
200  // Please change this to state exactly what you do use, even if it is no parameters
202  desc.addUntracked<std::string>( "dqmPath", "HLT/TimerService");
203  descriptions.add("fastTimerServiceClient", desc);
204 }
205 
206 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1574
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:35
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
const T & max(const T &a, const T &b)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
FastTimerServiceClient(edm::ParameterSet const &)
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:648
void fillProcessSummaryPlots(std::string const &path)
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
void endRun(edm::Run const &run, edm::EventSetup const &setup) override
TH1F * getTH1F(void) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int average
Definition: PDRates.py:137
tuple events
Definition: patZpeak.py:19
static std::atomic< unsigned int > counter
TProfile * getTProfile(void) const
void fillPathSummaryPlots(double events, std::string const &path)
Definition: vlib.h:208
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41