Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:45

0001 //==========================================================================
0002 //  AIDA Detector description implementation
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //--------------------------------------------------------------------------
0011 //
0012 //  Run Geant4 using DDG4 from root prompt with test objects for
0013 //  Run/Event/Sensitive actions.
0014 //
0015 //  The Geant4 setup is programmed in the xml files to be parsed. Only
0016 //  the commands to parse these xml files is executed by root.
0017 //
0018 //  Usage:
0019 //  $> root.exe
0020 //  root[0] .x <installation-directory>/examples/DDG4/examples/initAClick.C
0021 //  root[1] .L <installation-directory>/examples/DDG4/examples/CLICSidXML.C+
0022 //  root[2] CLICSidAClick()
0023 //
0024 //
0025 //  Author     : M.Frank
0026 //
0027 //=====================================================------===============
0028 #include <DDG4/Geant4Config.h>
0029 #include <iostream>
0030 #include <ctime>
0031 
0032 using namespace std;
0033 using namespace dd4hep::sim::Setup;
0034 
0035 int setupG4_XML(bool interactive)  {
0036   string install_dir = getenv("DD4hepExamplesINSTALL");
0037   string det_dir     = getenv("DD4hepINSTALL");
0038   string prefix = "file:"+install_dir+"/examples/";
0039   Kernel& kernel = Kernel::instance(dd4hep::Detector::getInstance());
0040   kernel.loadGeometry((det_dir+"/DDDetectors/compact/SiD.xml").c_str());
0041   kernel.loadXML((prefix+"CLICSiD/sim/field.xml").c_str());
0042   kernel.loadXML((prefix+"CLICSiD/sim/sequences.xml").c_str());
0043   kernel.loadXML((prefix+"CLICSiD/sim/physics.xml").c_str());
0044   if ( interactive )  {
0045     kernel.property("UI") = "UI";
0046   }
0047   else   {
0048     kernel.property("NumEvents") = 4;
0049   }
0050   Action rndm(kernel, "Geant4Random/Random");
0051   rndm["Seed"] = ::time(0);
0052   kernel.registerGlobalAction(rndm);
0053 
0054   EventAction out(kernel,"Geant4Output2ROOT/RootOutput");
0055   out["Output"] = is_aclick() ? "CLICSiD.xml_aclick.root" : "CLICSiD.xml_exe.root";
0056   kernel.eventAction().adopt(out);
0057 
0058   kernel.configure();
0059   kernel.initialize();
0060   kernel.run();
0061   cout << "Successfully executed application .... " << endl;
0062   kernel.terminate();
0063   cout << "TEST_PASSED" << endl;
0064   return 0;
0065 }
0066 
0067 int CLICSiDXML()   {
0068   return setupG4_XML(false);
0069 }
0070 
0071 #if not(defined(G__DICTIONARY) || defined(__CLING__) || defined(__CINT__) || defined(__MAKECINT__))
0072 int main(int, char**)                              // Main program if linked standalone
0073 {
0074   std::cout << "Running CLICSiDXML as standalone executable...." << std::endl;
0075   return CLICSiDXML();
0076 }
0077 #endif
0078 
0079