Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file HadronicNucleusXS.cc 27 /// \brief Main program, 28 /// hadronic/FlukaCern/ProcessLevel/Cr 29 // 30 // Author: G.Hugo, 06 January 2023 31 // 32 // ------------------------------------------- 33 // 34 // GEANT4 HadronNucleusXS 35 // 36 /// This application allows the study of G4 c 37 /// and in addition, of the FLUKA hadron-nucl 38 /// 39 /// The user can printout any particle-materi 40 /// The XS are exactly the ones defined in an 41 /// or from FLUKA (hadron-nucleus inelastic c 42 /// 43 /// In the input file, the user can set: 44 /// - projectile. 45 /// - target material (element, compound or e 46 /// - plotting options. 47 /// 48 /// All plots (created via the G4 analysis ma 49 /// to any of the usually supported formats ( 50 /// but also in a Flair-compatible format. 51 /// 52 /// NB 1: Unlike the FlukaCern/ProcessLevel/F 53 /// the choice here is to directly use physic 54 /// (hence under the hood, the processes they 55 /// instead of 'hardcoding' processes of inte 56 /// This allows to directly study ALL XS, wit 57 /// with respect to what is defined inside th 58 /// 59 /// NB 2: Note that here, the application is 60 /// from the event loop, gun, detector etc: 61 /// the XS printout happend outside of the ev 62 /// Hence, the fakeRun mode is used (setting 63 /// This implies that no ActionInitialization 64 /// (nor would be used anyway, if ever constr 65 /// and that the detector is a dummy, empty o 66 67 /// Use: build/HadronNucleusXS all_XS.in FTFP 68 /// build/HadronNucleusXS all_XS.in G4_H 69 // 70 // ------------------------------------------- 71 // 72 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oo 74 75 #include "DetectorConstruction.hh" 76 77 #include "G4PhysListFactory.hh" 78 #include "G4RunManager.hh" 79 #include "G4RunManagerFactory.hh" 80 #include "G4VModularPhysicsList.hh" 81 82 #ifdef G4_USE_FLUKA 83 # include "FLUKAParticleTable.hh" 84 85 # include "G4_HP_CernFLUKAHadronInelastic_Phy 86 #endif 87 88 #include "XSHistoManager.hh" 89 90 #include "G4Exception.hh" 91 #include "G4UImanager.hh" 92 93 //....oooOO0OOooo........oooOO0OOooo........oo 94 95 G4int main(G4int argc, char** argv) 96 { 97 // Check number of arguments 98 if (argc != 3) { 99 G4Exception("HadronNucleusXS (main)", "Wro 100 "Example use: build/HadronNucl 101 } 102 103 // Construct a serial RUN MANAGER. 104 std::unique_ptr<G4RunManager> runManager( 105 G4RunManagerFactory::CreateRunManager(G4Ru 106 107 // Empty DETECTOR (compulsory). 108 const auto dummyDetector = new DetectorConst 109 // The detector is owned by G4RunManager. 110 runManager->SetUserInitialization(dummyDetec 111 112 // Get PHYSICS LIST from command line argume 113 // Default: G4_HP_CFLUKAHI. 114 const G4String physicsListName = (argc >= 3 115 const G4bool isFLUKAPhysicsList = (physicsLi 116 117 G4VModularPhysicsList* physicsList = nullptr 118 119 // Create physics list with hadron inelastic 120 if (isFLUKAPhysicsList) { 121 #ifdef G4_USE_FLUKA 122 physicsList = new G4_HP_CernFLUKAHadronIne 123 #else 124 G4Exception("HadronNucleusXS.cc", "Wrong c 125 "Requested G4_HP_CernFLUKAHadr 126 "This requires COMPILATION in 127 "Please fully recompile the ex 128 "For example:\n" 129 "source geant4/examples/extend 130 "env_FLUKA_G4_interface.sh\n" 131 "cd geant4/examples/extended/h 132 "mkdir build\n" 133 "cd build\n" 134 "cmake -DGeant4_DIR=your_path_ 135 "make -j8 G4_USE_FLUKA=1\n" 136 "NB: First time use of FLUKA i 137 "Do not forget to first compil 138 "For example: cd geant4/exampl 139 "&& make interface && make env 140 "FlukaInterface/env_FLUKA_G4_i 141 "in whichever terminal you wan 142 #endif 143 } 144 // Create G4 physics list from available cat 145 else { 146 auto factory = G4PhysListFactory(); 147 physicsList = factory.GetReferencePhysList 148 } 149 150 // The physics list is owned by G4RunManager 151 runManager->SetUserInitialization(physicsLis 152 153 #ifdef G4_USE_FLUKA 154 if (isFLUKAPhysicsList) { 155 // Initialize FLUKA <-> G4 particles conve 156 fluka_particle_table::initialize(); 157 } 158 #endif 159 160 // Create HISTO MANAGER (and its messenger). 161 auto histoManager = XSHistoManager(); 162 163 // User interface manager (owned by G4RunMan 164 const auto uiManager = G4UImanager::GetUIpoi 165 // BATCH MODE. 166 const G4String command = "/control/execute " 167 const G4String fileName = argv[1]; 168 uiManager->ApplyCommand(command + fileName); 169 170 // CREATE HISTOGRAMS AND FILL THEM (independ 171 histoManager.Book(); 172 histoManager.EndOfRun(); 173 } 174 175 //....oooOO0OOooo........oooOO0OOooo........oo 176