Newer
Older
Markus Frank
committed
//==========================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
Markus Frank
committed
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
Markus Frank
committed
//#define G4UI_USE
//#define G4VIS_USE
//#define G4INTY_USE_XT
Markus Frank
committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//#define G4UI_USE_TCSH
#include "G4PVPlacement.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIsession.hh"
#include "Randomize.hh"
#ifdef G4VIS_USE_OPENGLX
#include "G4OpenGLImmediateX.hh"
#include "G4OpenGLStoredX.hh"
#endif
#include "G4VisManager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4VUserPhysicsList.hh"
#include "G4ParticleTypes.hh"
#include "globals.hh"
#include "DDG4/Geant4GDMLDetector.h"
#include <cerrno>
#include <stdexcept>
using namespace std;
using namespace DD4hep::Simulation;
namespace {
class EmptyPhysicsList: public G4VUserPhysicsList {
public:
EmptyPhysicsList() { }
~EmptyPhysicsList() { }
// Construct particle and physics process
void ConstructParticle() { G4Geantino::GeantinoDefinition(); }
void ConstructProcess() { AddTransportation(); }
void SetCuts() { SetCutsWithDefault(); }
};
}
static const char* get_arg(int argc, char** argv,int which) {
if ( which>0 && which < argc ) return argv[which];
throw runtime_error("Invalid argument sequence");
}
int main(int argc, char** argv) {
string gdml = argv[1];
string setup = argv[2];
const char* args[] = {"cmd"};
for(int i=1; i<argc;++i) {
if ( argv[i][0]=='-' ) {
Markus Frank
committed
string n = argv[i]+1;
if ( ::strncmp(n.c_str(),"gdml",4) == 0 )
Markus Frank
committed
gdml = get_arg(argc,argv,++i);
Markus Frank
committed
else if ( ::strncmp(n.c_str(),"guisetup",3) == 0 )
Markus Frank
committed
setup = get_arg(argc,argv,++i);
Markus Frank
committed
}
}
if ( gdml.empty() || setup.empty() ) {
cout << " usage: g4gdmlDisplay -gdml <file-name> -guisetup <g4 macro>" << endl;
return EINVAL;
}
G4RunManager * run = new G4RunManager;
run->SetUserInitialization(new Geant4GDMLDetector(gdml));
run->SetUserInitialization(new EmptyPhysicsList());
//
// Initialize G4 kernel
run->Initialize();
//
// Initialize visualization
G4VisManager* vis = new G4VisExecutive;
vis->Initialize();
//
// Get the pointer to the User Interface manager
G4UImanager* uiman = G4UImanager::GetUIpointer();
Markus Frank
committed
G4UIExecutive* ui = new G4UIExecutive(1,(char**)args);
Markus Frank
committed
uiman->ApplyCommand("/control/execute "+setup);
ui->SessionStart();
// end ...
delete ui;
delete vis;
delete run;
return 0;
}