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 // Root headers
6 #include <TH1F.h>
7 
8 // CMSSW headers
22 
24 public:
25  explicit FastTimerServiceClient(edm::ParameterSet const &);
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
29 
30 private:
32 
33  void analyze(const edm::Event & event, const edm::EventSetup & setup);
34  void beginJob();
35  void endJob();
36  void beginRun(edm::Run const & run, edm::EventSetup const & setup);
37  void endRun (edm::Run const & run, edm::EventSetup const & setup);
40 
41 private:
42  void fillSummaryPlots();
43 };
44 
46  m_dqm_path( config.getUntrackedParameter<std::string>( "dqmPath" ) )
47 {
48 }
49 
51 {
52 }
53 
54 void
56 {
57 }
58 
59 void
61 {
62 }
63 
64 void
66 {
67 }
68 
69 void
71 {
72 }
73 
74 void
76 {
78 }
79 
80 void
82 {
83 }
84 
85 void
87 {
89 }
90 
91 void
93 {
95  if (dqm == 0)
96  // cannot access the DQM store
97  return;
98 
99  MonitorElement * me;
100  me = dqm->get(m_dqm_path + "/event");
101  if (me == 0)
102  // no FastTimerService DQM information
103  return;
104  double events = me->getTH1F()->GetEntries();
105 
106  // note: the following (identical) loops need to be kept separate, as any of these group of histograms might be missing
107  // 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
109  TProfile const * paths = nullptr;
110  uint32_t size = 0;
111 
112  // extract the list of Paths and EndPaths from the summary plots
113  if (( me = dqm->get(m_dqm_path + "/paths_active_time") )) {
114  paths = me->getTProfile();
115  size = paths->GetXaxis()->GetNbins();
116  } else
117  if (( me = dqm->get(m_dqm_path + "/paths_total_time") )) {
118  paths = me->getTProfile();
119  size = paths->GetXaxis()->GetNbins();
120  } else
121  if (( me = dqm->get(m_dqm_path + "/paths_exclusive_time") )) {
122  paths = me->getTProfile();
123  size = paths->GetXaxis()->GetNbins();
124  }
125 
126  if (paths == nullptr)
127  return;
128 
129  // for each path, fill histograms with
130  // - the average time spent in each module (total time spent in that module, averaged over all events)
131  // - the running time spent in each module (total time spent in that module, averaged over the events where that module actually ran)
132  // - the "efficiency" of each module (number of time a module succeded divided by the number of times the has run)
133  dqm->setCurrentFolder(m_dqm_path + "/Paths");
134  for (uint32_t p = 1; p <= size; ++p) {
135  // extract the list of Paths and EndPaths from the bin labels of one of the summary plots
136  std::string label = paths->GetXaxis()->GetBinLabel(p);
137  MonitorElement * me_counter = dqm->get( m_dqm_path + "/Paths/" + label + "_module_counter" );
138  MonitorElement * me_total = dqm->get( m_dqm_path + "/Paths/" + label + "_module_total" );
139  if (me_counter == 0 or me_total == 0)
140  continue;
141  TH1F * counter = me_counter->getTH1F();
142  TH1F * total = me_total ->getTH1F();
143  uint32_t bins = counter->GetXaxis()->GetNbins();
144  double min = counter->GetXaxis()->GetXmin();
145  double max = counter->GetXaxis()->GetXmax();
146  TH1F * average = dqm->book1D(label + "_module_average", label + " module average", bins, min, max)->getTH1F();
147  TH1F * running = dqm->book1D(label + "_module_running", label + " module running", bins, min, max)->getTH1F();
148  TH1F * efficiency = dqm->book1D(label + "_module_efficiency", label + " module efficiency", bins, min, max)->getTH1F();
149  for (uint32_t i = 1; i <= bins; ++i) {
150  const char * module = counter->GetXaxis()->GetBinLabel(i);
151  average ->GetXaxis()->SetBinLabel(i, module);
152  running ->GetXaxis()->SetBinLabel(i, module);
153  efficiency->GetXaxis()->SetBinLabel(i, module);
154  double t = total ->GetBinContent(i);
155  double n = counter->GetBinContent(i);
156  double p = counter->GetBinContent(i+1);
157  average ->SetBinContent(i, t / events);
158  if (n) {
159  running ->SetBinContent(i, t / n);
160  efficiency->SetBinContent(i, p / n);
161  }
162  }
163  average->SetYTitle("processing time [ms]");
164  running->SetYTitle("processing time [ms]");
165  }
166 
167 }
168 
169 void
171  // The following says we do not know what parameters are allowed so do no validation
172  // Please change this to state exactly what you do use, even if it is no parameters
174  desc.addUntracked<std::string>( "dqmPath", "HLT/TimerService");
175  descriptions.add("fastTimerServiceClient", desc);
176 }
177 
178 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
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
#define min(a, b)
Definition: mlp_lapack.h:161
void analyze(const edm::Event &event, const edm::EventSetup &setup)
void endRun(edm::Run const &run, edm::EventSetup const &setup)
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
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:1473
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
void beginRun(edm::Run const &run, edm::EventSetup const &setup)
FastTimerServiceClient(edm::ParameterSet const &)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
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
TProfile * getTProfile(void) const
Definition: vlib.h:209
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:434
Definition: Run.h:36