[819] | 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 | // |
---|
| 27 | // Hadronic Process: Nuclear De-excitations |
---|
| 28 | // by V. Lara (Nov 1998) |
---|
| 29 | |
---|
| 30 | #include "G4FermiConfigurationList.hh" |
---|
| 31 | #include "G4FermiSplitter.hh" |
---|
| 32 | #include "G4HadronicException.hh" |
---|
| 33 | |
---|
| 34 | G4FermiFragmentsPool & G4FermiConfigurationList::GetFragmentsPoolInstance() |
---|
| 35 | { |
---|
| 36 | static G4FermiFragmentsPool theFragmentsPool; |
---|
| 37 | return theFragmentsPool; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | G4FermiConfigurationList::G4FermiConfigurationList() |
---|
| 41 | { |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | G4FermiConfigurationList::G4FermiConfigurationList(const G4FermiConfigurationList &) |
---|
| 45 | { |
---|
| 46 | throw G4HadronicException(__FILE__, __LINE__, "G4FermiConfigurationList::copy_constructor meant to not be accessable"); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | const G4FermiConfigurationList & G4FermiConfigurationList:: |
---|
| 51 | operator=(const G4FermiConfigurationList &) |
---|
| 52 | { |
---|
| 53 | throw G4HadronicException(__FILE__, __LINE__, "G4FermiConfigurationList::operator= meant to not be accessable"); |
---|
| 54 | return *this; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | G4bool G4FermiConfigurationList::operator==(const G4FermiConfigurationList &) const |
---|
| 59 | { |
---|
| 60 | return false; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | G4bool G4FermiConfigurationList::operator!=(const G4FermiConfigurationList &) const |
---|
| 64 | { |
---|
| 65 | return true; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | G4bool G4FermiConfigurationList:: |
---|
| 71 | Initialize(const G4int A, const G4int Z, const G4double TotalEnergyRF) |
---|
| 72 | { |
---|
| 73 | // |
---|
| 74 | // let's split nucleus into k = 2,...,A fragments |
---|
| 75 | // |
---|
| 76 | Configurations.clear(); |
---|
| 77 | NormalizedWeights.clear(); |
---|
| 78 | G4FermiSplitter aSplitter(&GetFragmentsPoolInstance()); |
---|
| 79 | G4double NormStatWeight = 0.0; |
---|
| 80 | for (G4int k = 2; k <= A; k++) |
---|
| 81 | { |
---|
| 82 | // Initialize Configuration for k fragments |
---|
| 83 | aSplitter.Initialize(A,Z,k); |
---|
| 84 | for (G4int i = 0; i < aSplitter.GetNumberOfSplits(); i++) |
---|
| 85 | { |
---|
| 86 | // Create a configuration from a split |
---|
| 87 | G4FermiConfiguration * aConfiguration = new G4FermiConfiguration(aSplitter.GetSplit(i)); |
---|
| 88 | |
---|
| 89 | // Store configuration |
---|
| 90 | Configurations.push_back(aConfiguration); |
---|
| 91 | |
---|
| 92 | // Non-Normalized statistical weight for given channel with k fragments |
---|
| 93 | G4double StatWeight = aConfiguration->DecayProbability(A,TotalEnergyRF); |
---|
| 94 | NormStatWeight += StatWeight; |
---|
| 95 | // Statistical weights (it will be normalized...) |
---|
| 96 | NormalizedWeights.push_back(StatWeight); |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | if (NormStatWeight > 0.0) |
---|
| 101 | { |
---|
| 102 | // Let's normalize statistical weights of channels |
---|
| 103 | std::transform(NormalizedWeights.begin(), NormalizedWeights.end(), |
---|
| 104 | NormalizedWeights.begin(), |
---|
| 105 | std::bind2nd(std::divides<G4double>(),NormStatWeight)); |
---|
| 106 | return true; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | return false; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | G4FermiConfiguration G4FermiConfigurationList::ChooseConfiguration(void) |
---|
| 115 | { |
---|
| 116 | G4double RandomWeight = G4UniformRand(); |
---|
| 117 | G4double AcumWeight = 0.0; |
---|
| 118 | std::vector<G4double>::iterator thisConfig; |
---|
| 119 | for (thisConfig = NormalizedWeights.begin(); thisConfig != NormalizedWeights.end(); ++thisConfig) |
---|
| 120 | { |
---|
| 121 | // We are adding the prob. of each configuration |
---|
| 122 | AcumWeight += *thisConfig; |
---|
| 123 | if (AcumWeight >= RandomWeight) break; |
---|
| 124 | } |
---|
| 125 | if (thisConfig == NormalizedWeights.end()) |
---|
| 126 | { |
---|
| 127 | throw G4HadronicException(__FILE__, __LINE__, "G4FermiConfigurationList::ChooseConfigration: Cannot choose a configuration"); |
---|
| 128 | G4FermiConfiguration dummy; |
---|
| 129 | return dummy; |
---|
| 130 | } |
---|
| 131 | else |
---|
| 132 | { |
---|
| 133 | #ifdef G4NO_ISO_VECDIST |
---|
| 134 | std::vector<G4double>::difference_type n = 0; |
---|
| 135 | std::distance(NormalizedWeights.begin(),thisConfig,n); |
---|
| 136 | return *(Configurations[n]); |
---|
| 137 | #else |
---|
| 138 | return *(Configurations[std::distance(NormalizedWeights.begin(),thisConfig)]); |
---|
| 139 | #endif |
---|
| 140 | } |
---|
| 141 | } |
---|