CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  SummaryGenerator("SummaryGeneratorReadoutView") {;}
17 
18 // -----------------------------------------------------------------------------
19 //
21  const sistrip::Granularity& granularity,
22  const uint32_t& device_key,
23  const float& value,
24  const float& error ) {
25 
26  // Check granularity is recognised
28 
29  if ( granularity != sistrip::UNDEFINED_GRAN &&
30  granularity != sistrip::FE_DRIVER &&
31  granularity != sistrip::FE_UNIT &&
32  granularity != sistrip::FE_CHAN &&
33  granularity != sistrip::APV ) {
36  << "[SummaryGeneratorReadoutView::" << __func__ << "]"
37  << " Unexpected granularity requested: " << gran;
38  return;
39  }
40 
41  // Create key representing "top level" directory
42  SiStripFedKey top( top_level_dir );
43 
44  // Path and std::string for "present working directory" as defined by device key
45  SiStripFedKey path( device_key );
46  std::string pwd = path.path();
47 
48  // Check path is "within" top-level directory structure
49  if ( top.isValid() &&
50  path.isValid() &&
51  ( path.fedId() == top.fedId() || !top.fedId() ) &&
52  ( path.feUnit() == top.feUnit() || !top.feUnit() ) &&
53  ( path.feChan() == top.feChan() || !top.feChan() ) ) {
54 
55  // Extract path and std::string corresponding to "top-level down to granularity"
56  std::string sub_dir = pwd;
57  size_t pos = pwd.find( gran );
58  if ( pos != std::string::npos ) {
59  sub_dir = pwd.substr( 0, pwd.find(sistrip::dir_,pos) );
60  } else if ( granularity == sistrip::UNKNOWN_GRAN ) {
61  sub_dir = pwd;
62  }
63 
64  SiStripFedKey sub_path( sub_dir );
65 
66 // LogTrace(mlTest_)
67 // << "TEST "
68 // << "sub_path " << sub_path;
69 
70  // Construct bin label
71  std::stringstream bin;
72  if ( sub_path.fedId() && sub_path.fedId() != sistrip::invalid_ ) { bin << std::setw(3) << std::setfill('0') << sub_path.fedId(); }
73  if ( sub_path.feUnit() && sub_path.feUnit() != sistrip::invalid_ ) { bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.feUnit(); }
74  if ( sub_path.feChan() && sub_path.feChan() != sistrip::invalid_ ) { bin << sistrip::dir_ << std::setw(2) << std::setfill('0') << sub_path.feChan(); }
75  if ( sub_path.fedApv() && sub_path.fedApv() != sistrip::invalid_ ) { bin << sistrip::dir_ << std::setw(1) << std::setfill('0') << sub_path.fedApv(); }
76 // if ( granularity == sistrip::APV &&
77 // path.fedApv() != sistrip::invalid_ ) { bin << sistrip::dot_ << path.fedApv(); }
78 
79  // Store "value" in appropriate std::vector within std::map (key is bin label)
80  map_[bin.str()].push_back( Data(value,error) );
81  entries_ += value;
82 // LogTrace(mlTest_)
83 // << "TEST "
84 // << " filling " << bin.str()
85 // << " " << value
86 // << " " << error;
87 
88 
89  } else {
90 // std::stringstream ss;
91 // ss << "[SummaryGeneratorReadoutView::" << __func__ << "]"
92 // << " Path for 'pwd' is not within top-level directory!" << std::endl
93 // << "Top-level: " << top << std::endl
94 // << "Path: " << path << std::endl;
95 // edm::LogWarning(mlSummaryPlots_) << ss.str();
96  }
97 
98 }
99 
static const char dir_[]
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:57
static std::string granularity(const sistrip::Granularity &)
: Fills summary histograms.
std::pair< float, float > Data
bool isValid() const
const std::string & path() const
Definition: SiStripKey.h:127
void fill(const std::string &directory_level, const sistrip::Granularity &, const uint32_t &key, const float &value, const float &error)
static const char mlSummaryPlots_[]
const uint16_t & fedApv() const
const uint16_t & feUnit() const
static const uint16_t invalid_
Definition: Constants.h:17
const uint16_t & feChan() const
const uint16_t & fedId() const