Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ParticleHPProduct.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// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// particle_hp -- source file
27// J.P. Wellisch, Nov-1996
28// A prototype of the low energy neutron transport model.
29//
30// 080718 As for secondary photons, if its mean value has a value of integer,
31// then a sampling of multiplicity that based on Poisson Distribution
32// is not carried out and the mean is used as a multiplicity.
33// modified by T. Koi.
34// 080721 Using ClearHistories() methodl for limiting the sum of secondary energies
35// modified by T. Koi.
36// 080901 bug fix of too many secnodaries production in nd reactinos by T. Koi
37//
38// P. Arce, June-2014 Conversion neutron_hp to particle_hp
39//
40#include "G4ParticleHPProduct.hh"
41#include "G4Poisson.hh"
42#include "G4Proton.hh"
44
46{
47 if ( theDist == 0 ) {
48 fCache.Get().theCurrentMultiplicity = 0;
49 return 0;
50 }
51
52 G4double mean = theYield.GetY(anEnergy);
53 if ( mean <= 0. ) {
54 fCache.Get().theCurrentMultiplicity = 0;
55 return 0;
56 }
57
58 G4int multi;
59 multi = G4int(mean+0.0001);
60#ifdef PHP_AS_HP
61 if ( theMassCode == 0 ) // DELETE THIS: IT MUST BE DONE FOR ALL PARTICLES
62#endif
63 {
64 if ( G4int ( mean ) == mean )
65 {
66 multi = (G4int) mean;
67 }
68 else
69 {
70#ifdef PHP_AS_HP
71 multi = G4Poisson ( mean );
72#else
73 if( theMultiplicityMethod == G4HPMultiPoisson )
74 {
75 multi = (G4int)G4Poisson ( mean );
76 }
77 else
78 {
80 G4int imulti = G4int(mean);
81 multi = imulti + G4int(radnf < mean-imulti);
82 }
83#endif
84 }
85#ifdef G4PHPDEBUG
86 #ifdef G4VERBOSE
87 if( std::getenv("G4ParticleHPDebug") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
88 G4cout << "G4ParticleHPProduct::GetMultiplicity " << theMassCode
89 << " " << theMass << " multi " << multi << " mean " << mean
90 << G4endl;
91 #endif
92#endif
93 }
94
95 fCache.Get().theCurrentMultiplicity = static_cast<G4int>(mean);
96
97 return multi;
98}
99
100
102{
103 if(theDist == 0) { return nullptr; }
105
106 theDist->SetTarget(fCache.Get().theTarget);
107 theDist->SetProjectileRP(fCache.Get().theProjectileRP);
108 G4int i;
109 G4ReactionProduct * tmp;
110 theDist->ClearHistories();
111
112 for(i=0; i<multi; ++i)
113 {
114#ifdef G4PHPDEBUG
115
116#endif
117 tmp = theDist->Sample(anEnergy, theMassCode, theMass);
118 if(tmp != 0) { result->push_back(tmp); }
119#ifndef G4PHPDEBUG //GDEB
120 #ifdef G4VERBOSE
121 if( std::getenv("G4ParticleHPDebug")
122 && tmp != 0 && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
123 G4cout << multi << " " << i << " @@@ G4ParticleHPProduct::Sample "
124 << tmp->GetDefinition()->GetParticleName() << " E= "
125 << tmp->GetKineticEnergy() << G4endl;
126 #endif
127#endif
128 }
129 if(multi == 0)
130 {
131 tmp = theDist->Sample(anEnergy, theMassCode, theMass);
132 delete tmp;
133 }
134
135 return result;
136}
@ G4HPMultiPoisson
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:50
std::vector< G4ReactionProduct * > G4ReactionProductVector
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static double shoot()
Definition: RandFlat.cc:61
value_type & Get() const
Definition: G4Cache.hh:315
static G4HadronicParameters * Instance()
const G4String & GetParticleName() const
G4ReactionProductVector * Sample(G4double anEnergy, G4int nParticles)
G4int GetMultiplicity(G4double anEnergy)
G4double GetY(G4double x)
G4double GetKineticEnergy() const
const G4ParticleDefinition * GetDefinition() const
void SetProjectileRP(G4ReactionProduct *aIncidentParticleRP)
virtual G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass)=0
void SetTarget(G4ReactionProduct *aTarget)