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 //--------------------------------------------------------------------------- 27 // 28 // 28 // GEANT4 Class file 29 // GEANT4 Class file 29 // 30 // 30 // Description: Data structure for cross secti 31 // Description: Data structure for cross sections, shell cross sections 31 // isotope cross sections 32 // isotope cross sections 32 // 33 // 33 // Author: V.Ivanchenko 10.03.2011 34 // Author: V.Ivanchenko 10.03.2011 34 // 35 // 35 // Modifications: 36 // Modifications: 36 // 37 // 37 //-------------------------------------------- 38 //---------------------------------------------------------------------------- >> 39 // >> 40 >> 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 38 42 39 #include "G4ElementData.hh" 43 #include "G4ElementData.hh" 40 #include "G4ElementDataRegistry.hh" << 41 44 42 G4ElementData::G4ElementData(G4int length) << 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 : maxNumElm(length) << 46 >> 47 G4ElementData::G4ElementData() 44 { 48 { 45 elmData.resize(maxNumElm, nullptr); << 49 for(G4int i=0; i<maxNumElm; ++i) { 46 G4ElementDataRegistry::Instance()->RegisterM << 50 elmData[i] = nullptr; >> 51 elm2Data[i] = nullptr; >> 52 compLength[i] = 0; >> 53 compData[i] = nullptr; >> 54 compID[i] = nullptr; >> 55 } 47 } 56 } 48 57 >> 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 59 49 G4ElementData::~G4ElementData() 60 G4ElementData::~G4ElementData() 50 { 61 { 51 for (auto const & p : elmData) { delete p; } << 62 for(G4int i=0; i<maxNumElm; ++i) { 52 for (auto const & p : elm2Data) { delete p; << 63 delete elmData[i]; 53 for (auto const & p : compData) { << 64 delete elm2Data[i]; 54 if (nullptr != p ) { << 65 if(nullptr != compID[i]) { 55 for (auto const & q : *p) { delete q.sec << 66 for(size_t j=0; j<compID[i]->size(); ++j) { 56 delete p; << 67 delete (*(compData[i]))[j]; >> 68 } >> 69 delete compID[i]; >> 70 delete compData[i]; 57 } 71 } 58 } 72 } 59 for (auto const & p : comp2D) { << 60 if (nullptr != p ) { << 61 for (auto const & q : *p) { delete q.sec << 62 delete p; << 63 } << 64 } << 65 G4ElementDataRegistry::Instance()->RemoveMe( << 66 } 73 } 67 74 68 void G4ElementData::InitialiseForElement(G4int 75 void G4ElementData::InitialiseForElement(G4int Z, G4PhysicsVector* v) 69 { 76 { 70 if (Z < 0 || Z >= maxNumElm) { << 77 if(Z < 1 || Z >= maxNumElm) { 71 DataError(Z, "InitialiseForElement"); << 78 G4cout << "G4ElementData::InitialiseForElement ERROR for " << name >> 79 << " Z = " << Z << " is out of range!" << G4endl; >> 80 G4Exception("G4ElementData::InitialiseForElement()", "mat601", >> 81 FatalException, "Wrong data handling"); 72 return; 82 return; 73 } << 83 } 74 delete elmData[Z]; << 84 if(nullptr != elmData[Z]) { delete elmData[Z]; } 75 elmData[Z] = v; 85 elmData[Z] = v; 76 } 86 } 77 87 78 void G4ElementData::InitialiseForElement(G4int 88 void G4ElementData::InitialiseForElement(G4int Z, G4Physics2DVector* v) 79 { 89 { 80 if (Z < 0 || Z >= maxNumElm) { << 90 if(Z < 1 || Z >= maxNumElm) { 81 DataError(Z, "InitialiseForElement"); << 91 G4cout << "G4ElementData::InitialiseForElement ERROR for " << name >> 92 << " Z = " << Z << " is out of range!" << G4endl; >> 93 G4Exception("G4ElementData::InitialiseForElement()", "mat601", >> 94 FatalException, "Wrong data handling"); 82 return; 95 return; 83 } << 96 } 84 if (0 == elm2Data.size()) { << 97 if(nullptr != elm2Data[Z]) { delete elm2Data[Z]; } 85 elm2Data.resize(maxNumElm, nullptr); << 86 } << 87 delete elm2Data[Z]; << 88 elm2Data[Z] = v; 98 elm2Data[Z] = v; 89 } 99 } 90 100 91 void G4ElementData::InitialiseForComponent(G4i 101 void G4ElementData::InitialiseForComponent(G4int Z, G4int nComponents) 92 { 102 { 93 if (Z < 0 || Z >= maxNumElm) { << 103 if(Z < 1 || Z >= maxNumElm || nComponents < 0) { 94 DataError(Z, "InitialiseForComponent"); << 104 G4cout << "G4ElementData::InitialiseForComponent ERROR for " << name >> 105 << " Z= " << Z << " Ncomp= " << nComponents >> 106 << " is out of range!" << G4endl; >> 107 G4Exception("G4ElementData::InitialiseForComponent()", "mat602", >> 108 FatalException, "Wrong data handling"); 95 return; 109 return; 96 } 110 } 97 if (0 == compData.size()) { << 98 compData.resize(maxNumElm, nullptr); << 99 } << 100 delete compData[Z]; << 101 compData[Z] = new std::vector<std::pair<G4in << 102 if (0 < nComponents) { compData[Z]->reserve( << 103 } << 104 111 105 void G4ElementData::InitialiseFor2DComponent(G << 112 // reserve a new structure 106 { << 113 if(nullptr == compID[Z]) { 107 if (Z < 0 || Z >= maxNumElm) { << 114 compID[Z] = new std::vector<G4int>(); 108 DataError(Z, "InitialiseFor2DComponent"); << 115 compData[Z] = new std::vector<G4PhysicsVector*>(); 109 return; << 116 } 110 } << 117 compID[Z]->resize(nComponents, -1); 111 if (0 == comp2D.size()) { << 118 compData[Z]->resize(nComponents, nullptr); 112 comp2D.resize(maxNumElm, nullptr); << 119 compLength[Z] = 0; 113 } << 114 delete comp2D[Z]; << 115 comp2D[Z] = new std::vector<std::pair<G4int, << 116 if (0 < nComponents) { comp2D[Z]->reserve(nC << 117 } 120 } 118 121 119 void G4ElementData::AddComponent(G4int Z, G4in 122 void G4ElementData::AddComponent(G4int Z, G4int id, G4PhysicsVector* v) 120 { 123 { 121 if (Z < 0 || Z >= maxNumElm) { << 124 if(Z < 1 || Z >= maxNumElm || 122 DataError(Z, "AddComponent"); << 125 (G4int)compID[Z]->size() == compLength[Z]) { 123 return; << 126 G4cout << "G4ElementData::AddComponent ERROR for " << name 124 } << 127 << " Z = " << Z << " is out of range!" << G4endl; 125 if (0 == compData.size()) { << 128 G4Exception("G4ElementData::AddComponent()", "mat603", 126 compData.resize(maxNumElm, nullptr); << 129 FatalException, "Wrong data handling"); 127 } << 128 if (nullptr == compData[Z]) { << 129 compData[Z] = new std::vector<std::pair<G4 << 130 } << 131 compData[Z]->emplace_back(id, v); << 132 } << 133 << 134 void G4ElementData::Add2DComponent(G4int Z, G4 << 135 { << 136 if (Z < 0 || Z >= maxNumElm) { << 137 DataError(Z, "Add2DComponent"); << 138 return; 130 return; 139 } 131 } 140 if (0 == comp2D.size()) { << 132 (*(compData[Z]))[compLength[Z]] = v; 141 compData.resize(maxNumElm, nullptr); << 133 (*(compID[Z]))[compLength[Z]] = id; 142 } << 134 compLength[Z] = compLength[Z] + 1; 143 if (nullptr == comp2D[Z]) { << 144 comp2D[Z] = new std::vector<std::pair<G4in << 145 } << 146 comp2D[Z]->emplace_back(id, v); << 147 } << 148 << 149 void G4ElementData::DataError(G4int Z, const G << 150 { << 151 G4cout << "G4ElementData::" << type << " ERR << 152 << name << "> Z = " << Z << " is out << 153 G4Exception("G4ElementData", "mat603", Fatal << 154 } 135 } 155 136