DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
g4FromXML.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include "DDG4/Geant4Config.h"
16 
17 // C/C++ include files
18 #include <stdexcept>
19 #include <iostream>
20 #include <cerrno>
21 
22 using namespace dd4hep::sim::Setup;
23 
24 int setupG4_XML() {
26  Kernel& kernel = Kernel::instance(description);
27  kernel.loadGeometry("file:../DD4hep.trunk/DDExamples/CLICSiD/compact/compact.xml");
28  kernel.loadXML("DDG4_field.xml");
29  kernel.loadXML("sequences.xml");
30  kernel.loadXML("physics.xml");
31  kernel.configure();
32  kernel.initialize();
33  kernel.run();
34  std::cout << "Successfully executed application .... " << std::endl;
35  kernel.terminate();
36  return 1;
37 }
38 
40 int main(int, char**) {
41  try {
42  return setupG4_XML();
43  }
44  catch(const std::exception& e) {
45  std::cout << "Got uncaught exception: " << e.what() << std::endl;
46  }
47  catch (...) {
48  std::cout << "Got UNKNOWN uncaught exception." << std::endl;
49  }
50  return EINVAL;
51 }
dd4hep::sim::Setup
Convenience namespace to ease the setupup of DDG4 applications.
Definition: Geant4Config.h:57
dd4hep::sim::Geant4Kernel::configure
virtual int configure()
Run the simulation: Configure Geant4.
Definition: Geant4Kernel.cpp:385
dd4hep::sim::Geant4Kernel::loadXML
virtual void loadXML(const char *fname)
Load XML file.
Definition: Geant4Kernel.cpp:364
main
int main(int, char **)
Main entry point as a program.
Definition: g4FromXML.cpp:40
dd4hep::exception
void exception(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:69
dd4hep::sim::Geant4Kernel
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
Definition: Geant4Kernel.h:64
Geant4Config.h
dd4hep::Detector::getInstance
static Detector & getInstance(const std::string &name="default")
—Factory method----—
Definition: DetectorImp.cpp:150
dd4hep::sim::Geant4Kernel::initialize
virtual int initialize()
Run the simulation: Initialize Geant4.
Definition: Geant4Kernel.cpp:396
dd4hep::sim::Geant4Kernel::instance
static Geant4Kernel & instance(Detector &description)
Instance accessor.
Definition: Geant4Kernel.cpp:163
dd4hep::sim::Geant4Kernel::run
virtual int run()
Run the simulation: Simulate the number of events given by the property "NumEvents".
Definition: Geant4Kernel.cpp:407
dd4hep::sim::Geant4Kernel::loadGeometry
virtual void loadGeometry(const std::string &compact_file)
Construct detector geometry using description plugin.
Definition: Geant4Kernel.cpp:357
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
setupG4_XML
int setupG4_XML()
Definition: g4FromXML.cpp:24
dd4hep::sim::Geant4Kernel::terminate
virtual int terminate() override
Run the simulation: Terminate Geant4.
Definition: Geant4Kernel.cpp:428