Geant4  10.01.p02
G4MolecularDissociationTable.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: G4MolecularDissociationTable.cc 84858 2014-10-21 16:08:22Z 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 
41 using namespace std;
42 
44 {
45  ;
46 }
47 
49 {
50  channelsMap::iterator it_map = fDecayChannelsMap.begin();
51 
52  for (; it_map != fDecayChannelsMap.end(); it_map++)
53  {
54  vector<const G4MolecularDissociationChannel*>& decayChannels = it_map
55  ->second;
56  if (!decayChannels.empty())
57  {
58  for (int i = 0; i < (int) decayChannels.size(); i++)
59  {
60  if (decayChannels[i])
61  {
62  delete decayChannels[i];
63  decayChannels[i] = 0;
64  }
65  }
66  decayChannels.clear();
67  }
68  }
69  fDecayChannelsMap.clear();
70 }
71 
73 {
74  *this = right;
75 }
76 
78 {
79  fExcitedStatesMap = aMolecularDecayTable.fExcitedStatesMap;
80  fDecayChannelsMap = channelsMap(aMolecularDecayTable.GetDecayChannelsMap());
81  return *this;
82 }
83 
84 const vector<const G4MolecularDissociationChannel*>* G4MolecularDissociationTable::GetDecayChannels(const G4ElectronOccupancy* conf) const
85 {
86  statesMap::const_iterator it_exstates = fExcitedStatesMap.find(*conf);
87  if (it_exstates == fExcitedStatesMap.end()) return 0;
88  channelsMap::const_iterator it_decchannel = fDecayChannelsMap.find(
89  it_exstates->second);
90  if (it_decchannel == fDecayChannelsMap.end()) return 0;
91  return &(it_decchannel->second);
92 }
93 
94 const vector<const G4MolecularDissociationChannel*>* G4MolecularDissociationTable::GetDecayChannels(const G4String& exState) const
95 {
96  channelsMap::const_iterator it_decchannel = fDecayChannelsMap.find(exState);
97  if (it_decchannel == fDecayChannelsMap.end()) return 0;
98  return &(it_decchannel->second);
99 }
100 
102 {
103  statesMap::const_iterator it_exstates = fExcitedStatesMap.find(*conf);
104 
105  if (it_exstates == fExcitedStatesMap.end())
106  {
107  G4String errMsg = "Excited state not found";
108  G4Exception(
109  "G4MolecularDecayTable::GetExcitedState(const G4ElectronOccupancy*)",
110  "G4MolecularDecayTable001", FatalErrorInArgument, errMsg);
111 // return *(new G4String("IM FAKE")); // fake return statement
112  }
113 
114  return it_exstates->second;
115 }
116 
118 {
119  statesMap::const_iterator statesIter;
120  const G4ElectronOccupancy* conf(0);
121  for (statesIter = fExcitedStatesMap.begin();
122  statesIter != fExcitedStatesMap.end(); statesIter++)
123  {
124  if (exState == statesIter->second) conf = &(statesIter->first);
125  }
126 
127  if (statesIter == fExcitedStatesMap.end())
128  {
129  G4String errMsg = "Excited state" + exState + " not found";
130  G4Exception("G4MolecularDecayTable::GetElectronOccupancy(const G4String&)",
131  "G4MolecularDecayTable002", FatalErrorInArgument, errMsg);
132  }
133  return *conf;
134 }
135 
137 {
138  channelsMap::iterator channelsIter = fDecayChannelsMap.find(label);
139  if (channelsIter != fDecayChannelsMap.end())
140  {
141  G4String errMsg = "Excited state" + label
142  + " already registered in the decay table.";
143  G4Exception("G4MolecularDecayTable::AddExcitedState",
144  "G4MolecularDecayTable003", FatalErrorInArgument, errMsg);
145  return;
146  }
147  fDecayChannelsMap[label];
148 }
149 
151  const G4ElectronOccupancy& conf)
152 {
153  statesMap::iterator statesIter = fExcitedStatesMap.find(conf);
154 
155  if (statesIter == fExcitedStatesMap.end())
156  {
157  fExcitedStatesMap[conf] = label;
158  }
159  else
160  {
161  G4Exception(
162  "G4MolecularDecayTable::AddExcitedState", "G4MolecularDecayTable004",
164  "Electronic configuration already registered in the decay table");
165  }
166 }
167 
169  const G4MolecularDissociationChannel* channel)
170 {
171  fDecayChannelsMap[label].push_back(channel);
172 }
173 
175 {
176  channelsMap::iterator channelsIter;
177 
178  //Let's check probabilities
179 
180  for (channelsIter = fDecayChannelsMap.begin();
181  channelsIter != fDecayChannelsMap.end(); channelsIter++)
182  {
183 
184  vector<const G4MolecularDissociationChannel*>& decayVect = channelsIter
185  ->second;
186  G4double sum = 0;
187 
188  G4double max = decayVect.size();
189 
190  for (size_t i = 0; i < max; i++)
191  {
192  const G4MolecularDissociationChannel* decay = decayVect[i];
193  const G4double prob = decay->GetProbability();
194  sum += prob;
195  }
196 
197  if (sum != 1)
198  {
199  G4String errMsg = "Deexcitation Channels probabilities in "
200  + channelsIter->first + "excited state don't sum up to 1";
201  G4Exception("G4MolecularDecayTable::CheckDataConsistency",
202  "G4MolecularDecayTable005", FatalErrorInArgument, errMsg);
203  }
204  }
205 
206 }
207 
G4MolecularDissociationTable & operator=(const G4MolecularDissociationTable &right)
const G4ElectronOccupancy & GetElectronOccupancy(const G4String &) const
G4int first(char) const
const channelsMap & GetDecayChannelsMap() const
Class Description G4MolecularDecayTable operates as a container of deexcitation modes for excited or ...
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannels(const G4ElectronOccupancy *) const
ParticleList decay(Cluster *const c)
Carries out a cluster decay.
std::map< G4String, std::vector< const G4MolecularDissociationChannel * >, std::less< G4String > > channelsMap
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void AddDecayChannel(const G4String &, const G4MolecularDissociationChannel *)
void AddeConfToExcitedState(const G4String &, const G4ElectronOccupancy &)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double G4double
Definition: G4Types.hh:76
const G4String & GetExcitedState(const G4ElectronOccupancy *) const