Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-04 09:28: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 /// \file GB06/exampleGB06.cc
0027 /// \brief Main program of the GB06 example
0028 //
0029 //
0030 
0031 #include "FTFP_BERT.hh"
0032 #include "GB06ActionInitialization.hh"
0033 #include "GB06DetectorConstruction.hh"
0034 #include "GB06ParallelWorldForSlices.hh"
0035 #include "GB06PrimaryGeneratorAction.hh"
0036 
0037 #include "G4GenericBiasingPhysics.hh"
0038 #include "G4RunManagerFactory.hh"
0039 #include "G4Types.hh"
0040 #include "G4UIExecutive.hh"
0041 #include "G4UImanager.hh"
0042 #include "G4VisExecutive.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 namespace
0047 {
0048 void PrintUsage()
0049 {
0050   G4cerr << " Usage: " << G4endl;
0051   G4cerr << " ./exampleGB06 [-m macro ] "
0052          << " [-b biasing {'on','off'}]"
0053          << "\n or\n ./exampleGB06 [macro.mac]" << G4endl;
0054 }
0055 }  // namespace
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 int main(int argc, char** argv)
0060 {
0061   // Evaluate arguments
0062   //
0063   if (argc > 5) {
0064     PrintUsage();
0065     return 1;
0066   }
0067 
0068   G4String macro("");
0069   G4String onOffBiasing("");
0070   if (argc == 2)
0071     macro = argv[1];
0072   else {
0073     for (G4int i = 1; i < argc; i = i + 2) {
0074       if (G4String(argv[i]) == "-m")
0075         macro = argv[i + 1];
0076       else if (G4String(argv[i]) == "-b")
0077         onOffBiasing = argv[i + 1];
0078       else {
0079         PrintUsage();
0080         return 1;
0081       }
0082     }
0083   }
0084 
0085   if (onOffBiasing == "") onOffBiasing = "on";
0086 
0087   // Instantiate G4UIExecutive if interactive mode
0088   G4UIExecutive* ui = nullptr;
0089   if (macro == "") {
0090     ui = new G4UIExecutive(argc, argv);
0091   }
0092 
0093   // -- Construct the run manager : MT or sequential one
0094   auto* runManager = G4RunManagerFactory::CreateRunManager();
0095   runManager->SetNumberOfThreads(4);
0096 
0097   G4bool biasingFlag = (onOffBiasing == "on");
0098 
0099   // -- Set mandatory initialization classes
0100 
0101   // -- Create geometry:
0102   auto detector = new GB06DetectorConstruction();
0103   // -- Create parallel world:
0104   auto parallelWorld = new GB06ParallelWorldForSlices("parallelWorldForSlices", biasingFlag);
0105   // -- and "augment" detector geometry with the parallelWorld one:
0106   detector->RegisterParallelWorld(parallelWorld);
0107   runManager->SetUserInitialization(detector);
0108 
0109   // -- Select a physics list:
0110   auto physicsList = new FTFP_BERT;
0111   if (biasingFlag) {
0112     // -- and augment it with biasing facilities:
0113     auto biasingPhysics = new G4GenericBiasingPhysics();
0114     biasingPhysics->BeVerbose();
0115     // -- We use only the "non physics biasing" functionnality (ie, the ones which don't
0116     // -- alter physics processes behavior), and hence we equipe the physics list
0117     // -- accordingly:
0118     biasingPhysics->NonPhysicsBias("neutron");
0119     // -- we activate and configure the parallel geometry facility:
0120     biasingPhysics->AddParallelGeometry("neutron", "parallelWorldForSlices");
0121     physicsList->RegisterPhysics(biasingPhysics);
0122     G4cout << "      ********************************************************* " << G4endl;
0123     G4cout << "      ********** processes are wrapped for biasing ************ " << G4endl;
0124     G4cout << "      ********************************************************* " << G4endl;
0125   }
0126   else {
0127     G4cout << "      ************************************************* " << G4endl;
0128     G4cout << "      ********** processes are not wrapped ************ " << G4endl;
0129     G4cout << "      ************************************************* " << G4endl;
0130   }
0131   runManager->SetUserInitialization(physicsList);
0132 
0133   // -- Action initialization:
0134   runManager->SetUserInitialization(new GB06ActionInitialization);
0135 
0136   // Initialize G4 kernel
0137   runManager->Initialize();
0138 
0139   // Initialize visualization
0140   auto visManager = new G4VisExecutive;
0141   // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
0142   visManager->Initialize();
0143 
0144   // Get the pointer to the User Interface manager
0145   auto UImanager = G4UImanager::GetUIpointer();
0146 
0147   if (macro != "")  // batch mode
0148   {
0149     G4String command = "/control/execute ";
0150     UImanager->ApplyCommand(command + macro);
0151   }
0152   else {  // interactive mode : define UI session
0153     UImanager->ApplyCommand("/control/execute vis.mac");
0154     //      if (ui->IsGUI())
0155     //              UImanager->ApplyCommand("/control/execute gui.mac");
0156     ui->SessionStart();
0157     delete ui;
0158   }
0159 
0160   delete visManager;
0161   delete runManager;
0162 
0163   return 0;
0164 }
0165 
0166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....