Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/biasing/GB05/exampleGB05.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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