|
|
|||
File indexing completed on 2026-03-29 07:51:58
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 ts_scorers.cc 0027 /// \brief Main program of the parallel/ThreadsafeScorers example 0028 /// 0029 /// ts_scorers example shows how to use global scorers. The benefit of using 0030 /// global scorers in memory-savings for problems with very large amounts 0031 /// of scoring volumes. Additionally, the global scorers are more precise 0032 /// w.r.t. the serial solution because of the lack of compounding 0033 /// round-off error from multiple threads 0034 /// 0035 /// In this example, the global scorers are implemented as static member 0036 /// variables in TSRun because TSRun is thread-local. The G4atomic 0037 /// class is the core of the thread-safe scorers and can be uses 0038 // 0039 // 0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0042 0043 #include "G4RunManagerFactory.hh" 0044 #include "G4Threading.hh" 0045 #include "G4Types.hh" 0046 #include "Randomize.hh" 0047 0048 // User Defined Classes 0049 #include "TSActionInitialization.hh" 0050 #include "TSDetectorConstruction.hh" 0051 #include "TSPhysicsList.hh" 0052 0053 #include "G4Step.hh" 0054 #include "G4Track.hh" 0055 #include "G4UIExecutive.hh" 0056 #include "G4UImanager.hh" 0057 #include "G4VisExecutive.hh" 0058 0059 // for std::system(const char*) 0060 #include <cstdlib> 0061 0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0063 0064 void message(G4RunManager* runmanager) 0065 { 0066 G4MTRunManager* man = dynamic_cast<G4MTRunManager*>(runmanager); 0067 if (man) { 0068 man->SetNumberOfThreads(G4Threading::G4GetNumberOfCores()); 0069 G4cout << "\n\n\t--> Running in multithreaded mode with " << man->GetNumberOfThreads() 0070 << " threads\n\n" 0071 << G4endl; 0072 } 0073 else { 0074 G4cout << "\n\n\t--> Running in serial mode\n\n" << G4endl; 0075 } 0076 } 0077 0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0079 0080 int main(int argc, char** argv) 0081 { 0082 G4String macro; 0083 if (argc > 1) macro = argv[argc - 1]; 0084 0085 // Detect interactive mode (if no arguments) and define UI session 0086 // 0087 G4UIExecutive* ui = 0; 0088 if (macro.empty()) ui = new G4UIExecutive(argc, argv); 0089 0090 // Set the random seed 0091 CLHEP::HepRandom::setTheSeed(1245214UL); 0092 0093 G4RunManager* runmanager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Tasking); 0094 0095 message(runmanager); 0096 0097 runmanager->SetUserInitialization(new TSDetectorConstruction); 0098 0099 runmanager->SetUserInitialization(new TSPhysicsList); 0100 0101 runmanager->SetUserInitialization(new TSActionInitialization); 0102 0103 runmanager->Initialize(); 0104 0105 // Initialize visualization 0106 // 0107 G4VisManager* visManager = new G4VisExecutive; 0108 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 0109 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 0110 visManager->Initialize(); 0111 0112 // Get the pointer to the User Interface manager 0113 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0114 0115 // Process macro or start UI session 0116 // 0117 if (!ui) { 0118 // batch mode 0119 G4String command = "/control/execute "; 0120 UImanager->ApplyCommand(command + macro); 0121 } 0122 else { 0123 ui->SessionStart(); 0124 } 0125 0126 // Job termination 0127 // Free the store: user actions, physics_list and detector_description are 0128 // owned and deleted by the run manager, so they should not be deleted 0129 // in the main() program ! 0130 delete visManager; 0131 delete runmanager; 0132 0133 return 0; 0134 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|