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 // G4ParticleChangeForDecay class implementati << 27 // 26 // 28 // Author: Hisaya Kurashige, 23 March 1998 << 27 // $Id: G4ParticleChangeForDecay.cc,v 1.12 2010-07-21 09:30:15 gcosmo Exp $ 29 // ------------------------------------------- << 28 // GEANT4 tag $Name: geant4-09-04-patch-01 $ >> 29 // >> 30 // >> 31 // -------------------------------------------------------------- >> 32 // GEANT 4 class implementation file >> 33 // >> 34 // >> 35 // >> 36 // ------------------------------------------------------------ >> 37 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige >> 38 // Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige >> 39 // -------------------------------------------------------------- 30 40 31 #include "G4ParticleChangeForDecay.hh" 41 #include "G4ParticleChangeForDecay.hh" 32 #include "G4SystemOfUnits.hh" << 33 #include "G4Track.hh" 42 #include "G4Track.hh" 34 #include "G4Step.hh" 43 #include "G4Step.hh" >> 44 #include "G4TrackFastVector.hh" 35 #include "G4DynamicParticle.hh" 45 #include "G4DynamicParticle.hh" 36 #include "G4ExceptionSeverity.hh" 46 #include "G4ExceptionSeverity.hh" 37 47 38 // ------------------------------------------- << 39 G4ParticleChangeForDecay::G4ParticleChangeForD 48 G4ParticleChangeForDecay::G4ParticleChangeForDecay() 40 {} << 49 : G4VParticleChange(), theTimeChange(0.) >> 50 { >> 51 #ifdef G4VERBOSE >> 52 if (verboseLevel>2) { >> 53 G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl; >> 54 } >> 55 #endif >> 56 } >> 57 >> 58 G4ParticleChangeForDecay::~G4ParticleChangeForDecay() >> 59 { >> 60 #ifdef G4VERBOSE >> 61 if (verboseLevel>2) { >> 62 G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl; >> 63 } >> 64 #endif >> 65 } >> 66 >> 67 // copy and assignment operators are implemented as "shallow copy" >> 68 G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right) >> 69 { >> 70 theTimeChange = right.theTimeChange; >> 71 thePolarizationChange = right.thePolarizationChange; >> 72 } >> 73 >> 74 >> 75 G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right) >> 76 { >> 77 if (this != &right){ >> 78 theListOfSecondaries = right.theListOfSecondaries; >> 79 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; >> 80 theNumberOfSecondaries = right.theNumberOfSecondaries; >> 81 theStatusChange = right.theStatusChange; >> 82 theTrueStepLength = right.theTrueStepLength; >> 83 theLocalEnergyDeposit = right.theLocalEnergyDeposit; >> 84 theSteppingControlFlag = right.theSteppingControlFlag; >> 85 >> 86 theTimeChange = right.theTimeChange; >> 87 thePolarizationChange = right.thePolarizationChange; >> 88 } >> 89 return *this; >> 90 } >> 91 >> 92 G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const >> 93 { >> 94 return ((G4VParticleChange *)this == (G4VParticleChange *) &right); >> 95 } >> 96 >> 97 G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const >> 98 { >> 99 return ((G4VParticleChange *)this != (G4VParticleChange *) &right); >> 100 } 41 101 42 // ------------------------------------------- << 102 //---------------------------------------------------------------- >> 103 // methods for Initialization >> 104 // 43 void G4ParticleChangeForDecay::Initialize(cons 105 void G4ParticleChangeForDecay::Initialize(const G4Track& track) 44 { 106 { 45 // use base class's method at first 107 // use base class's method at first 46 G4VParticleChange::Initialize(track); 108 G4VParticleChange::Initialize(track); 47 109 48 // set TimeChange equal to local time of the << 110 const G4DynamicParticle* pParticle = track.GetDynamicParticle(); 49 theLocalTime0 = theTimeChange = track.GetLoc << 50 111 51 // set initial Local/Global time of the pare << 112 // set Time e equal to those of the parent track 52 theGlobalTime0 = track.GetGlobalTime(); << 113 theTimeChange = track.GetGlobalTime(); 53 114 54 // set the Polarization equal to those of th 115 // set the Polarization equal to those of the parent track 55 thePolarizationChange = track.GetDynamicPart << 116 thePolarizationChange = pParticle->GetPolarization(); 56 } 117 } 57 118 58 // ------------------------------------------- << 119 //---------------------------------------------------------------- 59 G4Step* G4ParticleChangeForDecay::UpdateStepFo << 120 // methods for updating G4Step 60 { << 121 // 61 G4StepPoint* pPostStepPoint = pStep->GetPost << 62 << 63 if(isParentWeightProposed) << 64 { << 65 pPostStepPoint->SetWeight(theParentWeight) << 66 } << 67 // update polarization << 68 pPostStepPoint->SetPolarization(thePolarizat << 69 122 70 // update the G4Step specific attributes << 123 G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep) >> 124 { >> 125 // Update the G4Step specific attributes 71 return UpdateStepInfo(pStep); 126 return UpdateStepInfo(pStep); 72 } 127 } 73 128 74 // ------------------------------------------- << 129 75 G4Step* G4ParticleChangeForDecay::UpdateStepFo 130 G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep) 76 { << 131 { 77 // A physics process always calculates the f 132 // A physics process always calculates the final state of the particle 78 133 79 G4StepPoint* pPostStepPoint = pStep->GetPost << 134 G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint(); >> 135 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 80 136 81 // update polarization 137 // update polarization 82 pPostStepPoint->SetPolarization(thePolarizat << 138 pPostStepPoint->SetPolarization( thePolarizationChange ); 83 << 139 84 // update time 140 // update time 85 pPostStepPoint->SetGlobalTime(GetGlobalTime( << 141 pPostStepPoint->SetGlobalTime( theTimeChange ); 86 pPostStepPoint->SetLocalTime(theTimeChange); << 142 pPostStepPoint->AddLocalTime( theTimeChange 87 pPostStepPoint->AddProperTime(theTimeChange << 143 - pPreStepPoint->GetGlobalTime()); >> 144 pPostStepPoint->AddProperTime( theTimeChange >> 145 - pPreStepPoint->GetGlobalTime()); >> 146 88 147 89 #ifdef G4VERBOSE 148 #ifdef G4VERBOSE 90 if(debugFlag) { CheckIt(*theCurrentTrack); } << 149 G4Track* aTrack = pStep->GetTrack(); >> 150 if (debugFlag) CheckIt(*aTrack); 91 #endif 151 #endif 92 152 93 if(isParentWeightProposed) << 153 // Update the G4Step specific attributes 94 pPostStepPoint->SetWeight(theParentWeight) << 95 << 96 // Update the G4Step specific attributes << 97 return UpdateStepInfo(pStep); 154 return UpdateStepInfo(pStep); 98 } 155 } 99 156 100 // ------------------------------------------- << 101 void G4ParticleChangeForDecay::DumpInfo() cons 157 void G4ParticleChangeForDecay::DumpInfo() const 102 { 158 { 103 // Show header << 159 // Show header 104 G4VParticleChange::DumpInfo(); 160 G4VParticleChange::DumpInfo(); 105 161 106 G4long oldprc = G4cout.precision(8); << 162 G4int oldprc = G4cout.precision(3); 107 G4cout << " --------------------------- << 163 G4cout << " Time (ns) : " 108 G4cout << " G4ParticleChangeForDecay prop << 164 << std::setw(20) << theTimeChange/ns << G4endl; 109 G4cout << " Proposed local Time (ns): " < << 110 << theTimeChange / ns << G4endl; << 111 G4cout << " Initial local Time (ns) : " < << 112 << theLocalTime0 / ns << G4endl; << 113 G4cout << " Initial global Time (ns): " < << 114 << theGlobalTime0 / ns << G4endl; << 115 G4cout << " Current global Time (ns): " < << 116 << theCurrentTrack->GetGlobalTime() / << 117 G4cout.precision(oldprc); 165 G4cout.precision(oldprc); 118 } 166 } 119 167 120 // ------------------------------------------- << 121 G4bool G4ParticleChangeForDecay::CheckIt(const 168 G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack) 122 { 169 { 123 // local time should not go back << 170 G4bool exitWithError = false; 124 G4bool itsOK = true; << 171 125 if(theTimeChange < theLocalTime0) << 172 G4double accuracy; 126 { << 173 127 itsOK = false; << 174 // global time should not go back 128 ++nError; << 175 G4bool itsOK =true; >> 176 accuracy = -1.0*(theTimeChange - aTrack.GetGlobalTime())/ns; >> 177 if (accuracy > accuracyForWarning) { 129 #ifdef G4VERBOSE 178 #ifdef G4VERBOSE 130 if(nError < maxError) << 179 G4cout << " G4ParticleChangeForDecay::CheckIt : "; 131 { << 180 G4cout << "the global time goes back !!" << G4endl; 132 G4cout << " G4ParticleChangeForDecay::C << 181 G4cout << " Difference: " << accuracy << "[ns] " <<G4endl; 133 G4cout << "the local time goes back !!" << 134 << " Difference: " << (theTimeChange << 135 << "[ns] " << G4endl; << 136 G4cout << "initial local time " << theLo << 137 << "initial global time " << theGlobalT << 138 << G4endl; << 139 } << 140 #endif 182 #endif 141 theTimeChange = theLocalTime0; << 183 itsOK = false; >> 184 if (accuracy > accuracyForException) exitWithError = true; 142 } 185 } 143 186 144 if(!itsOK) << 187 // dump out information of this particle change 145 { << 146 if(nError < maxError) << 147 { << 148 #ifdef G4VERBOSE 188 #ifdef G4VERBOSE 149 // dump out information of this particle << 189 if (!itsOK) { 150 DumpInfo(); << 190 G4cout << " G4ParticleChangeForDecay::CheckIt " <<G4endl; >> 191 DumpInfo(); >> 192 } 151 #endif 193 #endif 152 G4Exception("G4ParticleChangeForDecay::C << 194 153 JustWarning, "time is illega << 195 // Exit with error 154 } << 196 if (exitWithError) { >> 197 G4Exception("G4ParticleChangeForDecay::CheckIt", >> 198 "500", >> 199 EventMustBeAborted, >> 200 "time was illegal"); >> 201 } >> 202 >> 203 // correction >> 204 if (!itsOK) { >> 205 theTimeChange = aTrack.GetGlobalTime(); 155 } 206 } 156 207 157 return (itsOK) && G4VParticleChange::CheckIt << 208 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); >> 209 return itsOK; 158 } 210 } >> 211 >> 212 >> 213 >> 214 >> 215 159 216