Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPContEnergyAngular.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// 080721 To be "ClearHistories" effective, the selection scheme of angular distribution is modified by T. Koi
31//
32// P. Arce, Dec-2014 Conversion neutron_hp to particle_hp
33//
35
38 G4double /*mass*/)
39{
40 G4ReactionProduct* result;
41 G4int i(0);
42 G4int it(0);
43 for (i = 0; i < nEnergy; i++) {
44 it = i;
45#ifdef PHP_AS_HP
46 if(theAngular[i].GetEnergy() > anEnergy) break;
47#else
48 if(theAngular[i].GetEnergy() >= anEnergy) break;
49#endif
50 }
51
52 G4double targetMass = GetTarget()->GetMass();
53 if (it == 0) {
54 theAngular[0].SetTarget(GetTarget());
55 theAngular[0].SetTargetCode(theTargetCode);
56 theAngular[0].SetPrimary(GetProjectileRP());
57 result = theAngular[0].Sample(anEnergy, massCode, targetMass,
58 theAngularRep, theInterpolation);
59 currentMeanEnergy.Put(theAngular[0].MeanEnergyOfThisInteraction() );
60
61 } else {
62 // interpolation through alternating sampling. This needs improvement @@@
63 // This is the cause of the He3 problem !!!!!!!!
64 // See to it, if you can improve this.
65 //G4double random = G4UniformRand();
66 //G4double deltaE = theAngular[it].GetEnergy()-theAngular[it-1].GetEnergy();
67 //G4double offset = theAngular[it].GetEnergy()-anEnergy;
68 //if(random<offset/deltaE) it--;
69 //--- create new
70 // if (theManager.GetScheme(0) != LINLIN) {
71 // // asserted in G4ParticleHPContEnergyAngular::init there is only one range
72#ifdef PHP_AS_HP
73 theAngular[it].SetTarget(GetTarget());
74 theAngular[it].SetTargetCode(theTargetCode);
75 theAngular[it].SetPrimary(GetProjectileRP());
76 result = theAngular[it].Sample(anEnergy, massCode, targetMass,
77 theAngularRep, theInterpolation);
78 currentMeanEnergy.Put(theAngular[it].MeanEnergyOfThisInteraction() );
79#else
80 if (fCacheAngular.Get() == NULL) {
81 G4ParticleHPContAngularPar* angpar = new G4ParticleHPContAngularPar(theProjectile);
82 fCacheAngular.Put(angpar);
83 }
84 fCacheAngular.Get()->SetInterpolation(theInterpolation);
85 fCacheAngular.Get()->BuildByInterpolation(anEnergy, theManager.GetScheme(0),
86 (theAngular[it-1]), (theAngular[it]) );
87 fCacheAngular.Get()->SetTarget(GetTarget());
88 fCacheAngular.Get()->SetTargetCode(theTargetCode);
89 fCacheAngular.Get()->SetPrimary(GetProjectileRP());
90
91 result = fCacheAngular.Get()->Sample(anEnergy, massCode, targetMass,
92 theAngularRep, theInterpolation);
93 currentMeanEnergy.Put(fCacheAngular.Get()->MeanEnergyOfThisInteraction() );
94#endif
95 } // end (it != 0) branch
96
97 return result;
98}
99
100
102{
103 G4double result(0);
104 if (currentMeanEnergy.Get() < -1) {
105 throw G4HadronicException(__FILE__, __LINE__,
106 "G4ParticleHPContEnergyAngular: Logical error in Product class");
107 } else {
108 result = currentMeanEnergy.Get();
109 }
110 currentMeanEnergy.Put(-2);
111 return result;
112}
113
114
116{
117 if (theAngular!= NULL) {
118 for (G4int i = 0; i < nEnergy; i++) theAngular[i].ClearHistories();
119 }
120
121 // Added fCacheAngular ClearHistories() - this is the one actually used!
122 // Maybe theAngular does not even need ClearHistories()?
123 if (fCacheAngular.Get() != 0) fCacheAngular.Get()->ClearHistories();
124}
125
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
value_type & Get() const
Definition: G4Cache.hh:315
void Put(const value_type &val) const
Definition: G4Cache.hh:321
G4InterpolationScheme GetScheme(G4int index) const
G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass, G4int angularRep, G4int interpol)
void SetPrimary(G4ReactionProduct *aPrimary)
void SetTarget(G4ReactionProduct *aTarget)
void SetInterpolation(G4int theInterpolation)
void SetTargetCode(G4double aTargetCode)
void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme, G4ParticleHPContAngularPar &store1, G4ParticleHPContAngularPar &store2)
G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass)
G4double GetMass() const