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