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 // Author: Mathieu Karamitros (kara (AT) cenbg 27 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 28 // 28 // 29 // History: 29 // History: 30 // ----------- 30 // ----------- 31 // 10 Oct 2011 M.Karamitros created 31 // 10 Oct 2011 M.Karamitros created 32 // 32 // 33 // ------------------------------------------- 33 // ------------------------------------------------------------------- 34 34 35 #include "G4ITReactionChange.hh" 35 #include "G4ITReactionChange.hh" 36 36 37 G4ITReactionChange::G4ITReactionChange() << 37 G4ITReactionChange::G4ITReactionChange() : 38 = default; << 38 fSecondaries(0), >> 39 fNumberOfSecondaries(0), >> 40 fKillParents(false), >> 41 fParticleChangeIsSet(false) >> 42 { >> 43 //ctor >> 44 } 39 45 40 G4ITReactionChange::~G4ITReactionChange() 46 G4ITReactionChange::~G4ITReactionChange() 41 { 47 { 42 //dtor 48 //dtor 43 delete fSecondaries; 49 delete fSecondaries; 44 fSecondaries = nullptr; << 50 fSecondaries = 0; 45 } 51 } 46 52 47 // Should not be used 53 // Should not be used 48 G4ITReactionChange::G4ITReactionChange(const G << 54 G4ITReactionChange::G4ITReactionChange(const G4ITReactionChange& /*other*/) : >> 55 fSecondaries(0), >> 56 fNumberOfSecondaries(0), >> 57 fKillParents(false), >> 58 fParticleChangeIsSet(false) 49 { 59 { >> 60 //copy ctor 50 } 61 } 51 62 52 // should not be used 63 // should not be used 53 G4ITReactionChange& G4ITReactionChange::operat 64 G4ITReactionChange& G4ITReactionChange::operator=(const G4ITReactionChange& rhs) 54 { 65 { 55 if (this == &rhs) return *this; // handle se 66 if (this == &rhs) return *this; // handle self assignment 56 //assignment operator 67 //assignment operator 57 return *this; 68 return *this; 58 } 69 } 59 70 60 void G4ITReactionChange::Initialize(const G4Tr 71 void G4ITReactionChange::Initialize(const G4Track& trackA, 61 const G4Tr 72 const G4Track& trackB, 62 G4VParticl 73 G4VParticleChange* particleChangeA, 63 G4VParticl 74 G4VParticleChange* particleChangeB) 64 { 75 { 65 fParticleChange.clear(); 76 fParticleChange.clear(); 66 fParticleChange[&trackA] = particleChangeA; 77 fParticleChange[&trackA] = particleChangeA; 67 fParticleChange[&trackB] = particleChangeB; 78 fParticleChange[&trackB] = particleChangeB; 68 79 69 if ((particleChangeA != nullptr) || (particl << 80 if (particleChangeA || particleChangeB) 70 { 81 { 71 G4bool test = (particleChangeA != nullptr) << 82 G4bool test = particleChangeA && particleChangeB; 72 83 73 if (!test) << 84 if (test == false) 74 { 85 { 75 G4ExceptionDescription exceptionDescript 86 G4ExceptionDescription exceptionDescription; 76 exceptionDescription << "If you give for 87 exceptionDescription << "If you give for one track a particleChange, "; 77 exceptionDescription 88 exceptionDescription 78 << "G4ITReactionChange is expecting 89 << "G4ITReactionChange is expecting that you give for both "; 79 exceptionDescription << "reacting tracks 90 exceptionDescription << "reacting tracks a particleChange."; 80 G4Exception("G4ITReactionChange::Initial 91 G4Exception("G4ITReactionChange::Initialize", "ITReactionChange001", 81 FatalErrorInArgument, except 92 FatalErrorInArgument, exceptionDescription); 82 } 93 } 83 94 84 fParticleChangeIsSet = true; 95 fParticleChangeIsSet = true; 85 96 86 fParticleChange[&trackA]->Initialize(track 97 fParticleChange[&trackA]->Initialize(trackA); 87 fParticleChange[&trackB]->Initialize(track 98 fParticleChange[&trackB]->Initialize(trackB); 88 ; 99 ; 89 100 90 } 101 } 91 102 92 fSecondaries = nullptr; << 103 fSecondaries = 0; 93 fNumberOfSecondaries = 0; 104 fNumberOfSecondaries = 0; 94 fKillParents = false; 105 fKillParents = false; 95 } 106 } 96 107 97 void G4ITReactionChange::AddSecondary(G4Track* 108 void G4ITReactionChange::AddSecondary(G4Track* aTrack) 98 { 109 { 99 if (fSecondaries == nullptr) fSecondaries = << 110 if (fSecondaries == 0) fSecondaries = new std::vector<G4Track*>(); 100 fSecondaries->push_back(aTrack); 111 fSecondaries->push_back(aTrack); 101 fNumberOfSecondaries++; 112 fNumberOfSecondaries++; 102 } 113 } 103 114 104 void G4ITReactionChange::UpdateStepInfo(G4Step 115 void G4ITReactionChange::UpdateStepInfo(G4Step* stepA, G4Step* stepB) 105 { 116 { 106 fParticleChange[stepA->GetTrack()]->UpdateSt 117 fParticleChange[stepA->GetTrack()]->UpdateStepForPostStep(stepA); 107 fParticleChange[stepB->GetTrack()]->UpdateSt 118 fParticleChange[stepB->GetTrack()]->UpdateStepForPostStep(stepB); 108 } 119 } 109 120 110 G4VParticleChange* G4ITReactionChange::GetPart 121 G4VParticleChange* G4ITReactionChange::GetParticleChange(const G4Track* track) 111 { 122 { 112 auto it = fParticleChange << 123 std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange 113 .find(track); 124 .find(track); 114 125 115 if (it == fParticleChange.end()) return null << 126 if (it == fParticleChange.end()) return 0; 116 return it->second; << 127 else return it->second; 117 } 128 } 118 129 119 const G4Track* G4ITReactionChange::GetTrackA() 130 const G4Track* G4ITReactionChange::GetTrackA() 120 { 131 { 121 auto it = fParticleChange.begin(); 132 auto it = fParticleChange.begin(); 122 if (it != fParticleChange.end()) 133 if (it != fParticleChange.end()) 123 { 134 { 124 return it->first; 135 return it->first; 125 } 136 } 126 137 127 G4ExceptionDescription exceptionDescription; 138 G4ExceptionDescription exceptionDescription; 128 exceptionDescription 139 exceptionDescription 129 << "No track A found ! Have you initiali 140 << "No track A found ! Have you initialized the ReactionChange ?"; 130 G4Exception("G4ITReactionChange::GetTrackA", 141 G4Exception("G4ITReactionChange::GetTrackA", "ITReactionChange001", 131 FatalErrorInArgument, exceptionD 142 FatalErrorInArgument, exceptionDescription); 132 return nullptr; << 143 return 0; 133 } 144 } 134 145 135 const G4Track* G4ITReactionChange::GetTrackB() 146 const G4Track* G4ITReactionChange::GetTrackB() 136 { 147 { 137 auto it = fParticleChange.begin(); 148 auto it = fParticleChange.begin(); 138 auto next = it++; 149 auto next = it++; 139 if (next == fParticleChange.end()) 150 if (next == fParticleChange.end()) 140 { 151 { 141 G4ExceptionDescription exceptionDescriptio 152 G4ExceptionDescription exceptionDescription; 142 exceptionDescription 153 exceptionDescription 143 << "No track B found ! Have you initia 154 << "No track B found ! Have you initialized the ReactionChange ?"; 144 G4Exception("G4ITReactionChange::GetTrackB 155 G4Exception("G4ITReactionChange::GetTrackB", "ITReactionChange002", 145 FatalErrorInArgument, exceptio 156 FatalErrorInArgument, exceptionDescription); 146 } 157 } 147 158 148 return it->first; 159 return it->first; 149 } 160 } 150 161