00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "G4MolecularDecayTable.hh"
00039 #include "G4MolecularDecayChannel.hh"
00040
00041 using namespace std;
00042
00043 G4MolecularDecayTable::G4MolecularDecayTable()
00044 {;}
00045
00046 G4MolecularDecayTable::~G4MolecularDecayTable()
00047 {
00048 channelsMap::iterator it_map = fDecayChannelsMap.begin();
00049
00050 for(;it_map != fDecayChannelsMap.end() ; it_map++)
00051 {
00052 vector<const G4MolecularDecayChannel*>& decayChannels = it_map->second;
00053 if(!decayChannels.empty())
00054 {
00055 for(int i = 0 ; i < (int) decayChannels.size() ; i++)
00056 {
00057 if(decayChannels [i])
00058 {
00059 delete decayChannels[i];
00060 decayChannels[i] = 0;
00061 }
00062 }
00063 decayChannels.clear();
00064 }
00065 }
00066 fDecayChannelsMap.clear();
00067 }
00068
00069 G4MolecularDecayTable::G4MolecularDecayTable(const G4MolecularDecayTable& right)
00070 {
00071 *this = right;
00072 }
00073
00074 G4MolecularDecayTable& G4MolecularDecayTable::operator=(const G4MolecularDecayTable& aMolecularDecayTable)
00075 {
00076 fExcitedStatesMap = aMolecularDecayTable.fExcitedStatesMap;
00077 fDecayChannelsMap = channelsMap(aMolecularDecayTable.GetDecayChannelsMap());
00078 return *this;
00079 }
00080
00081 const vector<const G4MolecularDecayChannel*>* G4MolecularDecayTable::GetDecayChannels(const G4ElectronOccupancy* conf) const
00082 {
00083 statesMap::const_iterator it_exstates = fExcitedStatesMap.find(*conf);
00084 if(it_exstates == fExcitedStatesMap.end()) return 0;
00085 channelsMap::const_iterator it_decchannel = fDecayChannelsMap.find(it_exstates->second) ;
00086 if(it_decchannel == fDecayChannelsMap.end()) return 0;
00087 return &(it_decchannel->second);
00088 }
00089
00090 const vector<const G4MolecularDecayChannel*>* G4MolecularDecayTable::GetDecayChannels(const G4String& exState) const
00091 {
00092 channelsMap::const_iterator it_decchannel = fDecayChannelsMap.find(exState);
00093 if(it_decchannel == fDecayChannelsMap.end()) return 0;
00094 return &(it_decchannel->second);
00095 }
00096
00097 const G4String& G4MolecularDecayTable::GetExcitedState(const G4ElectronOccupancy* conf) const
00098 {
00099 statesMap::const_iterator it_exstates = fExcitedStatesMap.find(*conf);
00100
00101 if(it_exstates == fExcitedStatesMap.end())
00102 {
00103 G4String errMsg = "Excited state not found";
00104 G4Exception("G4MolecularDecayTable::GetExcitedState(const G4ElectronOccupancy*)",
00105 "G4MolecularDecayTable001",FatalErrorInArgument, errMsg);
00106
00107 }
00108
00109 return it_exstates->second;
00110 }
00111
00112 const G4ElectronOccupancy& G4MolecularDecayTable::GetElectronOccupancy(const G4String& exState) const
00113 {
00114 statesMap::const_iterator statesIter;
00115 const G4ElectronOccupancy* conf(0);
00116 for (statesIter=fExcitedStatesMap.begin(); statesIter!=fExcitedStatesMap.end(); statesIter++ )
00117 {
00118 if(exState == statesIter->second) conf = &(statesIter->first);
00119 }
00120
00121 if(statesIter == fExcitedStatesMap.end())
00122 {
00123 G4String errMsg = "Excited state" + exState + " not found";
00124 G4Exception("G4MolecularDecayTable::GetElectronOccupancy(const G4String&)",
00125 "G4MolecularDecayTable002",FatalErrorInArgument, errMsg);
00126 }
00127 return *conf;
00128 }
00129
00130 void G4MolecularDecayTable::AddExcitedState(const G4String& label)
00131 {
00132 channelsMap::iterator channelsIter = fDecayChannelsMap.find(label);
00133 if(channelsIter != fDecayChannelsMap.end())
00134 {
00135 G4String errMsg = "Excited state" + label + " already registered in the decay table.";
00136 G4Exception("G4MolecularDecayTable::AddExcitedState",
00137 "G4MolecularDecayTable003",FatalErrorInArgument, errMsg);
00138 return;
00139 }
00140 fDecayChannelsMap[label] ;
00141 }
00142
00143 void G4MolecularDecayTable::AddeConfToExcitedState(const G4String& label, const G4ElectronOccupancy& conf)
00144 {
00145 statesMap::iterator statesIter = fExcitedStatesMap.find(conf);
00146
00147 if (statesIter == fExcitedStatesMap.end())
00148 {
00149 fExcitedStatesMap[conf] = label;
00150 }
00151 else
00152 {
00153 G4Exception("G4MolecularDecayTable::AddExcitedState","G4MolecularDecayTable004",
00154 FatalErrorInArgument,"Electronic configuration already registered in the decay table");
00155 }
00156 }
00157
00158 void G4MolecularDecayTable::AddDecayChannel(const G4String& label, const G4MolecularDecayChannel* channel)
00159 {
00160 fDecayChannelsMap[label].push_back(channel);
00161 }
00162
00163 void G4MolecularDecayTable::CheckDataConsistency()
00164 {
00165 channelsMap::iterator channelsIter;
00166
00167
00168
00169 for (channelsIter=fDecayChannelsMap.begin(); channelsIter!=fDecayChannelsMap.end(); channelsIter++ )
00170 {
00171
00172 vector<const G4MolecularDecayChannel*>& decayVect = channelsIter->second;
00173 G4double sum=0;
00174
00175 G4double max = decayVect.size();
00176
00177 for (size_t i=0; i<max; i++)
00178 {
00179 const G4MolecularDecayChannel* decay = decayVect[i];
00180 const G4double prob = decay->GetProbability();
00181 sum += prob;
00182 }
00183
00184 if (sum != 1)
00185 {
00186 G4String errMsg = "Deexcitation Channels probabilities in " + channelsIter->first
00187 + "excited state don't sum up to 1";
00188 G4Exception("G4MolecularDecayTable::CheckDataConsistency",
00189 "G4MolecularDecayTable005",FatalErrorInArgument, errMsg);
00190 }
00191 }
00192
00193 }
00194