Geant4  10.02.p03
G4ParticleHPInelasticData Class Reference

#include <G4ParticleHPInelasticData.hh>

Inheritance diagram for G4ParticleHPInelasticData:
Collaboration diagram for G4ParticleHPInelasticData:

Public Member Functions

 G4ParticleHPInelasticData (G4ParticleDefinition *projectile=G4Neutron::Neutron())
 
 ~G4ParticleHPInelasticData ()
 
G4bool IsIsoApplicable (const G4DynamicParticle *, G4int, G4int, const G4Element *, const G4Material *)
 
G4double GetIsoCrossSection (const G4DynamicParticle *, G4int, G4int, const G4Isotope *, const G4Element *, const G4Material *)
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, G4double aT)
 
void BuildPhysicsTable (const G4ParticleDefinition &)
 
void DumpPhysicsTable (const G4ParticleDefinition &)
 
void IgnoreOnFlightDopplerBroadening ()
 
void EnableOnFlightDopplerBroadening ()
 
G4ParticleDefinitionGetProjectile ()
 
G4int GetVerboseLevel () const
 
void SetVerboseLevel (G4int)
 
virtual void CrossSectionDescription (std::ostream &) const
 
- Public Member Functions inherited from G4VCrossSectionDataSet
 G4VCrossSectionDataSet (const G4String &nam="")
 
virtual ~G4VCrossSectionDataSet ()
 
virtual G4bool IsElementApplicable (const G4DynamicParticle *, G4int Z, const G4Material *mat=0)
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *mat=0)
 
G4double ComputeCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *mat=0)
 
virtual G4double GetElementCrossSection (const G4DynamicParticle *, G4int Z, const G4Material *mat=0)
 
virtual G4IsotopeSelectIsotope (const G4Element *, G4double kinEnergy)
 
G4double GetMinKinEnergy () const
 
void SetMinKinEnergy (G4double value)
 
G4double GetMaxKinEnergy () const
 
void SetMaxKinEnergy (G4double value)
 
const G4StringGetName () const
 

Private Attributes

G4PhysicsTabletheCrossSections
 
G4bool onFlightDB
 
G4ParticleDefinitiontheProjectile
 
G4ParticleHPDatatheHPData
 
G4bool instanceOfWorker
 
G4double ke_cache
 
G4double xs_cache
 
const G4Elementelement_cache
 
const G4Materialmaterial_cache
 

Additional Inherited Members

- Protected Member Functions inherited from G4VCrossSectionDataSet
void SetName (const G4String &)
 
- Protected Attributes inherited from G4VCrossSectionDataSet
G4int verboseLevel
 

Detailed Description

Definition at line 53 of file G4ParticleHPInelasticData.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPInelasticData()

G4ParticleHPInelasticData::G4ParticleHPInelasticData ( G4ParticleDefinition projectile = G4Neutron::Neutron())

Definition at line 46 of file G4ParticleHPInelasticData.cc.

48 {
49  const char* dataDirVariable;
50  if( projectile == G4Neutron::Neutron() ) {
51  dataDirVariable = "G4NEUTRONHPDATA";
52  }else if( projectile == G4Proton::Proton() ) {
53  dataDirVariable = "G4PROTONHPDATA";
54  }else if( projectile == G4Deuteron::Deuteron() ) {
55  dataDirVariable = "G4DEUTERONHPDATA";
56  }else if( projectile == G4Triton::Triton() ) {
57  dataDirVariable = "G4TRITONHPDATA";
58  }else if( projectile == G4He3::He3() ) {
59  dataDirVariable = "G4HE3HPDATA";
60  }else if( projectile == G4Alpha::Alpha() ) {
61  dataDirVariable = "G4ALPHAHPDATA";
62  } else {
63  G4String message("G4ParticleHPInelasticData may only be called for neutron, proton, deuteron, triton, He3 or alpha, while it is called for " + projectile->GetParticleName());
64  throw G4HadronicException(__FILE__, __LINE__,message.c_str());
65  }
66  // G4cout << this << " G4ParticleHPInelasticData::G4ParticleHPInelasticData " << projectile->GetParticleName() << " DATADIR " << dataDirVariable << G4endl;//GDEB
67  G4String dataName = projectile->GetParticleName()+"HPInelasticXS";
68  dataName.at(0) = toupper(dataName.at(0)) ;
69  SetName( dataName );
70 
71  if(!getenv(dataDirVariable)){
72  G4String message("Please setenv " + G4String(dataDirVariable) + " to point to the " + projectile->GetParticleName() + " cross-section files.");
73  throw G4HadronicException(__FILE__, __LINE__,message.c_str());
74  }
75 
76  G4cout << "@@@ G4ParticleHPInelasticData instantiated for particle " << projectile->GetParticleName() << " data directory variable is " << dataDirVariable << " pointing to " << getenv(dataDirVariable) << G4endl;
77 
80 
81  onFlightDB = true;
82  theCrossSections = 0;
83  theProjectile=projectile;
84 
85  theHPData = NULL;
86  instanceOfWorker = false;
89  } else {
90  instanceOfWorker = true;
91  }
92 }
G4VCrossSectionDataSet(const G4String &nam="")
G4ParticleDefinition * theProjectile
void SetName(const G4String &)
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
void SetMinKinEnergy(G4double value)
static G4Triton * Triton()
Definition: G4Triton.cc:95
static G4Proton * Proton()
Definition: G4Proton.cc:93
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:94
void SetMaxKinEnergy(G4double value)
#define G4endl
Definition: G4ios.hh:61
G4bool IsMasterThread()
Definition: G4Threading.cc:136
static G4Alpha * Alpha()
Definition: G4Alpha.cc:89
static G4He3 * He3()
Definition: G4He3.cc:94
static const double MeV
Here is the call graph for this function:

