Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:26:25

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 #include "FTFP_BERT.hh"
0028 #include "GB03ActionInitialization.hh"
0029 #include "GB03DetectorConstruction.hh"
0030 #include "GB03PrimaryGeneratorAction.hh"
0031 
0032 #include "G4GenericBiasingPhysics.hh"
0033 #include "G4RunManagerFactory.hh"
0034 #include "G4Types.hh"
0035 #include "G4UIExecutive.hh"
0036 #include "G4UImanager.hh"
0037 #include "G4VisExecutive.hh"
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 namespace
0041 {
0042 void PrintUsage()
0043 {
0044   G4cerr << " Usage: " << G4endl;
0045   G4cerr << " ./exampleGB04 [-m macro ] "
0046          << " [-b biasing {'on','off'}]"
0047          << "\n or\n ./exampleGB04 [macro.mac]" << G4endl;
0048 }
0049 }  // namespace
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 int main(int argc, char** argv)
0054 {
0055   // Evaluate arguments
0056   //
0057   if (argc > 5) {
0058     PrintUsage();
0059     return 1;
0060   }
0061 
0062   G4String macro("");
0063   G4String onOffBiasing("");
0064   if (argc == 2)
0065     macro = argv[1];
0066   else {
0067     for (G4int i = 1; i < argc; i = i + 2) {
0068       if (G4String(argv[i]) == "-m")
0069         macro = argv[i + 1];
0070       else if (G4String(argv[i]) == "-b")
0071         onOffBiasing = argv[i + 1];
0072       else {
0073         PrintUsage();
0074         return 1;
0075       }
0076     }
0077   }
0078 
0079   if (onOffBiasing == "") onOffBiasing = "on";
0080 
0081   // Instantiate G4UIExecutive if interactive mode
0082   G4UIExecutive* ui = nullptr;
0083   if (macro == "") {
0084     ui = new G4UIExecutive(argc, argv);
0085   }
0086 
0087   // -- Construct the run manager : MT or sequential one
0088   auto* runManager = G4RunManagerFactory::CreateRunManager();
0089   runManager->SetNumberOfThreads(4);
0090 
0091   G4bool biasingFlag = (onOffBiasing == "on");
0092 
0093   // -- Set mandatory initialization classes
0094   G4VUserDetectorConstruction* detector = new GB03DetectorConstruction(biasingFlag);
0095   runManager->SetUserInitialization(detector);
0096   G4VModularPhysicsList* physicsList = new FTFP_BERT;
0097   // -- Setup biasing for neutron only. As will not bias any
0098   // -- physics process, require the G4GenericBiasingPhysics()
0099   // -- to modify the physics list just for "non-physics" biasing:
0100   if (biasingFlag) {
0101     auto biasingPhysics = new G4GenericBiasingPhysics();
0102     biasingPhysics->NonPhysicsBias("neutron");
0103     physicsList->RegisterPhysics(biasingPhysics);
0104     G4cout << "      ********************************************************* " << G4endl;
0105     G4cout << "      ********** processes are wrapped for biasing ************ " << G4endl;
0106     G4cout << "      ********************************************************* " << G4endl;
0107   }
0108   else {
0109     G4cout << "      ************************************************* " << G4endl;
0110     G4cout << "      ********** processes are not wrapped ************ " << G4endl;
0111     G4cout << "      ************************************************* " << G4endl;
0112   }
0113   runManager->SetUserInitialization(physicsList);
0114 
0115   // -- Set user action initialization class
0116   G4VUserActionInitialization* actions = new GB03ActionInitialization;
0117   runManager->SetUserInitialization(actions);
0118 
0119   // Visualization manager
0120   //
0121   auto visManager = new G4VisExecutive;
0122   visManager->Initialize();
0123 
0124   // Initialize G4 kernel
0125   //
0126   runManager->Initialize();
0127 
0128   // Get the pointer to the User Interface manager
0129   //
0130   auto UImanager = G4UImanager::GetUIpointer();
0131 
0132   if (ui)  // Define UI session for interactive mode
0133   {
0134     UImanager->ApplyCommand("/control/execute vis.mac");
0135     ui->SessionStart();
0136     delete ui;
0137   }
0138   else  // Batch mode
0139   {
0140     G4String command = "/control/execute ";
0141     UImanager->ApplyCommand(command + macro);
0142   }
0143 
0144   delete visManager;
0145   delete runManager;
0146 
0147   return 0;
0148 }