File indexing completed on 2023-03-17 10:51:54
0001 #include <cstdlib>
0002 #include <exception>
0003 #include <iostream>
0004 #include <string>
0005 #include <utility>
0006 #include <vector>
0007
0008 #include "DetectorDescription/Core/interface/DDBase.h"
0009 #include "DetectorDescription/Core/interface/DDCompactView.h"
0010 #include "DetectorDescription/Core/interface/DDConstant.h"
0011 #include "DetectorDescription/Core/interface/DDVector.h"
0012 #include "DetectorDescription/Parser/interface/DDLParser.h"
0013 #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
0014 #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
0015 #include "FWCore/Utilities/interface/Exception.h"
0016
0017 using namespace std;
0018 namespace DD {}
0019 using namespace DD;
0020
0021 int main(int argc, char* argv[]) {
0022 std::string const kProgramName = argv[0];
0023 int rc = 0;
0024
0025 try {
0026
0027
0028 cout << "initialize DDL parser" << endl;
0029 DDCompactView cpv;
0030 DDLParser myP(cpv);
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 cout << "about to start parsing" << endl;
0041 string configfile("DetectorDescription/RegressionTest/test/configuration.xml");
0042 if (argc == 2) {
0043 configfile = argv[1];
0044 }
0045
0046 FIPConfiguration fp(cpv);
0047 fp.readConfig(configfile);
0048 int parserResult = myP.parse(fp);
0049 cout << "done parsing" << std::endl;
0050 cout.flush();
0051 if (parserResult != 0) {
0052 cout << " problem encountered during parsing. exiting ... " << endl;
0053 exit(1);
0054 }
0055 cout << "parsing completed" << endl;
0056
0057 cout << endl << endl << "Start checking!" << endl << endl;
0058
0059 DDErrorDetection ed(cpv);
0060 ed.report(cpv, std::cout);
0061
0062 DDConstant::iterator<DDConstant> cit(DDConstant::begin()), ced(DDConstant::end());
0063 for (; cit != ced; ++cit) {
0064 cout << *cit << endl;
0065 }
0066
0067 std::vector<std::string> vnames;
0068 DDVector::iterator<DDVector> vit;
0069 DDVector::iterator<DDVector> ved(DDVector::end());
0070 if (vit == ved)
0071 std::cout << "No DDVectors found." << std::endl;
0072 for (; vit != ved; ++vit) {
0073 if (vit->isDefined().second) {
0074 std::cout << vit->toString() << std::endl;
0075 {
0076 DDName vname(vit->name());
0077 vnames.emplace_back(vname.name());
0078 }
0079 const std::vector<double>& tv = *vit;
0080 std::cout << "size: " << tv.size() << std::endl;
0081 for (double i : tv) {
0082 std::cout << i << "\t";
0083 }
0084 std::cout << std::endl;
0085 }
0086 }
0087
0088
0089 cpv.lockdown();
0090 for (const auto& it : vnames) {
0091 std::cout << it << std::endl;
0092 auto v = cpv.vector(it);
0093 std::cout << "size: " << v.size() << std::endl;
0094 for (double i : v) {
0095 std::cout << i << "\t";
0096 }
0097 std::cout << std::endl;
0098 }
0099
0100 return 0;
0101 }
0102
0103 catch (cms::Exception& e) {
0104 std::cout << "cms::Exception caught in " << kProgramName << "\n" << e.explainSelf();
0105 rc = 1;
0106 } catch (std::exception& e) {
0107 std::cout << "Standard library exception caught in " << kProgramName << "\n" << e.what();
0108 rc = 1;
0109 } catch (...) {
0110 std::cout << "Unknown exception caught in " << kProgramName;
0111 rc = 2;
0112 }
0113
0114 return rc;
0115 }