Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:47

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 /// \file movies.cc
0028 /// \brief Main program of the Movies example
0029 
0030 #include "FTFP_BERT.hh"
0031 #include "MoviesActionInitialization.hh"
0032 #include "MoviesDetectorConstruction.hh"
0033 
0034 #include "G4RunManagerFactory.hh"
0035 #include "G4UIExecutive.hh"
0036 #include "G4UIcommand.hh"
0037 #include "G4UImanager.hh"
0038 #include "G4VisExecutive.hh"
0039 #include "Randomize.hh"
0040 
0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0042 
0043 namespace
0044 {
0045 void PrintUsage()
0046 {
0047   G4cerr << " Usage: " << G4endl;
0048   G4cerr << " exampleMovies [-m macro ] [-u UIsession] [-t nThreads]" << G4endl;
0049   G4cerr << "   note: -t option is available only for multi-threaded mode." << G4endl;
0050 }
0051 }  // namespace
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0054 
0055 int main(int argc, char** argv)
0056 {
0057   // Evaluate arguments
0058   //
0059   if (argc > 7) {
0060     PrintUsage();
0061     return 1;
0062   }
0063 
0064   G4String macro;
0065   G4String session;
0066 #ifdef G4MULTITHREADED
0067   G4int nThreads = 0;
0068 #endif
0069   for (G4int i = 1; i < argc; i = i + 2) {
0070     if (G4String(argv[i]) == "-m")
0071       macro = argv[i + 1];
0072     else if (G4String(argv[i]) == "-u")
0073       session = argv[i + 1];
0074 #ifdef G4MULTITHREADED
0075     else if (G4String(argv[i]) == "-t") {
0076       nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
0077     }
0078 #endif
0079     else {
0080       PrintUsage();
0081       return 1;
0082     }
0083   }
0084 
0085   // Detect interactive mode (if no macro provided) and define UI session
0086   //
0087   G4UIExecutive* ui = nullptr;
0088   if (!macro.size()) {
0089     ui = new G4UIExecutive(argc, argv, session);
0090   }
0091 
0092   // Optionally: choose a different Random engine...
0093   //
0094   // G4Random::setTheEngine(new CLHEP::MTwistEngine);
0095 
0096   // Construct the default run manager
0097   //
0098   auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0099 #ifdef G4MULTITHREADED
0100   if (nThreads > 0) {
0101     runManager->SetNumberOfThreads(nThreads);
0102   }
0103 #endif
0104 
0105   // Set mandatory initialization classes
0106   //
0107   auto detConstruction = new MoviesDetectorConstruction();
0108   runManager->SetUserInitialization(detConstruction);
0109 
0110   auto physicsList = new FTFP_BERT;
0111   runManager->SetUserInitialization(physicsList);
0112 
0113   auto actionInitialization = new MoviesActionInitialization;
0114   runManager->SetUserInitialization(actionInitialization);
0115 
0116   // Initialize visualization
0117   //
0118   auto visManager = new G4VisExecutive;
0119   // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
0120   // G4VisManager* visManager = new G4VisExecutive("Quiet");
0121   visManager->Initialize();
0122 
0123   // Get the pointer to the User Interface manager
0124   auto UImanager = G4UImanager::GetUIpointer();
0125 
0126   // Process macro or start UI session
0127   //
0128   if (macro.size()) {
0129     // batch mode
0130     G4String command = "/control/execute ";
0131     UImanager->ApplyCommand(command + macro);
0132   }
0133   else {
0134     // interactive mode : define UI session
0135     UImanager->ApplyCommand("/control/execute init_vis.mac");
0136     if (ui->IsGUI()) {
0137       UImanager->ApplyCommand("/control/execute gui.mac");
0138     }
0139     ui->SessionStart();
0140     delete ui;
0141   }
0142 
0143   // Job termination
0144   // Free the store: user actions, physics_list and detector_description are
0145   // owned and deleted by the run manager, so they should not be deleted
0146   // in the main() program !
0147 
0148   delete visManager;
0149   delete runManager;
0150 }
0151 
0152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....