Geant4  10.03
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: G4FissionStore.cc 66241 2012-12-13 18:34:42Z gunter $
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 // 20150608 M. Kelsey -- Label all while loops as terminating.
32 // 20150619 M. Kelsey -- Replace std::exp with G4Exp
33 
34 #include "G4FissionStore.hh"
36 #include "G4Exp.hh"
37 
38 
39 G4FissionStore::G4FissionStore() : verboseLevel(0) {
40  if (verboseLevel > 1)
41  G4cout << " >>> G4FissionStore::G4FissionStore" << G4endl;
42 }
43 
45  G4double ek, G4double ev) {
46  G4FissionConfiguration config(a, z, ez, ek, ev);
47  configurations.push_back(config);
48  if (verboseLevel > 2) G4cout << config << G4endl;
49 }
50 
52  G4double rand) const {
53  if (verboseLevel > 1)
54  G4cout << " >>> G4FissionStore::generateConfiguration" << G4endl;
55 
56  const G4double small = -30.0;
57 
58  G4double totProb = 0.0;
59  configProbs.resize(size(),0.);
60 
61  if (verboseLevel > 3)
62  G4cout << " amax " << amax << " ic " << size() << G4endl;
63 
64  for (size_t i = 0; i < size(); i++) {
65  G4double ez = configurations[i].ezet;
66  G4double pr = ez - amax;
67 
68  if (pr < small) pr = small;
69  pr = G4Exp(pr);
70  if (verboseLevel > 2) {
71  G4cout << configurations[i] << "\n probability " << pr << G4endl;
72  }
73  totProb += pr;
74  configProbs[i] = totProb;
75  };
76 
77  G4double st = totProb * rand;
78 
79  size_t igen = 0;
80  /* Loop checking 08.06.2015 MHK */
81  while (configProbs[igen] <= st && igen < size()) igen++;
82 
83  if (verboseLevel > 3) G4cout << " igen " << igen << G4endl;
84 
85  return configurations[igen];
86 }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
std::vector< G4double > configProbs
std::vector< G4FissionConfiguration > configurations
G4GLOB_DLL std::ostream G4cout
struct config_s config
G4FissionConfiguration generateConfiguration(G4double amax, G4double rand) const
void addConfig(G4double a, G4double z, G4double ez, G4double ek, G4double ev)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
size_t size() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76