Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MolecularDecayTable.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: G4MolecularDecayTable.cc 65022 2012-11-12 16:43:12Z gcosmo $
27//
28// WARNING : This class is released as a prototype.
29// It might strongly evolve or even disapear in the next releases.
30//
31// ----------------------------------------------------------------------
32// GEANT 4 class implementation file
33//
34// History: first implementation by Alfonso Mantero 4 Mar 2009
35//
36// ----------------------------------------------------------------
37
40
41using namespace std;
42
44{;}
45
47{
48 channelsMap::iterator it_map = fDecayChannelsMap.begin();
49
50 for(;it_map != fDecayChannelsMap.end() ; it_map++)
51 {
52 vector<const G4MolecularDecayChannel*>& decayChannels = it_map->second;
53 if(!decayChannels.empty())
54 {
55 for(int i = 0 ; i < (int) decayChannels.size() ; i++)
56 {
57 if(decayChannels [i])
58 {
59 delete decayChannels[i];
60 decayChannels[i] = 0;
61 }
62 }
63 decayChannels.clear();
64 }
65 }
66 fDecayChannelsMap.clear();
67}
68
70{
71 *this = right;
72}
73
75{
76 fExcitedStatesMap = aMolecularDecayTable.fExcitedStatesMap;
77 fDecayChannelsMap = channelsMap(aMolecularDecayTable.GetDecayChannelsMap());
78 return *this;
79}
80
81const vector<const G4MolecularDecayChannel*>* G4MolecularDecayTable::GetDecayChannels(const G4ElectronOccupancy* conf) const
82{
83 statesMap::const_iterator it_exstates = fExcitedStatesMap.find(*conf);
84 if(it_exstates == fExcitedStatesMap.end()) return 0;
85 channelsMap::const_iterator it_decchannel = fDecayChannelsMap.find(it_exstates->second) ;
86 if(it_decchannel == fDecayChannelsMap.end()) return 0;
87 return &(it_decchannel->second);
88}
89
90const vector<const G4MolecularDecayChannel*>* G4MolecularDecayTable::GetDecayChannels(const G4String& exState) const
91{
92 channelsMap::const_iterator it_decchannel = fDecayChannelsMap.find(exState);
93 if(it_decchannel == fDecayChannelsMap.end()) return 0;
94 return &(it_decchannel->second);
95}
96
98{
99 statesMap::const_iterator it_exstates = fExcitedStatesMap.find(*conf);
100
101 if(it_exstates == fExcitedStatesMap.end())
102 {
103 G4String errMsg = "Excited state not found";
104 G4Exception("G4MolecularDecayTable::GetExcitedState(const G4ElectronOccupancy*)",
105 "G4MolecularDecayTable001",FatalErrorInArgument, errMsg);
106// return *(new G4String("IM FAKE")); // fake return statement
107 }
108
109 return it_exstates->second;
110}
111
113{
114 statesMap::const_iterator statesIter;
115 const G4ElectronOccupancy* conf(0);
116 for (statesIter=fExcitedStatesMap.begin(); statesIter!=fExcitedStatesMap.end(); statesIter++ )
117 {
118 if(exState == statesIter->second) conf = &(statesIter->first);
119 }
120
121 if(statesIter == fExcitedStatesMap.end())
122 {
123 G4String errMsg = "Excited state" + exState + " not found";
124 G4Exception("G4MolecularDecayTable::GetElectronOccupancy(const G4String&)",
125 "G4MolecularDecayTable002",FatalErrorInArgument, errMsg);
126 }
127 return *conf;
128}
129
131{
132 channelsMap::iterator channelsIter = fDecayChannelsMap.find(label);
133 if(channelsIter != fDecayChannelsMap.end())
134 {
135 G4String errMsg = "Excited state" + label + " already registered in the decay table.";
136 G4Exception("G4MolecularDecayTable::AddExcitedState",
137 "G4MolecularDecayTable003",FatalErrorInArgument, errMsg);
138 return;
139 }
140 fDecayChannelsMap[label] ;
141}
142
144{
145 statesMap::iterator statesIter = fExcitedStatesMap.find(conf);
146
147 if (statesIter == fExcitedStatesMap.end())
148 {
149 fExcitedStatesMap[conf] = label;
150 }
151 else
152 {
153 G4Exception("G4MolecularDecayTable::AddExcitedState","G4MolecularDecayTable004",
154 FatalErrorInArgument,"Electronic configuration already registered in the decay table");
155 }
156}
157
159{
160 fDecayChannelsMap[label].push_back(channel);
161}
162
164{
165 channelsMap::iterator channelsIter;
166
167 //Let's check probabilities
168
169 for (channelsIter=fDecayChannelsMap.begin(); channelsIter!=fDecayChannelsMap.end(); channelsIter++ )
170 {
171
172 vector<const G4MolecularDecayChannel*>& decayVect = channelsIter->second;
173 G4double sum=0;
174
175 G4double max = decayVect.size();
176
177 for (size_t i=0; i<max; i++)
178 {
179 const G4MolecularDecayChannel* decay = decayVect[i];
180 const G4double prob = decay->GetProbability();
181 sum += prob;
182 }
183
184 if (sum != 1)
185 {
186 G4String errMsg = "Deexcitation Channels probabilities in " + channelsIter->first
187 + "excited state don't sum up to 1";
188 G4Exception("G4MolecularDecayTable::CheckDataConsistency",
189 "G4MolecularDecayTable005",FatalErrorInArgument, errMsg);
190 }
191 }
192
193}
194
@ FatalErrorInArgument
std::map< G4String, std::vector< const G4MolecularDecayChannel * >, std::less< G4String > > channelsMap
double G4double
Definition: G4Types.hh:64
const channelsMap & GetDecayChannelsMap() const
G4MolecularDecayTable & operator=(const G4MolecularDecayTable &right)
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannels(const G4ElectronOccupancy *) const
const G4String & GetExcitedState(const G4ElectronOccupancy *) const
void AddeConfToExcitedState(const G4String &, const G4ElectronOccupancy &)
void AddDecayChannel(const G4String &, const G4MolecularDecayChannel *)
void AddExcitedState(const G4String &)
const G4ElectronOccupancy & GetElectronOccupancy(const G4String &) const
G4int first(char) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41