Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/SiPixelMonitorClient/interface/ANSIColors.h"
0002 #include "DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include <iostream>
0005 
0006 using namespace std;
0007 
0008 //
0009 // -- Constructor
0010 //
0011 SiPixelConfigParser::SiPixelConfigParser() {
0012   edm::LogInfo("SiPixelConfigParser") << " Creating SiPixelConfigParser "
0013                                       << "\n";
0014 }
0015 
0016 void SiPixelConfigParser::getDocument(std::string filename) {
0017   boost::property_tree::ptree xml;
0018   boost::property_tree::read_xml(filename, xml);
0019 
0020   auto it = xml.find("MonElementConfiguration");
0021   if (it == xml.not_found()) {
0022     throw cms::Exception("SiPixelConfigParser")
0023         << "SiPixelConfigParser XML needs to have a MonElementConfiguration node.";
0024   }
0025   this->config_ = it->second;
0026 }
0027 
0028 static bool readMEListHelper(boost::property_tree::ptree &config, string const &tagname, vector<string> &me_names) {
0029   for (auto &kv : config) {
0030     if (kv.first == tagname) {
0031       for (auto &mekv : kv.second) {
0032         if (mekv.first == "MonElement") {
0033           me_names.push_back(mekv.second.get<std::string>("<xmlattr>.name"));
0034         }
0035       }
0036       return true;
0037     }
0038   }
0039   return false;
0040 }
0041 
0042 //
0043 // -- Read ME list for the TrackerMap
0044 //
0045 bool SiPixelConfigParser::getMENamesForTrackerMap(string &tkmap_name, vector<string> &me_names) {
0046   tkmap_name = config_.get<std::string>("TkMap.<xmlattr>.name", "");
0047   return readMEListHelper(config_, "TkMap", me_names);
0048 }
0049 //
0050 // -- Read Update Frequency for the TrackerMap
0051 //
0052 bool SiPixelConfigParser::getFrequencyForTrackerMap(int &u_freq) {
0053   u_freq = config_.get<int>("TkMap.<xmlattr>.update_frequency", -1);
0054   if (u_freq >= 0)
0055     return true;
0056   return false;
0057 }
0058 //
0059 // -- Get List of MEs for the module tree plots:
0060 //
0061 bool SiPixelConfigParser::getMENamesForTree(string &structure_name, vector<string> &me_names) {
0062   structure_name = config_.get<std::string>("SummaryPlot.SubStructureLevel.<xmlattr>.name", "");
0063   auto it = config_.find("SummaryPlot");
0064   if (it == config_.not_found())
0065     return false;
0066   return readMEListHelper(it->second, "SubStructureLevel", me_names);
0067 }
0068 //
0069 // -- Get List of MEs for the summary plot and the
0070 //
0071 bool SiPixelConfigParser::getMENamesForBarrelSummary(string &structure_name, vector<string> &me_names) {
0072   structure_name = config_.get<std::string>("SummaryPlot.SubStructureBarrelLevel.<xmlattr>.name", "");
0073   auto it = config_.find("SummaryPlot");
0074   if (it == config_.not_found())
0075     return false;
0076   return readMEListHelper(it->second, "SubStructureBarrelLevel", me_names);
0077 }
0078 bool SiPixelConfigParser::getMENamesForEndcapSummary(string &structure_name, vector<string> &me_names) {
0079   structure_name = config_.get<std::string>("SummaryPlot.SubStructureEndcapLevel.<xmlattr>.name", "");
0080   auto it = config_.find("SummaryPlot");
0081   if (it == config_.not_found())
0082     return false;
0083   return readMEListHelper(it->second, "SubStructureEndcapLevel", me_names);
0084 }
0085 
0086 bool SiPixelConfigParser::getMENamesForFEDErrorSummary(string &structure_name, vector<string> &me_names) {
0087   structure_name = config_.get<std::string>("SummaryPlot.SubStructureNonDetId.<xmlattr>.name", "");
0088   auto it = config_.find("SummaryPlot");
0089   if (it == config_.not_found())
0090     return false;
0091   return readMEListHelper(it->second, "SubStructureNonDetId", me_names);
0092 }
0093 ////
0094 // -- Get List of MEs for the summary plot and the
0095 //
0096 bool SiPixelConfigParser::getFrequencyForBarrelSummary(int &u_freq) {
0097   u_freq = config_.get<int>("SummaryPlot.SubStructureBarrelLevel.<xmlattr>.update_frequency", -1);
0098   if (u_freq >= 0)
0099     return true;
0100   return false;
0101 }
0102 
0103 bool SiPixelConfigParser::getFrequencyForEndcapSummary(int &u_freq) {
0104   u_freq = config_.get<int>("SummaryPlot.SubStructureEndcapLevel.<xmlattr>.update_frequency", -1);
0105   if (u_freq >= 0)
0106     return true;
0107   return false;
0108 }
0109 
0110 bool SiPixelConfigParser::getMENamesForGrandBarrelSummary(string &structure_name, vector<string> &me_names) {
0111   structure_name = config_.get<std::string>("SummaryPlot.SubStructureGrandBarrelLevel.<xmlattr>.name", "");
0112   auto it = config_.find("SummaryPlot");
0113   if (it == config_.not_found())
0114     return false;
0115   return readMEListHelper(it->second, "SubStructureGrandBarrelLevel", me_names);
0116 }
0117 
0118 bool SiPixelConfigParser::getMENamesForGrandEndcapSummary(string &structure_name, vector<string> &me_names) {
0119   structure_name = config_.get<std::string>("SummaryPlot.SubStructureGrandEndcapLevel.<xmlattr>.name", "");
0120   auto it = config_.find("SummaryPlot");
0121   if (it == config_.not_found())
0122     return false;
0123   return readMEListHelper(it->second, "SubStructureGrandEndcapLevel", me_names);
0124 }
0125 
0126 bool SiPixelConfigParser::getFrequencyForGrandBarrelSummary(int &u_freq) {
0127   u_freq = config_.get<int>("SummaryPlot.SubStructureGrandBarrelLevel.<xmlattr>.update_frequency", -1);
0128   if (u_freq >= 0)
0129     return true;
0130   return false;
0131 }
0132 
0133 bool SiPixelConfigParser::getFrequencyForGrandEndcapSummary(int &u_freq) {
0134   u_freq = config_.get<int>("SummaryPlot.SubStructureGrandEndcapLevel.<xmlattr>.update_frequency", -1);
0135   if (u_freq >= 0)
0136     return true;
0137   return false;
0138 }
0139 
0140 bool SiPixelConfigParser::getMessageLimitForQTests(int &u_freq) {
0141   u_freq = config_.get<int>("QTests.QTestMessageLimit.<xmlattr>.value", -1);
0142   if (u_freq >= 0)
0143     return true;
0144   return false;
0145 }
0146 
0147 bool SiPixelConfigParser::getSourceType(int &u_freq) {
0148   u_freq = config_.get<int>("Source.SourceType.<xmlattr>.code", -1);
0149   if (u_freq >= 0)
0150     return true;
0151   return false;
0152 }
0153 
0154 bool SiPixelConfigParser::getCalibType(int &u_freq) {
0155   u_freq = config_.get<int>("Calib.CalibType.<xmlattr>.value", -1);
0156   if (u_freq >= 0)
0157     return true;
0158   return false;
0159 }