CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc

Go to the documentation of this file.
00001 #include "DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h"
00002 #include "DQM/SiPixelMonitorClient/interface/ANSIColors.h"
00003 #include "DQMServices/ClientConfig/interface/ParserFunctions.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include <iostream>
00006 
00007 using namespace xercesc;
00008 using namespace std;
00009 
00010 //
00011 // -- Constructor
00012 // 
00013 SiPixelConfigParser::SiPixelConfigParser() : DQMParserBase() {
00014   edm::LogInfo("SiPixelConfigParser") << 
00015     " Creating SiPixelConfigParser " << "\n" ;
00016 }
00017 //
00018 // --  Destructor
00019 // 
00020 SiPixelConfigParser::~SiPixelConfigParser() {
00021   edm::LogInfo("SiPixelActionExecutor") << 
00022     " Deleting SiPixelConfigParser " << "\n" ;
00023 }
00024 //
00025 // -- Read ME list for the TrackerMap
00026 //
00027 bool SiPixelConfigParser::getMENamesForTrackerMap(string& tkmap_name, 
00028                                                  vector<string>& me_names){
00029   if (!doc()) {
00030     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00031     return false;
00032   }
00033 
00034   me_names.clear();
00035   unsigned int tkMapNodes = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->getLength();
00036   if (tkMapNodes != 1) 
00037   {
00038    cout << ACYellow << ACBold 
00039         << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00040         << ACRed << ACBold
00041         << "No TkMap tag found in configuration file"
00042         << ACPlain << endl ;
00043    return false;
00044   }
00046   DOMNode* tkMapNode = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->item(0);
00047  //Get QTEST name
00048   if (! tkMapNode) 
00049   {
00050    cout << ACYellow << ACBold 
00051         << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00052         << ACRed << ACBold
00053         << " No TkMap tag elements found in configuration file"
00054         << ACPlain << endl ;
00055    return false;
00056   }
00057   DOMElement* tkMapElement = static_cast<DOMElement *>(tkMapNode);          
00058   if (! tkMapElement) 
00059   {
00060    cout << ACYellow << ACBold 
00061         << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00062         << ACRed << ACBold
00063         << " No TkMap tag dom elements found in configuration file"
00064         << ACPlain << endl ;
00065    return false;                 
00066   }             
00067   tkmap_name = qtxml::_toString(tkMapElement->getAttribute(qtxml::_toDOMS("name")));
00068         
00069   DOMNodeList * meList 
00070                   = tkMapElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00071   if( meList->getLength() == 0 )
00072   {
00073     cout << ACYellow << ACBold 
00074          << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00075          << ACRed << ACBold
00076          << " No MonElement found in configuration file"
00077          << ACPlain << endl ;
00078   }
00079   for (unsigned int k = 0; k < meList->getLength(); k++) {
00080     DOMNode* meNode = meList->item(k);
00081     if (!meNode) 
00082     {
00083      cout << ACYellow << ACBold 
00084           << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00085           << ACRed << ACBold
00086           << " No MonElement item found in configuration file"
00087           << ACPlain << endl ;
00088      return false;
00089     }
00090     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00091     if (!meElement) 
00092     { 
00093      cout << ACYellow << ACBold 
00094           << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00095           << ACRed << ACBold
00096           << " No MonElement sub-elements found in configuration file"
00097           << ACPlain << endl ;
00098      return false;
00099     }
00100     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00101     me_names.push_back(me_name);    
00102   }
00103   if (me_names.size() == 0) 
00104   {
00105     cout << ACYellow << ACBold 
00106          << "[SiPixelConfigParser::getMENamesForTrackerMap()]"
00107          << ACRed << ACBold
00108          << " No MonElement sub-element names found in configuration file"
00109          << ACPlain << endl ;
00110    return false;
00111   } else {
00112    return true;
00113   }
00114 }
00115 //
00116 // -- Read Update Frequency for the TrackerMap
00117 //
00118 bool SiPixelConfigParser::getFrequencyForTrackerMap(int& u_freq){
00119   if (!doc()) {
00120     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00121     return false;
00122   }
00123 
00124   unsigned int tkMapNodes = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->getLength();
00125   if (tkMapNodes != 1) return false;
00127   DOMNode* tkMapNode = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->item(0);
00128  //Get Node name
00129   if (! tkMapNode) return false;
00130   DOMElement* tkMapElement = static_cast<DOMElement *>(tkMapNode);          
00131   if (! tkMapElement) return false;              
00132                 
00133   u_freq = atoi(qtxml::_toString(tkMapElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str());
00134   return true;
00135 }
00136 //
00137 // -- Get List of MEs for the module tree plots:
00138 //
00139 bool SiPixelConfigParser::getMENamesForTree(string& structure_name,
00140                                                 vector<string>& me_names) {
00141   //cout<<"Entering SiPixelConfigParser::getMENamesForTree..."<<endl;
00142   if (!doc()) {
00143     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00144     return false;
00145   }
00146 
00147   me_names.clear();
00148   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureLevel"))->getLength();
00149   if (structureNodes == 0) return false;
00151   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureLevel"))->item(0);
00152  //Get QTEST name
00153   if (! structureNode) return false;
00154   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00155   if (! structureElement) return false;          
00156                 
00157   structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); 
00158 
00159   DOMNodeList * meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00160   for (unsigned int k = 0; k < meList->getLength(); k++) {
00161     DOMNode* meNode = meList->item(k);
00162     if (!meNode) return false;
00163     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00164     if (!meElement) return false;
00165     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00166     me_names.push_back(me_name);    
00167   }
00168   if (me_names.size() == 0) return false;
00169   else return true;
00170   //cout<<"...leaving SiPixelConfigParser::getMENamesForTree!"<<endl;
00171   
00172 }
00173 //
00174 // -- Get List of MEs for the summary plot and the
00175 //
00176 bool SiPixelConfigParser::getMENamesForBarrelSummary(string& structure_name,
00177                                                 vector<string>& me_names) {
00178 //  cout<<"Entering SiPixelConfigParser::getMENamesForBarrelSummary..."<<endl;
00179   if (!doc()) {
00180     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00181     return false;
00182   }
00183   me_names.clear();
00184   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->getLength();
00185   if (structureNodes == 0) return false;
00187   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->item(0);
00188  //Get QTEST name
00189   if (! structureNode) return false;
00190   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00191   if (! structureElement) return false;          
00192   structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); 
00193 
00194   DOMNodeList * meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00195   for (unsigned int k = 0; k < meList->getLength(); k++) {
00196     DOMNode* meNode = meList->item(k);
00197     if (!meNode) return false;
00198     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00199     if (!meElement) return false;
00200     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00201     me_names.push_back(me_name);    
00202   }
00203 //  cout<<"...leaving SiPixelConfigParser::getMENamesForBarrelSummary!"<<endl;
00204   if (me_names.size() == 0) return false;
00205   else return true;
00206   
00207 }
00208 bool SiPixelConfigParser::getMENamesForEndcapSummary(string& structure_name,
00209                                                 vector<string>& me_names) {
00210 //  cout<<"Entering SiPixelConfigParser::getMENamesForEndcapSummary..."<<endl;
00211   if (!doc()) {
00212     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00213     return false;
00214   }
00215 
00216   me_names.clear();
00217   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->getLength();
00218   if (structureNodes == 0) return false;
00220   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->item(0);
00221  //Get QTEST name
00222   if (! structureNode) return false;
00223   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00224   if (! structureElement) return false;          
00225                 
00226   structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); 
00227 
00228   DOMNodeList * meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00229   for (unsigned int k = 0; k < meList->getLength(); k++) {
00230     DOMNode* meNode = meList->item(k);
00231     if (!meNode) return false;
00232     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00233     if (!meElement) return false;
00234     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00235     me_names.push_back(me_name);    
00236   }
00237   if (me_names.size() == 0) return false;
00238   else return true;
00239 //  cout<<"...leaving SiPixelConfigParser::getMENamesForEndcapSummary!"<<endl;
00240   
00241 }
00242 
00243 
00244 bool SiPixelConfigParser::getMENamesForFEDErrorSummary(string& structure_name,
00245                                                        vector<string>& me_names) {
00246   //cout<<"Entering SiPixelConfigParser::getMENamesForFEDErrorSummary..."<<endl;
00247   if (!doc()) {
00248     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00249     return false;
00250   }
00251 
00252   me_names.clear();
00253   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureNonDetId"))->getLength();
00254   if (structureNodes == 0) return false;
00256   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureNonDetId"))->item(0);
00257  //Get QTEST name
00258   if (! structureNode) return false;
00259   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00260   if (! structureElement) return false;          
00261                 
00262   structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); 
00263 
00264   DOMNodeList * meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00265   for (unsigned int k = 0; k < meList->getLength(); k++) {
00266     DOMNode* meNode = meList->item(k);
00267     if (!meNode) return false;
00268     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00269     if (!meElement) return false;
00270     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00271     me_names.push_back(me_name);    
00272   }
00273   if (me_names.size() == 0) return false;
00274   else return true;
00275   //cout<<"...leaving SiPixelConfigParser::getMENamesForFEDErrorSummary!"<<endl;
00276   
00277 }
00279 // -- Get List of MEs for the summary plot and the
00280 //
00281 bool SiPixelConfigParser::getFrequencyForBarrelSummary(int& u_freq) {
00282   if (!doc()) {
00283     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00284     return false;
00285   }
00286 
00287   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->getLength();
00288   if (structureNodes == 0) return false;
00290   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->item(0);
00291  //Get Node name
00292   if (! structureNode) return false;
00293   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00294   if (! structureElement) return false;          
00295                 
00296   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str());
00297   return true;
00298 }
00299 
00300 
00301 bool SiPixelConfigParser::getFrequencyForEndcapSummary(int& u_freq) {
00302   if (!doc()) {
00303     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00304     return false;
00305   }
00306 
00307   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->getLength();
00308   if (structureNodes == 0) return false;
00310   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->item(0);
00311  //Get Node name
00312   if (! structureNode) return false;
00313   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00314   if (! structureElement) return false;          
00315                 
00316   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str());
00317   return true;
00318 }
00319 
00320 
00321 bool SiPixelConfigParser::getMENamesForGrandBarrelSummary(string& structure_name,
00322                                                 vector<string>& me_names) {
00323   //cout<<"Entering SiPixelConfigParser::getMENamesForGrandBarrelSummary..."<<endl;
00324   if (!doc()) {
00325     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00326     return false;
00327   }
00328 
00329   me_names.clear();
00330   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->getLength();
00331   if (structureNodes == 0) return false;
00333   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->item(0);
00334  //Get QTEST name
00335   if (! structureNode) return false;
00336   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00337   if (! structureElement) return false;          
00338                 
00339   structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); 
00340 
00341   DOMNodeList * meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00342   for (unsigned int k = 0; k < meList->getLength(); k++) {
00343     DOMNode* meNode = meList->item(k);
00344     if (!meNode) return false;
00345     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00346     if (!meElement) return false;
00347     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00348     me_names.push_back(me_name);    
00349   }
00350   if (me_names.size() == 0) return false;
00351   else return true;
00352   //cout<<"...leaving SiPixelConfigParser::getMENamesForGrandBarrelSummary!"<<endl;
00353   
00354 }
00355 
00356 
00357 bool SiPixelConfigParser::getMENamesForGrandEndcapSummary(string& structure_name,
00358                                                 vector<string>& me_names) {
00359   //cout<<"Entering SiPixelConfigParser::getMENamesForGrandEndcapSummary..."<<endl;
00360   if (!doc()) {
00361     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00362     return false;
00363   }
00364 
00365   me_names.clear();
00366   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->getLength();
00367   if (structureNodes == 0) return false;
00369   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->item(0);
00370  //Get QTEST name
00371   if (! structureNode) return false;
00372   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00373   if (! structureElement) return false;          
00374                 
00375   structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); 
00376 
00377   DOMNodeList * meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement"));
00378   for (unsigned int k = 0; k < meList->getLength(); k++) {
00379     DOMNode* meNode = meList->item(k);
00380     if (!meNode) return false;
00381     DOMElement* meElement = static_cast<DOMElement *>(meNode);          
00382     if (!meElement) return false;
00383     string me_name = qtxml::_toString(meElement->getAttribute (qtxml::_toDOMS ("name"))); 
00384     me_names.push_back(me_name);    
00385   }
00386   if (me_names.size() == 0) return false;
00387   else return true;
00388   //cout<<"...leaving SiPixelConfigParser::getMENamesForGrandEndcapSummary!"<<endl;
00389   
00390 }
00391 
00392 
00393 bool SiPixelConfigParser::getFrequencyForGrandBarrelSummary(int& u_freq) {
00394   if (!doc()) {
00395     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00396     return false;
00397   }
00398 
00399   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->getLength();
00400   if (structureNodes == 0) return false;
00402   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->item(0);
00403  //Get Node name
00404   if (! structureNode) return false;
00405   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00406   if (! structureElement) return false;          
00407                 
00408   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str());
00409   return true;
00410 }
00411 
00412 
00413 bool SiPixelConfigParser::getFrequencyForGrandEndcapSummary(int& u_freq) {
00414   if (!doc()) {
00415     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00416     return false;
00417   }
00418 
00419   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->getLength();
00420   if (structureNodes == 0) return false;
00422   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->item(0);
00423  //Get Node name
00424   if (! structureNode) return false;
00425   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00426   if (! structureElement) return false;          
00427                 
00428   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str());
00429   return true;
00430 }
00431 
00432 
00433 bool SiPixelConfigParser::getMessageLimitForQTests(int& u_freq) {
00434   if (!doc()) {
00435     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00436     return false;
00437   }
00438   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("QTestMessageLimit"))->getLength();
00439   if (structureNodes == 0) return false;
00441   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("QTestMessageLimit"))->item(0);
00442  //Get Node name
00443   if (! structureNode) return false;
00444   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00445   if (! structureElement) return false;
00446                 
00447   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("value"))).c_str());
00448   return true;
00449 }
00450 
00451 
00452 
00453 bool SiPixelConfigParser::getSourceType(int& u_freq) {
00454   if (!doc()) {
00455     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00456     return false;
00457   }
00458   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SourceType"))->getLength();
00459   if (structureNodes == 0) return false;
00461   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SourceType"))->item(0);
00462  //Get Node name
00463   if (! structureNode) return false;
00464   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00465   if (! structureElement) return false;
00466                 
00467   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("code"))).c_str());
00468   return true;
00469 }
00470 
00471 bool SiPixelConfigParser::getCalibType(int& u_freq) {
00472   if (!doc()) {
00473     cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl;
00474     return false;
00475   }
00476   unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("CalibType"))->getLength();
00477   if (structureNodes == 0) return false;
00479   DOMNode* structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("CalibType"))->item(0);
00480  //Get Node name
00481   if (! structureNode) return false;
00482   DOMElement* structureElement = static_cast<DOMElement *>(structureNode);          
00483   if (! structureElement) return false;
00484                 
00485   u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("value"))).c_str());
00486   return true;
00487 }
00488 
00489 
00490 
00491