ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gdml_det.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file gdml_det.cc
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 //
31 //
32 // --------------------------------------------------------------
33 // GEANT 4 - gdml_det
34 //
35 // --------------------------------------------------------------
36 
37 #include <vector>
38 
41 #include "G04SensitiveDetector.hh"
42 
43 #ifdef G4MULTITHREADED
44 #include "G4MTRunManager.hh"
45 #else
46 #include "G4RunManager.hh"
47 #endif
48 
49 #include "FTFP_BERT.hh"
50 #include "G4UImanager.hh"
51 #include "G4VisExecutive.hh"
52 #include "G4UIExecutive.hh"
53 #include "G4GDMLParser.hh"
54 
55 int main(int argc,char **argv)
56 {
57  G4cout << G4endl;
58  G4cout << "Usage: gdml_det <intput_gdml_file:mandatory>"
59  << G4endl;
60  G4cout << G4endl;
61 
62  if (argc<2)
63  {
64  G4cout << "Error! Mandatory input file is not specified!" << G4endl;
65  G4cout << G4endl;
66  return -1;
67  }
68 
69  // Detect interactive mode (if only one argument) and define UI session
70  //
71  G4UIExecutive* ui = 0;
72  if ( argc == 2 ) {
73  ui = new G4UIExecutive(argc, argv);
74  }
75 
77  parser.Read(argv[1]);
78 
79 #ifdef G4MULTITHREADED
80  G4MTRunManager* runManager = new G4MTRunManager;
81 #else
82  G4RunManager* runManager = new G4RunManager;
83 #endif
84 
85  runManager->SetUserInitialization(new G04DetectorConstruction(parser));
86  runManager->SetUserInitialization(new FTFP_BERT);
87 
88  // User action initialization
90  runManager->Initialize();
91 
92  // Initialize visualization
93  G4VisManager* visManager = new G4VisExecutive;
94  visManager->Initialize();
95 
96  // Get the pointer to the User Interface manager
98 
99  // Process macro or start UI session
100  if ( ! ui ) // batch mode
101  {
102  G4String command = "/control/execute ";
103  G4String fileName = argv[2];
104  UImanager->ApplyCommand(command+fileName);
105  }
106  else // interactive mode
107  {
108  UImanager->ApplyCommand("/control/execute vis.mac");
109  ui->SessionStart();
110  delete ui;
111  }
112 
113  delete visManager;
114  delete runManager;
115 }