Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:13

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 /// \file exoticphysics/monopole/monopole.cc
0027 /// \brief Main program of the exoticphysics/monopole example
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "ActionInitialization.hh"
0034 #include "DetectorConstruction.hh"
0035 
0036 #include "G4MonopolePhysics.hh"
0037 #include "G4PhysListFactory.hh"
0038 #include "G4RunManagerFactory.hh"
0039 #include "G4Types.hh"
0040 #include "G4UIExecutive.hh"
0041 #include "G4UImanager.hh"
0042 #include "G4VModularPhysicsList.hh"
0043 #include "G4VisExecutive.hh"
0044 #include "Randomize.hh"
0045 #include "globals.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 namespace
0050 {
0051 void PrintUsage()
0052 {
0053   G4cerr << " Usage: " << G4endl << " monopole [-m macro ] [-s setupMonopole] [-t nThreads]"
0054          << G4endl << "   Note: " << G4endl
0055          << "    -s should be followed by a composed string, eg. \'1 0 100 GeV\'" << G4endl
0056          << "    -t option is for multi-threaded mode." << G4endl << G4endl;
0057 }
0058 }  // namespace
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 
0062 int main(int argc, char** argv)
0063 {
0064   // Evaluate arguments
0065   //
0066   if (argc > 7) {
0067     PrintUsage();
0068     return 1;
0069   }
0070 
0071   G4String macro;
0072   G4String setupMonopole;
0073   G4int nThreads = 1;
0074   for (G4int i = 1; i < argc; i = i + 2) {
0075     if (G4String(argv[i]) == "-m")
0076       macro = argv[i + 1];
0077     else if (G4String(argv[i]) == "-s")
0078       setupMonopole = argv[i + 1];
0079     else if (G4String(argv[i]) == "-t") {
0080       nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
0081     }
0082     else {
0083       PrintUsage();
0084       return 1;
0085     }
0086   }
0087 
0088   // Construct the default run manager
0089   auto* runManager = G4RunManagerFactory::CreateRunManager();
0090   if (nThreads > 0) {
0091     runManager->SetNumberOfThreads(nThreads);
0092   }
0093   G4cout << "===== Example is started with " << runManager->GetNumberOfThreads()
0094          << " threads =====" << G4endl;
0095 
0096   // Instantiate G4UIExecutive if interactive
0097   G4UIExecutive* ui = nullptr;
0098   if (macro.empty()) {
0099     ui = new G4UIExecutive(argc, argv);
0100   }
0101 
0102   // get the pointer to the User Interface manager
0103   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0104 
0105   // create physicsList
0106   //  Physics List is defined via environment variable PHYSLIST
0107   G4PhysListFactory factory;
0108   G4VModularPhysicsList* phys = factory.GetReferencePhysList("FTFP_BERT");
0109 
0110   // monopole physics is added
0111   G4MonopolePhysics* theMonopole = new G4MonopolePhysics();
0112 
0113   // Setup monopole
0114   if (setupMonopole.size()) {
0115     UImanager->ApplyCommand("/control/verbose 1");
0116     UImanager->ApplyCommand("/monopole/setup " + setupMonopole);
0117   }
0118 
0119   // regsiter monopole physics
0120   phys->RegisterPhysics(theMonopole);
0121 
0122   runManager->SetUserInitialization(phys);
0123 
0124   // visualization manager
0125   G4VisManager* visManager = nullptr;
0126 
0127   // set detector construction
0128   DetectorConstruction* det = new DetectorConstruction();
0129   runManager->SetUserInitialization(det);
0130 
0131   // set user action classes
0132   runManager->SetUserInitialization(new ActionInitialization(det));
0133 
0134   // Process macro or start UI session
0135   //
0136   if (macro.size()) {
0137     // batch mode
0138     G4String command = "/control/execute ";
0139     UImanager->ApplyCommand(command + macro);
0140   }
0141   else {
0142     // interactive mode : define UI session
0143     visManager = new G4VisExecutive();
0144     visManager->Initialize();
0145     UImanager->ApplyCommand("/control/execute init_vis.mac");
0146     ui->SessionStart();
0147     delete ui;
0148   }
0149 
0150   delete visManager;
0151 
0152   // job termination
0153   delete runManager;
0154 
0155   return 0;
0156 }
0157 
0158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......