Go to the documentation of this file.00001
00002 #include <string>
00003 #include <cstring>
00004
00005
00006 #include <TH1F.h>
00007
00008
00009 #include "FWCore/Framework/interface/Frameworkfwd.h"
00010 #include "FWCore/Framework/interface/EDAnalyzer.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/Run.h"
00013 #include "FWCore/Framework/interface/LuminosityBlock.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00017 #include "FWCore/ParameterSet/interface/Registry.h"
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 #include "DataFormats/Provenance/interface/ProcessHistory.h"
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 #include "DQMServices/Core/interface/MonitorElement.h"
00022
00023 class FastTimerServiceClient : public edm::EDAnalyzer {
00024 public:
00025 explicit FastTimerServiceClient(edm::ParameterSet const &);
00026 ~FastTimerServiceClient();
00027
00028 static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
00029
00030 private:
00031 std::string m_dqm_path;
00032
00033 void analyze(const edm::Event & event, const edm::EventSetup & setup);
00034 void beginJob();
00035 void endJob();
00036 void beginRun(edm::Run const & run, edm::EventSetup const & setup);
00037 void endRun (edm::Run const & run, edm::EventSetup const & setup);
00038 void beginLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup);
00039 void endLuminosityBlock (edm::LuminosityBlock const & lumi, edm::EventSetup const & setup);
00040
00041 private:
00042 void fillSummaryPlots();
00043 };
00044
00045 FastTimerServiceClient::FastTimerServiceClient(edm::ParameterSet const & config) :
00046 m_dqm_path( config.getUntrackedParameter<std::string>( "dqmPath" ) )
00047 {
00048 }
00049
00050 FastTimerServiceClient::~FastTimerServiceClient()
00051 {
00052 }
00053
00054 void
00055 FastTimerServiceClient::analyze(edm::Event const & event, edm::EventSetup const & setup)
00056 {
00057 }
00058
00059 void
00060 FastTimerServiceClient::beginJob(void)
00061 {
00062 }
00063
00064 void
00065 FastTimerServiceClient::endJob(void)
00066 {
00067 }
00068
00069 void
00070 FastTimerServiceClient::beginRun(edm::Run const & run, edm::EventSetup const & setup)
00071 {
00072 }
00073
00074 void
00075 FastTimerServiceClient::endRun(edm::Run const & run, edm::EventSetup const & setup)
00076 {
00077 fillSummaryPlots();
00078 }
00079
00080 void
00081 FastTimerServiceClient::beginLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup)
00082 {
00083 }
00084
00085 void
00086 FastTimerServiceClient::endLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup)
00087 {
00088 fillSummaryPlots();
00089 }
00090
00091 void
00092 FastTimerServiceClient::fillSummaryPlots(void)
00093 {
00094 DQMStore * dqm = edm::Service<DQMStore>().operator->();
00095 if (dqm == 0)
00096
00097 return;
00098
00099 MonitorElement * me;
00100 me = dqm->get(m_dqm_path + "/event");
00101 if (me == 0)
00102
00103 return;
00104 double events = me->getTH1F()->GetEntries();
00105
00106
00107
00108 dqm->setCurrentFolder(m_dqm_path);
00109 TProfile const * paths = nullptr;
00110 uint32_t size = 0;
00111
00112
00113 if (( me = dqm->get(m_dqm_path + "/paths_active_time") )) {
00114 paths = me->getTProfile();
00115 size = paths->GetXaxis()->GetNbins();
00116 } else
00117 if (( me = dqm->get(m_dqm_path + "/paths_total_time") )) {
00118 paths = me->getTProfile();
00119 size = paths->GetXaxis()->GetNbins();
00120 } else
00121 if (( me = dqm->get(m_dqm_path + "/paths_exclusive_time") )) {
00122 paths = me->getTProfile();
00123 size = paths->GetXaxis()->GetNbins();
00124 }
00125
00126 if (paths == nullptr)
00127 return;
00128
00129
00130
00131
00132
00133 dqm->setCurrentFolder(m_dqm_path + "/Paths");
00134 for (uint32_t p = 1; p <= size; ++p) {
00135
00136 std::string label = paths->GetXaxis()->GetBinLabel(p);
00137 MonitorElement * me_counter = dqm->get( m_dqm_path + "/Paths/" + label + "_module_counter" );
00138 MonitorElement * me_total = dqm->get( m_dqm_path + "/Paths/" + label + "_module_total" );
00139 if (me_counter == 0 or me_total == 0)
00140 continue;
00141 TH1F * counter = me_counter->getTH1F();
00142 TH1F * total = me_total ->getTH1F();
00143 uint32_t bins = counter->GetXaxis()->GetNbins();
00144 double min = counter->GetXaxis()->GetXmin();
00145 double max = counter->GetXaxis()->GetXmax();
00146 TH1F * average = dqm->book1D(label + "_module_average", label + " module average", bins, min, max)->getTH1F();
00147 TH1F * running = dqm->book1D(label + "_module_running", label + " module running", bins, min, max)->getTH1F();
00148 TH1F * efficiency = dqm->book1D(label + "_module_efficiency", label + " module efficiency", bins, min, max)->getTH1F();
00149 for (uint32_t i = 1; i <= bins; ++i) {
00150 const char * module = counter->GetXaxis()->GetBinLabel(i);
00151 average ->GetXaxis()->SetBinLabel(i, module);
00152 running ->GetXaxis()->SetBinLabel(i, module);
00153 efficiency->GetXaxis()->SetBinLabel(i, module);
00154 double t = total ->GetBinContent(i);
00155 double n = counter->GetBinContent(i);
00156 double p = counter->GetBinContent(i+1);
00157 average ->SetBinContent(i, t / events);
00158 if (n) {
00159 running ->SetBinContent(i, t / n);
00160 efficiency->SetBinContent(i, p / n);
00161 }
00162 }
00163 average->SetYTitle("processing time [ms]");
00164 running->SetYTitle("processing time [ms]");
00165 }
00166
00167 }
00168
00169 void
00170 FastTimerServiceClient::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
00171
00172
00173 edm::ParameterSetDescription desc;
00174 desc.addUntracked<std::string>( "dqmPath", "HLT/TimerService");
00175 descriptions.add("fastTimerServiceClient", desc);
00176 }
00177
00178
00179 #include "FWCore/Framework/interface/MakerMacros.h"
00180 DEFINE_FWK_MODULE(FastTimerServiceClient);