Newer
Older
// $Id: Geant4Data.h 513 2013-04-05 14:31:53Z gaede $
//====================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------
//
// Run Geant4 using DDG4 from root prompt with test objects for
// Run/Event/Sensitive actions.
//
// The Geant4 setup is programmed as a root script.
//
// Usage:
// $> root.exe
// root[0] .x <installation-directory>/examples/DDG4/examples/initAClick.C
// root[1] .L <installation-directory>/examples/DDG4/examples/CLICSidAClick.C+
// root[2] CLICSidAClick()
//
//
// Author : M.Frank
//
//====================================================================
#include "DDG4/Geant4Config.h"
#include "DDG4/Geant4TestActions.h"
#include <iostream>
using namespace std;
using namespace DD4hep;
using namespace DD4hep::Simulation;
using namespace DD4hep::Simulation::Test;
using namespace DD4hep::Simulation::Setup;
SensitiveSeq::handled_type* setupDetector(Geant4Kernel& kernel, const std::string& name) {
SensitiveSeq sd = SensitiveSeq(kernel,name);
Sensitive sens = Sensitive(kernel,"Geant4TestSensitive/"+name+"Handler",name);
sd->adopt(sens);
sens = Sensitive(kernel,"Geant4TestSensitive/"+name+"Monitor",name);
sd->adopt(sens);
return sd;
}
void setupG4_CINT() {
//Geant4Kernel& kernel = Geant4Kernel::instance(Geometry::LCDD::getInstance());
Geant4Kernel kernel(Geometry::LCDD::getInstance());
string install_dir = getenv("DD4hepINSTALL");
string ddg4_examples = install_dir+"/examples/DDG4/examples";
kernel.loadGeometry(("file:"+install_dir+"/examples/CLICSiD/compact/compact.xml").c_str());
kernel.loadXML(("file:"+ddg4_examples+"/DDG4_field.xml").c_str());
kernel.property("UI") = "UI";
setPrintLevel(DEBUG);
Action ui(kernel,"Geant4UIManager/UI");
ui["HaveVIS"] = true;
ui["HaveUI"] = true;
ui["SessionType"] = "csh";
kernel.registerGlobalAction(ui);
GenAction gun(kernel,"Geant4ParticleGun/Gun");
gun["particle"] = "e-";
gun["multiplicity"] = 1;
RunAction run_init(kernel,"Geant4TestRunAction/RunInit");
kernel.eventAction().callAtBegin(run_init.get(),&Geant4TestRunAction::beginEvent);
kernel.eventAction().callAtEnd (run_init.get(),&Geant4TestRunAction::endEvent);
EventAction evt_1(kernel,"Geant4TestEventAction/UserEvent_1");
evt_1["Property_int"] = 12345;
evt_1["Property_string"] = "Events";
evt_1["OutputLevel"] = 5;
kernel.eventAction().adopt(evt_1);
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
p = kernel.addPhase<const G4Run*>("BeginRun");
p->add(evt_1.get(),&Geant4TestEventAction::beginRun);
kernel.runAction().callAtBegin(p.get(),&Geant4ActionPhase::call<const G4Run*>);
p = kernel.addPhase<const G4Run*>("EndRun");
p->add(evt_1.get(),&Geant4TestEventAction::endRun);
kernel.runAction().callAtEnd(p.get(),&Geant4ActionPhase::call<const G4Run*>);
EventAction evt_2(kernel,"Geant4TestEventAction/UserEvent_2");
kernel.eventAction().adopt(evt_2);
setupDetector(kernel,"SiVertexBarrel");
setupDetector(kernel,"SiVertexEndcap");
setupDetector(kernel,"SiTrackerBarrel");
setupDetector(kernel,"SiTrackerEndcap");
setupDetector(kernel,"SiTrackerForward");
setupDetector(kernel,"EcalBarrel");
setupDetector(kernel,"EcalEndcap");
setupDetector(kernel,"HcalBarrel");
setupDetector(kernel,"HcalEndcap");
setupDetector(kernel,"HcalPlug");
setupDetector(kernel,"MuonBarrel");
setupDetector(kernel,"MuonEndcap");
setupDetector(kernel,"LumiCal");
setupDetector(kernel,"BeamCal");
kernel.configure();
kernel.initialize();
kernel.run();
std::cout << "Successfully executed application .... " << std::endl;
kernel.terminate();
}