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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/Hadr09/Hadr09.cc-ION_PROJECTILE (Version 11.3.0) and /examples/extended/hadronic/Hadr09/Hadr09.cc-ION_PROJECTILE (Version 4.0.p1)


  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 //                                                
 27 /// \file Hadr09.cc                               
 28 /// \brief Main program of the hadronic/Hadr09    
 29 //                                                
 30 //--------------------------------------------    
 31 // This program shows how to use the class Had    
 32 // The class HadronicGenerator is a kind of "h    
 33 // provides Geant4 final states (i.e. secondar    
 34 // hadron-nuclear inelastic collisions.           
 35 // Please see the class itself for more inform    
 36 //                                                
 37 // The use of the class Hadronic Generator is     
 38 // the constructor needs to be invoked only on    
 39 // of the Geant4 "physics case" to consider ("    
 40 // considered as default is the name is not sp    
 41 // method needs to be called at each collision    
 42 // collision (hadron, energy, direction, mater    
 43 // The class HadronicGenerator is expected to     
 44 // multi-threaded environment with "external"     
 45 // that are not necessarily managed by Geant4     
 46 // each thread should have its own instance of    
 47 //                                                
 48 // See the string "***LOOKHERE***" below for t    
 49 // of this example: the "physics case", the se    
 50 // which to sample the projectile (i.e. whethe    
 51 // hadron or an ion - in the case of hadron pr    
 52 // is possible from which to sample at each co    
 53 // ion projectile, only one type of ion needs     
 54 // the kinetic energy of the projectile (which    
 55 // an interval), whether the direction of the     
 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    
 65 // of a G4VParticleChange object).                
 66 // Some information about this final-state is     
 67 //                                                
 68 // Usage:  Hadr09                                 
 69 //--------------------------------------------    
 70                                                   
 71 //....oooOO0OOooo........oooOO0OOooo........oo    
 72 //....oooOO0OOooo........oooOO0OOooo........oo    
 73                                                   
 74 #include <iomanip>                                
 75 #include "globals.hh"                             
 76 #include "G4ios.hh"                               
 77 #include "G4PhysicalConstants.hh"                 
 78 #include "G4SystemOfUnits.hh"                     
 79 #include "G4Material.hh"                          
 80 #include "G4NistManager.hh"                       
 81 #include "G4VParticleChange.hh"                   
 82 #include "G4UnitsTable.hh"                        
 83 #include "G4SystemOfUnits.hh"                     
 84 #include "HadronicGenerator.hh"                   
 85 #include "G4GenericIon.hh"                        
 86 #include "G4ProcessManager.hh"                    
 87 #include "G4ParticleTable.hh"                     
 88 #include "G4IonTable.hh"                          
 89 #include "CLHEP/Random/Randomize.h"               
 90 #include "CLHEP/Random/Ranlux64Engine.h"          
 91                                                   
 92 //....oooOO0OOooo........oooOO0OOooo........oo    
 93                                                   
 94 int main( int , char** ) {                        
 95                                                   
 96   G4cout << "=== Test of the HadronicGenerator    
 97                                                   
 98   // See the HadronicGenerator class for the p    
 99   // ( In short, it is the name of the Geant4     
100   //   the collision, with the possibility of     
101   //   a given energy interval, as in physics     
102   //const G4String namePhysics = "FTFP_BERT";     
103   //const G4String namePhysics = "FTFP_BERT_AT    
104   //const G4String namePhysics = "QGSP_BERT";     
105   //const G4String namePhysics = "QGSP_BIC";      
106   //const G4String namePhysics = "FTFP_INCLXX"    
107   const G4String namePhysics = "FTFP";            
108   //const G4String namePhysics = "QGSP";          
109   //const G4String namePhysics = "BERT";          
110   //const G4String namePhysics = "BIC";           
111   //const G4String namePhysics = "IonBIC";        
112   //const G4String namePhysics = "INCL";          
113                                                   
114   // The kinetic energy of the projectile will    
115   // in the interval [minEnergy, maxEnergy].      
116   G4double minEnergy =  1.0*CLHEP::GeV;  //***    
117   G4double maxEnergy = 30.0*CLHEP::GeV;  //***    
118                                                   
119   const G4int numCollisions = 1000;  //***LOOK    
120                                                   
121   // Enable or disable the print out of this p    
122   // produced in each collisions is printed ou    
123   // collisions, the list of secondaries is pr    
124   const G4bool isPrintingEnabled = true;          
125   const G4int  printingGap = 100;                 
126                                                   
127   // Vector of Geant4 names of hadron projecti    
128   // (with uniform probability) for each colli    
129   // Note: comment out the corresponding line     
130   std::vector< G4String > vecProjectiles;  //*    
131   vecProjectiles.push_back( "pi-" );              
132   //Note: vecProjectiles.push_back( "pi0" );      
133   vecProjectiles.push_back( "pi+" );              
134   vecProjectiles.push_back( "kaon-" );            
135   vecProjectiles.push_back( "kaon+" );            
136   vecProjectiles.push_back( "kaon0L" );           
137   vecProjectiles.push_back( "kaon0S" );           
138   //Note: vecProjectiles.push_back( "eta" );      
139   //Note: vecProjectiles.push_back( "eta_prime    
140   vecProjectiles.push_back( "proton" );           
141   vecProjectiles.push_back( "neutron" );          
142   vecProjectiles.push_back( "deuteron" );         
143   vecProjectiles.push_back( "triton" );           
144   vecProjectiles.push_back( "He3" );              
145   vecProjectiles.push_back( "alpha" );            
146   vecProjectiles.push_back( "lambda" );           
147   vecProjectiles.push_back( "sigma-" );           
148   //Note: vecProjectiles.push_back( "sigma0" )    
149   vecProjectiles.push_back( "sigma+" );           
150   vecProjectiles.push_back( "xi-" );              
151   vecProjectiles.push_back( "xi0" );              
152   vecProjectiles.push_back( "omega-" );           
153   vecProjectiles.push_back( "anti_proton" );      
154   vecProjectiles.push_back( "anti_neutron" );     
155   vecProjectiles.push_back( "anti_lambda" );      
156   vecProjectiles.push_back( "anti_sigma-" );      
157   //Note: vecProjectiles.push_back( "anti_sigm    
158   vecProjectiles.push_back( "anti_sigma+" );      
159   vecProjectiles.push_back( "anti_xi-" );         
160   vecProjectiles.push_back( "anti_xi0" );         
161   vecProjectiles.push_back( "anti_omega-" );      
162   vecProjectiles.push_back( "anti_deuteron" );    
163   vecProjectiles.push_back( "anti_triton" );      
164   vecProjectiles.push_back( "anti_He3" );         
165   vecProjectiles.push_back( "anti_alpha" );       
166   // Charm and bottom hadrons                     
167   vecProjectiles.push_back( "D+" );               
168   vecProjectiles.push_back( "D-" );               
169   vecProjectiles.push_back( "D0" );               
170   vecProjectiles.push_back( "anti_D0" );          
171   vecProjectiles.push_back( "Ds+" );              
172   vecProjectiles.push_back( "Ds-" );              
173   //Note: vecProjectiles.push_back( "etac" );     
174   //Note: vecProjectiles.push_back( "J/psi" );    
175   vecProjectiles.push_back( "B+" );               
176   vecProjectiles.push_back( "B-" );               
177   vecProjectiles.push_back( "B0" );               
178   vecProjectiles.push_back( "anti_B0" );          
179   vecProjectiles.push_back( "Bs0" );              
180   vecProjectiles.push_back( "anti_Bs0" );         
181   vecProjectiles.push_back( "Bc+" );              
182   vecProjectiles.push_back( "Bc-" );              
183   //Note: vecProjectiles.push_back( "Upsilon"     
184   vecProjectiles.push_back( "lambda_c+" );        
185   vecProjectiles.push_back( "anti_lambda_c+" )    
186   //Note: vecProjectiles.push_back( "sigma_c+"    
187   //Note: vecProjectiles.push_back( "anti_sigm    
188   //Note: vecProjectiles.push_back( "sigma_c0"    
189   //Note: vecProjectiles.push_back( "anti_sigm    
190   //Note: vecProjectiles.push_back( "sigma_c++    
191   //Note: vecProjectiles.push_back( "anti_sigm    
192   vecProjectiles.push_back( "xi_c+" );            
193   vecProjectiles.push_back( "anti_xi_c+" );       
194   vecProjectiles.push_back( "xi_c0" );            
195   vecProjectiles.push_back( "anti_xi_c0" );       
196   vecProjectiles.push_back( "omega_c0" );         
197   vecProjectiles.push_back( "anti_omega_c0" );    
198   vecProjectiles.push_back( "lambda_b" );         
199   vecProjectiles.push_back( "anti_lambda_b" );    
200   //Note: vecProjectiles.push_back( "sigma_b+"    
201   //Note: vecProjectiles.push_back( "anti_sigm    
202   //Note: vecProjectiles.push_back( "sigma_b0"    
203   //Note: vecProjectiles.push_back( "sigma_b0"    
204   //Note: vecProjectiles.push_back( "sigma_b-"    
205   //Note: vecProjectiles.push_back( "anti_sigm    
206   vecProjectiles.push_back( "xi_b0" );            
207   vecProjectiles.push_back( "anti_xi_b0" );       
208   vecProjectiles.push_back( "xi_b-" );            
209   vecProjectiles.push_back( "anti_xi_b-" );       
210   vecProjectiles.push_back( "omega_b-" );         
211   vecProjectiles.push_back( "anti_omega_b-" );    
212                                                   
213   G4ParticleDefinition* projectileNucleus = nu    
214   G4GenericIon* gion = G4GenericIon::GenericIo    
215   gion->SetProcessManager( new G4ProcessManage    
216   G4ParticleTable* partTable = G4ParticleTable    
217   G4IonTable* ions = partTable->GetIonTable();    
218   partTable->SetReadiness();                      
219   ions->CreateAllIon();                           
220   ions->CreateAllIsomer();                        
221                                                   
222   const G4bool isProjectileIon = true;   //***    
223   if ( isProjectileIon ) {                        
224     minEnergy = 40.0*13.0*CLHEP::GeV;    //***    
225     maxEnergy = 40.0*13.0*CLHEP::GeV;    //***    
226     G4int ionZ = 18, ionA = 40;          //***    
227     projectileNucleus = partTable->GetIonTable    
228   }                                               
229                                                   
230   // Vector of Geant4 NIST names of materials:    
231   // (with uniform probability) for each colli    
232   // Note: comment out the corresponding line     
233   //       or, vice versa, add a new line to e    
234   std::vector< G4String > vecMaterials;  //***    
235   //vecMaterials.push_back( "G4_H" );             
236   //vecMaterials.push_back( "G4_He" );            
237   //vecMaterials.push_back( "G4_Be" );            
238   //vecMaterials.push_back( "G4_C" );             
239   //vecMaterials.push_back( "G4_Al" );            
240   //vecMaterials.push_back( "G4_Si" );            
241   vecMaterials.push_back( "G4_Sc" );              
242   //vecMaterials.push_back( "G4_Ar" );            
243   //vecMaterials.push_back( "G4_Fe" );            
244   //vecMaterials.push_back( "G4_Cu" );            
245   //vecMaterials.push_back( "G4_W" );             
246   //vecMaterials.push_back( "G4_Pb" );            
247                                                   
248   const G4int numProjectiles = vecProjectiles.    
249   const G4int numMaterials = vecMaterials.size    
250                                                   
251   G4cout << G4endl                                
252          << "=================  Configuration     
253          << "Model: " << namePhysics << G4endl    
254          << "Ekin: [ " << minEnergy/CLHEP::GeV    
255          << " ] GeV" << G4endl                    
256          << "Number of collisions:  " << numCo    
257          << "Number of hadron projectiles: " <    
258          << "Number of materials:   " << numMa    
259    << "IsIonProjectile: " << ( projectileNucle    
260          << ( projectileNucleus != nullptr ? p    
261          << "=================================    
262          << G4endl;                               
263                                                   
264   CLHEP::Ranlux64Engine defaultEngine( 1234567    
265   CLHEP::HepRandom::setTheEngine( &defaultEngi    
266   G4int seed = time( NULL );                      
267   CLHEP::HepRandom::setTheSeed( seed );           
268   G4cout << G4endl << " Initial seed = " << se    
269                                                   
270   // Instanciate the HadronicGenerator providi    
271   HadronicGenerator* theHadronicGenerator = ne    
272   //******************************************    
273                                                   
274   if ( theHadronicGenerator == nullptr ) {        
275     G4cerr << "ERROR: theHadronicGenerator is     
276     return 1;                                     
277   } else if ( ! theHadronicGenerator->IsPhysic    
278     G4cerr << "ERROR: this physics case is NOT    
279     return 2;                                     
280   }                                               
281                                                   
282   // Loop over the collisions                     
283   G4double rnd1, rnd2, rnd3, rnd4, rnd5, rnd6,    
284   G4VParticleChange* aChange = nullptr;           
285   for ( G4int i = 0; i < numCollisions; ++i )     
286     // Draw some random numbers to select the     
287     // projectile hadron, projectile kinetic e    
288     rnd1 = CLHEP::HepRandom::getTheEngine()->f    
289     rnd2 = CLHEP::HepRandom::getTheEngine()->f    
290     rnd3 = CLHEP::HepRandom::getTheEngine()->f    
291     rnd4 = CLHEP::HepRandom::getTheEngine()->f    
292     rnd5 = CLHEP::HepRandom::getTheEngine()->f    
293     rnd6 = CLHEP::HepRandom::getTheEngine()->f    
294     // Sample the projectile kinetic energy       
295     projectileEnergy = minEnergy + rnd1*( maxE    
296     if ( projectileEnergy <= 0.0 ) projectileE    
297     // Sample the projectile direction            
298     normalization = 1.0 / std::sqrt( rnd2*rnd2    
299     const G4bool isOnSmearingDirection = false    
300     G4ThreeVector aDirection = G4ThreeVector(     
301     if ( isOnSmearingDirection ) {                
302       aDirection = G4ThreeVector( normalizatio    
303     }                                             
304     // Sample the projectile hadron from the v    
305     G4int index_projectile = std::trunc( rnd5*    
306     G4String nameProjectile = vecProjectiles[     
307     G4ParticleDefinition* projectile = partTab    
308     if ( projectileNucleus ) {                    
309       nameProjectile = projectileNucleus->GetP    
310       projectile = projectileNucleus;             
311     }                                             
312     // Sample the target material from the vec    
313     // (Note: the target nucleus will be sampl    
314     G4int index_material = std::trunc( rnd6*nu    
315     G4String nameMaterial = vecMaterials[ inde    
316     G4Material* material = G4NistManager::Inst    
317     if ( material == nullptr ) {                  
318       G4cerr << "ERROR: Material " << nameMate    
319       return 3;                                   
320     }                                             
321     if ( isPrintingEnabled ) {                    
322       G4cout << "\t Collision " << i << " ; pr    
323       if ( projectileNucleus ) {                  
324         G4cout << " ; Ekin[MeV]/nucleon=" << p    
325     static_cast< G4double >( std::abs( project    
326       } else {                                    
327         G4cout << " ; Ekin[MeV]=" << projectil    
328       }                                           
329       G4cout << " ; direction=" << aDirection     
330     }                                             
331                                                   
332     // Call here the "hadronic generator" to g    
333     aChange = theHadronicGenerator->GenerateIn    
334     /* ***************************************    
335                                                   
336     G4int nsec = aChange ? aChange->GetNumberO    
337     G4bool isPrintingOfSecondariesEnabled = fa    
338     if ( isPrintingEnabled ) {                    
339       G4cout << G4endl << "\t --> #secondaries    
340              << " ; impactParameter[fm]=" << t    
341        << " ; #projectileSpectatorNucleons=" <    
342        << " ; #targetSpectatorNucleons=" << th    
343        << " ; #NNcollisions=" << theHadronicGe    
344       if ( i % printingGap == 0 ) {               
345         isPrintingOfSecondariesEnabled = true;    
346         G4cout << "\t \t List of produced seco    
347       }                                           
348     }                                             
349     // Loop over produced secondaries and even    
350     for ( G4int j = 0; j < nsec; ++j ) {          
351       const G4DynamicParticle* sec = aChange->    
352       if ( isPrintingOfSecondariesEnabled ) {     
353         G4cout << "\t \t \t j=" << j << "\t" <    
354                << "\t p=" << sec->Get4Momentum    
355       }                                           
356       delete aChange->GetSecondary(j);            
357     }                                             
358     if ( aChange ) aChange->Clear();              
359   }                                               
360                                                   
361   G4cout << G4endl << " Final random number =     
362          << G4endl << "=== End of test ===" <<    
363 }                                                 
364                                                   
365 //....oooOO0OOooo........oooOO0OOooo........oo