Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4MolecularDissociationTable.cc 93883 2015-11-03 08:25:04Z gcosmo $ 26 // 27 // 27 // WARNING : This class is released as a proto 28 // WARNING : This class is released as a prototype. 28 // It might strongly evolve or even disapear i 29 // It might strongly evolve or even disapear in the next releases. 29 // 30 // 30 // ------------------------------------------- 31 // ---------------------------------------------------------------------- 31 // GEANT 4 class implementation file 32 // GEANT 4 class implementation file 32 // 33 // 33 // History: first implementation by Alfon 34 // History: first implementation by Alfonso Mantero 4 Mar 2009 34 // 35 // 35 // ------------------------------------------- 36 // ---------------------------------------------------------------- 36 37 37 #include "G4MolecularDissociationTable.hh" 38 #include "G4MolecularDissociationTable.hh" 38 #include "G4MolecularDissociationChannel.hh" 39 #include "G4MolecularDissociationChannel.hh" 39 #include "G4MolecularConfiguration.hh" 40 #include "G4MolecularConfiguration.hh" 40 41 41 using namespace std; 42 using namespace std; 42 using namespace G4DNA; 43 using namespace G4DNA; 43 44 44 //____________________________________________ 45 //______________________________________________________________________________ 45 46 46 G4MolecularDissociationTable::G4MolecularDisso 47 G4MolecularDissociationTable::G4MolecularDissociationTable() 47 = default; << 48 { >> 49 ; >> 50 } 48 51 49 //____________________________________________ 52 //______________________________________________________________________________ 50 53 51 G4MolecularDissociationTable::~G4MolecularDiss 54 G4MolecularDissociationTable::~G4MolecularDissociationTable() 52 { 55 { 53 auto it_map = fDissociationChannels.begin(); << 56 ChannelMap::iterator it_map = fDissociationChannels.begin(); 54 57 55 for (; it_map != fDissociationChannels.end() 58 for (; it_map != fDissociationChannels.end(); it_map++) 56 { 59 { 57 vector<const G4MolecularDissociationChanne 60 vector<const G4MolecularDissociationChannel*>& decayChannels = it_map 58 ->second; 61 ->second; 59 if (!decayChannels.empty()) 62 if (!decayChannels.empty()) 60 { 63 { 61 for (auto & decayChannel : decayChannels << 64 for (int i = 0; i < (int) decayChannels.size(); i++) 62 { 65 { 63 if (decayChannel != nullptr) << 66 if (decayChannels[i]) 64 { 67 { 65 delete decayChannel; << 68 delete decayChannels[i]; 66 decayChannel = nullptr; << 69 decayChannels[i] = 0; 67 } 70 } 68 } 71 } 69 decayChannels.clear(); 72 decayChannels.clear(); 70 } 73 } 71 } 74 } 72 fDissociationChannels.clear(); 75 fDissociationChannels.clear(); 73 } 76 } 74 77 75 //____________________________________________ 78 //______________________________________________________________________________ 76 79 77 G4MolecularDissociationTable:: 80 G4MolecularDissociationTable:: 78 G4MolecularDissociationTable(const G4Molecul 81 G4MolecularDissociationTable(const G4MolecularDissociationTable& right) 79 { 82 { 80 *this = right; 83 *this = right; 81 } 84 } 82 85 83 //____________________________________________ 86 //______________________________________________________________________________ 84 87 85 G4MolecularDissociationTable& 88 G4MolecularDissociationTable& 86 G4MolecularDissociationTable::operator=(const 89 G4MolecularDissociationTable::operator=(const G4MolecularDissociationTable& right) 87 { 90 { 88 if(this == &right) return *this; 91 if(this == &right) return *this; 89 fDissociationChannels = right.fDissociationC 92 fDissociationChannels = right.fDissociationChannels; 90 return *this; 93 return *this; 91 } 94 } 92 95 93 //____________________________________________ 96 //______________________________________________________________________________ 94 97 95 const vector<const G4MolecularDissociationChan 98 const vector<const G4MolecularDissociationChannel*>* 96 G4MolecularDissociationTable:: 99 G4MolecularDissociationTable:: 97 GetDecayChannels(const G4MolecularConfigurat 100 GetDecayChannels(const G4MolecularConfiguration* conf) const 98 { 101 { 99 auto it_exstates = fDissociationChannels.fin << 102 ChannelMap::const_iterator it_exstates = fDissociationChannels.find(conf); 100 if (it_exstates == fDissociationChannels.end << 103 if (it_exstates == fDissociationChannels.end()) return 0; 101 return &(it_exstates->second); 104 return &(it_exstates->second); 102 } 105 } 103 106 104 //____________________________________________ 107 //______________________________________________________________________________ 105 108 106 const vector<const G4MolecularDissociationChan 109 const vector<const G4MolecularDissociationChannel*>* 107 G4MolecularDissociationTable::GetDecayChannels 110 G4MolecularDissociationTable::GetDecayChannels(const G4String& exState) const 108 { 111 { 109 for(const auto & fDissociationChannel : fDis << 112 for(ChannelMap::const_iterator it = fDissociationChannels.begin() ; >> 113 it!=fDissociationChannels.end() ; ++it >> 114 ) 110 { 115 { 111 if(fDissociationChannel.first->GetLabel() << 116 if(it->first->GetLabel() == exState) return &(it->second); 112 } 117 } 113 return nullptr; << 118 return 0; 114 } 119 } 115 120 116 //____________________________________________ 121 //______________________________________________________________________________ 117 122 118 //void G4MolecularDissociationTable:: 123 //void G4MolecularDissociationTable:: 119 // AddExcitedState(const G4String& label, 124 // AddExcitedState(const G4String& label, 120 // const G4MolecularConfigura 125 // const G4MolecularConfiguration* molConf); 121 //{ 126 //{ 122 // 127 // 123 //} 128 //} 124 129 125 //____________________________________________ 130 //______________________________________________________________________________ 126 131 127 void G4MolecularDissociationTable:: 132 void G4MolecularDissociationTable:: 128 AddChannel(const G4MolecularConfiguration* m 133 AddChannel(const G4MolecularConfiguration* molConf, 129 const G4MolecularDissociationChan 134 const G4MolecularDissociationChannel* channel) 130 { 135 { 131 fDissociationChannels[molConf].push_back(cha 136 fDissociationChannels[molConf].push_back(channel); 132 } 137 } 133 138 134 //____________________________________________ 139 //______________________________________________________________________________ 135 140 136 void G4MolecularDissociationTable::CheckDataCo 141 void G4MolecularDissociationTable::CheckDataConsistency() const 137 { 142 { 138 ChannelMap::const_iterator channelsIter; 143 ChannelMap::const_iterator channelsIter; 139 144 140 for(channelsIter = fDissociationChannels.beg 145 for(channelsIter = fDissociationChannels.begin(); 141 channelsIter != fDissociationChannels.en 146 channelsIter != fDissociationChannels.end(); ++channelsIter) 142 { 147 { 143 148 144 const vector<const G4MolecularDissociation 149 const vector<const G4MolecularDissociationChannel*>& decayVect = 145 channelsIter->second; 150 channelsIter->second; 146 G4double sum = 0; 151 G4double sum = 0; 147 152 148 G4double max = decayVect.size(); 153 G4double max = decayVect.size(); 149 154 150 for(size_t i = 0; i < max; i++) 155 for(size_t i = 0; i < max; i++) 151 { 156 { 152 const G4MolecularDissociationChannel* de 157 const G4MolecularDissociationChannel* decay = decayVect[i]; 153 const G4double prob = decay->GetProbabil 158 const G4double prob = decay->GetProbability(); 154 sum += prob; 159 sum += prob; 155 } 160 } 156 161 157 if(sum != 1) 162 if(sum != 1) 158 { 163 { 159 G4ExceptionDescription errMsg; 164 G4ExceptionDescription errMsg; 160 errMsg << "The probabilities for deecita 165 errMsg << "The probabilities for deecitation of molecular configuration " 161 << channelsIter->first->GetName() 166 << channelsIter->first->GetName() 162 << " with label :" << channelsIt 167 << " with label :" << channelsIter->first->GetLabel() 163 << " don't sum up to 1"; 168 << " don't sum up to 1"; 164 G4Exception("G4MolecularDissociationTabl 169 G4Exception("G4MolecularDissociationTable::CheckDataConsistency", 165 "BRANCHING_RATIOS_CONSISTENC 170 "BRANCHING_RATIOS_CONSISTENCY", 166 FatalErrorInArgument, 171 FatalErrorInArgument, 167 errMsg); 172 errMsg); 168 } 173 } 169 } 174 } 170 } 175 } 171 176 172 void G4MolecularDissociationTable::Serialize(s 177 void G4MolecularDissociationTable::Serialize(std::ostream& /*char_traits*/) 173 { 178 { 174 // TODO 179 // TODO 175 } 180 } 176 181