Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FissionStore.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$
27//
28// 20100728 Move ::addConfig() implementation to .cc file
29// 20110801 Make configuration probs a data member array, reduce memory churn
30// 20110922 Replace config::print() with stream output.
31
32#include "G4FissionStore.hh"
34#include <cmath>
35
36G4FissionStore::G4FissionStore() : verboseLevel(0) {
37 if (verboseLevel > 1)
38 G4cout << " >>> G4FissionStore::G4FissionStore" << G4endl;
39}
40
42 G4double ek, G4double ev) {
43 G4FissionConfiguration config(a, z, ez, ek, ev);
44 configurations.push_back(config);
45 if (verboseLevel > 2) G4cout << config << G4endl;
46}
47
49 G4double rand) const {
50 if (verboseLevel > 1)
51 G4cout << " >>> G4FissionStore::generateConfiguration" << G4endl;
52
53 const G4double small = -30.0;
54
55 G4double totProb = 0.0;
56 configProbs.resize(size(),0.);
57
58 if (verboseLevel > 3)
59 G4cout << " amax " << amax << " ic " << size() << G4endl;
60
61 for (size_t i = 0; i < size(); i++) {
62 G4double ez = configurations[i].ezet;
63 G4double pr = ez - amax;
64
65 if (pr < small) pr = small;
66 pr = std::exp(pr);
67 if (verboseLevel > 2) {
68 G4cout << configurations[i] << "\n probability " << pr << G4endl;
69 }
70 totProb += pr;
71 configProbs[i] = totProb;
72 };
73
74 G4double st = totProb * rand;
75
76 size_t igen = 0;
77 while (configProbs[igen] <= st && igen < size()) igen++;
78
79 if (verboseLevel > 3) G4cout << " igen " << igen << G4endl;
80
81 return configurations[igen];
82}
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
size_t size() const
void addConfig(G4double a, G4double z, G4double ez, G4double ek, G4double ev)
G4FissionConfiguration generateConfiguration(G4double amax, G4double rand) const
struct config_s config