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 // 29 // GEANT4 Class file 29 // GEANT4 Class file 30 // 30 // 31 // File name: G4HadDataHandler 31 // File name: G4HadDataHandler 32 // 32 // 33 // Author: V. Ivanchenko 33 // Author: V. Ivanchenko 34 // 34 // 35 // Creation date: 05 July 2022 35 // Creation date: 05 July 2022 36 // 36 // 37 // Modifications: 37 // Modifications: 38 // 38 // 39 // ------------------------------------------- 39 // ------------------------------------------------------------------- 40 // 40 // 41 // 41 // 42 42 43 #include "G4HadDataHandler.hh" 43 #include "G4HadDataHandler.hh" 44 44 45 //....oooOO0OOooo........oooOO0OOooo........oo 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 46 47 G4HadDataHandler::G4HadDataHandler(std::size_t 47 G4HadDataHandler::G4HadDataHandler(std::size_t n) : tLength(n) 48 { 48 { 49 data.resize(n, nullptr); 49 data.resize(n, nullptr); 50 } 50 } 51 51 52 //....oooOO0OOooo........oooOO0OOooo........oo 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 53 54 G4HadDataHandler::~G4HadDataHandler() 54 G4HadDataHandler::~G4HadDataHandler() 55 { 55 { 56 for(std::size_t i=0; i<tLength; ++i) { 56 for(std::size_t i=0; i<tLength; ++i) { 57 for(std::size_t j = i+1; j<tLength; ++j) { 57 for(std::size_t j = i+1; j<tLength; ++j) { 58 if(data[j] == data[i]) { data[j] = nullp 58 if(data[j] == data[i]) { data[j] = nullptr; } 59 } 59 } 60 CleanTable(i); 60 CleanTable(i); 61 } 61 } 62 } 62 } 63 63 64 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 65 66 void G4HadDataHandler::AddTable(G4PhysicsTable 66 void G4HadDataHandler::AddTable(G4PhysicsTable* ptr) 67 { 67 { 68 data.push_back(ptr); 68 data.push_back(ptr); 69 ++tLength; 69 ++tLength; 70 } 70 } 71 71 72 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 73 74 void G4HadDataHandler::UpdateTable(G4PhysicsTa 74 void G4HadDataHandler::UpdateTable(G4PhysicsTable* ptr, std::size_t idx) 75 { 75 { 76 // update table pointer but not delete previ 76 // update table pointer but not delete previous 77 if(idx < tLength) { 77 if(idx < tLength) { 78 if(ptr != data[idx]) { data[idx] = ptr; } 78 if(ptr != data[idx]) { data[idx] = ptr; } 79 } else { 79 } else { 80 G4cout << "### G4HadDataHandler::UpdateTab 80 G4cout << "### G4HadDataHandler::UpdateTable fail for idx=" << idx 81 << " length=" << tLength << G4endl; 81 << " length=" << tLength << G4endl; 82 } 82 } 83 } 83 } 84 84 85 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 86 86 87 void G4HadDataHandler::CleanTable(std::size_t 87 void G4HadDataHandler::CleanTable(std::size_t idx) 88 { 88 { 89 if(idx < tLength && nullptr != data[idx]) { 89 if(idx < tLength && nullptr != data[idx]) { 90 data[idx]->clearAndDestroy(); 90 data[idx]->clearAndDestroy(); 91 delete data[idx]; 91 delete data[idx]; 92 data[idx] = nullptr; 92 data[idx] = nullptr; 93 } 93 } 94 } 94 } 95 95 96 //....oooOO0OOooo........oooOO0OOooo........oo 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 97 97 98 void G4HadDataHandler::SetMasterProcess(const 98 void G4HadDataHandler::SetMasterProcess(const G4VProcess* ptr) 99 { 99 { 100 masterProcess.push_back(ptr); 100 masterProcess.push_back(ptr); 101 } 101 } 102 102 103 //....oooOO0OOooo........oooOO0OOooo........oo 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 104 104 105 const G4VProcess* G4HadDataHandler::GetMasterP 105 const G4VProcess* G4HadDataHandler::GetMasterProcess(const size_t idx) const 106 { 106 { 107 return (idx < masterProcess.size()) ? master 107 return (idx < masterProcess.size()) ? masterProcess[idx] : nullptr; 108 } 108 } 109 109 110 //....oooOO0OOooo........oooOO0OOooo........oo 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111 111