Skip to content
Snippets Groups Projects
plugin_runner.cpp 2.14 KiB
Newer Older
//==========================================================================
Markus Frank's avatar
Markus Frank committed
//  AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
// Copyright (C) Organisation européenne pour la Recherche nucléaire (CERN)
// All rights reserved.
Markus Frank's avatar
Markus Frank committed
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
Markus Frank's avatar
Markus Frank committed
//
// Author     : M.Frank
//
//==========================================================================

// Framework include files
Markus Frank's avatar
Markus Frank committed

//______________________________________________________________________________
namespace {
  void usage() {
Markus Frank's avatar
Markus Frank committed
      "        -plugin <name>  [REQUIRED]  Plugin to be executed and applied.        \n"
      "        -input  <file>  [OPTIONAL]  Specify geometry input file.              \n";
    print_default_args() << endl;
Markus Frank's avatar
Markus Frank committed
    exit(EINVAL);
  }
}

//______________________________________________________________________________
int main(int argc,char** argv)  {
  char plugin_runner[64] = "plugin_runner";
  string plugin;
  Args arguments;
  vector<const char*> options;
  options.push_back(plugin_runner);
Markus Frank's avatar
Markus Frank committed
  for(int i=1; i<argc;++i) {
    if ( argv[i][0]=='-' ) {
      if ( arguments.handle(i,argc,argv) )
Markus Frank's avatar
Markus Frank committed
      else if ( strncmp(argv[i],"-plugin",2)==0 )
        plugin = argv[++i];
      else
Markus Frank's avatar
Markus Frank committed
    }
    else {
      usage();
    }
  }
Markus Frank's avatar
Markus Frank committed
    usage();
  options.push_back(0);
  LCDD& lcdd = dd4hep_instance();
  // Load compact files if required by plugin
  if ( !arguments.geo_files.empty() )   {
    load_compact(lcdd, arguments);
  }
  else  {
    cout << "geoPluginRun: No geometry input supplied. No geometry will be loaded." << endl;
  }
  // Create volume manager and populate it required
  if ( arguments.volmgr  ) run_plugin(lcdd,"DD4hepVolumeManager",0,0);
  run_plugin(lcdd,plugin.c_str(),(int)(options.size()-1),(char**)&options[0]);
  if ( arguments.destroy ) delete &lcdd;