CMS 3D CMS Logo

SummaryGeneratorReadoutView.cc
Go to the documentation of this file.
6 #include <iostream>
7 #include <iomanip>
8 #include <sstream>
9 #include <cmath>
10 
11 using namespace sistrip;
12 
13 // -----------------------------------------------------------------------------
14 //
16 
17 // -----------------------------------------------------------------------------
18 //
21  const uint32_t& device_key,
22  const float& value,
23  const float& error) {
24  // Check granularity is recognised
26 
30  edm::LogWarning(mlSummaryPlots_) << "[SummaryGeneratorReadoutView::" << __func__ << "]"
31  << " Unexpected granularity requested: " << gran;
32  return;
33  }
34 
35  // Create key representing "top level" directory
36  SiStripFedKey top(top_level_dir);
37 
38  // Path and std::string for "present working directory" as defined by device key
39  SiStripFedKey path(device_key);
40  const std::string& pwd = path.path();
41 
42  // Check path is "within" top-level directory structure
43  if (top.isValid() && path.isValid() && (path.fedId() == top.fedId() || !top.fedId()) &&
44  (path.feUnit() == top.feUnit() || !top.feUnit()) && (path.feChan() == top.feChan() || !top.feChan())) {
45  // Extract path and std::string corresponding to "top-level down to granularity"
46  std::string sub_dir = pwd;
47  size_t pos = pwd.find(gran);
48  if (pos != std::string::npos) {
49  sub_dir = pwd.substr(0, pwd.find(sistrip::dir_, pos));
50  } else if (granularity == sistrip::UNKNOWN_GRAN) {
51  sub_dir = pwd;
52  }
53 
54  SiStripFedKey sub_path(sub_dir);
55 
56  // LogTrace(mlTest_)
57  // << "TEST "
58  // << "sub_path " << sub_path;
59 
60  // Construct bin label
61  std::stringstream bin;
62  if (sub_path.fedId() && sub_path.fedId() != sistrip::invalid_) {
63  bin << std::setw(3) << std::setfill('0') << sub_path.fedId();
64  }
65  if (sub_path.feUnit() && sub_path.feUnit() != sistrip::invalid_) {
66  bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.feUnit();
67  }
68  if (sub_path.feChan() && sub_path.feChan() != sistrip::invalid_) {
69  bin << sistrip::dir_ << std::setw(2) << std::setfill('0') << sub_path.feChan();
70  }
71  if (sub_path.fedApv() && sub_path.fedApv() != sistrip::invalid_) {
72  bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.fedApv();
73  }
74  // if ( granularity == sistrip::APV &&
75  // path.fedApv() != sistrip::invalid_ ) { bin << sistrip::dot_ << path.fedApv(); }
76 
77  // Store "value" in appropriate std::vector within std::map (key is bin label)
78  map_[bin.str()].push_back(Data(value, error));
79  entries_ += value;
80  // LogTrace(mlTest_)
81  // << "TEST "
82  // << " filling " << bin.str()
83  // << " " << value
84  // << " " << error;
85 
86  } else {
87  // std::stringstream ss;
88  // ss << "[SummaryGeneratorReadoutView::" << __func__ << "]"
89  // << " Path for 'pwd' is not within top-level directory!" << std::endl
90  // << "Top-level: " << top << std::endl
91  // << "Path: " << path << std::endl;
92  // edm::LogWarning(mlSummaryPlots_) << ss.str();
93  }
94 }
void fill(const std::string &directory_level, const sistrip::Granularity &, const uint32_t &key, const float &value, const float &error) override
const uint16_t & fedApv() const
const uint16_t & feChan() const
static const char dir_[]
const uint16_t & feUnit() const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
static std::string granularity(const sistrip::Granularity &)
: Fills summary histograms.
sistrip classes
Definition: value.py:1
static const char mlSummaryPlots_[]
const uint16_t & fedId() const
std::pair< float, float > Data
static const uint16_t invalid_
Definition: Constants.h:16
Log< level::Warning, false > LogWarning
bool isValid() const override