Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:35

0001 #include <cstdlib>
0002 #include <fstream>
0003 #include <map>
0004 #include <set>
0005 #include <string>
0006 #include <utility>
0007 
0008 #include "DetectorDescription/Core/interface/DDCompactView.h"
0009 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0010 #include "DetectorDescription/RegressionTest/src/DDCheck.h"
0011 #include "DetectorDescription/Core/interface/LogicalPart.h"
0012 #include "DetectorDescription/Parser/interface/DDLParser.h"
0013 #include "DetectorDescription/Parser/interface/DDLSAX2FileHandler.h"
0014 #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
0015 #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
0016 #include "DetectorDescription/RegressionTest/interface/DDHtmlFormatter.h"
0017 #include "FWCore/PluginManager/interface/PluginManager.h"
0018 #include "FWCore/PluginManager/interface/standard.h"
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 
0021 int main(int argc, char* argv[]) {
0022   if (argc < 2) {
0023     std::cout << "This program does nothing unless it is given a command line argument.\n";
0024     std::cout << "The argument should be the name of an xml configuration file.\n";
0025     return 0;
0026   }
0027 
0028   // required for main() in cmssw framework
0029   edmplugin::PluginManager::configure(edmplugin::standard::config());
0030 
0031   try {
0032     // Initialize a DDL Schema aware parser for DDL-documents
0033     // (DDL ... Detector Description Language)
0034     std::cout << "initialize DDL parser" << std::endl;
0035     DDCompactView ddcpv;
0036     DDLParser myP(ddcpv);
0037     myP.getDDLSAX2FileHandler()->setUserNS(false);
0038 
0039     std::cout << "about to set configuration" << std::endl;
0040     //  std::string configfile("configuration.xml");
0041     std::string configfile("DetectorDescription/RegressionTest/test/");
0042     if (argc == 2) {
0043       configfile += argv[1];
0044     } else {
0045       configfile += "configuration.xml";
0046     }
0047     std::cout << configfile << std::endl;
0048     FIPConfiguration fp(ddcpv);
0049     fp.readConfig(configfile);
0050     fp.dumpFileList();
0051     std::cout << "about to start parsing" << std::endl;
0052     int parserResult = myP.parse(fp);
0053 
0054     if (parserResult != 0) {
0055       std::cout << " problem encountered during parsing. exiting ... " << std::endl;
0056       exit(1);
0057     }
0058     std::cout << " parsing completed" << std::endl;
0059 
0060     std::cout << std::endl << std::endl << "Start checking!" << std::endl << std::endl;
0061 
0062     DDCheck(ddcpv, std::cout);
0063 
0064     std::cout << std::endl << "Done with DDCheck!" << std::endl << std::endl;
0065 
0066     typedef DDHtmlFormatter::ns_type ns_type;
0067 
0068     ns_type names;
0069     {
0070       DDLogicalPart lp;
0071       findNameSpaces(lp, names);
0072     }
0073 
0074     std::cout << names.size() << " namespaces found: " << std::endl << std::endl;
0075     ns_type::const_iterator nit = names.begin();
0076     for (; nit != names.end(); ++nit) {
0077       std::cout << nit->first << " has " << nit->second.size() << " entries." << std::endl;
0078     }
0079 
0080     DDErrorDetection ed(ddcpv);
0081 
0082     ed.report(ddcpv, std::cout);
0083 
0084     DDHtmlLpDetails lpd("lp", "LogicalParts");
0085     dd_to_html(lpd);
0086 
0087     DDHtmlMaDetails mad("ma", "Materials");
0088     dd_to_html(mad);
0089 
0090     DDHtmlSoDetails sod("so", "Solids");
0091     dd_to_html(sod);
0092 
0093     DDHtmlRoDetails rod("ro", "Rotations");
0094     dd_to_html(rod);
0095 
0096     DDHtmlSpDetails spd("sp", "Specifics (SpecPars)");
0097     dd_to_html(spd);
0098 
0099     std::ofstream fr;
0100 
0101     fr.open("index.html");
0102     dd_html_menu_frameset(fr);
0103     fr.close();
0104 
0105     fr.open("menu.html");
0106     dd_html_menu(fr);
0107     fr.close();
0108 
0109     fr.open("lp/index.html");
0110     dd_html_frameset(fr);
0111     fr.close();
0112 
0113     fr.open("ma/index.html");
0114     dd_html_frameset(fr);
0115     fr.close();
0116 
0117     fr.open("so/index.html");
0118     dd_html_frameset(fr);
0119     fr.close();
0120 
0121     fr.open("ro/index.html");
0122     dd_html_frameset(fr);
0123     fr.close();
0124 
0125     fr.open("sp/index.html");
0126     dd_html_frameset(fr);
0127     fr.close();
0128 
0129     return 0;
0130 
0131   } catch (cms::Exception& e)  // DDD-Exceptions are simple string for the Prototype
0132   {
0133     std::cerr << "DDD-PROBLEM:" << std::endl << e << std::endl;
0134   }
0135 }