Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:05

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 //
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 #include "G4RunManagerFactory.hh"
0032 #include "G4SteppingVerbose.hh"
0033 #include "G4Types.hh"
0034 #include "G4UIExecutive.hh"
0035 #include "G4UImanager.hh"
0036 #include "G4VisExecutive.hh"
0037 
0038 #include "ActionInitialization.hh"
0039 #include "DetectorConstruction.hh"
0040 #include "PhysicsList.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 int main(int argc, char** argv)
0045 {
0046   // detect interactive mode (if no arguments) and define UI session
0047   G4UIExecutive* ui = nullptr;
0048   if (argc == 1) ui = new G4UIExecutive(argc, argv);
0049 
0050   // Use SteppingVerbose with Unit
0051   G4int precision = 4;
0052   G4SteppingVerbose::UseBestUnit(precision);
0053 
0054   if (argc == 2) {
0055     G4Exception("argument", "Fatal error in Argument", FatalErrorInArgument,
0056                 "Type of simulation must be precised: either ./stim_pixe_tomography -p "
0057                 "pixe3d.mac or ./stim_pixe_tomography -s pixe3d.mac");
0058   }
0059   G4bool isPIXE = false;
0060   if (argc > 2) {
0061     G4String s;
0062     s = argv[1];
0063     if (s == "-p")
0064       isPIXE = true;
0065     else if (s == "-s")
0066       isPIXE = false;
0067     else {
0068       G4Exception("argument", "Fatal error in Argument", FatalErrorInArgument,
0069                   "Type of simulation must be precised: /stim_pixe_tomography -p "
0070                   "pixe3d.mac or ./stim_pixe_tomography -s pixe3d.mac");
0071     }
0072   }
0073   G4int nThreads = 4;
0074   if (argc == 4) nThreads = G4UIcommand::ConvertToInt(argv[3]);
0075   auto* runManager = G4RunManagerFactory::CreateRunManager();
0076   runManager->SetNumberOfThreads(nThreads);
0077 
0078   // UserInitialization classes - mandatory
0079   runManager->SetUserInitialization(new DetectorConstruction());
0080   runManager->SetUserInitialization(new PhysicsList());
0081   runManager->SetUserInitialization(new ActionInitialization(isPIXE));
0082 
0083   // initialize visualization
0084   auto visManager = new G4VisExecutive;
0085   visManager->Initialize();
0086 
0087   // get the pointer to the User Interface manager
0088   auto UImanager = G4UImanager::GetUIpointer();
0089 
0090   // User interactions
0091   // Define (G)UI for interactive mode
0092   if (ui) {
0093     UImanager->ApplyCommand("/control/execute init_vis.mac");
0094     ui->SessionStart();
0095     delete ui;
0096   }
0097   else {
0098     G4String command;
0099     command = "/control/execute ";
0100     G4String fileName;
0101     fileName = argv[2];
0102     UImanager->ApplyCommand(command + fileName);
0103   }
0104 
0105   // job termination
0106   delete visManager;
0107   delete runManager;
0108   return 0;
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......