Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4ParticleChangeForDecay class implementati << 27 // 23 // 28 // Author: Hisaya Kurashige, 23 March 1998 << 24 // $Id: G4ParticleChangeForDecay.cc,v 1.7 2001/08/16 08:17:59 kurasige Exp $ 29 // ------------------------------------------- << 25 // GEANT4 tag $Name: geant4-04-01 $ >> 26 // >> 27 // >> 28 // -------------------------------------------------------------- >> 29 // GEANT 4 class implementation file >> 30 // >> 31 // >> 32 // >> 33 // ------------------------------------------------------------ >> 34 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige >> 35 // Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige >> 36 // -------------------------------------------------------------- 30 37 31 #include "G4ParticleChangeForDecay.hh" 38 #include "G4ParticleChangeForDecay.hh" 32 #include "G4SystemOfUnits.hh" << 33 #include "G4Track.hh" 39 #include "G4Track.hh" 34 #include "G4Step.hh" 40 #include "G4Step.hh" >> 41 #include "G4TrackFastVector.hh" 35 #include "G4DynamicParticle.hh" 42 #include "G4DynamicParticle.hh" 36 #include "G4ExceptionSeverity.hh" << 37 43 38 // ------------------------------------------- << 44 G4ParticleChangeForDecay::G4ParticleChangeForDecay():G4VParticleChange() 39 G4ParticleChangeForDecay::G4ParticleChangeForD << 45 { 40 {} << 46 #ifdef G4VERBOSE >> 47 if (verboseLevel>2) { >> 48 G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl; >> 49 } >> 50 #endif >> 51 } 41 52 42 // ------------------------------------------- << 53 G4ParticleChangeForDecay::~G4ParticleChangeForDecay() 43 void G4ParticleChangeForDecay::Initialize(cons << 44 { 54 { 45 // use base class's method at first << 55 #ifdef G4VERBOSE 46 G4VParticleChange::Initialize(track); << 56 if (verboseLevel>2) { >> 57 G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl; >> 58 } >> 59 #endif >> 60 } 47 61 48 // set TimeChange equal to local time of the << 62 // copy and assignment operators are implemented as "shallow copy" 49 theLocalTime0 = theTimeChange = track.GetLoc << 63 G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right) >> 64 { >> 65 theTimeChange = right.theTimeChange; >> 66 } 50 67 51 // set initial Local/Global time of the pare << 52 theGlobalTime0 = track.GetGlobalTime(); << 53 68 54 // set the Polarization equal to those of th << 69 G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right) 55 thePolarizationChange = track.GetDynamicPart << 70 { >> 71 if (this != &right){ >> 72 theListOfSecondaries = right.theListOfSecondaries; >> 73 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; >> 74 theNumberOfSecondaries = right.theNumberOfSecondaries; >> 75 theStatusChange = right.theStatusChange; >> 76 theTrueStepLength = right.theTrueStepLength; >> 77 theLocalEnergyDeposit = right.theLocalEnergyDeposit; >> 78 theSteppingControlFlag = right.theSteppingControlFlag; >> 79 >> 80 theTimeChange = right.theTimeChange; >> 81 } >> 82 return *this; 56 } 83 } 57 84 58 // ------------------------------------------- << 85 G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const 59 G4Step* G4ParticleChangeForDecay::UpdateStepFo << 60 { 86 { 61 G4StepPoint* pPostStepPoint = pStep->GetPost << 87 return ((G4VParticleChange *)this == (G4VParticleChange *) &right); >> 88 } 62 89 63 if(isParentWeightProposed) << 90 G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const 64 { << 91 { 65 pPostStepPoint->SetWeight(theParentWeight) << 92 return ((G4VParticleChange *)this != (G4VParticleChange *) &right); 66 } << 93 } 67 // update polarization << 68 pPostStepPoint->SetPolarization(thePolarizat << 69 94 70 // update the G4Step specific attributes << 95 //---------------------------------------------------------------- >> 96 // methods for Initialization >> 97 // >> 98 void G4ParticleChangeForDecay::Initialize(const G4Track& track) >> 99 { >> 100 // use base class's method at first >> 101 G4VParticleChange::Initialize(track); >> 102 >> 103 // set Time e equal to those of the parent track >> 104 theTimeChange = track.GetGlobalTime(); >> 105 } >> 106 >> 107 //---------------------------------------------------------------- >> 108 // methods for updating G4Step >> 109 // >> 110 >> 111 G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep) >> 112 { >> 113 // Update the G4Step specific attributes 71 return UpdateStepInfo(pStep); 114 return UpdateStepInfo(pStep); 72 } 115 } 73 116 74 // ------------------------------------------- << 117 75 G4Step* G4ParticleChangeForDecay::UpdateStepFo 118 G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep) 76 { << 119 { 77 // A physics process always calculates the f 120 // A physics process always calculates the final state of the particle 78 121 79 G4StepPoint* pPostStepPoint = pStep->GetPost << 122 G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint(); 80 << 123 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 81 // update polarization << 124 82 pPostStepPoint->SetPolarization(thePolarizat << 83 << 84 // update time 125 // update time 85 pPostStepPoint->SetGlobalTime(GetGlobalTime( << 126 pPostStepPoint->SetGlobalTime( theTimeChange ); 86 pPostStepPoint->SetLocalTime(theTimeChange); << 127 pPostStepPoint->AddLocalTime( theTimeChange 87 pPostStepPoint->AddProperTime(theTimeChange << 128 - pPreStepPoint->GetGlobalTime()); >> 129 pPostStepPoint->AddProperTime( theTimeChange >> 130 - pPreStepPoint->GetGlobalTime()); >> 131 88 132 89 #ifdef G4VERBOSE 133 #ifdef G4VERBOSE 90 if(debugFlag) { CheckIt(*theCurrentTrack); } << 134 G4Track* aTrack = pStep->GetTrack(); >> 135 if (debugFlag) CheckIt(*aTrack); 91 #endif 136 #endif 92 137 93 if(isParentWeightProposed) << 138 // Update the G4Step specific attributes 94 pPostStepPoint->SetWeight(theParentWeight) << 95 << 96 // Update the G4Step specific attributes << 97 return UpdateStepInfo(pStep); 139 return UpdateStepInfo(pStep); 98 } 140 } 99 141 100 // ------------------------------------------- << 101 void G4ParticleChangeForDecay::DumpInfo() cons 142 void G4ParticleChangeForDecay::DumpInfo() const 102 { 143 { 103 // Show header << 144 // Show header 104 G4VParticleChange::DumpInfo(); 145 G4VParticleChange::DumpInfo(); 105 146 106 G4long oldprc = G4cout.precision(8); << 147 G4cout.precision(3); 107 G4cout << " --------------------------- << 148 G4cout << " Time (ns) : " 108 G4cout << " G4ParticleChangeForDecay prop << 149 << G4std::setw(20) << theTimeChange/ns 109 G4cout << " Proposed local Time (ns): " < << 150 << 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 } 151 } 119 152 120 // ------------------------------------------- << 121 G4bool G4ParticleChangeForDecay::CheckIt(const 153 G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack) 122 { 154 { 123 // local time should not go back << 155 G4bool exitWithError = false; 124 G4bool itsOK = true; << 156 125 if(theTimeChange < theLocalTime0) << 157 G4double accuracy; 126 { << 158 127 itsOK = false; << 159 // global time should not go back 128 ++nError; << 160 G4bool itsOK =true; 129 #ifdef G4VERBOSE << 161 accuracy = -1.0*(theTimeChange - aTrack.GetGlobalTime())/ns; 130 if(nError < maxError) << 162 if (accuracy > accuracyForWarning) { 131 { << 163 G4cout << " G4ParticleChangeForDecay::CheckIt : "; 132 G4cout << " G4ParticleChangeForDecay::C << 164 G4cout << "the global time goes back !!" << G4endl; 133 G4cout << "the local time goes back !!" << 165 G4cout << " Difference: " << accuracy << "[ns] " <<G4endl; 134 << " Difference: " << (theTimeChange << 166 itsOK = false; 135 << "[ns] " << G4endl; << 167 if (accuracy > accuracyForException) exitWithError = true; 136 G4cout << "initial local time " << theLo << 137 << "initial global time " << theGlobalT << 138 << G4endl; << 139 } << 140 #endif << 141 theTimeChange = theLocalTime0; << 142 } 168 } 143 169 144 if(!itsOK) << 170 // dump out information of this particle change 145 { << 171 if (!itsOK) { 146 if(nError < maxError) << 172 G4cout << " G4ParticleChangeForDecay::CheckIt " <<G4endl; 147 { << 173 DumpInfo(); 148 #ifdef G4VERBOSE << 149 // dump out information of this particle << 150 DumpInfo(); << 151 #endif << 152 G4Exception("G4ParticleChangeForDecay::C << 153 JustWarning, "time is illega << 154 } << 155 } 174 } 156 175 157 return (itsOK) && G4VParticleChange::CheckIt << 176 // Exit with error >> 177 if (exitWithError) G4Exception("G4ParticleChangeForDecay::CheckIt"); >> 178 >> 179 // correction >> 180 if (!itsOK) { >> 181 theTimeChange = aTrack.GetGlobalTime(); >> 182 } >> 183 >> 184 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); >> 185 return itsOK; 158 } 186 } >> 187 >> 188 >> 189 >> 190 >> 191 159 192