◆ ~G4ParticleHPInelasticData()

G4ParticleHPInelasticData::~G4ParticleHPInelasticData ( )

Definition at line 94 of file G4ParticleHPInelasticData.cc.

95 {
96  if ( theCrossSections != NULL && instanceOfWorker != true ) {
98  delete theCrossSections;
99  theCrossSections = NULL;
100  }
101 }
void clearAndDestroy()
Here is the call graph for this function:

Member Function Documentation

◆ BuildPhysicsTable()

void G4ParticleHPInelasticData::BuildPhysicsTable ( const G4ParticleDefinition projectile)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 143 of file G4ParticleHPInelasticData.cc.

144 {
145  // if(&projectile!=G4Neutron::Neutron())
146  // throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
147 
148 //080428
149  if ( G4ParticleHPManager::GetInstance()->GetNeglectDoppler() )
150  {
151  G4cout << "Find a flag of \"G4PHP_NEGLECT_DOPPLER\"." << G4endl;
152  G4cout << "On the fly Doppler broadening will be neglect in the cross section calculation of inelastic scattering of neutrons (<20MeV)." << G4endl;
153  onFlightDB = false;
154  }
155 
156  if ( G4Threading::IsWorkerThread() ) {
158  return;
159  } else {
160  if ( theHPData == NULL ) theHPData = G4ParticleHPData::Instance( const_cast<G4ParticleDefinition*> ( &projectile ) );
161  }
162 
163 
164 
165  size_t numberOfElements = G4Element::GetNumberOfElements();
166 // theCrossSections = new G4PhysicsTable( numberOfElements );
167 // TKDB
168  //if ( theCrossSections == 0 )
169  //{ theCrossSections = new G4PhysicsTable( numberOfElements ); }
170  if ( theCrossSections == NULL )
171  theCrossSections = new G4PhysicsTable( numberOfElements );
172  else
174 
175  // make a PhysicsVector for each element
176 
177  //G4ParticleHPData* hpData = new G4ParticleHPData(projectile); //NEW
178  static G4ThreadLocal G4ElementTable *theElementTable = 0 ;
179  if (!theElementTable) theElementTable= G4Element::GetElementTable();
180  for( size_t i=0; i<numberOfElements; ++i )
181  {
182  //NEW G4PhysicsVector* physVec = G4ParticleHPData::
183  //NEW Instance(projectile, dataDirVariable)->MakePhysicsVector((*theElementTable)[i], this);
184  //G4PhysicsVector* physVec = hpData->MakePhysicsVector((*theElementTable)[i], this);
185  G4PhysicsVector* physVec = theHPData->MakePhysicsVector((*theElementTable)[i], this);
186  theCrossSections->push_back(physVec);
187  }
188 
190 }
static G4ParticleHPManager * GetInstance()
void RegisterInelasticCrossSections(const G4ParticleDefinition *, G4PhysicsTable *)
void push_back(G4PhysicsVector *)
#define G4ThreadLocal
Definition: tls.hh:89
G4GLOB_DLL std::ostream G4cout
static size_t GetNumberOfElements()
Definition: G4Element.cc:402
G4bool IsWorkerThread()
Definition: G4Threading.cc:135
G4PhysicsVector * MakePhysicsVector(G4Element *thE, G4ParticleHPFissionData *theP)
G4PhysicsTable * GetInelasticCrossSections(const G4ParticleDefinition *)
static G4ParticleHPData * Instance(G4ParticleDefinition *projectile)
#define G4endl
Definition: G4ios.hh:61
std::vector< G4Element * > G4ElementTable
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:395
void clearAndDestroy()
Here is the call graph for this function:

