Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPEnAngCorrelation.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// 100413 Fix bug in incidence energy by T. Koi
31//
32// P. Arce, June-2014 Conversion neutron_hp to particle_hp
33//
34// June-2019 - E. Mendoza --> Part of the code trying to preserve the baryonic number has been deleted. One has to assume that it is not preserved when using ENDF-6 data and it caused problems.
35
37#include "G4LorentzRotation.hh"
38#include "G4LorentzVector.hh"
39#include "G4RotationMatrix.hh"
40#include "G4IonTable.hh"
41
43{
45
46 // do we have an appropriate distribution
47 if(nProducts!=1) throw G4HadronicException(__FILE__, __LINE__, "More than one product in SampleOne");
48
49 // get the result
51 G4int i=0;
52
53 G4int icounter=0;
54 G4int icounter_max=1024;
55 while(temp == 0) {
56 icounter++;
57 if ( icounter > icounter_max ) {
58 G4cout << "Loop-counter exceeded the threshold value at " << __LINE__ << "th line of " << __FILE__ << "." << G4endl;
59 break;
60 }
61 temp = theProducts[i++].Sample(anEnergy,1);
62 }
63
64 // is the multiplicity correct
65 if(temp->size()!=1) throw G4HadronicException(__FILE__, __LINE__, "SampleOne: Yield not correct");
66
67 // fill result
68 result = temp->operator[](0);
69
70 // some garbage collection
71 delete temp;
72
73 // return result
74 return result;
75}
76
78{
80 G4int i;
82 G4ReactionProduct theCMS;
84
85 if(frameFlag==2
86 || frameFlag==3) // Added for particle HP
87 {
88 // simplify and double check @
89 G4ThreeVector the3IncidentPart = fCache.Get().theProjectileRP->GetMomentum(); //theProjectileRP has value in LAB
90 G4double nEnergy = fCache.Get().theProjectileRP->GetTotalEnergy();
91 G4ThreeVector the3Target = fCache.Get().theTarget->GetMomentum(); //theTarget has value in LAB
92 G4double tEnergy = fCache.Get().theTarget->GetTotalEnergy();
93 G4double totE = nEnergy+tEnergy;
94 G4ThreeVector the3CMS = the3Target+the3IncidentPart;
95 theCMS.SetMomentum(the3CMS);
96 G4double cmsMom = std::sqrt(the3CMS*the3CMS);
97 G4double sqrts = std::sqrt((totE-cmsMom)*(totE+cmsMom));
98 theCMS.SetMass(sqrts);
99 theCMS.SetTotalEnergy(totE);
100 G4ReactionProduct aIncidentPart;
101 aIncidentPart.Lorentz(*fCache.Get().theProjectileRP, theCMS);
102 //TKDB 100413
103 //ENDF-6 Formats Manual ENDF-102
104 //CHAPTER 6. FILE 6: PRODUCT ENERGY-ANGLE DISTRIBUTIONS
105 //LCT Reference system for secondary energy and angle (incident energy is always given in the LAB system)
106 //anEnergy = aIncidentPart.GetKineticEnergy();
107 anEnergy = fCache.Get().theProjectileRP->GetKineticEnergy(); //should be same argumment of "anEnergy"
108
109 G4LorentzVector Ptmp (aIncidentPart.GetMomentum(), aIncidentPart.GetTotalEnergy());
110
111 toZ.rotateZ(-1*Ptmp.phi());
112 toZ.rotateY(-1*Ptmp.theta());
113 }
114 fCache.Get().theTotalMeanEnergy=0;
115 G4LorentzRotation toLab(toZ.inverse()); //toLab only change axis NOT to LAB system
116
117 for(i=0; i<nProducts; i++)
118 {
119 G4int nPart = theProducts[i].GetMultiplicity(anEnergy);
120 //- if( nParticles[i] == 0 ) continue;
121 it = theProducts[i].Sample(anEnergy,nPart);
122 G4double aMeanEnergy = theProducts[i].MeanEnergyOfThisInteraction();
123 //if(aMeanEnergy>0)
124 //151120 TK Modified for solving reproducibility problem
125 //This change may have side effect.
126 if(aMeanEnergy>=0)
127 {
128 fCache.Get().theTotalMeanEnergy += aMeanEnergy;
129 }
130 else
131 {
132 fCache.Get().theTotalMeanEnergy = anEnergy/nProducts+theProducts[i].GetQValue();
133 }
134 if(it!=0)
135 {
136 for(unsigned int ii=0; ii<it->size(); ii++)
137 {
138 //if(!std::getenv("G4PHP_NO_LORENTZ_BOOST")) {
139 G4LorentzVector pTmp1 (it->operator[](ii)->GetMomentum(),
140 it->operator[](ii)->GetTotalEnergy());
141 pTmp1 = toLab*pTmp1;
142 it->operator[](ii)->SetMomentum(pTmp1.vect());
143 it->operator[](ii)->SetTotalEnergy(pTmp1.e());
144
145 if(frameFlag==1) // target rest //TK 100413 should be LAB?
146 {
147 it->operator[](ii)->Lorentz(*(it->operator[](ii)), -1.*(*fCache.Get().theTarget)); //TK 100413 Is this really need?
148 }
149 else if(frameFlag==2 ) // CMS
150 {
151#ifdef G4PHPDEBUG
152 if( std::getenv("G4ParticleHPDebug") )
153 G4cout <<"G4ParticleHPEnAngCorrelation: before Lorentz boost "<<
154 it->at(ii)->GetKineticEnergy()<<" "<<
155 it->at(ii)->GetMomentum()<<G4endl;
156#endif
157 it->operator[](ii)->Lorentz(*(it->operator[](ii)), -1.*theCMS);
158#ifdef G4PHPDEBUG
159 if( std::getenv("G4ParticleHPDebug") )
160 G4cout <<"G4ParticleHPEnAngCorrelation: after Lorentz boost "<<
161 it->at(ii)->GetKineticEnergy()<<" "<<
162 it->at(ii)->GetMomentum()<<G4endl;
163#endif
164 }
165 //TK120515 migrate frameFlag (MF6 LCT) = 3
166 else if(frameFlag==3) // CMS A<=4 other LAB
167 {
168 if ( theProducts[i].GetMassCode() > 2004.5 ) //Alpha AWP 3.96713
169 {
170 //LAB
171 it->operator[](ii)->Lorentz(*(it->operator[](ii)), -1.*(*fCache.Get().theTarget)); //TK 100413 Is this really need?
172#ifdef G4PHPDEBUG
173 if( std::getenv("G4ParticleHPDebug") )
174 G4cout <<"G4ParticleHPEnAngCorrelation: after Lorentz boost "<<
175 it->at(ii)->GetKineticEnergy()<<" "<<
176 it->at(ii)->GetMomentum()<<G4endl;
177#endif
178 }
179 else
180 {
181 //CMS
182 it->operator[](ii)->Lorentz(*(it->operator[](ii)), -1.*theCMS);
183#ifdef G4PHPDEBUG
184 if( std::getenv("G4ParticleHPDebug") )
185 G4cout <<"G4ParticleHPEnAngCorrelation: after Lorentz boost "<<
186 it->at(ii)->GetKineticEnergy()<<" "<<
187 it->at(ii)->GetMomentum()<<G4endl;
188#endif
189 }
190 }
191 else
192 {
193 throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPEnAngCorrelation::Sample: The frame of the finalstate is not specified");
194 }
195
196 // }//getenv("G4PHP_NO_LORENTZ_BOOST"))
197 // G4cout << ii << " EnAnG energy after boost " << it->operator[](ii)->GetKineticEnergy() << G4endl; //GDEB
198 result->push_back(it->operator[](ii));
199 }
200 delete it;
201 }
202 }
203
204 return result;
205}
206
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
HepLorentzRotation & rotateY(double delta)
HepLorentzRotation & rotateZ(double delta)
HepLorentzRotation inverse() const
double theta() const
Hep3Vector vect() const
value_type & Get() const
Definition: G4Cache.hh:315
G4ReactionProduct * SampleOne(G4double anEnergy)
G4ReactionProductVector * Sample(G4double anEnergy)
G4ReactionProductVector * Sample(G4double anEnergy, G4int nParticles)
G4double MeanEnergyOfThisInteraction()
G4int GetMultiplicity(G4double anEnergy)
void SetMomentum(const G4double x, const G4double y, const G4double z)
void SetTotalEnergy(const G4double en)
G4double GetTotalEnergy() const
G4ThreeVector GetMomentum() const
void Lorentz(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
void SetMass(const G4double mas)