CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/SiStripCommissioningSummary/src/SummaryGeneratorReadoutView.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningSummary/interface/SummaryGeneratorReadoutView.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00004 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <iostream>
00007 #include <iomanip>
00008 #include <sstream>
00009 #include <cmath>
00010 
00011 using namespace sistrip;
00012 
00013 // -----------------------------------------------------------------------------
00014 // 
00015 SummaryGeneratorReadoutView::SummaryGeneratorReadoutView() :
00016   SummaryGenerator("SummaryGeneratorReadoutView") {;}
00017 
00018 // -----------------------------------------------------------------------------
00019 // 
00020 void SummaryGeneratorReadoutView::fill( const std::string& top_level_dir,
00021                                         const sistrip::Granularity& granularity,
00022                                         const uint32_t& device_key, 
00023                                         const float& value,
00024                                         const float& error ) {
00025   
00026   // Check granularity is recognised
00027   std::string gran = SiStripEnumsAndStrings::granularity( granularity );
00028   
00029   if ( granularity != sistrip::UNDEFINED_GRAN &&
00030        granularity != sistrip::FE_DRIVER &&
00031        granularity != sistrip::FE_UNIT &&
00032        granularity != sistrip::FE_CHAN &&
00033        granularity != sistrip::APV ) {
00034     std::string temp = SiStripEnumsAndStrings::granularity( sistrip::FE_CHAN );
00035     edm::LogWarning(mlSummaryPlots_) 
00036       << "[SummaryGeneratorReadoutView::" << __func__ << "]"
00037       << " Unexpected granularity requested: " << gran;
00038     return;
00039   }
00040   
00041   // Create key representing "top level" directory 
00042   SiStripFedKey top( top_level_dir );
00043   
00044   // Path and std::string for "present working directory" as defined by device key
00045   SiStripFedKey path( device_key );
00046   std::string pwd = path.path();
00047   
00048   // Check path is "within" top-level directory structure 
00049   if ( top.isValid() &&
00050        path.isValid() &&
00051        ( path.fedId() == top.fedId() || !top.fedId() ) && 
00052        ( path.feUnit() == top.feUnit() || !top.feUnit() ) && 
00053        ( path.feChan() == top.feChan() || !top.feChan() ) ) {
00054     
00055     // Extract path and std::string corresponding to "top-level down to granularity" 
00056     std::string sub_dir = pwd;
00057     size_t pos = pwd.find( gran );
00058     if ( pos != std::string::npos ) {
00059       sub_dir = pwd.substr( 0, pwd.find(sistrip::dir_,pos) );
00060     } else if ( granularity == sistrip::UNKNOWN_GRAN ) {
00061       sub_dir = pwd;
00062     }
00063     
00064     SiStripFedKey sub_path( sub_dir );
00065 
00066 //     LogTrace(mlTest_)
00067 //       << "TEST " 
00068 //       << "sub_path " << sub_path; 
00069     
00070     // Construct bin label
00071     std::stringstream bin;
00072     if ( sub_path.fedId()  && sub_path.fedId()  != sistrip::invalid_ ) { bin << std::setw(3) << std::setfill('0') << sub_path.fedId(); }
00073     if ( sub_path.feUnit() && sub_path.feUnit() != sistrip::invalid_ ) { bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.feUnit(); }
00074     if ( sub_path.feChan() && sub_path.feChan() != sistrip::invalid_ ) { bin << sistrip::dir_ << std::setw(2) << std::setfill('0') << sub_path.feChan(); }
00075     if ( sub_path.fedApv() && sub_path.fedApv() != sistrip::invalid_ ) { bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.fedApv(); }
00076 //     if ( granularity == sistrip::APV &&
00077 //       path.fedApv() != sistrip::invalid_ ) { bin << sistrip::dot_ << path.fedApv(); }
00078     
00079     // Store "value" in appropriate std::vector within std::map (key is bin label)
00080     map_[bin.str()].push_back( Data(value,error) );
00081     entries_ += value;
00082 //     LogTrace(mlTest_)
00083 //       << "TEST " 
00084 //       << " filling " << bin.str() 
00085 //       << " " << value 
00086 //       << " " << error;
00087     
00088     
00089   } else {
00090 //     std::stringstream ss;
00091 //     ss << "[SummaryGeneratorReadoutView::" << __func__ << "]"
00092 //        << " Path for 'pwd' is not within top-level directory!" << std::endl
00093 //        << "Top-level: " << top << std::endl
00094 //        << "Path: " << path << std::endl;
00095 //     edm::LogWarning(mlSummaryPlots_) << ss.str();
00096   }
00097   
00098 }
00099