Geant4 Cross Reference |
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 // 26 // 27 /// \file Hadr09.cc 27 /// \file Hadr09.cc 28 /// \brief Main program of the hadronic/Hadr09 28 /// \brief Main program of the hadronic/Hadr09 example 29 // 29 // 30 //-------------------------------------------- 30 //------------------------------------------------------------------------ 31 // This program shows how to use the class Had 31 // This program shows how to use the class Hadronic Generator. 32 // The class HadronicGenerator is a kind of "h 32 // The class HadronicGenerator is a kind of "hadronic generator", i.e. 33 // provides Geant4 final states (i.e. secondar 33 // provides Geant4 final states (i.e. secondary particles) produced by 34 // hadron-nuclear inelastic collisions. 34 // hadron-nuclear inelastic collisions. 35 // Please see the class itself for more inform 35 // Please see the class itself for more information. 36 // 36 // 37 // The use of the class Hadronic Generator is 37 // The use of the class Hadronic Generator is very simple: 38 // the constructor needs to be invoked only on 38 // the constructor needs to be invoked only once - specifying the name 39 // of the Geant4 "physics case" to consider (" << 39 // of the Geant4 "physics case" to consider ("FTFP_BERT_ATL" will be 40 // considered as default is the name is not sp 40 // considered as default is the name is not specified) - and then one 41 // method needs to be called at each collision 41 // method needs to be called at each collision, specifying the type of 42 // collision (hadron, energy, direction, mater 42 // collision (hadron, energy, direction, material) to be simulated. 43 // The class HadronicGenerator is expected to 43 // The class HadronicGenerator is expected to work also in a 44 // multi-threaded environment with "external" 44 // multi-threaded environment with "external" threads (i.e. threads 45 // that are not necessarily managed by Geant4 45 // that are not necessarily managed by Geant4 run-manager): 46 // each thread should have its own instance of 46 // each thread should have its own instance of the class. 47 // 47 // 48 // See the string "***LOOKHERE***" below for t 48 // See the string "***LOOKHERE***" below for the setting of parameters 49 // of this example: the "physics case", the se 49 // of this example: the "physics case", the set of possibilities from 50 // which to sample the projectile (i.e. whethe << 50 // which to sample the collision, i.e. the type of projectile hadron, 51 // hadron or an ion - in the case of hadron pr << 51 // its kinetic energy, its direction and the target material (from the 52 // is possible from which to sample at each co << 52 // latter, the target nucleus will be chosen randomly by Geant4 itself), 53 // ion projectile, only one type of ion needs << 53 // and whether to print out some information or not and how frequently. 54 // the kinetic energy of the projectile (which << 54 // Once a well-defined type of hadron-nuclear inelastic collisions has 55 // an interval), whether the direction of the << 55 // been chosen, the method HadronicGenerator::GenerateInteraction 56 // sampled at each collision, the target mater << 57 // is possible, from which the target material << 58 // collision, and then from this target materi << 59 // will be chosen randomly by Geant4 itself), << 60 // some information or not and how frequently. << 61 // Once a well-defined type of hadron-nucleus << 62 // inelastic collision has been chosen, the me << 63 // HadronicGenerator::GenerateInteraction << 64 // returns the secondaries produced by that in 56 // returns the secondaries produced by that interaction (in the form 65 // of a G4VParticleChange object). 57 // of a G4VParticleChange object). 66 // Some information about this final-state is 58 // Some information about this final-state is printed out as an example. 67 // 59 // 68 // Usage: Hadr09 60 // Usage: Hadr09 69 //-------------------------------------------- 61 //------------------------------------------------------------------------ 70 62 71 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 65 74 #include "CLHEP/Random/Randomize.h" << 66 #include <iomanip> 75 #include "CLHEP/Random/Ranlux64Engine.h" << 67 #include "globals.hh" 76 #include "HadronicGenerator.hh" << 68 #include "G4ios.hh" 77 << 78 #include "G4GenericIon.hh" << 79 #include "G4HadronicParameters.hh" << 80 #include "G4IonTable.hh" << 81 #include "G4Material.hh" << 82 #include "G4NistManager.hh" << 83 #include "G4ParticleTable.hh" << 84 #include "G4PhysicalConstants.hh" 69 #include "G4PhysicalConstants.hh" 85 #include "G4ProcessManager.hh" << 86 #include "G4SystemOfUnits.hh" 70 #include "G4SystemOfUnits.hh" 87 #include "G4UnitsTable.hh" << 71 #include "G4Material.hh" >> 72 #include "G4NistManager.hh" 88 #include "G4VParticleChange.hh" 73 #include "G4VParticleChange.hh" 89 #include "G4ios.hh" << 74 #include "G4UnitsTable.hh" 90 #include "globals.hh" << 75 #include "G4SystemOfUnits.hh" 91 << 76 #include "HadronicGenerator.hh" 92 #include <iomanip> << 77 #include "CLHEP/Random/Randomize.h" >> 78 #include "CLHEP/Random/Ranlux64Engine.h" 93 79 94 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 81 96 int main(int, char**) << 82 int main( int , char** ) { 97 { << 83 98 G4cout << "=== Test of the HadronicGenerator 84 G4cout << "=== Test of the HadronicGenerator ===" << G4endl; 99 85 100 // Enable light hypernuclei and anti-hypernu << 101 G4HadronicParameters::Instance()->SetEnableH << 102 << 103 // See the HadronicGenerator class for the p 86 // See the HadronicGenerator class for the possibilities and meaning of the "physics cases". 104 // ( In short, it is the name of the Geant4 87 // ( In short, it is the name of the Geant4 hadronic model used for the simulation of 105 // the collision, with the possibility of 88 // the collision, with the possibility of having a transition between two models in 106 // a given energy interval, as in physics 89 // a given energy interval, as in physics lists. ) 107 const G4String namePhysics = "FTFP_BERT"; / << 90 const G4String namePhysics = "FTFP_BERT_ATL"; //***LOOKHERE*** PHYSICS CASE 108 // const G4String namePhysics = "FTFP_BERT_A << 91 //const G4String namePhysics = "FTFP_BERT"; 109 // const G4String namePhysics = "QGSP_BERT"; << 92 //const G4String namePhysics = "QGSP_BERT"; 110 // const G4String namePhysics = "QGSP_BIC"; << 93 //const G4String namePhysics = "QGSP_BIC"; 111 // const G4String namePhysics = "FTFP_INCLXX << 94 //const G4String namePhysics = "FTFP_INCLXX"; 112 // const G4String namePhysics = "FTFP"; << 95 //const G4String namePhysics = "FTFP"; 113 // const G4String namePhysics = "QGSP"; << 96 //const G4String namePhysics = "QGSP"; 114 // const G4String namePhysics = "BERT"; << 97 //const G4String namePhysics = "BERT"; 115 // const G4String namePhysics = "BIC"; << 98 //const G4String namePhysics = "BIC"; 116 // const G4String namePhysics = "IonBIC"; << 99 //const G4String namePhysics = "IonBIC"; 117 // const G4String namePhysics = "INCL"; << 100 //const G4String namePhysics = "INCL"; 118 << 101 119 // The kinetic energy of the projectile will 102 // The kinetic energy of the projectile will be sampled randomly, with flat probability 120 // in the interval [minEnergy, maxEnergy]. 103 // in the interval [minEnergy, maxEnergy]. 121 G4double minEnergy = 1.0 * CLHEP::GeV; //** << 104 const G4double minEnergy = 1.0*CLHEP::GeV; //***LOOKHERE*** PROJECTILE MIN Ekin 122 G4double maxEnergy = 30.0 * CLHEP::GeV; //* << 105 const G4double maxEnergy = 30.0*CLHEP::GeV; //***LOOKHERE*** PROJECTILE MAX Ekin 123 << 106 124 const G4int numCollisions = 1000; //***LOOK << 107 const G4int numCollisions = 1000; //***LOOKHERE*** NUMBER OF COLLISIONS 125 108 126 // Enable or disable the print out of this p 109 // Enable or disable the print out of this program: if enabled, the number of secondaries 127 // produced in each collisions is printed ou 110 // produced in each collisions is printed out; moreover, once every "printingGap" 128 // collisions, the list of secondaries is pr 111 // collisions, the list of secondaries is printed out. 129 const G4bool isPrintingEnabled = true; //** << 112 const G4bool isPrintingEnabled = true; //***LOOKHERE*** PRINT OUT ON/OFF 130 const G4int printingGap = 100; //***LOOKHER << 113 const G4int printingGap = 100; //***LOOKHERE*** GAP IN PRINTING 131 << 114 132 // Vector of Geant4 names of hadron projecti 115 // Vector of Geant4 names of hadron projectiles: one of this will be sampled randomly 133 // (with uniform probability) for each colli << 116 // (with uniform probability) for each collision. 134 // (note that the 6 light hypernuclei and an << 135 // other hadrons, not as generic ions). << 136 // Note: comment out the corresponding line 117 // Note: comment out the corresponding line in order to exclude a particle. 137 std::vector<G4String> vecProjectiles; //*** << 118 std::vector< G4String > vecProjectiles; //***LOOKHERE*** : possible hadron projectiles 138 vecProjectiles.push_back("pi-"); << 119 vecProjectiles.push_back( "pi-" ); 139 // Note: vecProjectiles.push_back( "pi0" ); << 120 //Note: vecProjectiles.push_back( "pi0" ); // Excluded because too short-lived 140 vecProjectiles.push_back("pi+"); << 121 vecProjectiles.push_back( "pi+" ); 141 vecProjectiles.push_back("kaon-"); << 122 vecProjectiles.push_back( "kaon-" ); 142 vecProjectiles.push_back("kaon+"); << 123 vecProjectiles.push_back( "kaon+" ); 143 vecProjectiles.push_back("kaon0L"); << 124 vecProjectiles.push_back( "kaon0L" ); 144 vecProjectiles.push_back("kaon0S"); << 125 vecProjectiles.push_back( "kaon0S" ); 145 // Note: vecProjectiles.push_back( "eta" ); << 126 vecProjectiles.push_back( "proton" ); 146 // Note: vecProjectiles.push_back( "eta_prim << 127 vecProjectiles.push_back( "neutron" ); 147 vecProjectiles.push_back("proton"); << 128 vecProjectiles.push_back( "deuteron" ); 148 vecProjectiles.push_back("neutron"); << 129 vecProjectiles.push_back( "triton" ); 149 vecProjectiles.push_back("deuteron"); << 130 vecProjectiles.push_back( "He3" ); 150 vecProjectiles.push_back("triton"); << 131 vecProjectiles.push_back( "alpha" ); 151 vecProjectiles.push_back("He3"); << 132 vecProjectiles.push_back( "lambda" ); 152 vecProjectiles.push_back("alpha"); << 133 vecProjectiles.push_back( "sigma-" ); 153 vecProjectiles.push_back("lambda"); << 134 //Note: vecProjectiles.push_back( "sigma0" ); // Excluded because too short-lived 154 vecProjectiles.push_back("sigma-"); << 135 vecProjectiles.push_back( "sigma+" ); 155 // Note: vecProjectiles.push_back( "sigma0" << 136 vecProjectiles.push_back( "xi-" ); 156 vecProjectiles.push_back("sigma+"); << 137 vecProjectiles.push_back( "xi0" ); 157 vecProjectiles.push_back("xi-"); << 138 vecProjectiles.push_back( "omega-" ); 158 vecProjectiles.push_back("xi0"); << 139 vecProjectiles.push_back( "anti_proton" ); 159 vecProjectiles.push_back("omega-"); << 140 vecProjectiles.push_back( "anti_neutron" ); 160 vecProjectiles.push_back("anti_proton"); << 141 vecProjectiles.push_back( "anti_lambda" ); 161 vecProjectiles.push_back("anti_neutron"); << 142 vecProjectiles.push_back( "anti_sigma-" ); 162 vecProjectiles.push_back("anti_lambda"); << 143 //Note: vecProjectiles.push_back( "anti_sigma0" ); // Excluded because too short-lived 163 vecProjectiles.push_back("anti_sigma-"); << 144 vecProjectiles.push_back( "anti_sigma+" ); 164 // Note: vecProjectiles.push_back( "anti_sig << 145 vecProjectiles.push_back( "anti_xi-" ); 165 vecProjectiles.push_back("anti_sigma+"); << 146 vecProjectiles.push_back( "anti_xi0" ); 166 vecProjectiles.push_back("anti_xi-"); << 147 vecProjectiles.push_back( "anti_omega-" ); 167 vecProjectiles.push_back("anti_xi0"); << 148 vecProjectiles.push_back( "anti_deuteron" ); 168 vecProjectiles.push_back("anti_omega-"); << 149 vecProjectiles.push_back( "anti_triton" ); 169 vecProjectiles.push_back("anti_deuteron"); << 150 vecProjectiles.push_back( "anti_He3" ); 170 vecProjectiles.push_back("anti_triton"); << 151 vecProjectiles.push_back( "anti_alpha" ); 171 vecProjectiles.push_back("anti_He3"); << 152 172 vecProjectiles.push_back("anti_alpha"); << 173 << 174 // Only FTFP and QGSP can handle nuclear int << 175 if (namePhysics == "FTFP_BERT" || namePhysic << 176 || namePhysics == "QGSP_BIC" || namePhys << 177 { << 178 // Charm and bottom hadrons << 179 vecProjectiles.push_back("D+"); << 180 vecProjectiles.push_back("D-"); << 181 vecProjectiles.push_back("D0"); << 182 vecProjectiles.push_back("anti_D0"); << 183 vecProjectiles.push_back("Ds+"); << 184 vecProjectiles.push_back("Ds-"); << 185 // Note: vecProjectiles.push_back( "etac" << 186 // Note: vecProjectiles.push_back( "J/psi" << 187 vecProjectiles.push_back("B+"); << 188 vecProjectiles.push_back("B-"); << 189 vecProjectiles.push_back("B0"); << 190 vecProjectiles.push_back("anti_B0"); << 191 vecProjectiles.push_back("Bs0"); << 192 vecProjectiles.push_back("anti_Bs0"); << 193 vecProjectiles.push_back("Bc+"); << 194 vecProjectiles.push_back("Bc-"); << 195 // Note: vecProjectiles.push_back( "Upsilo << 196 vecProjectiles.push_back("lambda_c+"); << 197 vecProjectiles.push_back("anti_lambda_c+") << 198 // Note: vecProjectiles.push_back( "sigma_ << 199 // Note: vecProjectiles.push_back( "anti_s << 200 // Note: vecProjectiles.push_back( "sigma_ << 201 // Note: vecProjectiles.push_back( "anti_s << 202 // Note: vecProjectiles.push_back( "sigma_ << 203 // Note: vecProjectiles.push_back( "anti_s << 204 vecProjectiles.push_back("xi_c+"); << 205 vecProjectiles.push_back("anti_xi_c+"); << 206 vecProjectiles.push_back("xi_c0"); << 207 vecProjectiles.push_back("anti_xi_c0"); << 208 vecProjectiles.push_back("omega_c0"); << 209 vecProjectiles.push_back("anti_omega_c0"); << 210 vecProjectiles.push_back("lambda_b"); << 211 vecProjectiles.push_back("anti_lambda_b"); << 212 // Note: vecProjectiles.push_back( "sigma_ << 213 // Note: vecProjectiles.push_back( "anti_s << 214 // Note: vecProjectiles.push_back( "sigma_ << 215 // Note: vecProjectiles.push_back( "sigma_ << 216 // Note: vecProjectiles.push_back( "sigma_ << 217 // Note: vecProjectiles.push_back( "anti_s << 218 vecProjectiles.push_back("xi_b0"); << 219 vecProjectiles.push_back("anti_xi_b0"); << 220 vecProjectiles.push_back("xi_b-"); << 221 vecProjectiles.push_back("anti_xi_b-"); << 222 vecProjectiles.push_back("omega_b-"); << 223 vecProjectiles.push_back("anti_omega_b-"); << 224 } << 225 << 226 // If the hadronic interactions of light hyp << 227 // are swtiched on, then only FTFP and INCL << 228 // of light hypernuclei, and only FTFP is ca << 229 // interactions of light anti-hypernuclei. << 230 if (G4HadronicParameters::Instance()->Enable << 231 if (namePhysics == "FTFP_BERT" || namePhys << 232 || namePhysics == "INCL") << 233 { << 234 // Light hypernuclei << 235 vecProjectiles.push_back("hypertriton"); << 236 vecProjectiles.push_back("hyperalpha"); << 237 vecProjectiles.push_back("hyperH4"); << 238 vecProjectiles.push_back("doublehyperH4" << 239 vecProjectiles.push_back("doublehyperdou << 240 vecProjectiles.push_back("hyperHe5"); << 241 } << 242 if (namePhysics == "FTFP_BERT" || namePhys << 243 // Light anti-hypernuclei << 244 vecProjectiles.push_back("anti_hypertrit << 245 vecProjectiles.push_back("anti_hyperalph << 246 vecProjectiles.push_back("anti_hyperH4") << 247 vecProjectiles.push_back("anti_doublehyp << 248 vecProjectiles.push_back("anti_doublehyp << 249 vecProjectiles.push_back("anti_hyperHe5" << 250 } << 251 } << 252 << 253 G4ParticleDefinition* projectileNucleus = nu << 254 G4GenericIon* gion = G4GenericIon::GenericIo << 255 gion->SetProcessManager(new G4ProcessManager << 256 G4ParticleTable* partTable = G4ParticleTable << 257 G4IonTable* ions = partTable->GetIonTable(); << 258 partTable->SetReadiness(); << 259 ions->CreateAllIon(); << 260 ions->CreateAllIsomer(); << 261 << 262 const G4bool isProjectileIon = false; //*** << 263 if (isProjectileIon) { << 264 minEnergy = 40.0 * 13.0 * CLHEP::GeV; //* << 265 maxEnergy = 40.0 * 13.0 * CLHEP::GeV; //* << 266 G4int ionZ = 18, ionA = 40; //***LOOKHERE << 267 projectileNucleus = partTable->GetIonTable << 268 } << 269 << 270 // Vector of Geant4 NIST names of materials: 153 // Vector of Geant4 NIST names of materials: one of this will be sampled randomly 271 // (with uniform probability) for each colli 154 // (with uniform probability) for each collision and used as target material. 272 // Note: comment out the corresponding line 155 // Note: comment out the corresponding line in order to exclude a material; 273 // or, vice versa, add a new line to e 156 // or, vice versa, add a new line to extend the list with another material. 274 std::vector<G4String> vecMaterials; //***LO << 157 std::vector< G4String > vecMaterials; //***LOOKHERE*** : possible NIST materials 275 vecMaterials.push_back("G4_H"); << 158 vecMaterials.push_back( "G4_H" ); 276 vecMaterials.push_back("G4_He"); << 159 vecMaterials.push_back( "G4_He" ); 277 vecMaterials.push_back("G4_Be"); << 160 vecMaterials.push_back( "G4_Be" ); 278 vecMaterials.push_back("G4_C"); << 161 vecMaterials.push_back( "G4_C" ); 279 vecMaterials.push_back("G4_Al"); << 162 vecMaterials.push_back( "G4_Al" ); 280 vecMaterials.push_back("G4_Si"); << 163 vecMaterials.push_back( "G4_Si" ); 281 // vecMaterials.push_back( "G4_Sc" ); << 164 vecMaterials.push_back( "G4_Ar" ); 282 vecMaterials.push_back("G4_Ar"); << 165 vecMaterials.push_back( "G4_Fe" ); 283 vecMaterials.push_back("G4_Fe"); << 166 vecMaterials.push_back( "G4_Cu" ); 284 vecMaterials.push_back("G4_Cu"); << 167 vecMaterials.push_back( "G4_W" ); 285 vecMaterials.push_back("G4_W"); << 168 vecMaterials.push_back( "G4_Pb" ); 286 vecMaterials.push_back("G4_Pb"); << 287 169 288 const G4int numProjectiles = vecProjectiles. 170 const G4int numProjectiles = vecProjectiles.size(); 289 const G4int numMaterials = vecMaterials.size 171 const G4int numMaterials = vecMaterials.size(); 290 172 291 G4cout << G4endl << "================= Conf << 173 G4cout << G4endl 292 << "Model: " << namePhysics << G4endl << 174 << "================= Configuration ==================" << G4endl 293 << maxEnergy / CLHEP::GeV << " ] GeV" << 175 << "Model: " << namePhysics << G4endl >> 176 << "Ekin: [ " << minEnergy/CLHEP::GeV << " , " << maxEnergy/CLHEP::GeV >> 177 << " ] GeV" << G4endl 294 << "Number of collisions: " << numCo 178 << "Number of collisions: " << numCollisions << G4endl 295 << "Number of hadron projectiles: " < << 179 << "Number of projectiles: " << numProjectiles << G4endl 296 << "Number of materials: " << numMa << 180 << "Number of materials: " << numMaterials << G4endl 297 << "IsIonProjectile: " << (projectile << 181 << "===================================================" << G4endl 298 << (projectileNucleus != nullptr ? pr << 182 << G4endl; 299 << G4endl << "======================= << 183 300 << 184 CLHEP::Ranlux64Engine defaultEngine( 1234567, 4 ); 301 CLHEP::Ranlux64Engine defaultEngine(1234567, << 185 CLHEP::HepRandom::setTheEngine( &defaultEngine ); 302 CLHEP::HepRandom::setTheEngine(&defaultEngin << 186 G4int seed = time( NULL ); 303 G4int seed = time(NULL); << 187 CLHEP::HepRandom::setTheSeed( seed ); 304 CLHEP::HepRandom::setTheSeed(seed); << 188 G4cout << G4endl << " Initial seed = " << seed << G4endl << G4endl; 305 G4cout << G4endl << " Initial seed = " << se << 189 306 << 307 // Instanciate the HadronicGenerator providi 190 // Instanciate the HadronicGenerator providing the name of the "physics case" 308 HadronicGenerator* theHadronicGenerator = ne << 191 HadronicGenerator* theHadronicGenerator = new HadronicGenerator( namePhysics ); 309 //****************************************** 192 //**************************************************************************** 310 << 193 311 if (theHadronicGenerator == nullptr) { << 194 if ( theHadronicGenerator == nullptr ) { 312 G4cerr << "ERROR: theHadronicGenerator is 195 G4cerr << "ERROR: theHadronicGenerator is NULL !" << G4endl; 313 return 1; 196 return 1; 314 } << 197 } else if ( ! theHadronicGenerator->IsPhysicsCaseSupported() ) { 315 else if (!theHadronicGenerator->IsPhysicsCas << 316 G4cerr << "ERROR: this physics case is NOT 198 G4cerr << "ERROR: this physics case is NOT supported !" << G4endl; 317 return 2; 199 return 2; 318 } 200 } 319 << 201 320 // Loop over the collisions 202 // Loop over the collisions 321 G4double rnd1, rnd2, rnd3, rnd4, rnd5, rnd6, 203 G4double rnd1, rnd2, rnd3, rnd4, rnd5, rnd6, normalization, projectileEnergy; 322 G4VParticleChange* aChange = nullptr; 204 G4VParticleChange* aChange = nullptr; 323 for (G4int i = 0; i < numCollisions; ++i) { << 205 for ( G4int i = 0; i < numCollisions; ++i ) { 324 // Draw some random numbers to select the 206 // Draw some random numbers to select the hadron-nucleus interaction: 325 // projectile hadron, projectile kinetic e 207 // projectile hadron, projectile kinetic energy, projectile direction, and target material. 326 rnd1 = CLHEP::HepRandom::getTheEngine()->f << 208 rnd1 = CLHEP::HepRandom::getTheEngine()->flat(); 327 rnd2 = CLHEP::HepRandom::getTheEngine()->f 209 rnd2 = CLHEP::HepRandom::getTheEngine()->flat(); 328 rnd3 = CLHEP::HepRandom::getTheEngine()->f 210 rnd3 = CLHEP::HepRandom::getTheEngine()->flat(); 329 rnd4 = CLHEP::HepRandom::getTheEngine()->f 211 rnd4 = CLHEP::HepRandom::getTheEngine()->flat(); 330 rnd5 = CLHEP::HepRandom::getTheEngine()->f 212 rnd5 = CLHEP::HepRandom::getTheEngine()->flat(); 331 rnd6 = CLHEP::HepRandom::getTheEngine()->f 213 rnd6 = CLHEP::HepRandom::getTheEngine()->flat(); 332 // Sample the projectile kinetic energy 214 // Sample the projectile kinetic energy 333 projectileEnergy = minEnergy + rnd1 * (max << 215 projectileEnergy = minEnergy + rnd1*( maxEnergy - minEnergy ); 334 if (projectileEnergy <= 0.0) projectileEne << 216 if ( projectileEnergy <= 0.0 ) projectileEnergy = minEnergy; 335 // Sample the projectile direction 217 // Sample the projectile direction 336 normalization = 1.0 / std::sqrt(rnd2 * rnd << 218 normalization = 1.0 / std::sqrt( rnd2*rnd2 + rnd3*rnd3 + rnd4*rnd4 ); 337 const G4bool isOnSmearingDirection = true; << 219 G4ThreeVector aDirection = 338 G4ThreeVector aDirection = G4ThreeVector(0 << 220 G4ThreeVector( normalization*rnd2, normalization*rnd3, normalization*rnd4 ); 339 if (isOnSmearingDirection) { << 340 aDirection = G4ThreeVector(normalization << 341 } << 342 // Sample the projectile hadron from the v 221 // Sample the projectile hadron from the vector vecProjectiles 343 G4int index_projectile = std::trunc(rnd5 * << 222 G4int index_projectile = std::trunc( rnd5*numProjectiles ); 344 G4String nameProjectile = vecProjectiles[i << 223 G4String nameProjectile = vecProjectiles[ index_projectile ]; 345 G4ParticleDefinition* projectile = partTab << 346 if (projectileNucleus) { << 347 nameProjectile = projectileNucleus->GetP << 348 projectile = projectileNucleus; << 349 } << 350 // Sample the target material from the vec 224 // Sample the target material from the vector vecMaterials 351 // (Note: the target nucleus will be sampl 225 // (Note: the target nucleus will be sampled by Geant4) 352 G4int index_material = std::trunc(rnd6 * n << 226 G4int index_material = std::trunc( rnd6*numMaterials ); 353 G4String nameMaterial = vecMaterials[index << 227 G4String nameMaterial = vecMaterials[ index_material ]; 354 G4Material* material = G4NistManager::Inst << 228 G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial( nameMaterial ); 355 if (material == nullptr) { << 229 if ( material == nullptr ) { 356 G4cerr << "ERROR: Material " << nameMate 230 G4cerr << "ERROR: Material " << nameMaterial << " is not found !" << G4endl; 357 return 3; 231 return 3; 358 } 232 } 359 if (isPrintingEnabled) { << 233 if ( isPrintingEnabled ) { 360 G4cout << "\t Collision " << i << " ; pr << 234 G4cout << "\t Collision " << i << " ; projectile=" << nameProjectile 361 if (projectileNucleus) { << 235 << " ; Ekin(MeV)=" << projectileEnergy /* << " ; direction=" << aDirection */ 362 G4cout << " ; Ekin[MeV]/nucleon=" << 236 << " ; material=" << nameMaterial; 363 << projectileEnergy << 364 / static_cast<G4double>(st << 365 } << 366 else { << 367 G4cout << " ; Ekin[MeV]=" << projectil << 368 } << 369 G4cout << " ; direction=" << aDirection << 370 } 237 } 371 << 238 372 // Call here the "hadronic generator" to g 239 // Call here the "hadronic generator" to get the secondaries produced by the hadronic collision 373 aChange = theHadronicGenerator->GenerateIn << 240 aChange = theHadronicGenerator->GenerateInteraction( nameProjectile, projectileEnergy, 374 projectile, projectileEnergy, << 241 /* ********************************************** */ aDirection, material ); 375 /* ************************************* << 242 376 << 377 G4int nsec = aChange ? aChange->GetNumberO 243 G4int nsec = aChange ? aChange->GetNumberOfSecondaries() : 0; 378 G4bool isPrintingOfSecondariesEnabled = fa 244 G4bool isPrintingOfSecondariesEnabled = false; 379 if (isPrintingEnabled) { << 245 if ( isPrintingEnabled ) { 380 G4cout << G4endl << "\t --> #secondaries << 246 G4cout << " ---> #secondaries=" << nsec << G4endl; 381 << " ; impactParameter[fm]=" << t << 247 if ( i % printingGap == 0 ) { 382 << " ; #projectileSpectatorNucleo << 383 << theHadronicGenerator->GetNumbe << 384 << " ; #targetSpectatorNucleons=" << 385 << theHadronicGenerator->GetNumbe << 386 << " ; #NNcollisions=" << theHadr << 387 if (i % printingGap == 0) { << 388 isPrintingOfSecondariesEnabled = true; 248 isPrintingOfSecondariesEnabled = true; 389 G4cout << "\t \t List of produced seco 249 G4cout << "\t \t List of produced secondaries: " << G4endl; 390 } 250 } 391 } 251 } 392 // Loop over produced secondaries and even 252 // Loop over produced secondaries and eventually print out some information. 393 for (G4int j = 0; j < nsec; ++j) { << 253 for ( G4int j = 0; j < nsec; ++j ) { 394 const G4DynamicParticle* sec = aChange-> 254 const G4DynamicParticle* sec = aChange->GetSecondary(j)->GetDynamicParticle(); 395 if (isPrintingOfSecondariesEnabled) { << 255 if ( isPrintingOfSecondariesEnabled ) { 396 G4cout << "\t \t \t j=" << j << "\t" < 256 G4cout << "\t \t \t j=" << j << "\t" << sec->GetDefinition()->GetParticleName() 397 << "\t p=" << sec->Get4Momentum 257 << "\t p=" << sec->Get4Momentum() << " MeV" << G4endl; 398 } 258 } 399 delete aChange->GetSecondary(j); 259 delete aChange->GetSecondary(j); 400 } 260 } 401 if (aChange) aChange->Clear(); << 261 if ( aChange ) aChange->Clear(); 402 } 262 } 403 263 404 G4cout << G4endl << " Final random number = 264 G4cout << G4endl << " Final random number = " << CLHEP::HepRandom::getTheEngine()->flat() 405 << G4endl << "=== End of test ===" << 265 << G4endl << "=== End of test ===" << G4endl; 406 } 266 } 407 267 408 //....oooOO0OOooo........oooOO0OOooo........oo 268 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 409 269