CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/SiStripCommissioningSummary/src/SummaryGeneratorControlView.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningSummary/interface/SummaryGeneratorControlView.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00004 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.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 SummaryGeneratorControlView::SummaryGeneratorControlView() :
00016   SummaryGenerator("SummaryGeneratorControlView") {;}
00017 
00018 // -----------------------------------------------------------------------------
00019 // 
00020 void SummaryGeneratorControlView::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::FEC_CRATE &&
00031        granularity != sistrip::FEC_SLOT &&
00032        granularity != sistrip::FEC_RING &&
00033        granularity != sistrip::CCU_ADDR &&
00034        granularity != sistrip::CCU_CHAN &&
00035        granularity != sistrip::LLD_CHAN && 
00036        granularity != sistrip::APV ) {
00037     std::string temp = SiStripEnumsAndStrings::granularity( sistrip::LLD_CHAN );
00038     edm::LogWarning(mlSummaryPlots_) 
00039       << "[SummaryGeneratorControlView::" << __func__ << "]"
00040       << " Unexpected granularity requested: " << gran;
00041     return;
00042   }
00043   
00044   // Create key representing "top level" directory 
00045   SiStripFecKey top( top_level_dir );
00046   
00047   // Path and std::string for "present working directory" as defined by device key
00048   SiStripFecKey path( device_key );
00049   std::string pwd = path.path();
00050 
00051 //   LogTrace(mlTest_)
00052 //     << "TEST " 
00053 //     << "top " << top 
00054 //     << "path " << path;
00055   
00056   if ( top.isValid() &&
00057        path.isValid() &&
00058        ( path.fecCrate() == top.fecCrate() || !top.fecCrate() ) && 
00059        ( path.fecSlot() == top.fecSlot() || !top.fecSlot() ) && 
00060        ( path.fecRing() == top.fecRing() || !top.fecRing() ) && 
00061        ( path.ccuAddr() == top.ccuAddr() || !top.ccuAddr() ) && 
00062        ( path.ccuChan() == top.ccuChan() || !top.ccuChan() ) ) {
00063     
00064     // Extract path and std::string corresponding to "top-level down to granularity" 
00065     std::string sub_dir = pwd;
00066     size_t pos = pwd.find( gran );
00067     if ( pos != std::string::npos ) {
00068       sub_dir = pwd.substr( 0, pwd.find(sistrip::dir_,pos) );
00069     } else if ( granularity == sistrip::UNKNOWN_GRAN ) {
00070       sub_dir = pwd;
00071     }
00072 
00073     SiStripFecKey sub_path( sub_dir );
00074 
00075 //     LogTrace(mlTest_)
00076 //       << "TEST " 
00077 //       << "sub_path " << sub_path; 
00078     
00079     // Construct bin label
00080     std::stringstream bin;
00081     if ( sub_path.fecCrate() != sistrip::invalid_ ) { bin << std::setw(1) << std::setfill('0') << sub_path.fecCrate(); }
00082     if ( sub_path.fecSlot()  != sistrip::invalid_ ) { bin << sistrip::dot_ << std::setw(2) << std::setfill('0') << sub_path.fecSlot(); }
00083     if ( sub_path.fecRing()  != sistrip::invalid_ ) { bin << sistrip::dot_ << std::setw(1) << std::setfill('0') << sub_path.fecRing(); }
00084     if ( sub_path.ccuAddr()  != sistrip::invalid_ ) { bin << sistrip::dot_ << std::setw(3) << std::setfill('0') << sub_path.ccuAddr(); }
00085     if ( sub_path.ccuChan()  != sistrip::invalid_ ) { bin << sistrip::dot_ << std::setw(2) << std::setfill('0') << sub_path.ccuChan(); }
00086     if ( ( granularity == sistrip::LLD_CHAN || 
00087            granularity == sistrip::APV ) && 
00088          path.channel() != sistrip::invalid_ ) { bin << sistrip::dot_ << path.channel(); }
00089     
00090     // Store "value" in appropriate std::vector within std::map (key is bin label)
00091     map_[bin.str()].push_back( Data(value,error) );
00092     entries_++;
00093 //     LogTrace(mlTest_)
00094 //       << "TEST " 
00095 //       << " filling " << bin.str() << " " << value << " " << error << " ";
00096 
00097   }
00098   
00099 }
00100