G4MolecularDecayTable.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id: G4MolecularDecayTable.cc 65022 2012-11-12 16:43:12Z gcosmo $
00027 //
00028 // WARNING : This class is released as a prototype.
00029 // It might strongly evolve or even disapear in the next releases.
00030 //
00031 // ----------------------------------------------------------------------
00032 //      GEANT 4 class implementation file
00033 //
00034 //      History: first implementation by Alfonso Mantero 4 Mar 2009
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 //        return *(new G4String("IM FAKE"));  // fake return statement
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     //Let's check probabilities
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 

Generated on Mon May 27 17:48:53 2013 for Geant4 by  doxygen 1.4.7