Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPInelastic.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// this code implementation is the intellectual property of
27// neutron_hp -- source file
28// J.P. Wellisch, Nov-1996
29// A prototype of the low energy neutron transport model.
30//
31// By copying, distributing or modifying the Program (or any work
32// based on the Program) you indicate your acceptance of this statement,
33// and all its terms.
34//
35//
36// 070523 bug fix for G4FPE_DEBUG on by A. Howard (and T. Koi)
37// 081203 limit maximum trial for creating final states add protection for 1H isotope case by T. Koi
38//
39// P. Arce, June-2014 Conversion neutron_hp to particle_hp
40//
42#include "G4SystemOfUnits.hh"
46#include "G4Threading.hh"
47
84
86 const char* name )
87 : G4HadronicInteraction(name), theInelastic(nullptr), numEle(0)
88 , theProjectile(projectile)
89{
90 G4String baseName;
91 if ( G4FindDataDir("G4PARTICLEHPDATA") ) {
92 baseName = G4FindDataDir( "G4PARTICLEHPDATA" );
93 }
94 //const char* dataDirVariable;
95 G4String particleName;
96 if ( theProjectile == G4Neutron::Neutron() ) {
97 dataDirVariable = "G4NEUTRONHPDATA";
98 } else if( theProjectile == G4Proton::Proton() ) {
99 dataDirVariable = "G4PROTONHPDATA";
100 particleName = "Proton";
101 } else if( theProjectile == G4Deuteron::Deuteron() ) {
102 dataDirVariable = "G4DEUTERONHPDATA";
103 particleName = "Deuteron";
104 } else if( theProjectile == G4Triton::Triton() ) {
105 dataDirVariable = "G4TRITONHPDATA";
106 particleName = "Triton";
107 } else if( theProjectile == G4He3::He3() ) {
108 dataDirVariable = "G4HE3HPDATA";
109 particleName = "He3";
110 } else if( theProjectile == G4Alpha::Alpha() ) {
111 dataDirVariable = "G4ALPHAHPDATA";
112 particleName = "Alpha";
113 } else {
114 G4String message("G4ParticleHPInelastic may only be called for neutron, proton, deuteron, triton, He3 or alpha, while it is called for " + theProjectile->GetParticleName());
115 throw G4HadronicException(__FILE__, __LINE__,message.c_str());
116 }
117
118 SetMinEnergy( 0.0 );
119 SetMaxEnergy( 20.*MeV );
120
121 //G4cout << " entering G4ParticleHPInelastic constructor"<<G4endl;
122 if ( !G4FindDataDir("G4PARTICLEHPDATA") && !G4FindDataDir(dataDirVariable) ) {
123 G4String message("Please setenv G4PARTICLEHPDATA (recommended) or, at least setenv " +
124 G4String(dataDirVariable) + " to point to the " + theProjectile->GetParticleName() + " cross-section files." );
125 throw G4HadronicException(__FILE__, __LINE__,message.c_str());
126 }
129 } else {
130 dirName = baseName + "/" + particleName;
131 }
132
133#ifdef G4VERBOSE
135#endif
136
137 G4String tString = "/Inelastic";
138 dirName = dirName + tString;
139
140#ifdef G4VERBOSE
142 G4cout << "@@@ G4ParticleHPInelastic instantiated for particle " << theProjectile->GetParticleName() << " data directory variable is " << dataDirVariable << " pointing to " << dirName << G4endl;
143#endif
144 }
145
147 {
148 //Vector is shared, only master deletes
150 if ( theInelastic != nullptr ) {
151 for ( auto it=theInelastic->cbegin(); it!=theInelastic->cend(); ++it ) {
152 delete *it;
153 }
154 theInelastic->clear();
155 }
156 }
157 }
158
160 {
162 const G4Material * theMaterial = aTrack.GetMaterial();
163 G4int n = (G4int)theMaterial->GetNumberOfElements();
164 std::size_t index = theMaterial->GetElement(0)->GetIndex();
165 G4int it=0;
166 if(n!=1)
167 {
168 G4double* xSec = new G4double[n];
169 G4double sum=0;
170 G4int i;
171 const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
172 G4double rWeight;
173 G4ParticleHPThermalBoost aThermalE;
174 for (i=0; i<n; ++i)
175 {
176 index = theMaterial->GetElement(i)->GetIndex();
177 rWeight = NumAtomsPerVolume[i];
178 if ( aTrack.GetDefinition() == G4Neutron::Neutron() ) {
179 xSec[i] = ((*theInelastic)[index])->GetXsec(aThermalE.GetThermalEnergy(aTrack,
180 theMaterial->GetElement(i),
181 theMaterial->GetTemperature()));
182 } else {
183 xSec[i] = ((*theInelastic)[index])->GetXsec(aTrack.GetKineticEnergy());
184 }
185 xSec[i] *= rWeight;
186 sum+=xSec[i];
187#ifdef G4PHPDEBUG
188 #ifdef G4VERBOSE
189 if( std::getenv("G4ParticleHPDebug") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
190 G4cout << " G4ParticleHPInelastic XSEC ELEM " << i << " = " << xSec[i] << G4endl;
191 #endif
192#endif
193
194 }
195 G4double random = G4UniformRand();
196 G4double running = 0;
197 for (i=0; i<n; ++i)
198 {
199 running += xSec[i];
200 index = theMaterial->GetElement(i)->GetIndex();
201 it = i;
202 //if(random<=running/sum) break;
203 if( sum == 0 || random<=running/sum) break;
204 }
205 delete [] xSec;
206 }
207
208#ifdef G4PHPDEBUG
209 #ifdef G4VERBOSE
210 if( std::getenv("G4ParticleHPDebug") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
211 G4cout << " G4ParticleHPInelastic SELECTED ELEM " << it << " = " << theMaterial->GetElement(it)->GetName() << " FROM MATERIAL " << theMaterial->GetName() << G4endl;
212 #endif
213#endif
214 //return theInelastic[index].ApplyYourself(theMaterial->GetElement(it), aTrack);
215 G4HadFinalState* result = ((*theInelastic)[index])->ApplyYourself(theMaterial->GetElement(it), aTrack);
216 //
218 const G4Element* target_element = (*G4Element::GetElementTable())[index];
219 const G4Isotope* target_isotope = nullptr;
220 G4int iele = (G4int)target_element->GetNumberOfIsotopes();
221 for ( G4int j = 0 ; j != iele ; ++j ) {
222 target_isotope=target_element->GetIsotope( j );
223 if ( target_isotope->GetN() == G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA() ) break;
224 }
225 aNucleus.SetIsotope( target_isotope );
226
228
229 return result;
230 }
231
232const std::pair<G4double, G4double> G4ParticleHPInelastic::GetFatalEnergyCheckLevels() const
233{
234 // max energy non-conservation is mass of heavy nucleus
235 return std::pair<G4double, G4double>(10.0*perCent, 350.0*CLHEP::GeV);
236}
237
239{
241}
243{
245}
246
248
250
251 theInelastic = hpmanager->GetInelasticFinalStates( &projectile );
252
254
255 if ( theInelastic == nullptr ) theInelastic = new std::vector<G4ParticleHPChannelList*>;
256
257 if ( numEle == (G4int)G4Element::GetNumberOfElements() ) return;
258
259 if ( theInelastic->size() == G4Element::GetNumberOfElements() ) {
261 return;
262 }
263#ifdef G4VERBOSE
265 hpmanager->DumpSetting();
266 G4cout << "@@@ G4ParticleHPInelastic instantiated for particle " << projectile.GetParticleName() << " data directory variable is " << dataDirVariable << " pointing to " << dirName << G4endl;
267 }
268#endif
269 for (G4int i = numEle ; i < (G4int)G4Element::GetNumberOfElements(); ++i)
270 {
271 theInelastic->push_back( new G4ParticleHPChannelList );
272 ((*theInelastic)[i])->Init((*(G4Element::GetElementTable()))[i], dirName, const_cast<G4ParticleDefinition*>(&projectile));
273 G4int itry = 0;
274 do
275 {
276 ((*theInelastic)[i])->Register( new G4ParticleHPNInelasticFS , "F01"); // has
277 ((*theInelastic)[i])->Register( new G4ParticleHPNXInelasticFS , "F02");
278 ((*theInelastic)[i])->Register( new G4ParticleHP2NDInelasticFS , "F03");
279 ((*theInelastic)[i])->Register( new G4ParticleHP2NInelasticFS , "F04"); // has, E Done
280 ((*theInelastic)[i])->Register( new G4ParticleHP3NInelasticFS , "F05"); // has, E Done
281 ((*theInelastic)[i])->Register( new G4ParticleHPNAInelasticFS , "F06");
282 ((*theInelastic)[i])->Register( new G4ParticleHPN3AInelasticFS , "F07");
283 ((*theInelastic)[i])->Register( new G4ParticleHP2NAInelasticFS , "F08");
284 ((*theInelastic)[i])->Register( new G4ParticleHP3NAInelasticFS , "F09");
285 ((*theInelastic)[i])->Register( new G4ParticleHPNPInelasticFS , "F10");
286 ((*theInelastic)[i])->Register( new G4ParticleHPN2AInelasticFS , "F11");
287 ((*theInelastic)[i])->Register( new G4ParticleHP2N2AInelasticFS , "F12");
288 ((*theInelastic)[i])->Register( new G4ParticleHPNDInelasticFS , "F13");
289 ((*theInelastic)[i])->Register( new G4ParticleHPNTInelasticFS , "F14");
290 ((*theInelastic)[i])->Register( new G4ParticleHPNHe3InelasticFS , "F15");
291 ((*theInelastic)[i])->Register( new G4ParticleHPND2AInelasticFS , "F16");
292 ((*theInelastic)[i])->Register( new G4ParticleHPNT2AInelasticFS , "F17");
293 ((*theInelastic)[i])->Register( new G4ParticleHP4NInelasticFS , "F18"); // has, E Done
294 ((*theInelastic)[i])->Register( new G4ParticleHP2NPInelasticFS , "F19");
295 ((*theInelastic)[i])->Register( new G4ParticleHP3NPInelasticFS , "F20");
296 ((*theInelastic)[i])->Register( new G4ParticleHPN2PInelasticFS , "F21");
297 ((*theInelastic)[i])->Register( new G4ParticleHPNPAInelasticFS , "F22");
298 ((*theInelastic)[i])->Register( new G4ParticleHPPInelasticFS , "F23");
299 ((*theInelastic)[i])->Register( new G4ParticleHPDInelasticFS , "F24");
300 ((*theInelastic)[i])->Register( new G4ParticleHPTInelasticFS , "F25");
301 ((*theInelastic)[i])->Register( new G4ParticleHPHe3InelasticFS , "F26");
302 ((*theInelastic)[i])->Register( new G4ParticleHPAInelasticFS , "F27");
303 ((*theInelastic)[i])->Register( new G4ParticleHP2AInelasticFS , "F28");
304 ((*theInelastic)[i])->Register( new G4ParticleHP3AInelasticFS , "F29");
305 ((*theInelastic)[i])->Register( new G4ParticleHP2PInelasticFS , "F30");
306 ((*theInelastic)[i])->Register( new G4ParticleHPPAInelasticFS , "F31");
307 ((*theInelastic)[i])->Register( new G4ParticleHPD2AInelasticFS , "F32");
308 ((*theInelastic)[i])->Register( new G4ParticleHPT2AInelasticFS , "F33");
309 ((*theInelastic)[i])->Register( new G4ParticleHPPDInelasticFS , "F34");
310 ((*theInelastic)[i])->Register( new G4ParticleHPPTInelasticFS , "F35");
311 ((*theInelastic)[i])->Register( new G4ParticleHPDAInelasticFS , "F36");
312 ((*theInelastic)[i])->RestartRegistration();
313 itry++;
314 }
315 while( !((*theInelastic)[i])->HasDataInAnyFinalState() && itry < 6 ); // Loop checking, 11.05.2015, T. Koi
316 // 6 is corresponding to the value(5) of G4ParticleHPChannel. TK
317
318 if ( itry == 6 ) {
319 // No Final State at all.
320#ifdef G4VERBOSE
323 G4cout << "ParticleHP::Inelastic for " << projectile.GetParticleName() << ". Do not know what to do with element of \"" << (*(G4Element::GetElementTable()))[i]->GetName() << "\"." << G4endl;
324 G4cout << "The components of the element are" << G4endl;
325 for ( G4int ii = 0 ; ii < (G4int)( (*(G4Element::GetElementTable()))[i]->GetNumberOfIsotopes() ) ; ++ii ) {
326 G4cout << " Z: " << (*(G4Element::GetElementTable()))[i]->GetIsotope( ii )->GetZ() << ", A: " << (*(G4Element::GetElementTable()))[i]->GetIsotope( ii )->GetN() << G4endl;
327 }
328 G4cout << "No possible final state data of the element is found in " << dataDirVariable << "." << G4endl;
329 }
330#endif
331 }
332 }
333 hpmanager->RegisterInelasticFinalStates( &projectile , theInelastic );
334 }
336}
337
338void G4ParticleHPInelastic::ModelDescription(std::ostream& outFile) const
339{
340 outFile << "Extension of High Precision model for inelastic reaction of proton,\n"
341 << "deuteron, triton, He3 and alpha below 20MeV\n";
342}
const char * G4FindDataDir(const char *)
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
static G4Alpha * Alpha()
Definition: G4Alpha.cc:88
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:93
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:403
static size_t GetNumberOfElements()
Definition: G4Element.cc:410
const G4Isotope * GetIsotope(G4int iso) const
Definition: G4Element.hh:170
size_t GetIndex() const
Definition: G4Element.hh:182
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:159
const G4String & GetName() const
Definition: G4Element.hh:127
const G4Material * GetMaterial() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
void SetMinEnergy(G4double anEnergy)
void SetMaxEnergy(const G4double anEnergy)
static G4HadronicParameters * Instance()
static G4He3 * He3()
Definition: G4He3.cc:93
G4int GetN() const
Definition: G4Isotope.hh:93
G4double GetTemperature() const
Definition: G4Material.hh:177
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:197
size_t GetNumberOfElements() const
Definition: G4Material.hh:181
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:201
const G4String & GetName() const
Definition: G4Material.hh:172
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103
void SetParameters(const G4double A, const G4double Z, const G4int numberOfLambdas=0)
Definition: G4Nucleus.cc:307
void SetIsotope(const G4Isotope *iso)
Definition: G4Nucleus.hh:114
const G4String & GetParticleName() const
G4ParticleHPInelastic(G4ParticleDefinition *projectile=G4Neutron::Neutron(), const char *name="NeutronHPInelastic")
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &aTargetNucleus)
void BuildPhysicsTable(const G4ParticleDefinition &)
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
std::vector< G4ParticleHPChannelList * > * theInelastic
virtual void ModelDescription(std::ostream &outFile) const
std::vector< G4ParticleHPChannelList * > * GetInelasticFinalStates(const G4ParticleDefinition *)
void RegisterInelasticFinalStates(const G4ParticleDefinition *, std::vector< G4ParticleHPChannelList * > *)
static G4ParticleHPManager * GetInstance()
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
G4double GetThermalEnergy(const G4HadProjectile &aP, const G4Element *anE, G4double aT)
static G4Proton * Proton()
Definition: G4Proton.cc:92
static G4Triton * Triton()
Definition: G4Triton.cc:93
G4bool IsWorkerThread()
Definition: G4Threading.cc:123
G4bool IsMasterThread()
Definition: G4Threading.cc:124