Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:38

0001 #include "DQM/SiStripCommissioningSummary/interface/SummaryGeneratorReadoutView.h"
0002 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0004 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <iostream>
0007 #include <iomanip>
0008 #include <sstream>
0009 #include <cmath>
0010 
0011 using namespace sistrip;
0012 
0013 // -----------------------------------------------------------------------------
0014 //
0015 SummaryGeneratorReadoutView::SummaryGeneratorReadoutView() : SummaryGenerator("SummaryGeneratorReadoutView") { ; }
0016 
0017 // -----------------------------------------------------------------------------
0018 //
0019 void SummaryGeneratorReadoutView::fill(const std::string& top_level_dir,
0020                                        const sistrip::Granularity& granularity,
0021                                        const uint32_t& device_key,
0022                                        const float& value,
0023                                        const float& error) {
0024   // Check granularity is recognised
0025   std::string gran = SiStripEnumsAndStrings::granularity(granularity);
0026 
0027   if (granularity != sistrip::UNDEFINED_GRAN && granularity != sistrip::FE_DRIVER && granularity != sistrip::FE_UNIT &&
0028       granularity != sistrip::FE_CHAN && granularity != sistrip::APV) {
0029     std::string temp = SiStripEnumsAndStrings::granularity(sistrip::FE_CHAN);
0030     edm::LogWarning(mlSummaryPlots_) << "[SummaryGeneratorReadoutView::" << __func__ << "]"
0031                                      << " Unexpected granularity requested: " << gran;
0032     return;
0033   }
0034 
0035   // Create key representing "top level" directory
0036   SiStripFedKey top(top_level_dir);
0037 
0038   // Path and std::string for "present working directory" as defined by device key
0039   SiStripFedKey path(device_key);
0040   const std::string& pwd = path.path();
0041 
0042   // Check path is "within" top-level directory structure
0043   if (top.isValid() && path.isValid() && (path.fedId() == top.fedId() || !top.fedId()) &&
0044       (path.feUnit() == top.feUnit() || !top.feUnit()) && (path.feChan() == top.feChan() || !top.feChan())) {
0045     // Extract path and std::string corresponding to "top-level down to granularity"
0046     std::string sub_dir = pwd;
0047     size_t pos = pwd.find(gran);
0048     if (pos != std::string::npos) {
0049       sub_dir = pwd.substr(0, pwd.find(sistrip::dir_, pos));
0050     } else if (granularity == sistrip::UNKNOWN_GRAN) {
0051       sub_dir = pwd;
0052     }
0053 
0054     SiStripFedKey sub_path(sub_dir);
0055 
0056     //     LogTrace(mlTest_)
0057     //       << "TEST "
0058     //       << "sub_path " << sub_path;
0059 
0060     // Construct bin label
0061     std::stringstream bin;
0062     if (sub_path.fedId() && sub_path.fedId() != sistrip::invalid_) {
0063       bin << std::setw(3) << std::setfill('0') << sub_path.fedId();
0064     }
0065     if (sub_path.feUnit() && sub_path.feUnit() != sistrip::invalid_) {
0066       bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.feUnit();
0067     }
0068     if (sub_path.feChan() && sub_path.feChan() != sistrip::invalid_) {
0069       bin << sistrip::dir_ << std::setw(2) << std::setfill('0') << sub_path.feChan();
0070     }
0071     if (sub_path.fedApv() && sub_path.fedApv() != sistrip::invalid_) {
0072       bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.fedApv();
0073     }
0074     //     if ( granularity == sistrip::APV &&
0075     //   path.fedApv() != sistrip::invalid_ ) { bin << sistrip::dot_ << path.fedApv(); }
0076 
0077     // Store "value" in appropriate std::vector within std::map (key is bin label)
0078     map_[bin.str()].push_back(Data(value, error));
0079     entries_ += value;
0080     //     LogTrace(mlTest_)
0081     //       << "TEST "
0082     //       << " filling " << bin.str()
0083     //       << " " << value
0084     //       << " " << error;
0085 
0086   } else {
0087     //     std::stringstream ss;
0088     //     ss << "[SummaryGeneratorReadoutView::" << __func__ << "]"
0089     //        << " Path for 'pwd' is not within top-level directory!" << std::endl
0090     //        << "Top-level: " << top << std::endl
0091     //        << "Path: " << path << std::endl;
0092     //     edm::LogWarning(mlSummaryPlots_) << ss.str();
0093   }
0094 }