Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:20:16

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 // Author: Haegin Han
0027 // Contributor: Min Cheol Han, Bangho Shin, Chansoo Choi, Yeon Soo Yeom, 
0028 //              Jonghwi Jeong, Chan Hyeong Kim
0029 // Reference: ICRP Publication 145. Ann. ICRP 49(3), 2020.
0030 // Geant4 Contributors: J. Allison and S. Guatelli
0031 //
0032 #include "TETDetectorConstruction.hh"
0033 #include "TETModelImport.hh"
0034 #include "TETActionInitialization.hh"
0035 #include "G4RunManagerFactory.hh"
0036 #include "G4UImanager.hh"
0037 #include "G4UIterminal.hh"
0038 #include "G4VisExecutive.hh"
0039 #include "G4UIExecutive.hh"
0040 #include "Randomize.hh"
0041 #include "QGSP_BIC_HP.hh"
0042 
0043 void PrintUsage(){
0044     G4cerr<< "Usage: ./External -m [MACRO] -o [OUTPUT] -f (option for MRCP-AF phantom)"  <<G4endl;
0045     G4cerr<< "Example: ./External -m run.mac -o run.out (-f)" <<G4endl;
0046 }
0047 
0048 int main(int argc,char** argv) 
0049 {
0050     // Read the arguments for batch mode
0051     //
0052     G4String macro;
0053     G4String output;
0054     G4bool   isAF(false);
0055     G4UIExecutive* ui = nullptr;
0056 
0057     for ( G4int i=1; i<argc; i++ ) {
0058         // macro file name
0059         if ( G4String(argv[i]) == "-m" ) {
0060             macro = argv[i+1];
0061             i++;
0062         }
0063         // output file name
0064         else if ( G4String(argv[i]) == "-o" ) {
0065             output = argv[i+1];
0066             i++;
0067         }
0068         // switch for MRCP-AF phantom
0069         else if ( G4String(argv[i]) == "-f" ) {
0070             isAF = true;
0071         }
0072         else {
0073             PrintUsage();
0074             return 1;
0075         }
0076     }
0077 
0078     // print usage when there are more than six arguments
0079     if ( argc>6 ){
0080         PrintUsage();
0081         return 1;
0082     }
0083 
0084     // Detect interactive mode (if no macro file name) and define UI session
0085     //
0086     if ( !macro.size() ) {
0087         ui = new G4UIExecutive(argc, argv);
0088     }
0089     // default output file name
0090     else if ( !output.size() ) output = macro + ".out";
0091 
0092     // Choose the Random engine
0093     //
0094     //G4Random::setTheSeed(time(0));
0095 
0096     // Construct the default run manager
0097     //
0098        auto* runManager = G4RunManagerFactory::CreateRunManager();
0099        G4int nThreads = 4;
0100        runManager->SetNumberOfThreads(nThreads);
0101  
0102     // Set a class to import phantom data
0103     //
0104     auto* tetData = new TETModelImport(isAF, ui);
0105 
0106     // Set mandatory initialisation classes
0107     //
0108     // detector construction
0109     runManager->SetUserInitialization(new TETDetectorConstruction(tetData));
0110     // physics list
0111     //runManager->SetUserInitialization(new TETPhysicsList());
0112     runManager->SetUserInitialization(new QGSP_BIC_HP());
0113     // user action initialisation
0114     runManager->SetUserInitialization(new TETActionInitialization(tetData, output));
0115     
0116     // Visualization manager
0117     //
0118     G4VisManager* visManager = new G4VisExecutive;
0119     visManager->Initialise();
0120 
0121     // Process macro or start UI session
0122     //
0123     G4UImanager* UImanager = G4UImanager::GetUIpointer();
0124 
0125     if ( ! ui ){
0126         // batch mode
0127         G4String command = "/control/execute ";
0128         UImanager->ApplyCommand(command+macro);
0129     }
0130     else {
0131         // interactive mode
0132         UImanager->ApplyCommand("/control/execute init_vis.mac");
0133         ui->SessionStart();
0134         
0135         delete ui;
0136     }
0137 
0138     delete visManager;
0139     delete runManager;
0140 }
0141 
0142