00001 #include "Validation/RecoTau/plugins/DQMSimpleFileSaver.h" 00002 00003 // framework & common header files 00004 #include "FWCore/Framework/interface/Frameworkfwd.h" 00005 #include "FWCore/Framework/interface/MakerMacros.h" 00006 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00007 00008 //DQM services 00009 #include "DQMServices/Core/interface/DQMStore.h" 00010 #include "FWCore/ServiceRegistry/interface/Service.h" 00011 #include "DQMServices/Core/interface/MonitorElement.h" 00012 00013 #include <iostream> 00014 00015 DQMSimpleFileSaver::DQMSimpleFileSaver(const edm::ParameterSet& cfg) 00016 { 00017 //std::cout << "<DQMSimpleFileSaver::DQMSimpleFileSaver>:" << std::endl; 00018 00019 cfgError_ = 0; 00020 00021 outputFileName_ = cfg.getParameter<std::string>("outputFileName"); 00022 if ( outputFileName_ == "" ) { 00023 edm::LogError("DQMSimpleFileSaver") << " No outputFileName specified --> histograms will NOT be saved !!"; 00024 cfgError_ = 1; 00025 } else if ( outputFileName_.find(".root") == std::string::npos ) { 00026 edm::LogError("DQMSimpleFileSaver") << " Invalid outputFileName = " << outputFileName_ << " --> histograms will NOT be saved !!"; 00027 cfgError_ = 1; 00028 } 00029 } 00030 00031 DQMSimpleFileSaver::~DQMSimpleFileSaver() 00032 { 00033 // nothing to be done yet... 00034 } 00035 00036 void DQMSimpleFileSaver::analyze(const edm::Event&, const edm::EventSetup&) 00037 { 00038 // nothing to be done yet... 00039 } 00040 00041 void DQMSimpleFileSaver::endJob() 00042 { 00043 std::cout << "<DQMSimpleFileSaver::endJob>:" << std::endl; 00044 00045 //--- check that configuration parameters contain no errors 00046 if ( cfgError_ ) { 00047 edm::LogError ("endJob") << " Error in Configuration ParameterSet --> histograms will NOT be saved !!"; 00048 return; 00049 } 00050 00051 //--- check that DQMStore service is available 00052 if ( !edm::Service<DQMStore>().isAvailable() ) { 00053 edm::LogError ("endJob") << " Failed to access dqmStore --> histograms will NOT be saved !!"; 00054 return; 00055 } 00056 00057 DQMStore& dqmStore = (*edm::Service<DQMStore>()); 00058 dqmStore.save(outputFileName_); 00059 } 00060 00061 #include "FWCore/Framework/interface/MakerMacros.h" 00062 00063 DEFINE_FWK_MODULE(DQMSimpleFileSaver);