LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ArParticleHPCapture.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 // neutron_hp -- source file
27 // J.P. Wellisch, Nov-1996
28 // A prototype of the low energy neutron transport model.
29 //
30 // 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi)
31 //
32 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
33 //
34 
35 // -- artg4tk includes
38 
39 #include "Geant4/G4IonTable.hh"
40 #include "Geant4/G4ParticleHPCapture.hh"
41 #include "Geant4/G4ParticleHPDeExGammas.hh"
42 #include "Geant4/G4ParticleHPManager.hh"
43 #include "Geant4/G4ParticleTable.hh"
44 #include "Geant4/G4SystemOfUnits.hh"
45 #include "Geant4/G4Threading.hh"
46 
48  : G4HadronicInteraction("NeutronHPCapture"), theCapture(NULL), numEle(0)
49 {
50  SetMinEnergy(0.0);
51  SetMaxEnergy(20. * MeV);
52 }
53 
55 {
56  if (!G4Threading::IsWorkerThread()) {
57  if (theCapture != NULL) {
59  ite != theCapture->end();
60  ite++) {
61  delete *ite;
62  }
63  theCapture->clear();
64  }
65  }
66 }
67 
68 #include "Geant4/G4ParticleHPThermalBoost.hh"
69 G4HadFinalState*
70 ArParticleHPCapture::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& aNucleus)
71 {
72  G4ParticleHPManager::GetInstance()->OpenReactionWhiteBoard();
73  if (std::getenv("NeutronHPCapture"))
74  G4cout << " ####### ArParticleHPCapture called" << G4endl;
75  const G4Material* theMaterial = aTrack.GetMaterial();
76  G4int n = theMaterial->GetNumberOfElements();
77  G4int index = theMaterial->GetElement(0)->GetIndex();
78  if (n != 1) {
79  G4double* xSec = new G4double[n];
80  G4double sum = 0;
81  G4int i;
82  const G4double* NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
83  G4double rWeight;
84  G4ParticleHPThermalBoost aThermalE;
85  for (i = 0; i < n; i++) {
86  index = theMaterial->GetElement(i)->GetIndex();
87  rWeight = NumAtomsPerVolume[i];
88  xSec[i] = ((*theCapture)[index])
89  ->GetXsec(aThermalE.GetThermalEnergy(
90  aTrack, theMaterial->GetElement(i), theMaterial->GetTemperature()));
91  xSec[i] *= rWeight;
92  sum += xSec[i];
93  }
94  G4double random = G4UniformRand();
95  G4double running = 0;
96  for (i = 0; i < n; i++) {
97  running += xSec[i];
98  index = theMaterial->GetElement(i)->GetIndex();
99  if (sum == 0 || random <= running / sum)
100  break;
101  }
102  if (i == n)
103  i = std::max(0, n - 1);
104  delete[] xSec;
105  }
106 
107  G4HadFinalState* result = ((*theCapture)[index])->ApplyYourself(aTrack);
108 
109  // Overwrite target parameters
110  aNucleus.SetParameters(G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA(),
111  G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargZ());
112  const G4Element* target_element = (*G4Element::GetElementTable())[index];
113  const G4Isotope* target_isotope = NULL;
114  G4int iele = target_element->GetNumberOfIsotopes();
115  for (G4int j = 0; j != iele; j++) {
116  target_isotope = target_element->GetIsotope(j);
117  if (target_isotope->GetN() ==
118  G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA())
119  break;
120  }
121  aNucleus.SetIsotope(target_isotope);
122 
123  G4ParticleHPManager::GetInstance()->CloseReactionWhiteBoard();
124  return result;
125 }
126 
127 const std::pair<G4double, G4double>
129 {
130  return std::pair<G4double, G4double>(10 * perCent, DBL_MAX);
131 }
132 
133 G4int
135 {
136  return G4ParticleHPManager::GetInstance()->GetVerboseLevel();
137 }
138 void
140 {
141  G4ParticleHPManager::GetInstance()->SetVerboseLevel(newValue);
142 }
143 
144 void
145 ArParticleHPCapture::BuildPhysicsTable(const G4ParticleDefinition&)
146 {
147 
148  G4ParticleHPManager* hpmanager = G4ParticleHPManager::GetInstance();
149 
150  theCapture = hpmanager->GetCaptureFinalStates();
151 
152  if (G4Threading::IsMasterThread()) {
153 
154  if (theCapture == NULL)
155  theCapture = new std::vector<G4ParticleHPChannel*>;
156 
157  if (numEle == (G4int)G4Element::GetNumberOfElements())
158  return;
159 
160  if (theCapture->size() == G4Element::GetNumberOfElements()) {
161  numEle = G4Element::GetNumberOfElements();
162  return;
163  }
164 
165  if (!std::getenv("G4NEUTRONHPDATA"))
166  throw G4HadronicException(
167  __FILE__,
168  __LINE__,
169  "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
170  dirName = std::getenv("G4NEUTRONHPDATA");
171  G4String tString = "/Capture";
172  dirName = dirName + tString;
173 
174  G4ParticleHPCaptureFS* theFS = new G4ParticleHPCaptureFS;
176  for (G4int i = numEle; i < (G4int)G4Element::GetNumberOfElements(); i++) {
177  theCapture->push_back(new G4ParticleHPChannel);
178  ((*theCapture)[i])->Init((*(G4Element::GetElementTable()))[i], dirName);
179  if ((*(G4Element::GetElementTable()))[i]->GetZ() == 18) {
180  ((*theCapture)[i])->Register(theArFS);
181  std::cout << "======= use new Argon Capture =======" << std::endl; // Jingbo Wang
182  } else
183  ((*theCapture)[i])->Register(theFS);
184  }
185  delete theFS;
186  delete theArFS;
187  hpmanager->RegisterCaptureFinalStates(theCapture);
188  }
189  numEle = G4Element::GetNumberOfElements();
190 }
191 
192 void
193 ArParticleHPCapture::ModelDescription(std::ostream& outFile) const
194 {
195  outFile << "High Precision model based on Evaluated Nuclear Data Files (ENDF) for radiative "
196  "capture reaction of neutrons below 20MeV\n";
197 }
intermediate_table::iterator iterator
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &aTargetNucleus) override
std::vector< G4ParticleHPChannel * > * theCapture
G4int GetVerboseLevel() const
const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const override
void BuildPhysicsTable(const G4ParticleDefinition &) override
void ModelDescription(std::ostream &outFile) const override
Char_t n[5]
Double_t sum
Definition: plot.C:31