Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gdml_det.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 // $Id: gdml_det.cc 93506 2015-10-23 12:30:58Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - gdml_det
35 //
36 // --------------------------------------------------------------
37 
38 #include <vector>
39 
42 #include "G04SensitiveDetector.hh"
43 
44 #ifdef G4MULTITHREADED
45 #include "G4MTRunManager.hh"
46 #else
47 #include "G4RunManager.hh"
48 #endif
49 
50 #include "FTFP_BERT.hh"
51 #include "G4UImanager.hh"
52 #include "G4VisExecutive.hh"
53 #include "G4UIExecutive.hh"
54 #include "G4GDMLParser.hh"
55 
56 int main(int argc,char **argv)
57 {
58  G4cout << G4endl;
59  G4cout << "Usage: gdml_det <intput_gdml_file:mandatory>"
60  << G4endl;
61  G4cout << G4endl;
62 
63  if (argc<2)
64  {
65  G4cout << "Error! Mandatory input file is not specified!" << G4endl;
66  G4cout << G4endl;
67  return -1;
68  }
69 
70  // Detect interactive mode (if only one argument) and define UI session
71  //
72  G4UIExecutive* ui = 0;
73  if ( argc == 2 ) {
74  ui = new G4UIExecutive(argc, argv);
75  }
76 
78  parser.Read(argv[1]);
79 
80 #ifdef G4MULTITHREADED
81  G4MTRunManager* runManager = new G4MTRunManager;
82 #else
83  G4RunManager* runManager = new G4RunManager;
84 #endif
85 
86  runManager->SetUserInitialization(new G04DetectorConstruction(parser));
87  runManager->SetUserInitialization(new FTFP_BERT);
88 
89  // User action initialization
91  runManager->Initialize();
92 
93  // Initialize visualization
94  G4VisManager* visManager = new G4VisExecutive;
95  visManager->Initialize();
96 
97  // Get the pointer to the User Interface manager
99 
100  // Process macro or start UI session
101  if ( ! ui ) // batch mode
102  {
103  G4String command = "/control/execute ";
104  G4String fileName = argv[2];
105  UImanager->ApplyCommand(command+fileName);
106  }
107  else // interactive mode
108  {
109  UImanager->ApplyCommand("/control/execute vis.mac");
110  ui->SessionStart();
111  delete ui;
112  }
113 
114  delete visManager;
115  delete runManager;
116 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Definition of the G04DetectorConstruction class.
Detector construction for laoding GDML geometry.
int main(int argc, char **argv)
Definition: genwindef.cpp:30
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
Action initialization class.
G4GLOB_DLL std::ostream G4cout
Definition of the G04SensitiveDetector class.
CommandLineParser * parser(0)
void Initialize()
void Read(const G4String &filename, G4bool Validate=true)
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
Definition of the G04ActionInitialization class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447