14 #pragma GCC diagnostic ignored "-Wunused-function"
24 "geoConverter -opt [-opt] \n"
25 " Action flags: Usage is exclusive, 1 required! \n"
26 " -compact2description Convert compact xml geometry to description.\n"
27 " -compact2gdml Convert compact xml geometry to gdml. \n"
28 " -compact2pandora Convert compact xml to pandora xml. \n"
29 " -compact2tgeo Convert compact xml to TGeo in ROOT file. \n"
30 " -compact2vis Convert compact xml to visualisation attrs\n\n"
31 " -input <file> [REQUIRED] Specify input file. \n"
32 " -output <file> [OPTIONAL] Specify output file. \n"
33 " if no output file is specified, the output \n"
34 " device is stdout. \n"
35 " -ascii [OPTIONAL] Dump visualisation attrs in csv format. \n"
36 " [Only valid for -compact2vis] \n"
37 " -destroy [OPTIONAL] Force destruction of the Detector instance \n"
38 " before exiting the application \n"
39 " -volmgr [OPTIONAL] Load and populate phys.volume manager to \n"
40 " check the volume ids for duplicates etc. \n"
47 int invoke_converter(
int argc,
char** argv) {
51 bool compact2description =
false;
52 bool compact2gdml =
false;
53 bool compact2pand =
false;
54 bool compact2tgeo =
false;
55 bool compact2vis =
false;
57 std::vector<char*> geo_files;
58 for(
int i=1; i<argc;++i) {
59 if ( argv[i][0]==
'-' ) {
60 if ( strncmp(argv[i],
"-compact2description",12)==0 )
61 compact2description =
true;
62 else if ( strncmp(argv[i],
"-compact2gdml",12)==0 )
64 else if ( strncmp(argv[i],
"-compact2pandora",12)==0 )
66 else if ( strncmp(argv[i],
"-compact2tgeo",12)==0 )
68 else if ( strncmp(argv[i],
"-compact2vis",12)==0 )
70 else if ( strncmp(argv[i],
"-input",2)==0 )
71 geo_files.emplace_back(argv[++i]);
72 else if ( strncmp(argv[i],
"-output",2)==0 )
74 else if ( strncmp(argv[i],
"-ascii",5)==0 )
76 else if ( strncmp(argv[i],
"-destroy",2)==0 )
78 else if ( strncmp(argv[i],
"-volmgr",2)==0 )
87 if ( geo_files.empty() || (!compact2description && !compact2gdml && !compact2pand && !compact2tgeo && !compact2vis))
92 for(
size_t i=0; i<geo_files.size(); ++i) {
93 const char* plugin_argv[] = {geo_files[i], 0};
94 run_plugin(description,
"DD4hep_CompactLoader",1,(
char**)plugin_argv);
97 if ( volmgr ) run_plugin(description,
"DD4hepVolumeManager",0,0);
99 if ( compact2description )
100 run_plugin(description,
"DD4hepGeometry2Detector",output,&argv[output]);
101 else if ( compact2gdml )
102 run_plugin(description,
"DD4hepGeometry2GDML",output,&argv[output]);
103 else if ( compact2pand )
104 run_plugin(description,
"DD4hepGeometry2PANDORA",output,&argv[output]);
105 else if ( compact2tgeo )
106 run_plugin(description,
"DD4hepGeometry2TGeo",argc-output,&argv[output]);
107 else if ( compact2vis &&
ascii )
108 run_plugin(description,
"DD4hepGeometry2VISASCII",output,&argv[output]);
109 else if ( compact2vis )
110 run_plugin(description,
"DD4hepGeometry2VIS",output,&argv[output]);
111 if ( destroy )
delete &description;
117 int main(
int argc,
char** argv) {
119 return invoke_converter(argc, argv);
122 std::cout <<
"Got uncaught exception: " << e.what() << std::endl;
125 std::cout <<
"Got UNKNOWN uncaught exception." << std::endl;