Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:38:17

0001 // $Id: Geant4Data.h 513 2013-04-05 14:31:53Z gaede $
0002 //====================================================================
0003 //  AIDA Detector description implementation
0004 //--------------------------------------------------------------------
0005 //
0006 //  Run Geant4 using DDG4 from root prompt with test objects for
0007 //  Run/Event/Sensitive actions.
0008 //
0009 //  The Geant4 setup is programmed as a root script.
0010 //
0011 //  Usage:
0012 //  $> root.exe
0013 //  root[0] .x <installation-directory>/examples/LHeD/scripts/initACLick.C
0014 //  root[1] .L <installation-directory>/examples/LHeD/scripts/initACLick.C+
0015 //  root[2] LHeDACLick()
0016 //
0017 //
0018 //  Author     : M.Frank
0019 //
0020 //====================================================================
0021 
0022 #include "DDG4/Geant4Config.h"
0023 #include "DDG4/Geant4TestActions.h"
0024 #include "CLHEP/Units/SystemOfUnits.h"
0025 #include "TSystem.h"
0026 #include <iostream>
0027 
0028 using namespace std;
0029 using namespace dd4hep;
0030 using namespace dd4hep::sim;
0031 using namespace dd4hep::sim::Test;
0032 using namespace dd4hep::sim::Setup;
0033 
0034 Geant4SensDetActionSequence* setupDetector(Geant4Kernel& kernel, const std::string& name)   {
0035   SensitiveSeq sd = SensitiveSeq(kernel,"Geant4SensDetActionSequence/"+name);
0036   Sensitive  sens = Sensitive(kernel,"Geant4TestSensitive/"+name+"Handler",name);
0037   sens["OutputLevel"] = 2;
0038   sd->adopt(sens);
0039   sens = Sensitive(kernel,"Geant4TestSensitive/"+name+"Monitor",name);
0040   sd->adopt(sens);
0041   return sd;
0042 }
0043 
0044 int setupG4_CINT(bool interactive)  {
0045   Geant4Kernel& kernel = Geant4Kernel::instance(Detector::getInstance());
0046   string install_dir = getenv("DD4hepExamplesINSTALL");
0047   Phase p;
0048 
0049   kernel.loadGeometry(("file:"+install_dir+"/examples/LHeD/compact/compact.xml").c_str());
0050   kernel.loadXML(("file:"+install_dir+"/examples/LHeD/sim/field.xml").c_str());
0051 
0052   if ( interactive )   {
0053     kernel.property("UI") = "UI";
0054     setPrintLevel(DEBUG);
0055 
0056     Action ui(kernel,"Geant4UIManager/UI");
0057     ui["HaveVIS"]     = true;
0058     ui["HaveUI"]      = true;
0059     ui["SessionType"] = "csh";
0060     kernel.registerGlobalAction(ui);
0061   }
0062   else   {
0063     kernel.property("NumEvents") = 3;
0064   }
0065   GenAction gun(kernel,"Geant4ParticleGun/Gun");
0066   gun["energy"]       = 10*CLHEP::GeV;
0067   gun["particle"]     = "e-";
0068   gun["multiplicity"] = 1;
0069   gun["OutputLevel"]  = 3;
0070   kernel.generatorAction().adopt(gun);
0071 
0072   RunAction run_init(kernel,"Geant4TestRunAction/RunInit");
0073   run_init["Property_int"] = 12345;
0074   kernel.runAction().adopt(run_init);
0075   kernel.eventAction().callAtBegin(run_init.get(),&Geant4TestRunAction::beginEvent);
0076   kernel.eventAction().callAtEnd  (run_init.get(),&Geant4TestRunAction::endEvent);
0077 
0078   EventAction evt_1(kernel,"Geant4TestEventAction/UserEvent_1");
0079   evt_1["Property_int"] = 12345;
0080   evt_1["Property_string"] = "Events";
0081   evt_1["OutputLevel"] = 3;
0082   kernel.eventAction().adopt(evt_1);
0083 
0084   p = kernel.addPhase<const G4Run*>("BeginRun");
0085   p->add(evt_1.get(),&Geant4TestEventAction::beginRun);
0086   kernel.runAction().callAtBegin(p.get(),&Geant4ActionPhase::call<const G4Run*>);
0087 
0088   p = kernel.addPhase<const G4Run*>("EndRun");
0089   p->add(evt_1.get(),&Geant4TestEventAction::endRun);
0090   kernel.runAction().callAtEnd(p.get(),&Geant4ActionPhase::call<const G4Run*>);
0091 
0092   EventAction evt_2(kernel,"Geant4TestEventAction/UserEvent_2");
0093   kernel.eventAction().adopt(evt_2);
0094  
0095   setupDetector(kernel,"SiVertexBarrel");
0096   setupDetector(kernel,"SiTrackerBarrel");
0097   setupDetector(kernel,"SiTrackerBackward");
0098   setupDetector(kernel,"SiTrackerForward");
0099   setupDetector(kernel,"EcalBarrel");
0100   setupDetector(kernel,"EcalEndcap_fwd");
0101   setupDetector(kernel,"EcalEndcap_bwd");
0102   setupDetector(kernel,"HcalBarrel");
0103   setupDetector(kernel,"HcalEndcap_fwd");
0104   setupDetector(kernel,"HcalEndcap_bwd");
0105   setupDetector(kernel,"HcalPlug_fwd");
0106   setupDetector(kernel,"HcalPlug_bwd");
0107   setupDetector(kernel,"MuonBarrel");
0108   setupDetector(kernel,"MuonEndcap_fwd1");
0109   setupDetector(kernel,"MuonEndcap_fwd2");
0110   setupDetector(kernel,"MuonEndcap_bwd1");
0111   setupDetector(kernel,"MuonEndcap_bwd2");
0112 
0113   kernel.configure();
0114   kernel.initialize();
0115   kernel.run();
0116   std::cout << "LHeD, Successfully executed application .... " << std::endl;
0117   kernel.terminate();
0118   std::cout << "TEST_PASSED" << std::endl;
0119   return 0;
0120 }
0121 
0122 #if defined(G__DICTIONARY) || defined(__CLING__) || defined(__CINT__) || defined(__MAKECINT__) // CINT script
0123 int LHeDACLick()
0124 #else
0125 int main(int, char**)                              // Main program if linked standalone
0126 #endif
0127 {
0128   return setupG4_CINT(false);
0129 }