Go to the documentation of this file.00001
00002 #include <string>
00003 #include <cstring>
00004
00005
00006 #include <boost/foreach.hpp>
00007
00008
00009 #include <TH1F.h>
00010
00011
00012 #include "FWCore/Framework/interface/Frameworkfwd.h"
00013 #include "FWCore/Framework/interface/EDAnalyzer.h"
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/Run.h"
00016 #include "FWCore/Framework/interface/LuminosityBlock.h"
00017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00019 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00020 #include "FWCore/ParameterSet/interface/Registry.h"
00021 #include "FWCore/ServiceRegistry/interface/Service.h"
00022 #include "DataFormats/Provenance/interface/ProcessHistory.h"
00023 #include "DQMServices/Core/interface/DQMStore.h"
00024 #include "DQMServices/Core/interface/MonitorElement.h"
00025
00026 class FastTimerServiceClient : public edm::EDAnalyzer {
00027 public:
00028 explicit FastTimerServiceClient(edm::ParameterSet const &);
00029 ~FastTimerServiceClient();
00030
00031 static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
00032
00033 private:
00034 std::string m_dqm_path;
00035
00036 void analyze(const edm::Event & event, const edm::EventSetup & setup);
00037 void beginJob();
00038 void endJob();
00039 void beginRun(edm::Run const & run, edm::EventSetup const & setup);
00040 void endRun (edm::Run const & run, edm::EventSetup const & setup);
00041 void beginLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup);
00042 void endLuminosityBlock (edm::LuminosityBlock const & lumi, edm::EventSetup const & setup);
00043 };
00044
00045 FastTimerServiceClient::FastTimerServiceClient(edm::ParameterSet const & config) :
00046 m_dqm_path( config.getUntrackedParameter<std::string>( "dqmPath", "TimerService") )
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 DQMStore * dqm = edm::Service<DQMStore>().operator->();
00078 if (dqm == 0)
00079
00080 return;
00081
00082 MonitorElement * me;
00083 me = dqm->get(m_dqm_path + "/event");
00084 if (me == 0)
00085
00086 return;
00087 double events = me->getTH1F()->GetEntries();
00088
00089
00090 dqm->setCurrentFolder(m_dqm_path);
00091 TH1F * path_active = dqm->get(m_dqm_path + "/path_active_time")->getTH1F();
00092 TH1F * path_total = dqm->get(m_dqm_path + "/path_total_time")->getTH1F();
00093 size_t size = path_total->GetXaxis()->GetNbins();
00094 for (size_t i = 0; i < size; ++i) {
00095
00096 std::string label = path_total->GetXaxis()->GetBinLabel(i+1);
00097 if (( me = dqm->get(m_dqm_path + "/Paths/" + label + "_total") ))
00098 path_total ->Fill(i, me->getTH1F()->GetMean());
00099 if (( me = dqm->get(m_dqm_path + "/Paths/" + label + "_active") ))
00100 path_active->Fill(i, me->getTH1F()->GetMean());
00101 }
00102
00103
00104
00105
00106
00107 dqm->setCurrentFolder(m_dqm_path + "/Paths");
00108 for (size_t p = 1; p <= size; ++p) {
00109
00110 std::string label = path_total->GetXaxis()->GetBinLabel(p);
00111 MonitorElement * me_counter = dqm->get( m_dqm_path + "/Paths/" + label + "_module_counter" );
00112 MonitorElement * me_total = dqm->get( m_dqm_path + "/Paths/" + label + "_module_total" );
00113 if (me_counter == 0 or me_total == 0)
00114 continue;
00115 TH1F * counter = me_counter->getTH1F();
00116 TH1F * total = me_total ->getTH1F();
00117 size_t bins = counter->GetXaxis()->GetNbins();
00118 double min = counter->GetXaxis()->GetXmin();
00119 double max = counter->GetXaxis()->GetXmax();
00120 TH1F * average = dqm->book1D(label + "_module_average", label + " module average", bins, min, max)->getTH1F();
00121 TH1F * running = dqm->book1D(label + "_module_running", label + " module running", bins, min, max)->getTH1F();
00122 TH1F * efficiency = dqm->book1D(label + "_module_efficiency", label + " module efficiency", bins, min, max)->getTH1F();
00123 for (size_t i = 1; i <= bins; ++i) {
00124 const char * module = counter->GetXaxis()->GetBinLabel(i);
00125 average ->GetXaxis()->SetBinLabel(i, module);
00126 running ->GetXaxis()->SetBinLabel(i, module);
00127 efficiency->GetXaxis()->SetBinLabel(i, module);
00128 double x = total ->GetBinContent(i);
00129 double n = counter->GetBinContent(i);
00130 double p = counter->GetBinContent(i+1);
00131 average ->SetBinContent(i, x / events);
00132 if (n) {
00133 running ->SetBinContent(i, x / n);
00134 efficiency->SetBinContent(i, p / n);
00135 }
00136 }
00137 }
00138
00139 }
00140
00141 void
00142 FastTimerServiceClient::beginLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup)
00143 {
00144 }
00145
00146 void
00147 FastTimerServiceClient::endLuminosityBlock(edm::LuminosityBlock const & lumi, edm::EventSetup const & setup)
00148 {
00149 }
00150
00151 void
00152 FastTimerServiceClient::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
00153
00154
00155 edm::ParameterSetDescription desc;
00156 desc.setUnknown();
00157 descriptions.addDefault(desc);
00158 }
00159
00160
00161 #include "FWCore/Framework/interface/MakerMacros.h"
00162 DEFINE_FWK_MODULE(FastTimerServiceClient);