Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-23 08:28:59

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