Back to home page

EIC code displayed by LXR

 
 

    


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

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 OpNovice/OpNovice.cc
0027 /// \brief Main program of the OpNovice example
0028 //
0029 //
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 //
0034 // Description: Test of Continuous Process G4Cerenkov
0035 //              and RestDiscrete Process G4Scintillation
0036 //              -- Generation Cerenkov Photons --
0037 //              -- Generation Scintillation Photons --
0038 //              -- Transport of optical Photons --
0039 // Version:     5.0
0040 // Created:     1996-04-30
0041 // Author:      Juliet Armstrong
0042 //
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 #include "OpNoviceDetectorConstruction.hh"
0046 #ifdef GEANT4_USE_GDML
0047 #  include "OpNoviceGDMLDetectorConstruction.hh"
0048 #endif
0049 #include "FTFP_BERT.hh"
0050 #include "OpNoviceActionInitialization.hh"
0051 
0052 #include "G4EmStandardPhysics_option4.hh"
0053 #include "G4OpticalPhysics.hh"
0054 #include "G4RunManagerFactory.hh"
0055 #include "G4Types.hh"
0056 #include "G4UIExecutive.hh"
0057 #include "G4UImanager.hh"
0058 #include "G4VisExecutive.hh"
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 namespace
0062 {
0063 void PrintUsage()
0064 {
0065   G4cerr << " Usage: " << G4endl;
0066 #ifdef GEANT4_USE_GDML
0067   G4cerr << " OpNovice [-g gdmlfile] [-m macro ] [-u UIsession] [-t "
0068             "nThreads] [-r seed] "
0069          << G4endl;
0070 #else
0071   G4cerr << " OpNovice  [-m macro ] [-u UIsession] [-t nThreads] [-r seed] " << G4endl;
0072 #endif
0073   G4cerr << "   note: -t option is available only for multi-threaded mode." << G4endl;
0074 }
0075 }  // namespace
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 
0079 int main(int argc, char** argv)
0080 {
0081   // Evaluate arguments
0082   //
0083   if (argc > 9) {
0084     PrintUsage();
0085     return 1;
0086   }
0087   G4String gdmlfile;
0088   G4String macro;
0089   G4String session;
0090 #ifdef G4MULTITHREADED
0091   G4int nThreads = 0;
0092 #endif
0093 
0094   G4long myseed = 345354;
0095   for (G4int i = 1; i < argc; i = i + 2) {
0096     if (G4String(argv[i]) == "-g")
0097       gdmlfile = argv[i + 1];
0098     else if (G4String(argv[i]) == "-m")
0099       macro = argv[i + 1];
0100     else if (G4String(argv[i]) == "-u")
0101       session = argv[i + 1];
0102     else if (G4String(argv[i]) == "-r")
0103       myseed = atoi(argv[i + 1]);
0104 #ifdef G4MULTITHREADED
0105     else if (G4String(argv[i]) == "-t") {
0106       nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
0107     }
0108 #endif
0109     else {
0110       PrintUsage();
0111       return 1;
0112     }
0113   }
0114 
0115   // Instantiate G4UIExecutive if interactive mode
0116   G4UIExecutive* ui = nullptr;
0117   if (macro.size() == 0) {
0118     ui = new G4UIExecutive(argc, argv);
0119   }
0120 
0121   // Construct the default run manager
0122   auto runManager = G4RunManagerFactory::CreateRunManager();
0123 #ifdef G4MULTITHREADED
0124   if (nThreads > 0) runManager->SetNumberOfThreads(nThreads);
0125 #endif
0126 
0127   // Seed the random number generator manually
0128   G4Random::setTheSeed(myseed);
0129 
0130   // Set mandatory initialization classes
0131   //
0132   // Detector construction
0133   if (gdmlfile != "") {
0134 #ifdef GEANT4_USE_GDML
0135     runManager->SetUserInitialization(new OpNoviceGDMLDetectorConstruction(gdmlfile));
0136 #else
0137     G4cout << "Error! Input gdml file specified, but Geant4 wasn't" << G4endl
0138            << "built with gdml support." << G4endl;
0139     return 1;
0140 #endif
0141   }
0142   else {
0143     runManager->SetUserInitialization(new OpNoviceDetectorConstruction());
0144   }
0145   // Physics list
0146   G4VModularPhysicsList* physicsList = new FTFP_BERT;
0147   physicsList->ReplacePhysics(new G4EmStandardPhysics_option4());
0148   auto opticalPhysics = new G4OpticalPhysics();
0149   physicsList->RegisterPhysics(opticalPhysics);
0150   runManager->SetUserInitialization(physicsList);
0151 
0152   runManager->SetUserInitialization(new OpNoviceActionInitialization());
0153 
0154   G4VisManager* visManager = new G4VisExecutive("Quiet");
0155   visManager->Initialize();
0156 
0157   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0158 
0159   if (macro.size()) {
0160     G4String command = "/control/execute ";
0161     UImanager->ApplyCommand(command + macro);
0162   }
0163   else  // Define UI session for interactive mode
0164   {
0165     UImanager->ApplyCommand("/control/execute vis.mac");
0166     if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac");
0167     ui->SessionStart();
0168     delete ui;
0169   }
0170 
0171   delete visManager;
0172   delete runManager;
0173 
0174   return 0;
0175 }
0176 
0177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......