◆ CrossSectionDescription()

void G4ParticleHPInelasticData::CrossSectionDescription ( std::ostream &  outFile) const
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 352 of file G4ParticleHPInelasticData.cc.

353 {
354  outFile << "Extension of High Precision cross section for inelastic reaction of proton, deuteron, triton, He3 and alpha below 20MeV\n";
355 }
Here is the caller graph for this function:

◆ DumpPhysicsTable()

void G4ParticleHPInelasticData::DumpPhysicsTable ( const G4ParticleDefinition projectile)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 192 of file G4ParticleHPInelasticData.cc.

193 {
194  if(&projectile!=theProjectile)
195  throw G4HadronicException(__FILE__, __LINE__, "Attempt to use ParticleHP data for a wrong projectile!!!");
196 
197 //
198 // Dump element based cross section
199 // range 10e-5 eV to 20 MeV
200 // 10 point per decade
201 // in barn
202 //
203 
204  G4cout << G4endl;
205  G4cout << G4endl;
206  G4cout << "Inelastic Cross Section of Neutron HP"<< G4endl;
207  G4cout << "(Pointwise cross-section at 0 Kelvin.)" << G4endl;
208  G4cout << G4endl;
209  G4cout << "Name of Element" << G4endl;
210  G4cout << "Energy[eV] XS[barn]" << G4endl;
211  G4cout << G4endl;
212 
213  size_t numberOfElements = G4Element::GetNumberOfElements();
214  static G4ThreadLocal G4ElementTable *theElementTable = 0 ;
215  if (!theElementTable) theElementTable= G4Element::GetElementTable();
216 
217  for ( size_t i = 0 ; i < numberOfElements ; ++i )
218  {
219 
220  G4cout << (*theElementTable)[i]->GetName() << G4endl;
221 
222  G4int ie = 0;
223 
224  for ( ie = 0 ; ie < 130 ; ie++ )
225  {
226  G4double eKinetic = 1.0e-5 * G4Pow::GetInstance()->powA ( 10.0 , ie/10.0 ) *CLHEP::eV;
227  G4bool outOfRange = false;
228 
229  if ( eKinetic < 20*CLHEP::MeV )
230  {
231  G4cout << eKinetic/CLHEP::eV << " " << (*((*theCrossSections)(i))).GetValue(eKinetic, outOfRange)/CLHEP::barn << G4endl;
232  }
233 
234  }
235 
236  G4cout << G4endl;
237  }
238 
239  //G4cout << "G4ParticleHPInelasticData::DumpPhysicsTable still to be implemented"<<G4endl;
240 }
static G4Pow * GetInstance()
Definition: G4Pow.cc:55
G4ParticleDefinition * theProjectile
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static size_t GetNumberOfElements()
Definition: G4Element.cc:402
bool G4bool
Definition: G4Types.hh:79
static const double barn
Definition: SystemOfUnits.h:84
#define G4endl
Definition: G4ios.hh:61
G4double powA(G4double A, G4double y) const
Definition: G4Pow.hh:259
std::vector< G4Element * > G4ElementTable
double G4double
Definition: G4Types.hh:76
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:395
static const double eV
static const double MeV
Here is the call graph for this function:

◆ EnableOnFlightDopplerBroadening()

void G4ParticleHPInelasticData::EnableOnFlightDopplerBroadening ( )
inline

Definition at line 86 of file G4ParticleHPInelasticData.hh.

◆ GetCrossSection()

G4double G4ParticleHPInelasticData::GetCrossSection ( const G4DynamicParticle projectile,
const G4Element anE,
G4double  aT 
)

Definition at line 245 of file G4ParticleHPInelasticData.cc.

