CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/SiStripCommissioningSummary/src/SummaryPlot.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningSummary/interface/SummaryPlot.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 using namespace sistrip;
00006 
00007 // -----------------------------------------------------------------------------
00008 // 
00009 SummaryPlot::SummaryPlot( const std::string& monitorable, 
00010                           const std::string& presentation, 
00011                           const std::string& granularity, 
00012                           const std::string& level ) :
00013   mon_( sistrip::UNKNOWN_MONITORABLE ),
00014   pres_( sistrip::UNKNOWN_PRESENTATION ),
00015   view_( sistrip::UNKNOWN_VIEW ),
00016   gran_( sistrip::UNKNOWN_GRAN ),
00017   level_(""),
00018   isValid_(false)
00019 {
00020   
00021   // Extract enums from strings 
00022   mon_ = SiStripEnumsAndStrings::monitorable( monitorable );
00023   pres_ = SiStripEnumsAndStrings::presentation( presentation );
00024   gran_ = SiStripEnumsAndStrings::granularity( granularity );
00025   level_ = level;
00026   
00027   // Extract view and perform checks
00028   check();
00029   isValid_ = true;
00030 
00031   // Checks on member data
00032   if ( mon_ == sistrip::UNKNOWN_MONITORABLE ||
00033        mon_ == sistrip::UNDEFINED_MONITORABLE ) {
00034     edm::LogWarning(mlSummaryPlots_) 
00035       << "[SummaryPlot::" << __func__ << "]"
00036       << " Unexpected monitorable \"" 
00037       << SiStripEnumsAndStrings::monitorable(mon_) 
00038       << "\" based on input string \""
00039       << monitorable << "\"";
00040     isValid_ = false;
00041   }
00042   
00043   if ( pres_ == sistrip::UNKNOWN_PRESENTATION ||
00044        pres_ == sistrip::UNDEFINED_PRESENTATION ) {
00045     edm::LogWarning(mlSummaryPlots_) 
00046       << "[SummaryPlot::" << __func__ << "]"
00047       << " Unexpected presentation \"" 
00048       << SiStripEnumsAndStrings::presentation(pres_)
00049       << "\" based on input string \""
00050       << presentation << "\"";
00051     isValid_ = false;
00052   }
00053 
00054   if ( view_ == sistrip::UNKNOWN_VIEW ||
00055        view_ == sistrip::UNDEFINED_VIEW ) {
00056     edm::LogWarning(mlSummaryPlots_) 
00057       << "[SummaryPlot::" << __func__ << "]"
00058       << " Unexpected view \"" 
00059       << SiStripEnumsAndStrings::view(level_)
00060       << "\" based on input string \""
00061       << level << "\"";
00062     isValid_ = false;
00063   }
00064   
00065   if ( level_.empty() ||
00066        level_.find(sistrip::unknownView_) != std::string::npos ||
00067        level_.find(sistrip::undefinedView_) != std::string::npos ) {
00068     edm::LogWarning(mlSummaryPlots_) 
00069       << "[SummaryPlot::" << __func__ << "]"
00070       << " Unexpected top-level directory: \"" 
00071       << level_ << "\"";
00072     isValid_ = false;
00073   } 
00074   
00075   if ( gran_ == sistrip::UNKNOWN_GRAN ||
00076        ( gran_ == sistrip::UNDEFINED_GRAN && 
00077          pres_ != sistrip::HISTO_1D ) ) {
00078     edm::LogWarning(mlSummaryPlots_) 
00079       << "[SummaryPlot::" << __func__ << "]"
00080       << " Unexpected granularity: \"" 
00081       << SiStripEnumsAndStrings::granularity(gran_)
00082       << "\" based on input string \""
00083       << granularity << "\"";
00084     isValid_ = false;
00085   }
00086 
00087 }
00088 
00089 // -----------------------------------------------------------------------------
00090 // 
00091 SummaryPlot::SummaryPlot( const SummaryPlot& input ) :
00092   mon_( input.monitorable() ),
00093   pres_( input.presentation() ),
00094   view_( input.view() ),
00095   gran_( input.granularity() ),
00096   level_( input.level() ),
00097   isValid_( input.isValid() )
00098 {;}
00099 
00100 // -----------------------------------------------------------------------------
00101 // 
00102 SummaryPlot::SummaryPlot() :
00103   mon_( sistrip::UNKNOWN_MONITORABLE ),
00104   pres_( sistrip::UNKNOWN_PRESENTATION ),
00105   view_( sistrip::UNKNOWN_VIEW ),
00106   gran_( sistrip::UNKNOWN_GRAN ),
00107   level_(""),
00108   isValid_(false)
00109 {;}
00110 
00111 // -----------------------------------------------------------------------------
00112 // 
00113 void SummaryPlot::reset() {
00114   mon_ =  sistrip::UNKNOWN_MONITORABLE;
00115   pres_ =  sistrip::UNKNOWN_PRESENTATION;
00116   view_ = sistrip::UNKNOWN_VIEW;
00117   gran_ =  sistrip::UNKNOWN_GRAN;
00118   level_ = "";
00119   isValid_ = false;
00120 }
00121 
00122 // -----------------------------------------------------------------------------
00123 // 
00124 void SummaryPlot::check() {
00125 
00126   // Remove end "/" from level_ if it exists
00127   if ( !level_.empty() ) {
00128     std::string slash = level_.substr( level_.size()-1, 1 );
00129     if ( slash == sistrip::dir_ ) { level_ = level_.substr( 0, level_.size()-1 ); }
00130   }
00131   
00132   // Extract and check view 
00133   sistrip::View check = SiStripEnumsAndStrings::view( level_ );
00134   view_ = check;
00135   if ( check == sistrip::UNKNOWN_VIEW || 
00136        check == sistrip::UNDEFINED_VIEW ) {
00137     edm::LogWarning(mlSummaryPlots_)
00138       << "[SummaryPlot::" << __func__ << "]"
00139       << " Unexpected view \"" 
00140       << SiStripEnumsAndStrings::view( check )
00141       << "\"";
00142   }
00143   
00144   // Prepend sistrip::root_ to level_ if not found
00145   if ( level_.find( sistrip::root_ ) == std::string::npos ) { 
00146     if ( check == sistrip::UNKNOWN_VIEW ) {
00147       level_ = 
00148         std::string(sistrip::root_) + sistrip::dir_ + 
00149         sistrip::unknownView_ + sistrip::dir_ + 
00150         level_; 
00151     } else if ( check == sistrip::UNDEFINED_VIEW ) {
00152       level_ = 
00153         std::string(sistrip::root_) + sistrip::dir_ + 
00154         sistrip::undefinedView_ + sistrip::dir_ + 
00155         level_; 
00156     } else { 
00157       level_ = 
00158         std::string(sistrip::root_) + sistrip::dir_ + 
00159         level_; 
00160     }
00161   }
00162   
00163 }
00164 
00165 // -----------------------------------------------------------------------------
00166 // 
00167 void SummaryPlot::print( std::stringstream& ss ) const {
00168   ss << "[SummaryPlot::" << __func__ << "]" << std::endl
00169      << " Monitorable:  " <<  SiStripEnumsAndStrings::monitorable(mon_) << std::endl
00170      << " Presentation: " << SiStripEnumsAndStrings::presentation(pres_) << std::endl
00171      << " View:         " << SiStripEnumsAndStrings::view(view_) << std::endl
00172      << " TopLevelDir:  " << level_ << std::endl
00173      << " Granularity:  " << SiStripEnumsAndStrings::granularity(gran_) << std::endl;
00174 }
00175 
00176 // -----------------------------------------------------------------------------
00177 //
00178 std::ostream& operator<< ( std::ostream& os, const SummaryPlot& summary ) {
00179   std::stringstream ss;
00180   summary.print(ss);
00181   os << ss.str();
00182   return os;
00183 }
00184 
00185 
00186