Geant4  10.01.p01
G4DNABornExcitationModel.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 // $Id: G4DNABornExcitationModel.cc 87137 2014-11-25 09:12:48Z gcosmo $
27 //
28 
30 #include "G4SystemOfUnits.hh"
31 #include "G4DNAChemistryManager.hh"
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
35 
36 using namespace std;
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39 
41  const G4String& nam) :
42  G4VEmModel(nam), isInitialised(false)
43 {
44  // nistwater = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
46 
47  verboseLevel = 0;
48  // Verbosity scale:
49  // 0 = nothing
50  // 1 = warning for energy non-conservation
51  // 2 = details of energy budget
52  // 3 = calculation of cross sections, file openings, sampling of atoms
53  // 4 = entering in methods
54 
55  if (verboseLevel > 0)
56  {
57  G4cout << "Born excitation model is constructed " << G4endl;
58  }
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
63 
65 {
66  // Cross section
67 
68  std::map<G4String, G4DNACrossSectionDataSet*, std::less<G4String> >::iterator pos;
69  for (pos = tableData.begin(); pos != tableData.end(); ++pos)
70  {
71  G4DNACrossSectionDataSet* table = pos->second;
72  delete table;
73  }
74 
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78 
80  const G4DataVector& /*cuts*/)
81 {
82 
83  if (verboseLevel > 3)
84  G4cout << "Calling G4DNABornExcitationModel::Initialise()" << G4endl;
85 
86  G4String fileElectron("dna/sigma_excitation_e_born");
87  G4String fileProton("dna/sigma_excitation_p_born");
88 
91 
94 
95  G4double scaleFactor = (1.e-22 / 3.343) * m*m;
96 
97  // *** ELECTRON
98 
99  electron = electronDef->GetParticleName();
100 
101  tableFile[electron] = fileElectron;
102 
103  lowEnergyLimit[electron] = 9. * eV;
104  highEnergyLimit[electron] = 1. * MeV;
105 
106  // Cross section
107 
109  tableE->LoadData(fileElectron);
110 
111  tableData[electron] = tableE;
112 
113  // *** PROTON
114 
115  proton = protonDef->GetParticleName();
116 
117  tableFile[proton] = fileProton;
118 
119  lowEnergyLimit[proton] = 500. * keV;
120  highEnergyLimit[proton] = 100. * MeV;
121 
122  // Cross section
123 
125  tableP->LoadData(fileProton);
126 
127  tableData[proton] = tableP;
128 
129  //
130 
131  if (particle==electronDef)
132  {
135  }
136 
137  if (particle==protonDef)
138  {
141  }
142 
143  if( verboseLevel>0 )
144  {
145  G4cout << "Born excitation model is initialized " << G4endl
146  << "Energy range: "
147  << LowEnergyLimit() / eV << " eV - "
148  << HighEnergyLimit() / keV << " keV for "
149  << particle->GetParticleName()
150  << G4endl;
151  }
152 
153  // Initialize water density pointer
155 
156  if (isInitialised)
157  { return;}
159  isInitialised = true;
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
163 
165  const G4ParticleDefinition* particleDefinition,
166  G4double ekin,
167  G4double,
168  G4double)
169 {
170  if (verboseLevel > 3)
171  G4cout << "Calling CrossSectionPerVolume() of G4DNABornExcitationModel"
172  << G4endl;
173 
174  if (
175  particleDefinition != G4Proton::ProtonDefinition()
176  &&
177  particleDefinition != G4Electron::ElectronDefinition()
178  )
179 
180  return 0;
181 
182  // Calculate total cross section for model
183 
184  G4double lowLim = 0;
185  G4double highLim = 0;
186  G4double sigma=0;
187 
188  G4double waterDensity = (*fpMolWaterDensity)[material->GetIndex()];
189 
190  if(waterDensity!= 0.0)
191  // if (material == nistwater || material->GetBaseMaterial() == nistwater)
192  {
193  const G4String& particleName = particleDefinition->GetParticleName();
194 
195  std::map< G4String,G4double,std::less<G4String> >::iterator pos1;
196  pos1 = lowEnergyLimit.find(particleName);
197  if (pos1 != lowEnergyLimit.end())
198  {
199  lowLim = pos1->second;
200  }
201 
202  std::map< G4String,G4double,std::less<G4String> >::iterator pos2;
203  pos2 = highEnergyLimit.find(particleName);
204  if (pos2 != highEnergyLimit.end())
205  {
206  highLim = pos2->second;
207  }
208 
209  if (ekin >= lowLim && ekin < highLim)
210  {
211  std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos;
212  pos = tableData.find(particleName);
213 
214  if (pos != tableData.end())
215  {
216  G4DNACrossSectionDataSet* table = pos->second;
217  if (table != 0)
218  {
219  sigma = table->FindValue(ekin);
220  }
221  }
222  else
223  {
224  G4Exception("G4DNABornExcitationModel::CrossSectionPerVolume","em0002",
225  FatalException,"Model not applicable to particle type.");
226  }
227  }
228 
229  if (verboseLevel > 2)
230  {
231  G4cout << "__________________________________" << G4endl;
232  G4cout << "=== G4DNABornExcitationModel - XS INFO START" << G4endl;
233  G4cout << "=== Kinetic energy(eV)=" << ekin/eV << " particle : " << particleName << G4endl;
234  G4cout << "=== Cross section per water molecule (cm^2)=" << sigma/cm/cm << G4endl;
235  G4cout << "=== Cross section per water molecule (cm^-1)=" << sigma*waterDensity/(1./cm) << G4endl;
236  // G4cout << " - Cross section per water molecule (cm^-1)=" << sigma*material->GetAtomicNumDensityVector()[1]/(1./cm) << G4endl;
237  G4cout << "=== G4DNABornExcitationModel - XS INFO END" << G4endl;
238  }
239 
240  } // if (waterMaterial)
241 
242  return sigma*waterDensity;
243  // return sigma*material->GetAtomicNumDensityVector()[1];
244 }
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
247 
248 void G4DNABornExcitationModel::SampleSecondaries(std::vector<G4DynamicParticle*>* /*fvect*/,
249  const G4MaterialCutsCouple* /*couple*/,
250  const G4DynamicParticle* aDynamicParticle,
251  G4double,
252  G4double)
253 {
254 
255  if (verboseLevel > 3)
256  G4cout << "Calling SampleSecondaries() of G4DNABornExcitationModel" << G4endl;
257 
258  G4double k = aDynamicParticle->GetKineticEnergy();
259 
260  const G4String& particleName = aDynamicParticle->GetDefinition()->GetParticleName();
261 
262  G4int level = RandomSelect(k,particleName);
263  G4double excitationEnergy = waterStructure.ExcitationEnergy(level);
264  G4double newEnergy = k - excitationEnergy;
265 
266  if (newEnergy > 0)
267  {
271  }
272 
273  const G4Track * theIncomingTrack = fParticleChangeForGamma->GetCurrentTrack();
275  level,
276  theIncomingTrack);
277 }
278 
279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
280 
282  const G4String& particle)
283 {
284  G4int level = 0;
285 
286  std::map<G4String, G4DNACrossSectionDataSet*, std::less<G4String> >::iterator pos;
287  pos = tableData.find(particle);
288 
289  if (pos != tableData.end())
290  {
291  G4DNACrossSectionDataSet* table = pos->second;
292 
293  if (table != 0)
294  {
295  G4double* valuesBuffer = new G4double[table->NumberOfComponents()];
296  const size_t n(table->NumberOfComponents());
297  size_t i(n);
298  G4double value = 0.;
299 
300  while (i > 0)
301  {
302  i--;
303  valuesBuffer[i] = table->GetComponent(i)->FindValue(k);
304  value += valuesBuffer[i];
305  }
306 
307  value *= G4UniformRand();
308 
309  i = n;
310 
311  while (i > 0)
312  {
313  i--;
314 
315  if (valuesBuffer[i] > value)
316  {
317  delete[] valuesBuffer;
318  return i;
319  }
320  value -= valuesBuffer[i];
321  }
322 
323  if (valuesBuffer) delete[] valuesBuffer;
324 
325  }
326  }
327  else
328  {
329  G4Exception("G4DNABornExcitationModel::RandomSelect", "em0002",
330  FatalException, "Model not applicable to particle type.");
331  }
332  return level;
333 }
334 
static const double cm
Definition: G4SIunits.hh:106
static G4Electron * ElectronDefinition()
Definition: G4Electron.cc:89
G4ParticleChangeForGamma * fParticleChangeForGamma
G4double LowEnergyLimit() const
Definition: G4VEmModel.hh:622
static const double MeV
Definition: G4SIunits.hh:193
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
std::map< G4String, G4double, std::less< G4String > > lowEnergyLimit
G4double GetKineticEnergy() const
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:615
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
size_t GetIndex() const
Definition: G4Material.hh:262
static G4Proton * ProtonDefinition()
Definition: G4Proton.cc:88
virtual G4double CrossSectionPerVolume(const G4Material *material, const G4ParticleDefinition *p, G4double ekin, G4double emin, G4double emax)
virtual G4bool LoadData(const G4String &argFileName)
const std::vector< G4double > * fpMolWaterDensity
G4ParticleDefinition * GetDefinition() const
int G4int
Definition: G4Types.hh:78
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
const G4String & GetParticleName() const
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetHighEnergyLimit(G4double)
Definition: G4VEmModel.hh:706
G4DNAWaterExcitationStructure waterStructure
G4DNABornExcitationModel(const G4ParticleDefinition *p=0, const G4String &nam="DNABornExcitationModel")
#define G4UniformRand()
Definition: Randomize.hh:95
G4GLOB_DLL std::ostream G4cout
const std::vector< double > * GetNumMolPerVolTableFor(const G4Material *) const
G4int RandomSelect(G4double energy, const G4String &particle)
const G4ThreeVector & GetMomentumDirection() const
const G4int n
virtual G4double FindValue(G4double e, G4int componentId=0) const
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &=*(new G4DataVector()))
virtual size_t NumberOfComponents(void) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4DNAChemistryManager * Instance()
static const double eV
Definition: G4SIunits.hh:194
static G4DNAMolecularMaterial * Instance()
void CreateWaterMolecule(ElectronicModification, G4int, const G4Track *)
Method used by DNA physics model to create a water molecule.
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
std::map< G4String, G4double, std::less< G4String > > highEnergyLimit
const G4Track * GetCurrentTrack() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:110
static const double keV
Definition: G4SIunits.hh:195
double G4double
Definition: G4Types.hh:76
void SetLowEnergyLimit(G4double)
Definition: G4VEmModel.hh:713
static const G4double pos
G4ParticleChangeForGamma * GetParticleChangeForGamma()
Definition: G4VEmModel.cc:134