246 {
247  G4double result = 0;
248  G4bool outOfRange;
249  G4int index = anE->GetIndex();
250 
251  // prepare neutron
252  G4double eKinetic = projectile->GetKineticEnergy();
253 
254  if ( !onFlightDB )
255  {
256  //NEGLECT_DOPPLER
257  G4double factor = 1.0;
258  if ( eKinetic < aT * CLHEP::k_Boltzmann )
259  {
260  // below 0.1 eV neutrons
261  // Have to do some, but now just igonre.
262  // Will take care after performance check.
263  // factor = factor * targetV;
264  }
265  return ( (*((*theCrossSections)(index))).GetValue(eKinetic, outOfRange) )* factor;
266 
267  }
268 
269  G4ReactionProduct theNeutron( projectile->GetDefinition() );
270  theNeutron.SetMomentum( projectile->GetMomentum() );
271  theNeutron.SetKineticEnergy( eKinetic );
272 
273  // prepare thermal nucleus
274  G4Nucleus aNuc;
275  G4double eps = 0.0001;
276  G4double theA = anE->GetN();
277  G4double theZ = anE->GetZ();
278  G4double eleMass;
279  eleMass = G4NucleiProperties::GetNuclearMass(static_cast<G4int>(theA+eps), static_cast<G4int>(theZ+eps) );
280 
281  G4ReactionProduct boosted;
282  G4double aXsection;
283 
284  // MC integration loop
285  G4int counter = 0;
286  G4int failCount = 0;
287  G4double buffer = 0; G4int size = G4int(std::max(10., aT/60*CLHEP::kelvin));
288  G4ThreeVector neutronVelocity = 1./theProjectile->GetPDGMass()*theNeutron.GetMomentum();
289  G4double neutronVMag = neutronVelocity.mag();
290 
291  // G4cout << " G4ParticleHPInelasticData 2 " << size << G4endl;//GDEB
292 #ifndef G4PHP_DOPPLER_LOOP_ONCE
293  while(counter == 0 || std::abs(buffer-result/std::max(1,counter)) > 0.01*buffer) // Loop checking, 11.05.2015, T. Koi
294  {
295  if(counter) buffer = result/counter;
296  while (counter<size) // Loop checking, 11.05.2015, T. Koi
297  {
298  counter ++;
299 #endif
300  //G4ReactionProduct aThermalNuc = aNuc.GetThermalNucleus( eleMass/theProjectile->GetPDGMass(), aT );
301  //G4Nucleus::GetThermalNucleus requests normalization of mass in neutron mass
302  G4ReactionProduct aThermalNuc = aNuc.GetThermalNucleus( eleMass/G4Neutron::Neutron()->GetPDGMass(), aT );
303  boosted.Lorentz(theNeutron, aThermalNuc);
304  G4double theEkin = boosted.GetKineticEnergy();
305  aXsection = (*((*theCrossSections)(index))).GetValue(theEkin, outOfRange);
306  // G4cout << " G4ParticleHPInelasticData aXsection " << aXsection << " index " << index << " theEkin " << theEkin << " outOfRange " << outOfRange <<G4endl;//GDEB
307  if(aXsection <0)
308  {
309  if(failCount<1000)
310  {
311  failCount++;
312 #ifndef G4PHP_DOPPLER_LOOP_ONCE
313  counter--;
314  continue;
315 #endif
316  }
317  else
318  {
319  aXsection = 0;
320  }
321  }
322  // velocity correction.
323  G4ThreeVector targetVelocity = 1./aThermalNuc.GetMass()*aThermalNuc.GetMomentum();
324  aXsection *= (targetVelocity-neutronVelocity).mag()/neutronVMag;
325  result += aXsection;
326  }
327 #ifndef G4PHP_DOPPLER_LOOP_ONCE
328  size += size;
329  }
330  result /= counter;
331 #endif
332 
333 /*
334  // Checking impact of G4PHP_NEGLECT_DOPPLER
335  G4cout << " result " << result << " "
336  << (*((*theCrossSections)(index))).GetValue(eKinetic, outOfRange) << " "
337  << (*((*theCrossSections)(index))).GetValue(eKinetic, outOfRange) /result << G4endl;
338 */
339 // G4cout << this << " G4ParticleHPInelasticData result " << result << G4endl; //GDEB
340 
341  return result;
342 }
G4double GetMass() const
static const double kelvin
static G4double GetNuclearMass(const G4double A, const G4double Z)
void Lorentz(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
Int_t index
G4ReactionProduct GetThermalNucleus(G4double aMass, G4double temp=-1) const
Definition: G4Nucleus.cc:143
size_t GetIndex() const
Definition: G4Element.hh:181
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4ParticleDefinition * theProjectile
#define buffer
Definition: xmlparse.cc:628
static const G4double eps
int G4int
Definition: G4Types.hh:78
G4double GetN() const
Definition: G4Element.hh:134
G4double GetKineticEnergy() const
G4ThreeVector GetMomentum() const
bool G4bool
Definition: G4Types.hh:79
double mag() const
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
static const G4double factor
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
G4double GetZ() const
Definition: G4Element.hh:131
static const double k_Boltzmann
G4ThreeVector GetMomentum() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIsoCrossSection()

G4double G4ParticleHPInelasticData::GetIsoCrossSection ( const G4DynamicParticle dp,
G4int  ,
G4int  ,
const G4Isotope ,
const G4Element element,
const G4Material material 
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 116 of file G4ParticleHPInelasticData.cc.

121 {
122  if ( dp->GetKineticEnergy() == ke_cache && element == element_cache && material == material_cache ) return xs_cache;
123 
124  ke_cache = dp->GetKineticEnergy();
125  element_cache = element;
127  G4double xs = GetCrossSection( dp , element , material->GetTemperature() );
128  xs_cache = xs;
129  return xs;
130 }
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, G4double aT)
string material
Definition: eplot.py:19
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ GetProjectile()

G4ParticleDefinition* G4ParticleHPInelasticData::GetProjectile ( )
inline

Definition at line 88 of file G4ParticleHPInelasticData.hh.

88 {return theProjectile;}
G4ParticleDefinition * theProjectile
Here is the call graph for this function:

◆ GetVerboseLevel()

G4int G4ParticleHPInelasticData::GetVerboseLevel ( ) const
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 344 of file G4ParticleHPInelasticData.cc.

345 {
347 }
static G4ParticleHPManager * GetInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IgnoreOnFlightDopplerBroadening()

void G4ParticleHPInelasticData::IgnoreOnFlightDopplerBroadening ( )
inline

Definition at line 85 of file G4ParticleHPInelasticData.hh.

◆ IsIsoApplicable()

G4bool G4ParticleHPInelasticData::IsIsoApplicable ( const G4DynamicParticle dp,
G4int  ,
G4int  ,
const G4Element ,
const G4Material  
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 103 of file G4ParticleHPInelasticData.cc.

107 {
108  G4double eKin = dp->GetKineticEnergy();
109  if ( eKin > GetMaxKinEnergy()
110  || eKin < GetMinKinEnergy()
111  || dp->GetDefinition() != theProjectile ) return false;
112 
113  return true;
114 }
G4ParticleDefinition * theProjectile
G4double GetKineticEnergy() const
G4ParticleDefinition * GetDefinition() const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ SetVerboseLevel()

void G4ParticleHPInelasticData::SetVerboseLevel ( G4int  newValue)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 348 of file G4ParticleHPInelasticData.cc.

349 {
351 }
static G4ParticleHPManager * GetInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ element_cache

const G4Element* G4ParticleHPInelasticData::element_cache
private

Definition at line 109 of file G4ParticleHPInelasticData.hh.

◆ instanceOfWorker

G4bool G4ParticleHPInelasticData::instanceOfWorker
private

Definition at line 105 of file G4ParticleHPInelasticData.hh.

◆ ke_cache

G4double G4ParticleHPInelasticData::ke_cache
private

Definition at line 107 of file G4ParticleHPInelasticData.hh.

◆ material_cache

const G4Material* G4ParticleHPInelasticData::material_cache
private

Definition at line 110 of file G4ParticleHPInelasticData.hh.

◆ onFlightDB

G4bool G4ParticleHPInelasticData::onFlightDB
private

Definition at line 99 of file G4ParticleHPInelasticData.hh.

◆ theCrossSections

G4PhysicsTable* G4ParticleHPInelasticData::theCrossSections
private

Definition at line 97 of file G4ParticleHPInelasticData.hh.

◆ theHPData

G4ParticleHPData* G4ParticleHPInelasticData::theHPData
private

Definition at line 103 of file G4ParticleHPInelasticData.hh.

◆ theProjectile

G4ParticleDefinition* G4ParticleHPInelasticData::theProjectile
private

Definition at line 101 of file G4ParticleHPInelasticData.hh.

◆ xs_cache

G4double G4ParticleHPInelasticData::xs_cache
private

Definition at line 108 of file G4ParticleHPInelasticData.hh.


The documentation for this class was generated from the following files: