Geant4  10.01.p01
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"
43 
45 {
46  if(theDist == 0) { return 0; }
47 
48  G4double mean = theYield.GetY(anEnergy);
49  //g G4cout << "G4ParticleHPProduct MEAN NUMBER OF PARTICLES " << mean << " for " << theMass << G4endl;
50  if( mean <= 0. ) return 0;
51 
52  G4int multi;
53  multi = G4int(mean+0.0001);
54  //if(theMassCode==0) multi = G4Poisson(mean); // @@@@gammas. please X-check this
55  //080718
56 #ifdef PHP_AS_HP
57  if ( theMassCode == 0 ) // DELETE THIS: IT MUST BE DONE FOR ALL PARTICLES
58 #endif
59  {
60  if ( G4int ( mean ) == mean )
61  {
62  multi = (G4int) mean;
63  }
64  else
65  {
66 #ifdef PHP_AS_HP
67  multi = G4Poisson ( mean );
68 #else
70  multi = G4Poisson ( mean );
71  if( getenv("G4PHPTEST") ) G4cout << " MULTIPLICITY MULTIPLIED " << multi << " " << theMassCode << G4endl;
72  } else { // if( theMultiplicityMethod == G4HPMultiBetweenInts ) {
74  G4int imulti = G4int(mean);
75  multi = imulti + G4int(radnf < mean-imulti);
76  // G4cout << theMass << " multi " << multi << " mean " << mean
77  // << " radnf " << radnf << " mean-imulti " << mean-imulti << G4endl;
78  }
79 #endif
80  // multi = int(mean);
81  // if( CLHEP::RandFlat::shoot() > mean-multi ) multi++;
82  }
83 #ifdef G4PHPDEBUG
84  if( getenv("G4ParticleHPDebug") ) G4cout << "G4ParticleHPProduct::GetMultiplicity " << theMassCode << " " << theMass << " multi " << multi << " mean " << mean << G4endl;
85 #endif
86  }
87 
88  theCurrentMultiplicity = static_cast<G4int>(mean);
89 
90  return multi;
91 }
92 
93 
95 {
96  if(theDist == 0) { return 0; }
98 
101  G4int i;
102 // G4double eMax = GetTarget()->GetMass()+GetNeutron()->GetMass()
103 // - theActualStateQValue;
104  G4ReactionProduct * tmp;
106 
107  for(i=0;i<multi;i++)
108  {
109 #ifdef G4PHPDEBUG
110  if( getenv("G4PHPTEST") )
111  if( getenv("G4ParticleHPDebug") && tmp != 0 ) G4cout << multi << " " << i << " @@@ G4ParticleHPProduct::Sample " << anEnergy << " Mass " << theMassCode << " " << theMass << G4endl;
112 #endif
113  tmp = theDist->Sample(anEnergy, theMassCode, theMass);
114  if(tmp != 0) { result->push_back(tmp); }
115 #ifndef G4PHPDEBUG //GDEB
116  if( getenv("G4ParticleHPDebug") && tmp != 0 ) G4cout << multi << " " << i << " @@@ G4ParticleHPProduct::Sample " << tmp->GetDefinition()->GetParticleName() << " E= " << tmp->GetKineticEnergy() << G4endl;
117 #endif
118  }
119  if(multi == 0)
120  {
121  tmp = theDist->Sample(anEnergy, theMassCode, theMass);
122  delete tmp;
123  }
124  /*
125  //080901 TK Comment out, too many secondaries are produced in deuteron reactions
126  if(theTarget->GetMass()<2*GeV) // @@@ take care of residuals in all cases
127  {
128  tmp = theDist->Sample(anEnergy, theMassCode, theMass);
129  tmp->SetDefinition(G4Proton::Proton());
130  if(tmp != 0) { result->push_back(tmp); }
131  }
132  */
133 
134  return result;
135 }
ThreeVector shoot(const G4int Ap, const G4int Af)
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:51
G4VParticleHPEnergyAngular * theDist
G4HPMultiMethod theMultiplicityMethod
G4ReactionProduct * theProjectileRP
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4ReactionProduct * theTarget
std::vector< G4ReactionProduct * > G4ReactionProductVector
const G4ParticleDefinition * GetDefinition() const
G4GLOB_DLL std::ostream G4cout
G4ParticleHPVector theYield
G4double GetY(G4double x)
void SetProjectileRP(G4ReactionProduct *aIncidentParticleRP)
G4double GetKineticEnergy() const
G4int GetMultiplicity(G4double anEnergy)
void SetTarget(G4ReactionProduct *aTarget)
virtual G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass)=0
G4ReactionProductVector * Sample(G4double anEnergy, G4int nParticles)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76