Go to the documentation of this file.00001 #include "DQM/SiStripCommissioningSummary/interface/SummaryPlotFactoryBase.h"
00002 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include <iostream>
00006
00007 using namespace sistrip;
00008
00009
00010
00011 SummaryPlotFactoryBase::SummaryPlotFactoryBase() :
00012 mon_(sistrip::UNKNOWN_MONITORABLE),
00013 pres_(sistrip::UNKNOWN_PRESENTATION),
00014 view_(sistrip::UNKNOWN_VIEW),
00015 level_(sistrip::root_),
00016 gran_(sistrip::UNKNOWN_GRAN),
00017 generator_(0)
00018 {;}
00019
00020
00021
00022 SummaryPlotFactoryBase::~SummaryPlotFactoryBase() {
00023 if ( generator_ ) { delete generator_; }
00024 }
00025
00026
00027
00028 void SummaryPlotFactoryBase::init( const sistrip::Monitorable& mon,
00029 const sistrip::Presentation& pres,
00030 const sistrip::View& view,
00031 const std::string& level,
00032 const sistrip::Granularity& gran ) {
00033
00034
00035 if ( generator_ ) { delete generator_; generator_ = 0; }
00036 generator_ = SummaryGenerator::instance( view );
00037
00038
00039 if ( !generator_ ) {
00040 edm::LogWarning(mlSummaryPlots_)
00041 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00042 << " NULL pointer to generator object!";
00043 return;
00044 }
00045
00046
00047 generator_->clearMap();
00048
00049
00050 mon_ = mon;
00051 pres_ = pres;
00052 view_ = view;
00053 level_ = level;
00054 gran_ = gran;
00055
00056
00057 if ( mon_ == sistrip::UNKNOWN_MONITORABLE ||
00058 mon_ == sistrip::UNDEFINED_MONITORABLE ) {
00059 edm::LogWarning(mlSummaryPlots_)
00060 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00061 << " Unexpected monitorable: "
00062 << SiStripEnumsAndStrings::monitorable(mon_);
00063 }
00064
00065 if ( pres_ == sistrip::UNKNOWN_PRESENTATION ||
00066 pres_ == sistrip::UNDEFINED_PRESENTATION ) {
00067 edm::LogWarning(mlSummaryPlots_)
00068 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00069 << " Unexpected presentation: "
00070 << SiStripEnumsAndStrings::presentation(pres_);
00071 }
00072
00073 if ( view_ == sistrip::UNKNOWN_VIEW ||
00074 view_ == sistrip::UNDEFINED_VIEW ) {
00075 edm::LogWarning(mlSummaryPlots_)
00076 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00077 << " Unexpected view: "
00078 << SiStripEnumsAndStrings::view(view_);
00079 }
00080
00081 if ( level_.empty() ||
00082 level_.find(sistrip::unknownView_) != std::string::npos ||
00083 level_.find(sistrip::undefinedView_) != std::string::npos ) {
00084 edm::LogWarning(mlSummaryPlots_)
00085 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00086 << " Unexpected top-level directory: \""
00087 << level_ << "\"";
00088 }
00089
00090 if ( ( gran_ == sistrip::UNKNOWN_GRAN ||
00091 gran_ == sistrip::UNDEFINED_GRAN ) &&
00092 pres != sistrip::HISTO_1D ) {
00093 edm::LogWarning(mlSummaryPlots_)
00094 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00095 << " Unexpected granularity: "
00096 << SiStripEnumsAndStrings::granularity(gran_);
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 }
00109
00110
00111
00112 void SummaryPlotFactoryBase::fill( TH1& summary_histo ) {
00113
00114
00115 if ( !generator_ ) {
00116 edm::LogWarning(mlSummaryPlots_)
00117 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00118 << " NULL pointer to SummaryGenerator object!";
00119 return;
00120 }
00121
00122
00123 if ( !generator_->nBins() ) {
00124 edm::LogWarning(mlSummaryPlots_)
00125 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00126 << " Zero bins returned by SummaryGenerator!";
00127 return;
00128 }
00129
00130
00131 if ( !(&summary_histo) ) {
00132 edm::LogWarning(mlSummaryPlots_)
00133 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00134 << " NULL pointer to TH1 object!";
00135 return;
00136 }
00137
00138
00139
00140
00141
00142 if ( pres_ == sistrip::HISTO_1D ) {
00143 generator_->histo1D( summary_histo );
00144 } else if ( pres_ == sistrip::HISTO_2D_SUM ) {
00145 generator_->histo2DSum( summary_histo );
00146 } else if ( pres_ == sistrip::HISTO_2D_SCATTER ) {
00147 generator_->histo2DScatter( summary_histo );
00148 } else if ( pres_ == sistrip::PROFILE_1D ) {
00149 generator_->profile1D( summary_histo );
00150 } else {
00151 edm::LogWarning(mlSummaryPlots_)
00152 << "[SummaryPlotFactoryBase::" << __func__ << "]"
00153 << " Unexpected presentation type: "
00154 << SiStripEnumsAndStrings::presentation( pres_ );
00155 return;
00156 }
00157
00158
00159 generator_->format( sistrip::UNKNOWN_RUN_TYPE,
00160 mon_,
00161 pres_,
00162 view_,
00163 level_,
00164 gran_,
00165 summary_histo );
00166
00167 }