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 // 26 // 27 // WARNING : This class is released as a proto 27 // WARNING : This class is released as a prototype. 28 // It might strongly evolve or even disapear i 28 // It might strongly evolve or even disapear in the next releases. 29 // 29 // 30 // ------------------------------------------- 30 // ---------------------------------------------------------------------- 31 // GEANT 4 class implementation file 31 // GEANT 4 class implementation file 32 // 32 // 33 // History: first implementation by Alfon 33 // History: first implementation by Alfonso Mantero 4 Mar 2009 34 // 34 // 35 // ------------------------------------------- 35 // ---------------------------------------------------------------- 36 36 37 #include "G4MolecularDissociationTable.hh" 37 #include "G4MolecularDissociationTable.hh" 38 #include "G4MolecularDissociationChannel.hh" 38 #include "G4MolecularDissociationChannel.hh" 39 #include "G4MolecularConfiguration.hh" 39 #include "G4MolecularConfiguration.hh" 40 40 41 using namespace std; 41 using namespace std; 42 using namespace G4DNA; 42 using namespace G4DNA; 43 43 44 //____________________________________________ 44 //______________________________________________________________________________ 45 45 46 G4MolecularDissociationTable::G4MolecularDisso 46 G4MolecularDissociationTable::G4MolecularDissociationTable() 47 = default; << 47 { >> 48 ; >> 49 } 48 50 49 //____________________________________________ 51 //______________________________________________________________________________ 50 52 51 G4MolecularDissociationTable::~G4MolecularDiss 53 G4MolecularDissociationTable::~G4MolecularDissociationTable() 52 { 54 { 53 auto it_map = fDissociationChannels.begin(); << 55 ChannelMap::iterator it_map = fDissociationChannels.begin(); 54 56 55 for (; it_map != fDissociationChannels.end() 57 for (; it_map != fDissociationChannels.end(); it_map++) 56 { 58 { 57 vector<const G4MolecularDissociationChanne 59 vector<const G4MolecularDissociationChannel*>& decayChannels = it_map 58 ->second; 60 ->second; 59 if (!decayChannels.empty()) 61 if (!decayChannels.empty()) 60 { 62 { 61 for (auto & decayChannel : decayChannels << 63 for (int i = 0; i < (int) decayChannels.size(); i++) 62 { 64 { 63 if (decayChannel != nullptr) << 65 if (decayChannels[i]) 64 { 66 { 65 delete decayChannel; << 67 delete decayChannels[i]; 66 decayChannel = nullptr; << 68 decayChannels[i] = 0; 67 } 69 } 68 } 70 } 69 decayChannels.clear(); 71 decayChannels.clear(); 70 } 72 } 71 } 73 } 72 fDissociationChannels.clear(); 74 fDissociationChannels.clear(); 73 } 75 } 74 76 75 //____________________________________________ 77 //______________________________________________________________________________ 76 78 77 G4MolecularDissociationTable:: 79 G4MolecularDissociationTable:: 78 G4MolecularDissociationTable(const G4Molecul 80 G4MolecularDissociationTable(const G4MolecularDissociationTable& right) 79 { 81 { 80 *this = right; 82 *this = right; 81 } 83 } 82 84 83 //____________________________________________ 85 //______________________________________________________________________________ 84 86 85 G4MolecularDissociationTable& 87 G4MolecularDissociationTable& 86 G4MolecularDissociationTable::operator=(const 88 G4MolecularDissociationTable::operator=(const G4MolecularDissociationTable& right) 87 { 89 { 88 if(this == &right) return *this; 90 if(this == &right) return *this; 89 fDissociationChannels = right.fDissociationC 91 fDissociationChannels = right.fDissociationChannels; 90 return *this; 92 return *this; 91 } 93 } 92 94 93 //____________________________________________ 95 //______________________________________________________________________________ 94 96 95 const vector<const G4MolecularDissociationChan 97 const vector<const G4MolecularDissociationChannel*>* 96 G4MolecularDissociationTable:: 98 G4MolecularDissociationTable:: 97 GetDecayChannels(const G4MolecularConfigurat 99 GetDecayChannels(const G4MolecularConfiguration* conf) const 98 { 100 { 99 auto it_exstates = fDissociationChannels.fin << 101 ChannelMap::const_iterator it_exstates = fDissociationChannels.find(conf); 100 if (it_exstates == fDissociationChannels.end << 102 if (it_exstates == fDissociationChannels.end()) return 0; 101 return &(it_exstates->second); 103 return &(it_exstates->second); 102 } 104 } 103 105 104 //____________________________________________ 106 //______________________________________________________________________________ 105 107 106 const vector<const G4MolecularDissociationChan 108 const vector<const G4MolecularDissociationChannel*>* 107 G4MolecularDissociationTable::GetDecayChannels 109 G4MolecularDissociationTable::GetDecayChannels(const G4String& exState) const 108 { 110 { 109 for(const auto & fDissociationChannel : fDis << 111 for(ChannelMap::const_iterator it = fDissociationChannels.begin() ; >> 112 it!=fDissociationChannels.end() ; ++it >> 113 ) 110 { 114 { 111 if(fDissociationChannel.first->GetLabel() << 115 if(it->first->GetLabel() == exState) return &(it->second); 112 } 116 } 113 return nullptr; << 117 return 0; 114 } 118 } 115 119 116 //____________________________________________ 120 //______________________________________________________________________________ 117 121 118 //void G4MolecularDissociationTable:: 122 //void G4MolecularDissociationTable:: 119 // AddExcitedState(const G4String& label, 123 // AddExcitedState(const G4String& label, 120 // const G4MolecularConfigura 124 // const G4MolecularConfiguration* molConf); 121 //{ 125 //{ 122 // 126 // 123 //} 127 //} 124 128 125 //____________________________________________ 129 //______________________________________________________________________________ 126 130 127 void G4MolecularDissociationTable:: 131 void G4MolecularDissociationTable:: 128 AddChannel(const G4MolecularConfiguration* m 132 AddChannel(const G4MolecularConfiguration* molConf, 129 const G4MolecularDissociationChan 133 const G4MolecularDissociationChannel* channel) 130 { 134 { 131 fDissociationChannels[molConf].push_back(cha 135 fDissociationChannels[molConf].push_back(channel); 132 } 136 } 133 137 134 //____________________________________________ 138 //______________________________________________________________________________ 135 139 136 void G4MolecularDissociationTable::CheckDataCo 140 void G4MolecularDissociationTable::CheckDataConsistency() const 137 { 141 { 138 ChannelMap::const_iterator channelsIter; 142 ChannelMap::const_iterator channelsIter; 139 143 140 for(channelsIter = fDissociationChannels.beg 144 for(channelsIter = fDissociationChannels.begin(); 141 channelsIter != fDissociationChannels.en 145 channelsIter != fDissociationChannels.end(); ++channelsIter) 142 { 146 { 143 147 144 const vector<const G4MolecularDissociation 148 const vector<const G4MolecularDissociationChannel*>& decayVect = 145 channelsIter->second; 149 channelsIter->second; 146 G4double sum = 0; 150 G4double sum = 0; 147 151 148 G4double max = decayVect.size(); 152 G4double max = decayVect.size(); 149 153 150 for(size_t i = 0; i < max; i++) 154 for(size_t i = 0; i < max; i++) 151 { 155 { 152 const G4MolecularDissociationChannel* de 156 const G4MolecularDissociationChannel* decay = decayVect[i]; 153 const G4double prob = decay->GetProbabil 157 const G4double prob = decay->GetProbability(); 154 sum += prob; 158 sum += prob; 155 } 159 } 156 160 157 if(sum != 1) 161 if(sum != 1) 158 { 162 { 159 G4ExceptionDescription errMsg; 163 G4ExceptionDescription errMsg; 160 errMsg << "The probabilities for deecita 164 errMsg << "The probabilities for deecitation of molecular configuration " 161 << channelsIter->first->GetName() 165 << channelsIter->first->GetName() 162 << " with label :" << channelsIt 166 << " with label :" << channelsIter->first->GetLabel() 163 << " don't sum up to 1"; 167 << " don't sum up to 1"; 164 G4Exception("G4MolecularDissociationTabl 168 G4Exception("G4MolecularDissociationTable::CheckDataConsistency", 165 "BRANCHING_RATIOS_CONSISTENC 169 "BRANCHING_RATIOS_CONSISTENCY", 166 FatalErrorInArgument, 170 FatalErrorInArgument, 167 errMsg); 171 errMsg); 168 } 172 } 169 } 173 } 170 } 174 } 171 175 172 void G4MolecularDissociationTable::Serialize(s 176 void G4MolecularDissociationTable::Serialize(std::ostream& /*char_traits*/) 173 { 177 { 174 // TODO 178 // TODO 175 } 179 } 176 180