Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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) { return 0; }
48 //151120 TK Modified for solving reproducibility problem
49 if ( theDist == 0 ) {
50 fCache.Get().theCurrentMultiplicity = 0;
51 return 0;
52 }
53
54 G4double mean = theYield.GetY(anEnergy);
55 //g G4cout << "G4ParticleHPProduct MEAN NUMBER OF PARTICLES " << mean << " for " << theMass << G4endl;
56 //if( mean <= 0. ) return 0;
57 //151120 TK Modified for solving reproducibility problem
58 //This is also a real fix
59 if ( mean <= 0. ) {
60 fCache.Get().theCurrentMultiplicity = 0;
61 return 0;
62 }
63
64 G4int multi;
65 multi = G4int(mean+0.0001);
66 //if(theMassCode==0) multi = G4Poisson(mean); // @@@@gammas. please X-check this
67 //080718
68#ifdef PHP_AS_HP
69 if ( theMassCode == 0 ) // DELETE THIS: IT MUST BE DONE FOR ALL PARTICLES
70#endif
71 {
72 if ( G4int ( mean ) == mean )
73 {
74 multi = (G4int) mean;
75 }
76 else
77 {
78#ifdef PHP_AS_HP
79 multi = G4Poisson ( mean );
80#else
81 if( theMultiplicityMethod == G4HPMultiPoisson ) {
82 multi = G4Poisson ( mean );
83 #ifdef G4VERBOSE
84 if( std::getenv("G4PHPTEST") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
85 G4cout << " MULTIPLICITY MULTIPLIED " << multi << " " << theMassCode << G4endl;
86 #endif
87 } else { // if( theMultiplicityMethod == G4HPMultiBetweenInts ) {
89 G4int imulti = G4int(mean);
90 multi = imulti + G4int(radnf < mean-imulti);
91 // G4cout << theMass << " multi " << multi << " mean " << mean
92 // << " radnf " << radnf << " mean-imulti " << mean-imulti << G4endl;
93 }
94#endif
95 // multi = int(mean);
96 // if( CLHEP::RandFlat::shoot() > mean-multi ) multi++;
97 }
98#ifdef G4PHPDEBUG
99 #ifdef G4VERBOSE
100 if( std::getenv("G4ParticleHPDebug") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
101 G4cout << "G4ParticleHPProduct::GetMultiplicity " << theMassCode << " " << theMass << " multi " << multi << " mean " << mean << G4endl;
102 #endif
103#endif
104 }
105
106 fCache.Get().theCurrentMultiplicity = static_cast<G4int>(mean);
107
108 return multi;
109}
110
111
113{
114 if(theDist == 0) { return 0; }
116
117 theDist->SetTarget(fCache.Get().theTarget);
118 theDist->SetProjectileRP(fCache.Get().theProjectileRP);
119 G4int i;
120// G4double eMax = GetTarget()->GetMass()+GetNeutron()->GetMass()
121// - theActualStateQValue;
122 G4ReactionProduct * tmp;
123 theDist->ClearHistories();
124
125 for(i=0;i<multi;i++)
126 {
127#ifdef G4PHPDEBUG
128 if( std::getenv("G4PHPTEST") )
129 #ifdef G4VERBOSE
130 if( std::getenv("G4ParticleHPDebug") && tmp != 0 && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
131 G4cout << multi << " " << i << " @@@ G4ParticleHPProduct::Sample " << anEnergy << " Mass " << theMassCode << " " << theMass << G4endl;
132 #endif
133#endif
134 tmp = theDist->Sample(anEnergy, theMassCode, theMass);
135 if(tmp != 0) { result->push_back(tmp); }
136#ifndef G4PHPDEBUG //GDEB
137 #ifdef G4VERBOSE
138 if( std::getenv("G4ParticleHPDebug") && tmp != 0 && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
139 G4cout << multi << " " << i << " @@@ G4ParticleHPProduct::Sample " << tmp->GetDefinition()->GetParticleName() << " E= " << tmp->GetKineticEnergy() << G4endl;
140 #endif
141#endif
142 }
143 if(multi == 0)
144 {
145 tmp = theDist->Sample(anEnergy, theMassCode, theMass);
146 delete tmp;
147 }
148 /*
149 //080901 TK Comment out, too many secondaries are produced in deuteron reactions
150 if(theTarget->GetMass()<2*GeV) // @@@ take care of residuals in all cases
151 {
152 tmp = theDist->Sample(anEnergy, theMassCode, theMass);
153 tmp->SetDefinition(G4Proton::Proton());
154 if(tmp != 0) { result->push_back(tmp); }
155 }
156 */
157
158 return result;
159}
@ 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)