EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eAST.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eAST.cc
1 // ********************************************************************
2 //
3 // eAST (eA Simulation Tool)
4 //
5 // eAST.cc - Main function of eAST
6 //
7 // History:
8 // April 28, 2021 - first implementation (M.Asai/SLAC)
9 //
10 // ********************************************************************
11 
12 #include "G4Types.hh"
13 
14 #include "G4RunManagerFactory.hh"
15 #include "G4VisExecutive.hh"
16 #include "G4UImanager.hh"
17 #include "G4UIExecutive.hh"
18 
19 #include "eASTInitialization.hh"
20 
21 int main(int argc,char** argv)
22 {
23  // Construct Run Manager
24  auto runManager = G4RunManagerFactory::CreateRunManager();
25 
26  // construct eAST initializer
27  auto eastInitialization = new eASTInitialization();
28 
29  // Visualization manager construction
30  auto visManager = new G4VisExecutive("Quiet");
31  visManager->Initialize();
32 
33  // Enable seach paths for component and b-field data
34  auto UImanager = G4UImanager::GetUIpointer();
35  G4String searchpath = UImanager->GetMacroSearchPath();
36  if (searchpath!="") searchpath += ":";
37 
38  // First, add "."
39  searchpath += ".";
40 
41  // Then the install path
42  searchpath += ":";
43  searchpath += CMAKE_INSTALL_FULL_DATADIR;
44  searchpath += "/east";
45 
46  // Finally, the original source directory
47  // This way, no "make install" should be necessary
48  searchpath += ":";
49  searchpath += G4String(CMAKE_PROJECT_SOURCE_DIR);
50 
51 
52 
53  UImanager->SetMacroSearchPath(searchpath);
54  UImanager->ParseMacroSearchPath();
55  if( UImanager->GetVerboseLevel() >0){
56  G4cout << " Search path is " << UImanager->GetMacroSearchPath() << G4endl;
57  }
58 
59  if ( argc == 2 ) {
60  // execute an argument macro file
61  G4String command = "/control/execute ";
62  G4String fileName = argv[1];
63  UImanager->ApplyCommand(command+fileName);
64  }
65  else {
66  // start interactive session
67  auto ui = new G4UIExecutive(argc, argv);
68  eastInitialization->SetWindowText(ui);
69  ui->SessionStart();
70  delete ui;
71  }
72 
73  // Job termination
74  delete eastInitialization;
75  delete visManager;
76  delete runManager;
77 }
78