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 93028 2015-09-30 16:09:00Z gcosmo $ 29 // ------------------------------------------- << 28 // >> 29 // >> 30 // -------------------------------------------------------------- >> 31 // GEANT 4 class implementation file >> 32 // >> 33 // >> 34 // >> 35 // ------------------------------------------------------------ >> 36 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige >> 37 // Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige >> 38 // -------------------------------------------------------------- 30 39 31 #include "G4ParticleChangeForDecay.hh" 40 #include "G4ParticleChangeForDecay.hh" 32 #include "G4SystemOfUnits.hh" 41 #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(), >> 50 theGlobalTime0(0.),theLocalTime0(0.),theTimeChange(0.) >> 51 { >> 52 #ifdef G4VERBOSE >> 53 if (verboseLevel>2) { >> 54 G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl; >> 55 } >> 56 #endif >> 57 } >> 58 >> 59 G4ParticleChangeForDecay::~G4ParticleChangeForDecay() >> 60 { >> 61 #ifdef G4VERBOSE >> 62 if (verboseLevel>2) { >> 63 G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl; >> 64 } >> 65 #endif >> 66 } 41 67 42 // ------------------------------------------- << 68 G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right) >> 69 { >> 70 theGlobalTime0 = right.theGlobalTime0; >> 71 theLocalTime0 = right.theLocalTime0; >> 72 theTimeChange = right.theTimeChange; >> 73 thePolarizationChange = right.thePolarizationChange; >> 74 } >> 75 >> 76 >> 77 G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right) >> 78 { >> 79 if (this != &right){ >> 80 if (theNumberOfSecondaries>0) { >> 81 #ifdef G4VERBOSE >> 82 if (verboseLevel>0) { >> 83 G4cout << "G4ParticleChangeForDecay: assignment operator Warning "; >> 84 G4cout << "theListOfSecondaries is not empty "; >> 85 } >> 86 #endif >> 87 for (G4int index= 0; index<theNumberOfSecondaries; index++){ >> 88 if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ; >> 89 } >> 90 } >> 91 delete theListOfSecondaries; >> 92 theListOfSecondaries = new G4TrackFastVector(); >> 93 theNumberOfSecondaries = right.theNumberOfSecondaries; >> 94 for (G4int index = 0; index<theNumberOfSecondaries; index++){ >> 95 G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] )); >> 96 theListOfSecondaries->SetElement(index, newTrack); } >> 97 >> 98 theStatusChange = right.theStatusChange; >> 99 theTrueStepLength = right.theTrueStepLength; >> 100 theLocalEnergyDeposit = right.theLocalEnergyDeposit; >> 101 theSteppingControlFlag = right.theSteppingControlFlag; >> 102 >> 103 theGlobalTime0 = right.theGlobalTime0; >> 104 theLocalTime0 = right.theLocalTime0; >> 105 theTimeChange = right.theTimeChange; >> 106 thePolarizationChange = right.thePolarizationChange; >> 107 } >> 108 return *this; >> 109 } >> 110 >> 111 G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const >> 112 { >> 113 return ((G4VParticleChange *)this == (G4VParticleChange *) &right); >> 114 } >> 115 >> 116 G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const >> 117 { >> 118 return ((G4VParticleChange *)this != (G4VParticleChange *) &right); >> 119 } >> 120 >> 121 //---------------------------------------------------------------- >> 122 // methods for Initialization >> 123 // 43 void G4ParticleChangeForDecay::Initialize(cons 124 void G4ParticleChangeForDecay::Initialize(const G4Track& track) 44 { 125 { 45 // use base class's method at first 126 // use base class's method at first 46 G4VParticleChange::Initialize(track); 127 G4VParticleChange::Initialize(track); 47 128 >> 129 const G4DynamicParticle* pParticle = track.GetDynamicParticle(); >> 130 48 // set TimeChange equal to local time of the 131 // set TimeChange equal to local time of the parent track 49 theLocalTime0 = theTimeChange = track.GetLoc << 132 theTimeChange = track.GetLocalTime(); 50 133 51 // set initial Local/Global time of the pare 134 // set initial Local/Global time of the parent track 52 theGlobalTime0 = track.GetGlobalTime(); << 135 theLocalTime0 = track.GetLocalTime(); >> 136 theGlobalTime0 = track.GetGlobalTime(); 53 137 54 // set the Polarization equal to those of th 138 // set the Polarization equal to those of the parent track 55 thePolarizationChange = track.GetDynamicPart << 139 thePolarizationChange = pParticle->GetPolarization(); 56 } 140 } 57 141 58 // ------------------------------------------- << 142 //---------------------------------------------------------------- >> 143 // methods for updating G4Step >> 144 // >> 145 59 G4Step* G4ParticleChangeForDecay::UpdateStepFo 146 G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep) 60 { << 147 { 61 G4StepPoint* pPostStepPoint = pStep->GetPost << 148 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 62 149 63 if(isParentWeightProposed) << 150 if (isParentWeightProposed ){ 64 { << 151 pPostStepPoint->SetWeight( theParentWeight ); 65 pPostStepPoint->SetWeight(theParentWeight) << 66 } 152 } 67 // update polarization 153 // update polarization 68 pPostStepPoint->SetPolarization(thePolarizat << 154 pPostStepPoint->SetPolarization( thePolarizationChange ); 69 155 70 // update the G4Step specific attributes << 156 // Update the G4Step specific attributes 71 return UpdateStepInfo(pStep); 157 return UpdateStepInfo(pStep); 72 } 158 } 73 159 74 // ------------------------------------------- << 160 75 G4Step* G4ParticleChangeForDecay::UpdateStepFo 161 G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep) 76 { << 162 { 77 // A physics process always calculates the f 163 // A physics process always calculates the final state of the particle 78 164 79 G4StepPoint* pPostStepPoint = pStep->GetPost << 165 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 80 166 81 // update polarization 167 // update polarization 82 pPostStepPoint->SetPolarization(thePolarizat << 168 pPostStepPoint->SetPolarization( thePolarizationChange ); 83 << 169 84 // update time 170 // update time 85 pPostStepPoint->SetGlobalTime(GetGlobalTime( << 171 pPostStepPoint->SetGlobalTime( GetGlobalTime() ); 86 pPostStepPoint->SetLocalTime(theTimeChange); << 172 pPostStepPoint->SetLocalTime( theTimeChange ); 87 pPostStepPoint->AddProperTime(theTimeChange << 173 pPostStepPoint->AddProperTime (theTimeChange-theLocalTime0); 88 174 89 #ifdef G4VERBOSE 175 #ifdef G4VERBOSE 90 if(debugFlag) { CheckIt(*theCurrentTrack); } << 176 G4Track* aTrack = pStep->GetTrack(); >> 177 if (debugFlag) CheckIt(*aTrack); 91 #endif 178 #endif 92 179 93 if(isParentWeightProposed) << 180 if (isParentWeightProposed )pPostStepPoint->SetWeight( theParentWeight ); 94 pPostStepPoint->SetWeight(theParentWeight) << 95 181 96 // Update the G4Step specific attributes << 182 // Update the G4Step specific attributes 97 return UpdateStepInfo(pStep); 183 return UpdateStepInfo(pStep); 98 } 184 } 99 185 100 // ------------------------------------------- << 101 void G4ParticleChangeForDecay::DumpInfo() cons 186 void G4ParticleChangeForDecay::DumpInfo() const 102 { 187 { 103 // Show header << 188 // Show header 104 G4VParticleChange::DumpInfo(); 189 G4VParticleChange::DumpInfo(); 105 190 106 G4long oldprc = G4cout.precision(8); << 191 G4int oldprc = G4cout.precision(3); 107 G4cout << " --------------------------- << 192 G4cout << " proposed local Time (ns) : " 108 G4cout << " G4ParticleChangeForDecay prop << 193 << std::setw(20) << theTimeChange/ns << G4endl; 109 G4cout << " Proposed local Time (ns): " < << 194 G4cout << " initial local Time (ns) : " 110 << theTimeChange / ns << G4endl; << 195 << std::setw(20) << theLocalTime0/ns << G4endl; 111 G4cout << " Initial local Time (ns) : " < << 196 G4cout << " initial global Time (ns) : " 112 << theLocalTime0 / ns << G4endl; << 197 << std::setw(20) << theGlobalTime0/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); 198 G4cout.precision(oldprc); 118 } 199 } 119 200 120 // ------------------------------------------- << 121 G4bool G4ParticleChangeForDecay::CheckIt(const 201 G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack) 122 { 202 { >> 203 G4bool exitWithError = false; >> 204 >> 205 G4double accuracy; >> 206 123 // local time should not go back 207 // local time should not go back 124 G4bool itsOK = true; << 208 G4bool itsOK =true; 125 if(theTimeChange < theLocalTime0) << 209 accuracy = -1.0*(theTimeChange - theLocalTime0)/ns; 126 { << 210 if (accuracy > accuracyForWarning) { 127 itsOK = false; << 211 itsOK = false; 128 ++nError; << 212 exitWithError = (accuracy > accuracyForException); 129 #ifdef G4VERBOSE << 213 #ifdef G4VERBOSE 130 if(nError < maxError) << 214 G4cout << " G4ParticleChangeForDecay::CheckIt : "; 131 { << 215 G4cout << "the local time goes back !!" 132 G4cout << " G4ParticleChangeForDecay::C << 216 << " Difference: " << accuracy << "[ns] " <<G4endl; 133 G4cout << "the local time goes back !!" << 217 G4cout << "initial local time "<< theLocalTime0/ns << "[ns] " 134 << " Difference: " << (theTimeChange << 218 << "initial global time "<< theGlobalTime0/ns << "[ns] " <<G4endl; 135 << "[ns] " << G4endl; << 219 G4cout << aTrack.GetDefinition()->GetParticleName() 136 G4cout << "initial local time " << theLo << 220 << " E=" << aTrack.GetKineticEnergy()/MeV 137 << "initial global time " << theGlobalT << 221 << " pos=" << aTrack.GetPosition().x()/m 138 << G4endl; << 222 << ", " << aTrack.GetPosition().y()/m 139 } << 223 << ", " << aTrack.GetPosition().z()/m >> 224 <<G4endl; 140 #endif 225 #endif 141 theTimeChange = theLocalTime0; << 142 } 226 } 143 227 144 if(!itsOK) << 228 // dump out information of this particle change 145 { << 146 if(nError < maxError) << 147 { << 148 #ifdef G4VERBOSE 229 #ifdef G4VERBOSE 149 // dump out information of this particle << 230 if (!itsOK) DumpInfo(); 150 DumpInfo(); << 151 #endif 231 #endif 152 G4Exception("G4ParticleChangeForDecay::C << 232 153 JustWarning, "time is illega << 233 // Exit with error 154 } << 234 if (exitWithError) { >> 235 G4Exception("G4ParticleChangeForDecay::CheckIt", >> 236 "TRACK005",EventMustBeAborted, >> 237 "time was illegal"); >> 238 } >> 239 >> 240 // correction >> 241 if (!itsOK) { >> 242 theTimeChange = aTrack.GetLocalTime(); 155 } 243 } 156 244 157 return (itsOK) && G4VParticleChange::CheckIt << 245 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); >> 246 return itsOK; 158 } 247 } >> 248 >> 249 >> 250 >> 251 >> 252 159 253