00001 #include "Validation/RecoTau/plugins/DQMHistAdder.h" 00002 00003 #include "Validation/RecoTau/plugins/dqmAuxFunctions.h" 00004 00005 // framework & common header files 00006 #include "FWCore/Framework/interface/Frameworkfwd.h" 00007 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00008 00009 //DQM services 00010 #include "DQMServices/Core/interface/DQMStore.h" 00011 #include "FWCore/ServiceRegistry/interface/Service.h" 00012 #include "DQMServices/Core/interface/MonitorElement.h" 00013 00014 #include <TH1.h> 00015 00016 #include <iostream> 00017 00018 const double defaultScaleFactor = 1.; 00019 00020 const int verbosity = 0; 00021 00022 // 00023 //----------------------------------------------------------------------------------------------------------------------- 00024 // 00025 00026 DQMHistAdder::cfgEntryAddJob::cfgEntryAddJob(const std::string& name, const edm::ParameterSet& cfg) 00027 { 00028 //std::cout << "<DQMHistAdder::cfgEntryAddJob>" << std::endl; 00029 00030 name_ = name; 00031 00032 dqmDirectories_input_ = cfg.getParameter<vstring>("dqmDirectories_input"); 00033 dqmDirectory_output_ = cfg.getParameter<std::string>("dqmDirectory_output"); 00034 00035 if ( verbosity ) print(); 00036 } 00037 00038 void DQMHistAdder::cfgEntryAddJob::print() const 00039 { 00040 std::cout << "<cfgEntryAddJob::print>:" << std::endl; 00041 std::cout << " name = " << name_ << std::endl; 00042 std::cout << " dqmDirectories_input = " << format_vstring(dqmDirectories_input_) << std::endl; 00043 std::cout << " dqmDirectory_output = " << dqmDirectory_output_ << std::endl; 00044 } 00045 00046 // 00047 //----------------------------------------------------------------------------------------------------------------------- 00048 // 00049 00050 DQMHistAdder::DQMHistAdder(const edm::ParameterSet& cfg) 00051 { 00052 std::cout << "<DQMHistAdder::DQMHistAdder>:" << std::endl; 00053 00054 cfgError_ = 0; 00055 00056 //--- configure processes 00057 //std::cout << "--> configuring addJobs..." << std::endl; 00058 readCfgParameter<cfgEntryAddJob>(cfg, addJobs_); 00059 00060 std::cout << "done." << std::endl; 00061 } 00062 00063 DQMHistAdder::~DQMHistAdder() 00064 { 00065 // nothing to be done yet... 00066 } 00067 00068 void DQMHistAdder::analyze(const edm::Event&, const edm::EventSetup&) 00069 { 00070 // nothing to be done yet... 00071 } 00072 00073 void DQMHistAdder::endJob() 00074 { 00075 std::cout << "<DQMHistAdder::endJob>:" << std::endl; 00076 00077 //--- check that configuration parameters contain no errors 00078 if ( cfgError_ ) { 00079 edm::LogError ("endJob") << " Error in Configuration ParameterSet --> histograms will NOT be added !!"; 00080 return; 00081 } 00082 00083 //--- check that DQMStore service is available 00084 if ( !edm::Service<DQMStore>().isAvailable() ) { 00085 edm::LogError ("endJob") << " Failed to access dqmStore --> histograms will NOT be added !!"; 00086 return; 00087 } 00088 00089 //--- stop ROOT from keeping references to all histograms 00090 //TH1::AddDirectory(false); 00091 00092 //--- add histograms 00093 //std::cout << "--> adding histograms..." << std::endl; 00094 DQMStore& dqmStore = (*edm::Service<DQMStore>()); 00095 for ( std::map<std::string, cfgEntryAddJob>::const_iterator addJob = addJobs_.begin(); 00096 addJob != addJobs_.end(); ++addJob ) { 00097 const std::string& dqmDirectory_output = addJob->second.dqmDirectory_output_; 00098 for ( vstring::const_iterator dqmDirectory_input = addJob->second.dqmDirectories_input_.begin(); 00099 dqmDirectory_input != addJob->second.dqmDirectories_input_.end(); ++dqmDirectory_input ) { 00100 00101 std::string inputDirectory = dqmDirectoryName(std::string(dqmRootDirectory)).append(*dqmDirectory_input); 00102 //std::cout << " inputDirectory = " << inputDirectory << std::endl; 00103 std::string outputDirectory = dqmDirectoryName(std::string(dqmRootDirectory)).append(dqmDirectory_output); 00104 //std::cout << " outputDirectory = " << outputDirectory << std::endl; 00105 00106 //--- when processing first inputDirectory, check that histograms in outputDirectory do not yet exist; 00107 // afterwards, add histograms in inputDirectory to those in outputDirectory 00108 int mode = ( dqmDirectory_input == addJob->second.dqmDirectories_input_.begin() ) ? 1 : 3; 00109 //std::cout << " mode = " << mode << std::endl; 00110 dqmCopyRecursively(dqmStore, inputDirectory, outputDirectory, 1., mode, false); 00111 } 00112 } 00113 00114 std::cout << "done." << std::endl; 00115 if ( verbosity ) dqmStore.showDirStructure(); 00116 } 00117 00118 #include "FWCore/Framework/interface/MakerMacros.h" 00119 00120 DEFINE_FWK_MODULE(DQMHistAdder);