Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
#include "DQM/SiPixelMonitorClient/interface/ANSIColors.h"
#include "DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iostream>

using namespace std;

//
// -- Constructor
//
SiPixelConfigParser::SiPixelConfigParser() {
  edm::LogInfo("SiPixelConfigParser") << " Creating SiPixelConfigParser "
                                      << "\n";
}

void SiPixelConfigParser::getDocument(std::string filename) {
  boost::property_tree::ptree xml;
  boost::property_tree::read_xml(filename, xml);

  auto it = xml.find("MonElementConfiguration");
  if (it == xml.not_found()) {
    throw cms::Exception("SiPixelConfigParser")
        << "SiPixelConfigParser XML needs to have a MonElementConfiguration node.";
  }
  this->config_ = it->second;
}

static bool readMEListHelper(boost::property_tree::ptree &config, string const &tagname, vector<string> &me_names) {
  for (auto &kv : config) {
    if (kv.first == tagname) {
      for (auto &mekv : kv.second) {
        if (mekv.first == "MonElement") {
          me_names.push_back(mekv.second.get<std::string>("<xmlattr>.name"));
        }
      }
      return true;
    }
  }
  return false;
}

//
// -- Read ME list for the TrackerMap
//
bool SiPixelConfigParser::getMENamesForTrackerMap(string &tkmap_name, vector<string> &me_names) {
  tkmap_name = config_.get<std::string>("TkMap.<xmlattr>.name", "");
  return readMEListHelper(config_, "TkMap", me_names);
}
//
// -- Read Update Frequency for the TrackerMap
//
bool SiPixelConfigParser::getFrequencyForTrackerMap(int &u_freq) {
  u_freq = config_.get<int>("TkMap.<xmlattr>.update_frequency", -1);
  if (u_freq >= 0)
    return true;
  return false;
}
//
// -- Get List of MEs for the module tree plots:
//
bool SiPixelConfigParser::getMENamesForTree(string &structure_name, vector<string> &me_names) {
  structure_name = config_.get<std::string>("SummaryPlot.SubStructureLevel.<xmlattr>.name", "");
  auto it = config_.find("SummaryPlot");
  if (it == config_.not_found())
    return false;
  return readMEListHelper(it->second, "SubStructureLevel", me_names);
}
//
// -- Get List of MEs for the summary plot and the
//
bool SiPixelConfigParser::getMENamesForBarrelSummary(string &structure_name, vector<string> &me_names) {
  structure_name = config_.get<std::string>("SummaryPlot.SubStructureBarrelLevel.<xmlattr>.name", "");
  auto it = config_.find("SummaryPlot");
  if (it == config_.not_found())
    return false;
  return readMEListHelper(it->second, "SubStructureBarrelLevel", me_names);
}
bool SiPixelConfigParser::getMENamesForEndcapSummary(string &structure_name, vector<string> &me_names) {
  structure_name = config_.get<std::string>("SummaryPlot.SubStructureEndcapLevel.<xmlattr>.name", "");
  auto it = config_.find("SummaryPlot");
  if (it == config_.not_found())
    return false;
  return readMEListHelper(it->second, "SubStructureEndcapLevel", me_names);
}

bool SiPixelConfigParser::getMENamesForFEDErrorSummary(string &structure_name, vector<string> &me_names) {
  structure_name = config_.get<std::string>("SummaryPlot.SubStructureNonDetId.<xmlattr>.name", "");
  auto it = config_.find("SummaryPlot");
  if (it == config_.not_found())
    return false;
  return readMEListHelper(it->second, "SubStructureNonDetId", me_names);
}
////
// -- Get List of MEs for the summary plot and the
//
bool SiPixelConfigParser::getFrequencyForBarrelSummary(int &u_freq) {
  u_freq = config_.get<int>("SummaryPlot.SubStructureBarrelLevel.<xmlattr>.update_frequency", -1);
  if (u_freq >= 0)
    return true;
  return false;
}

bool SiPixelConfigParser::getFrequencyForEndcapSummary(int &u_freq) {
  u_freq = config_.get<int>("SummaryPlot.SubStructureEndcapLevel.<xmlattr>.update_frequency", -1);
  if (u_freq >= 0)
    return true;
  return false;
}

bool SiPixelConfigParser::getMENamesForGrandBarrelSummary(string &structure_name, vector<string> &me_names) {
  structure_name = config_.get<std::string>("SummaryPlot.SubStructureGrandBarrelLevel.<xmlattr>.name", "");
  auto it = config_.find("SummaryPlot");
  if (it == config_.not_found())
    return false;
  return readMEListHelper(it->second, "SubStructureGrandBarrelLevel", me_names);
}

bool SiPixelConfigParser::getMENamesForGrandEndcapSummary(string &structure_name, vector<string> &me_names) {
  structure_name = config_.get<std::string>("SummaryPlot.SubStructureGrandEndcapLevel.<xmlattr>.name", "");
  auto it = config_.find("SummaryPlot");
  if (it == config_.not_found())
    return false;
  return readMEListHelper(it->second, "SubStructureGrandEndcapLevel", me_names);
}

bool SiPixelConfigParser::getFrequencyForGrandBarrelSummary(int &u_freq) {
  u_freq = config_.get<int>("SummaryPlot.SubStructureGrandBarrelLevel.<xmlattr>.update_frequency", -1);
  if (u_freq >= 0)
    return true;
  return false;
}

bool SiPixelConfigParser::getFrequencyForGrandEndcapSummary(int &u_freq) {
  u_freq = config_.get<int>("SummaryPlot.SubStructureGrandEndcapLevel.<xmlattr>.update_frequency", -1);
  if (u_freq >= 0)
    return true;
  return false;
}

bool SiPixelConfigParser::getMessageLimitForQTests(int &u_freq) {
  u_freq = config_.get<int>("QTests.QTestMessageLimit.<xmlattr>.value", -1);
  if (u_freq >= 0)
    return true;
  return false;
}

bool SiPixelConfigParser::getSourceType(int &u_freq) {
  u_freq = config_.get<int>("Source.SourceType.<xmlattr>.code", -1);
  if (u_freq >= 0)
    return true;
  return false;
}

bool SiPixelConfigParser::getCalibType(int &u_freq) {
  u_freq = config_.get<int>("Calib.CalibType.<xmlattr>.value", -1);
  if (u_freq >= 0)
    return true;
  return false;
}