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 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/hadronic/FlukaCern/ProcessLevel/CrossSection/HadronNucleusXS.cc (Version 11.3.0) and /examples/extended/hadronic/FlukaCern/ProcessLevel/CrossSection/HadronNucleusXS.cc (Version 11.2.2)


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