![]() |
|
|||
File indexing completed on 2025-04-17 08:10:29
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 HadronicNucleusXS.cc 0027 /// \brief Main program, 0028 /// hadronic/FlukaCern/ProcessLevel/CrossSection example. 0029 // 0030 // Author: G.Hugo, 06 January 2023 0031 // 0032 // ------------------------------------------------------------- 0033 // 0034 // GEANT4 HadronNucleusXS 0035 // 0036 /// This application allows the study of G4 cross-sections, 0037 /// and in addition, of the FLUKA hadron-nucleus inelastic cross sections. 0038 /// 0039 /// The user can printout any particle-material XS. 0040 /// The XS are exactly the ones defined in any default G4 PhysicsList chosen by the user, 0041 /// or from FLUKA (hadron-nucleus inelastic case). 0042 /// 0043 /// In the input file, the user can set: 0044 /// - projectile. 0045 /// - target material (element, compound or even mixture). 0046 /// - plotting options. 0047 /// 0048 /// All plots (created via the G4 analysis manager) can be dumped 0049 /// to any of the usually supported formats (e.g. ROOT format), 0050 /// but also in a Flair-compatible format. 0051 /// 0052 /// NB 1: Unlike the FlukaCern/ProcessLevel/FinalState example, 0053 /// the choice here is to directly use physics lists 0054 /// (hence under the hood, the processes they define), 0055 /// instead of 'hardcoding' processes of interest. 0056 /// This allows to directly study ALL XS, with no possible discrepancy 0057 /// with respect to what is defined inside the physics lists. 0058 /// 0059 /// NB 2: Note that here, the application is completely independent 0060 /// from the event loop, gun, detector etc: 0061 /// the XS printout happend outside of the event loop anyway. 0062 /// Hence, the fakeRun mode is used (setting number of events to 0). 0063 /// This implies that no ActionInitialization is needed 0064 /// (nor would be used anyway, if ever constructed), 0065 /// and that the detector is a dummy, empty one. 0066 0067 /// Use: build/HadronNucleusXS all_XS.in FTFP_BERT_HP 0068 /// build/HadronNucleusXS all_XS.in G4_HP_CFLUKAHI 0069 // 0070 // ------------------------------------------------------------- 0071 // 0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0074 0075 #include "DetectorConstruction.hh" 0076 0077 #include "G4PhysListFactory.hh" 0078 #include "G4RunManager.hh" 0079 #include "G4RunManagerFactory.hh" 0080 #include "G4VModularPhysicsList.hh" 0081 0082 #ifdef G4_USE_FLUKA 0083 # include "FLUKAParticleTable.hh" 0084 0085 # include "G4_HP_CernFLUKAHadronInelastic_PhysicsList.hh" 0086 #endif 0087 0088 #include "XSHistoManager.hh" 0089 0090 #include "G4Exception.hh" 0091 #include "G4UImanager.hh" 0092 0093 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0094 0095 G4int main(G4int argc, char** argv) 0096 { 0097 // Check number of arguments 0098 if (argc != 3) { 0099 G4Exception("HadronNucleusXS (main)", "Wrong number of input arguments.", FatalException, 0100 "Example use: build/HadronNucleusXS all_XS.in FTFP_BERT_HP"); 0101 } 0102 0103 // Construct a serial RUN MANAGER. 0104 std::unique_ptr<G4RunManager> runManager( 0105 G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly)); 0106 0107 // Empty DETECTOR (compulsory). 0108 const auto dummyDetector = new DetectorConstruction(); 0109 // The detector is owned by G4RunManager. 0110 runManager->SetUserInitialization(dummyDetector); 0111 0112 // Get PHYSICS LIST from command line argument. 0113 // Default: G4_HP_CFLUKAHI. 0114 const G4String physicsListName = (argc >= 3 ? argv[2] : "G4_HP_CFLUKAHI"); 0115 const G4bool isFLUKAPhysicsList = (physicsListName == "G4_HP_CFLUKAHI"); 0116 0117 G4VModularPhysicsList* physicsList = nullptr; 0118 0119 // Create physics list with hadron inelastic processes from FLUKA. 0120 if (isFLUKAPhysicsList) { 0121 #ifdef G4_USE_FLUKA 0122 physicsList = new G4_HP_CernFLUKAHadronInelastic_PhysicsList(); 0123 #else 0124 G4Exception("HadronNucleusXS.cc", "Wrong compilation mode.", FatalException, 0125 "Requested G4_HP_CernFLUKAHadronInelastic physics list.\n" 0126 "This requires COMPILATION in FLUKA mode.\n" 0127 "Please fully recompile the example with G4_USE_FLUKA=yes.\n" 0128 "For example:\n" 0129 "source geant4/examples/extended/hadronic/FlukaCern/FlukaInterface/" 0130 "env_FLUKA_G4_interface.sh\n" 0131 "cd geant4/examples/extended/hadronic/FlukaCern/ProcessLevel/CrossSection/\n" 0132 "mkdir build\n" 0133 "cd build\n" 0134 "cmake -DGeant4_DIR=your_path_to_geant4 -DG4_USE_FLUKA=1 .. \n" 0135 "make -j8 G4_USE_FLUKA=1\n" 0136 "NB: First time use of FLUKA interface:\n" 0137 "Do not forget to first compile the FLUKA interface itself.\n" 0138 "For example: cd geant4/examples/extended/hadronic/FlukaCern/FlukaInterface/ " 0139 "&& make interface && make env\n" 0140 "FlukaInterface/env_FLUKA_G4_interface.sh then needs to be sourced\n" 0141 "in whichever terminal you want to use the FLUKA interface.\n"); 0142 #endif 0143 } 0144 // Create G4 physics list from available catalog. 0145 else { 0146 auto factory = G4PhysListFactory(); 0147 physicsList = factory.GetReferencePhysList(physicsListName); 0148 } 0149 0150 // The physics list is owned by G4RunManager. 0151 runManager->SetUserInitialization(physicsList); 0152 0153 #ifdef G4_USE_FLUKA 0154 if (isFLUKAPhysicsList) { 0155 // Initialize FLUKA <-> G4 particles conversions tables. 0156 fluka_particle_table::initialize(); 0157 } 0158 #endif 0159 0160 // Create HISTO MANAGER (and its messenger). 0161 auto histoManager = XSHistoManager(); 0162 0163 // User interface manager (owned by G4RunManagerKernel). 0164 const auto uiManager = G4UImanager::GetUIpointer(); 0165 // BATCH MODE. 0166 const G4String command = "/control/execute "; 0167 const G4String fileName = argv[1]; 0168 uiManager->ApplyCommand(command + fileName); 0169 0170 // CREATE HISTOGRAMS AND FILL THEM (independent from event loop!). 0171 histoManager.Book(); 0172 histoManager.EndOfRun(); 0173 } 0174 0175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |