@@ -121,13 +121,14 @@ namespace {
121
121
122
122
// ______________________________________________________________________________
123
123
struct Args {
124
- bool volmgr, dry_run, destroy, interpreter, ui;
125
- dd4hep::PrintLevel print;
124
+ bool volmgr, dry_run, destroy, interpreter, ui, help ;
125
+ dd4hep::PrintLevel print;
126
126
std::vector<const char *> geo_files, build_types;
127
127
std::vector<std::vector<const char *> > plugins;
128
128
129
129
// ____________________________________________________________________________
130
130
Args () {
131
+ help = false ;
131
132
ui = false ;
132
133
volmgr = false ;
133
134
dry_run = false ;
@@ -148,6 +149,10 @@ namespace {
148
149
build_types.emplace_back (" BUILD_DEFAULT" );
149
150
}
150
151
}
152
+ else if ( ::strncmp (argv[i]," -help" ,5 )==0 )
153
+ help = true ;
154
+ else if ( ::strncmp (argv[i]," --help" ,6 )==0 )
155
+ help = true ;
151
156
else if ( ::strncmp (argv[i]," -load_only" ,5 )==0 )
152
157
dry_run = true ;
153
158
else if ( ::strncmp (argv[i]," -dry-run" ,5 )==0 )
@@ -315,55 +320,58 @@ namespace dd4hep {
315
320
Args arguments;
316
321
arguments.interpreter = false ;
317
322
318
- for (int i=1 ; i< argc;++i) {
319
- if ( argv[i][0 ]==' -' ) {
323
+ for ( int i=1 ; i < argc; ++i ) {
324
+ if ( argv[i][0 ]==' -' ) {
320
325
if ( arguments.handle (i,argc,argv) )
321
326
continue ;
322
327
}
323
328
else {
324
329
usage_plugin_runner ();
325
330
}
326
331
}
327
- if ( !arguments.dry_run &&
332
+ if ( !arguments.dry_run &&
328
333
!arguments.ui &&
329
334
!arguments.interpreter &&
330
335
arguments.plugins .empty () &&
331
336
arguments.geo_files .empty () )
332
337
{
333
338
usage_plugin_runner ();
334
339
}
340
+ if ( arguments.help ) {
341
+ usage_plugin_runner ();
342
+ }
335
343
std::unique_ptr<TRint> interpreter;
336
344
dd4hep::Detector& description = dd4hep_instance ();
337
345
// Load compact files if required by plugin
338
- if ( !arguments.geo_files .empty () ) {
346
+ if ( !arguments.geo_files .empty () ) {
339
347
load_compact (description, arguments);
340
348
}
341
349
else {
342
350
std::cout << " geoPluginRun: No geometry input supplied. "
343
351
<< " No geometry will be loaded." << std::endl << std::flush;
344
352
}
345
353
// Attach UI instance if requested to ease interaction from the ROOT prompt
346
- if ( arguments.ui ) {
354
+ if ( arguments.ui ) {
347
355
run_plugin (description," DD4hep_InteractiveUI" ,0 ,0 );
348
356
}
349
357
// Create volume manager and populate it required
350
- if ( arguments.volmgr ) {
358
+ if ( arguments.volmgr ) {
351
359
run_plugin (description," DD4hep_VolumeManager" ,0 ,0 );
352
360
}
353
- if ( arguments.interpreter ) {
361
+ if ( arguments.interpreter ) {
354
362
std::pair<int , char **> a (0 ,0 );
355
363
interpreter.reset (new TRint (" geoPluginRun" , &a.first , a.second ));
356
364
}
357
365
// Execute plugin
358
- for (size_t i=0 ; i< arguments.plugins .size (); ++i) {
366
+ for ( size_t i=0 ; i < arguments.plugins .size (); ++i ) {
359
367
std::vector<const char *>& plug = arguments.plugins [i];
360
368
int num_args = int (plug.size ())-2 ;
361
369
TTimeStamp start;
362
370
char text[32 ];
363
371
long result = run_plugin (description, plug[0 ], num_args, (char **)&plug[1 ]);
364
372
TTimeStamp stop;
365
373
::snprintf (text,sizeof (text),"[%8.3f sec]",stop.AsDouble()-start.AsDouble());
366
- if ( result == EINVAL ) {
374
+ if (result == EINVAL ) {
367
375
std::cout << " geoPluginRun: FAILED to execute dd4hep plugin: '" << plug[0 ]
368
376
<< " ' with args (" << num_args << " ) :[ " ;
369
377
for (size_t j = 1 ; j < plug.size (); ++j) {
@@ -374,33 +382,33 @@ namespace dd4hep {
374
382
}
375
383
std::cout << " geoPluginRun: " << text <<" Executed dd4hep plugin: '" << plug[0 ]
376
384
<< " ' with args (" << num_args << " ) :[ " ;
377
- for (size_t j=1 ; j< plug.size (); ++j) {
385
+ for ( size_t j=1 ; j < plug.size (); ++j ) {
378
386
if ( plug[j] ) std::cout << plug[j] << " " ;
379
387
}
380
388
std::cout << " ]" << std::endl << std::flush;
381
389
}
382
- if ( arguments.plugins .empty () ) {
390
+ if ( arguments.plugins .empty () ) {
383
391
// Create an interactive ROOT application
384
- if ( !arguments.dry_run ) {
392
+ if ( !arguments.dry_run ) {
385
393
long result = 0 ;
386
394
std::pair<int , char **> a (0 ,0 );
387
- if ( arguments.interpreter ) {
395
+ if ( arguments.interpreter ) {
388
396
TRint app (name, &a.first , a.second );
389
397
result = arguments.run (description, name);
390
- if ( result != EINVAL ) app.Run ();
398
+ if ( result != EINVAL ) app.Run ();
391
399
}
392
400
else
393
401
result = arguments.run (description, name);
394
- if ( result == EINVAL ) usage_default (name);
402
+ if ( result == EINVAL ) usage_default (name);
395
403
}
396
- else {
404
+ else {
397
405
std::cout << " The geometry was loaded. Application now exiting." << std::endl;
398
406
}
399
407
}
400
408
if ( !arguments.dry_run && interpreter.get () ) {
401
409
interpreter->Run ();
402
410
}
403
- try {
411
+ try {
404
412
if ( arguments.destroy ) description.destroyInstance ();
405
413
}
406
414
catch (const std::exception & e) {
0 commit comments