Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DPMJET2_5CrossSection.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * *
21 // * Parts of this code which have been developed by QinetiQ Ltd *
22 // * under contract to the European Space Agency (ESA) are the *
23 // * intellectual property of ESA. Rights to use, copy, modify and *
24 // * redistribute this software for general public use are granted *
25 // * in compliance with any licensing, distribution and development *
26 // * policy adopted by the Geant4 Collaboration. This code has been *
27 // * written by QinetiQ Ltd for the European Space Agency, under ESA *
28 // * contract 19770/06/NL/JD (Technology Research Programme). *
29 // * *
30 // * By using, copying, modifying or distributing the software (or *
31 // * any work based on the software) you agree to acknowledge its *
32 // * use in resulting scientific publications, and indicate your *
33 // * acceptance of all terms of the Geant4 Software license. *
34 // ********************************************************************
35 //
36 /// \file hadronic/Hadr02/src/G4DPMJET2_5CrossSection.cc
37 /// \brief Implementation of the G4DPMJET2_5CrossSection class
38 //
39 // $Id: G4DPMJET2_5CrossSection.cc 77519 2013-11-25 10:54:57Z gcosmo $
40 //
41 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 //
43 // MODULE: G4DPMJET2_5CrossSection.cc
44 //
45 // Version: 0.A
46 // Date: 02/04/08
47 // Author: P R Truscott
48 // Organisation: QinetiQ Ltd, UK
49 // Customer: ESA/ESTEC, NOORDWIJK
50 // Contract: 19770/06/NL/JD
51 //
52 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 ///////////////////////////////////////////////////////////////////////////////
54 //
55 #ifdef G4_USE_DPMJET
56 
57 
59 #include "G4DynamicParticle.hh"
60 #include "G4NucleiProperties.hh"
61 #include "G4PhysicalConstants.hh"
62 #include "G4SystemOfUnits.hh"
63 #include "G4HadronicException.hh"
64 
65 #include "globals.hh"
66 
67 #include <iomanip>
68 #include <fstream>
69 #include <sstream>
70 
71 #include "G4DynamicParticle.hh"
72 
73 using namespace std;
74 
75 ///////////////////////////////////////////////////////////////////////////////
76 //
78  upperLimit ( 1000.0 * TeV ), lowerLimit ( 5.0 * GeV ), maxA(240)
79 {
80  theCrossSectionIndex.clear();
81  Initialise();
82  //
83  //
84  // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
85  // This next bit is provisional, stating that this cross-section estimator
86  // is applicable to hydrogen targets. However, the cross-section will be
87  // set to zero.
88  //
89  ATmin = 1;
90  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91  //
92 }
93 ///////////////////////////////////////////////////////////////////////////////
94 //
96 {
97  //
98  // Go through the list of cross-section fit parameters and delete the arrays.
99  //
100  G4cout << "G4DPMJET2_5CrossSection::~G4DPMJET2_5CrossSection" << G4endl;
101  G4cout << "Size: " << theCrossSectionIndex.size() << G4endl;
102  /*
103  if(theCrossSectionIndex.size() > 0) {
104 
105  G4DPMJET2_5CrossSectionIndex::iterator it;
106  for (it=theCrossSectionIndex.begin(); it!=theCrossSectionIndex.end(); ++it)
107  {
108  G4DPMJET2_5CrossSectionParamSet *ptr = it->second;
109  for (G4DPMJET2_5CrossSectionParamSet *ptr1=ptr; ptr1<ptr+maxA; ptr1++)
110  { delete ptr1; }
111  }
112  }
113  */
114 }
115 ///////////////////////////////////////////////////////////////////////////////
116 //
117 G4bool
119  G4int, G4int AT,
120  const G4Element*, const G4Material*)
121 {
122  G4bool result = false;
123  G4int AP = theProjectile->GetDefinition()->GetBaryonNumber();
124  if(AP >= 1) {
125  G4double EPN = theProjectile->GetKineticEnergy()/G4double(AP);
126  result = (EPN >= lowerLimit && EPN <= upperLimit &&
127  AT >= ATmin && AT <= ATmax &&
128  AP >= APmin && AP <= APmax);
129  }
130  return result;
131 }
132 
133 ///////////////////////////////////////////////////////////////////////////////
134 //
135 G4double
137  const G4DynamicParticle* theProjectile,
138  G4int ZZ, G4int AT, const G4Isotope*,
139  const G4Element*, const G4Material*)
140 {
141  //
142  // Initialise the result.
143  G4double result = 0.0;
144  //
145  //
146  // Get details of the projectile and target (nucleon number, atomic number,
147  // kinetic enery and energy/nucleon.
148  //
149  G4int AP = theProjectile->GetDefinition()->GetBaryonNumber();
150  G4double TP = theProjectile->GetKineticEnergy();
151  G4double EPN = TP /G4double(AP);
152 
153  if (AT < ATmin || AT > ATmax || AP < APmin || AP > APmax ||
154  EPN < lowerLimit || EPN > upperLimit)
155  {
156  G4cout <<G4endl;
157  G4cout <<"ERROR IN G4DPMJET2_5CrossSection::GetIsoZACrossSection" <<G4endl;
158  G4cout <<"ATTEMPT TO USE CROSS-SECTION OUTSIDE OF RANGE" <<G4endl;
159  G4cout <<"NUCLEON NUMBER OF PROJECTILE = " <<AP <<G4endl;
160  G4cout <<"NUCLEON NUMBER OF TARGET = " <<AT <<G4endl;
161  G4cout <<"ENERGY PER NUCLEON = " <<EPN*MeV <<G4endl;
162  G4cout <<"ACCEPTABLE RANGE FOR AP = " <<APmin
163  <<" TO " <<APmax <<G4endl;
164  G4cout <<"ACCEPTABLE RANGE FOR AT = " <<ATmin
165  <<" TO " <<ATmax <<G4endl;
166  G4cout <<"ACCEPTABLE RANGE FOR ENERGY = " <<lowerLimit
167  <<" MeV/n TO " <<upperLimit
168  <<" MeV/n" <<G4endl;
169  G4cout <<G4endl;
170  return result;
171  }
172  //
173  //
174  // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
175  // This next bit is provisional, stating that this cross-section hydrogen
176  // targets is zero.
177  //
178  if ( AT == 1 ) return 0.0;
179  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
180  //
181  //
182  //
183  // Results are parameterised as a function of the natural logarithm of the
184  // centre of mass energy of the projectile and target system.
185  //
186  G4double sigma = 0.0;
188  G4double EP = theProjectile->GetTotalEnergy();
189  G4double mP = theProjectile->GetDefinition()->GetPDGMass();
190  G4double lnECM = std::log(std::sqrt(mP*mP + mT*mT + 2.0*mT*EP));
191  G4DPMJET2_5CrossSectionIndex::iterator it = theCrossSectionIndex.find(AT);
192  if (it != theCrossSectionIndex.end())
193  {
194  G4DPMJET2_5CrossSectionParamSet *ptr = (it->second) + AP;
195  G4double cc0 = (*ptr)[0];
196  G4double cc1 = (*ptr)[1];
197  G4double cc2 = (*ptr)[2];
198  sigma = cc0 + cc1*lnECM + cc2*lnECM*lnECM;
199  sigma = sigma * millibarn;
200  if (verboseLevel >= 2) {
201  G4cout <<"***************************************************************"
202  <<G4endl;
203  G4cout <<"G4DPMJET2_5CrossSection::GetIsoCrossSection" <<G4endl;
204  G4cout <<"PROJECTILE = "
205  <<theProjectile->GetDefinition()->GetParticleName() <<G4endl;
206  G4cout <<"TARGET (A,Z) = (" <<AT <<"," <<ZZ <<")" <<G4endl;
207  G4cout <<"K. ENERGY/NUC = " <<EPN/MeV <<" MeV/n" <<G4endl;
208  G4cout <<"CROSS SECTION = " <<sigma/millibarn <<" MILLIBARNS" <<G4endl;
209  G4cout <<"***************************************************************"
210  <<G4endl;
211  }
212  }
213  else
214  {
215  G4cout <<G4endl;
216  G4cout <<"ERROR IN G4DPMJET2_5CrossSection::GetIsoCrossSection" <<G4endl;
217  G4cout <<"NO CROSS-SECTION FIT DATA LOADED FOR AT = " <<AT <<G4endl;
218  G4cout <<G4endl;
219  }
220 
221  return sigma;
222 }
223 ///////////////////////////////////////////////////////////////////////////////
224 //
225 void G4DPMJET2_5CrossSection::Initialise ()
226 {
227  //verboseLevel = 2;
228  //
229  //
230  // Determine first if the environment variable G4DPMJET2_5DATA is set. If not
231  // then ask for it to be set and call exception.
232  //
233  if ( !getenv("G4DPMJET2_5DATA") )
234  {
235  G4cout <<"ENVIRONMENT VARIABLE G4DPMJET2_5DATA NOT SET " <<G4endl;
236  throw G4HadronicException(__FILE__, __LINE__,
237  "Please setenv G4DPMJET2_5DATA to point to the dpmjet2.5 data files.");
238  }
239 
240  G4String filename = G4String(getenv("G4DPMJET2_5DATA")) + "/" +
241  "GlauberCrossSections.dat";
242 
243  std::ifstream glauberXSFile(filename);
244  if (glauberXSFile) {
245  //
246  //
247  // Glaubercross-section file does exist, so read in maximum and minimum A
248  // for target and projectile.
249  //
250  glauberXSFile >>APmin >>APmax >>ATmin >>ATmax;
251  //
252  //
253  // Determine the list of targets based on the G4ElementList. The list of
254  // target nucleon numbers is stored as a ket to the map theCrossSectionIndex.
255  // G4double[240][3] array objects are created to allow storage of the
256  // cross-section fit parameters.
257  //
258  const G4ElementTable *theElementTable = G4Element::GetElementTable();
259  G4ElementTable::const_iterator it;
260  for (it=theElementTable->begin(); it!=theElementTable->end(); it++)
261  {
262  G4int nIso = (*it)->GetNumberOfIsotopes();
263  G4IsotopeVector* isoVector = (*it)->GetIsotopeVector();
264  for (G4int i = 0; i < nIso; i++)
265  {
266  G4int AA = (*isoVector)[i]->GetN();
267  if (theCrossSectionIndex.count(AA) == 0 &&
268  AA >= ATmin && AA <= ATmax)
269  {
270 //
271 //
272 // Whilst the use of std::map should eliminate duplication of keys, we need to
273 // know whether isotope's with the same nucleon number have been declared before
274 // creating the large arrays, hence the use of the "count" member function.
275 //
278  theCrossSectionIndex.insert(
279  G4DPMJET2_5CrossSectionIndex::value_type(AA,a));
280  }
281  }
282  }
283 
284  //
285  //
286  // Now proceed to read in the remainder of the GlauberCrossSection.dat file,
287  // loading into theCrossSectionIndex any relevant fitting parameters to the
288  // target nuclei.
289  //
290  char inputChars[80]={' '};
291  G4String inputLine;
292  while (-glauberXSFile.getline(inputChars, 80).eof() != EOF)
293  {
294  inputLine = inputChars;
295  if (inputLine.length() != 0)
296  {
297  std::istringstream tmpStream(inputLine);
298  G4int AP, AT;
299  G4double cc0, cc1, cc2;
300  tmpStream >>AP >>AT >>cc0 >>cc1 >>cc2;
301  G4DPMJET2_5CrossSectionIndex::iterator IT =
302  theCrossSectionIndex.find(AT);
303  if (IT != theCrossSectionIndex.end())
304  {
305  G4DPMJET2_5CrossSectionParamSet *ptr = (IT->second) + AP;
306  *ptr = G4DPMJET2_5CrossSectionParamSet(cc0,cc1,cc2);
307  }
308  }
309  }
310 
311  glauberXSFile.close();
312  G4cout << "G4DPMJET2_5CrossSection::Initialise () done!" << G4endl;
313  } else {
314  G4cout <<"GlauberCrossSections.dat DOES NOT EXIST" <<G4endl;
315  throw G4HadronicException(__FILE__, __LINE__,
316  "GlauberCrossSections.dat should be located in $G4DPMJET2_5DATA directory.");
317  }
318 }
319 ///////////////////////////////////////////////////////////////////////////////
320 //
322 {;}
323 ///////////////////////////////////////////////////////////////////////////////
324 //
326  &theProjectile)
327 {
328  const G4int AP = G4lrint(theProjectile.GetBaryonNumber());
329  G4cout <<G4endl;
330  G4cout <<"G4DPMJET2_5CrossSection::DumpPhysicsTable" <<G4endl;
331  G4cout <<"DUMPING CROSS-SECTION FITTING COEFFICIENTS FOR AP = "
332  <<AP <<G4endl;
333  G4cout <<G4endl;
334  G4cout <<" AT"
335  <<" c0"
336  <<" c1"
337  <<" c2"
338  <<G4endl;
339  G4DPMJET2_5CrossSectionIndex::iterator it;
340  for (it=theCrossSectionIndex.begin(); it!=theCrossSectionIndex.end(); it++)
341  {
342  G4cout.unsetf(std::ios::scientific);
343  G4cout.setf(std::ios::fixed|std::ios::right|std::ios::adjustfield);
344  G4cout.precision(0);
345  G4cout <<std::setw(5) <<it->first;
346 
347  G4cout.unsetf(std::ios::fixed);
348  G4cout.setf(std::ios::scientific|std::ios::right|std::ios::adjustfield);
349  G4cout.precision(7);
350  G4DPMJET2_5CrossSectionParamSet *ptr = (it->second) + AP;
351  G4cout <<std::setw(15) <<(*ptr)[0]
352  <<std::setw(15) <<(*ptr)[1]
353  <<std::setw(15) <<(*ptr)[2]
354  <<G4endl;
355  }
356  G4cout.setf(std::ios::fixed);
357 }
358 #endif
static G4double GetNuclearMass(const G4double A, const G4double Z)
std::vector< G4Isotope * > G4IsotopeVector
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
virtual G4bool IsIsoApplicable(const G4DynamicParticle *theProjectile, G4int ZZ, G4int AA, const G4Element *elm=0, const G4Material *mat=0)
G4ParticleDefinition * GetDefinition() const
int G4int
Definition: G4Types.hh:78
int millibarn
Definition: hepunit.py:40
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
virtual ~G4DPMJET2_5CrossSection()
virtual void DumpPhysicsTable(const G4ParticleDefinition &)
G4double GetPDGMass() const
int G4lrint(double ad)
Definition: templates.hh:163
#define G4endl
Definition: G4ios.hh:61
std::vector< G4Element * > G4ElementTable
double G4double
Definition: G4Types.hh:76
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:395
Definition of the G4DPMJET2_5CrossSection class.
virtual G4double GetIsoCrossSection(const G4DynamicParticle *theProjectile, G4int ZZ, G4int AA, const G4Isotope *, const G4Element *elm=0, const G4Material *mat=0)