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 // G4ParticleChangeForLoss class implementatio << 27 // 23 // 28 // Author: Hisaya Kurashige, 23 March 1998 << 24 // $Id: G4ParticleChangeForLoss.cc,v 1.14 2005/04/14 17:59:38 vnivanch Exp $ 29 // Revision: Vladimir Ivantchenko, 16 January << 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 30 // ------------------------------------------- << 26 // 31 << 27 // >> 28 // -------------------------------------------------------------- >> 29 // GEANT 4 class implementation file >> 30 // >> 31 // ------------------------------------------------------------ >> 32 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige >> 33 // -------------------------------------------------------------- >> 34 // >> 35 // Modified: >> 36 // 16.01.04 V.Ivanchenko update for model variant of energy loss >> 37 // 15.04.05 V.Ivanchenko inline update methods >> 38 // >> 39 // ------------------------------------------------------------ >> 40 // 32 #include "G4ParticleChangeForLoss.hh" 41 #include "G4ParticleChangeForLoss.hh" 33 #include "G4SystemOfUnits.hh" << 42 #include "G4Track.hh" >> 43 #include "G4Step.hh" >> 44 #include "G4DynamicParticle.hh" 34 #include "G4ExceptionSeverity.hh" 45 #include "G4ExceptionSeverity.hh" 35 46 36 // ------------------------------------------- << 47 G4ParticleChangeForLoss::G4ParticleChangeForLoss():G4VParticleChange() 37 G4ParticleChangeForLoss::G4ParticleChangeForLo << 38 { 48 { 39 // Disable flag that is enabled in G4VPartic << 49 theSteppingControlFlag = NormalCondition; 40 debugFlag = false; 50 debugFlag = false; 41 SetNumberOfSecondaries(1); << 51 #ifdef G4VERBOSE >> 52 if (verboseLevel>2) { >> 53 G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl; >> 54 } >> 55 #endif 42 } 56 } 43 57 44 // ------------------------------------------- << 58 G4ParticleChangeForLoss::~G4ParticleChangeForLoss() 45 void G4ParticleChangeForLoss::DumpInfo() const << 46 { 59 { 47 // use base-class DumpInfo << 60 #ifdef G4VERBOSE 48 G4VParticleChange::DumpInfo(); << 61 if (verboseLevel>2) { 49 << 62 G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl; 50 G4long oldprc = G4cout.precision(8); << 63 } 51 G4cout << " --------------------------- << 64 #endif 52 G4cout << " G4ParticleChangeForLoss p << 53 G4cout << " Charge (eplus) : " << s << 54 << currentCharge / eplus << G4endl; << 55 G4cout << " Kinetic Energy (MeV): " < << 56 << proposedKinEnergy / MeV << G4endl; << 57 G4cout << " Momentum Direct - x : " < << 58 << proposedMomentumDirection.x() << G << 59 G4cout << " Momentum Direct - y : " < << 60 << proposedMomentumDirection.y() << G << 61 G4cout << " Momentum Direct - z : " < << 62 << proposedMomentumDirection.z() << G << 63 G4cout.precision(oldprc); << 64 } 65 } 65 66 66 // ------------------------------------------- << 67 G4ParticleChangeForLoss::G4ParticleChangeForLoss( 67 G4Step* G4ParticleChangeForLoss::UpdateStepFor << 68 const G4ParticleChangeForLoss &right): G4VParticleChange(right) 68 { 69 { 69 const G4StepPoint* pPreStepPoint = pStep->Ge << 70 if (verboseLevel>1) { 70 G4StepPoint* pPostStepPoint = pStep->GetPost << 71 G4cout << "G4ParticleChangeForLoss:: copy constructor is called " << G4endl; 71 << 72 // accumulate change of the kinetic energy << 73 G4double preKinEnergy = pPreStepPoint->GetKi << 74 G4double kinEnergy = << 75 pPostStepPoint->GetKineticEnergy() + (prop << 76 << 77 pPostStepPoint->SetCharge(currentCharge); << 78 << 79 // calculate velocity << 80 if(kinEnergy > 0.0) << 81 { << 82 pPostStepPoint->SetKineticEnergy(kinEnergy << 83 << 84 // assuming that mass>0, zero mass particl << 85 pPostStepPoint->SetVelocity(CLHEP::c_light << 86 } << 87 else << 88 { << 89 pPostStepPoint->SetKineticEnergy(0.0); << 90 pPostStepPoint->SetVelocity(0.0); << 91 } 72 } >> 73 currentTrack = right.currentTrack; >> 74 proposedKinEnergy = right.proposedKinEnergy; >> 75 currentCharge = right.currentCharge; >> 76 //theProposedWeight = right.theProposedWeight; >> 77 proposedMomentumDirection = right.proposedMomentumDirection; >> 78 } 92 79 93 if(isParentWeightProposed) << 80 // assignment operator 94 { << 81 G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=( 95 pPostStepPoint->SetWeight(theParentWeight) << 82 const G4ParticleChangeForLoss &right) >> 83 { >> 84 if (verboseLevel>1) { >> 85 G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl; >> 86 } >> 87 if (this != &right) { >> 88 theListOfSecondaries = right.theListOfSecondaries; >> 89 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; >> 90 theNumberOfSecondaries = right.theNumberOfSecondaries; >> 91 theStatusChange = right.theStatusChange; >> 92 theLocalEnergyDeposit = right.theLocalEnergyDeposit; >> 93 theSteppingControlFlag = right.theSteppingControlFlag; >> 94 >> 95 currentTrack = right.currentTrack; >> 96 proposedKinEnergy = right.proposedKinEnergy; >> 97 currentCharge = right.currentCharge; >> 98 //theProposedWeight = right.theProposedWeight; >> 99 proposedMomentumDirection = right.proposedMomentumDirection; 96 } 100 } >> 101 return *this; >> 102 } >> 103 >> 104 //---------------------------------------------------------------- >> 105 // methods for printing messages >> 106 // 97 107 98 pStep->AddTotalEnergyDeposit(theLocalEnergyD << 108 void G4ParticleChangeForLoss::DumpInfo() const 99 pStep->AddNonIonizingEnergyDeposit(theNonIon << 109 { 100 return pStep; << 110 // use base-class DumpInfo >> 111 G4VParticleChange::DumpInfo(); >> 112 >> 113 G4cout.precision(3); >> 114 G4cout << " Charge (eplus) : " >> 115 << std::setw(20) << currentCharge/eplus >> 116 << G4endl; >> 117 G4cout << " Kinetic Energy (MeV): " >> 118 << std::setw(20) << proposedKinEnergy/MeV >> 119 << G4endl; >> 120 G4cout << " Momentum Direct - x : " >> 121 << std::setw(20) << proposedMomentumDirection.x() >> 122 << G4endl; >> 123 G4cout << " Momentum Direct - y : " >> 124 << std::setw(20) << proposedMomentumDirection.y() >> 125 << G4endl; >> 126 G4cout << " Momentum Direct - z : " >> 127 << std::setw(20) << proposedMomentumDirection.z() >> 128 << G4endl; 101 } 129 } 102 130 103 // ------------------------------------------- << 131 G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack) 104 G4Step* G4ParticleChangeForLoss::UpdateStepFor << 105 { 132 { 106 G4StepPoint* pPostStepPoint = pStep->GetPost << 133 G4bool itsOK = true; >> 134 G4bool exitWithError = false; 107 135 108 pPostStepPoint->SetCharge(currentCharge); << 136 G4double accuracy; 109 pPostStepPoint->SetMomentumDirection(propose << 110 if(proposedKinEnergy > 0.0) << 111 { << 112 pPostStepPoint->SetKineticEnergy(proposedK << 113 137 114 // assuming that mass>0, zero mass particl << 138 // Energy should not be lager than initial value 115 pPostStepPoint->SetVelocity(CLHEP::c_light << 139 accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV; >> 140 if (accuracy > accuracyForWarning) { >> 141 #ifdef G4VERBOSE >> 142 G4cout << "G4ParticleChangeForLoss::CheckIt: "; >> 143 G4cout << "KinEnergy become larger than the initial value!" << G4endl; >> 144 G4cout << " Difference: " << accuracy << "[MeV] " <<G4endl; >> 145 #endif >> 146 itsOK = false; >> 147 if (accuracy > accuracyForException) exitWithError = true; 116 } 148 } 117 else << 149 118 { << 150 // dump out information of this particle change 119 pPostStepPoint->SetKineticEnergy(0.0); << 151 #ifdef G4VERBOSE 120 pPostStepPoint->SetVelocity(0.0); << 152 if (!itsOK) { >> 153 G4cout << "G4ParticleChangeForLoss::CheckIt " << G4endl; >> 154 DumpInfo(); >> 155 } >> 156 #endif >> 157 >> 158 // Exit with error >> 159 if (exitWithError) { >> 160 G4Exception("G4ParticleChangeForLoss::CheckIt", >> 161 "400", >> 162 EventMustBeAborted, >> 163 "energy was illegal"); 121 } 164 } 122 pPostStepPoint->SetPolarization(proposedPola << 123 165 124 if(isParentWeightProposed) << 166 //correction 125 { << 167 if (!itsOK) { 126 pPostStepPoint->SetWeight(theParentWeight) << 168 proposedKinEnergy = aTrack.GetKineticEnergy(); 127 } 169 } 128 170 129 pStep->AddTotalEnergyDeposit(theLocalEnergyD << 171 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); 130 pStep->AddNonIonizingEnergyDeposit(theNonIon << 172 return itsOK; 131 return pStep; << 132 } 173 } 133 174