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 // G4ParticleChangeForGamma class implementati << 27 // 26 // 28 // Author: Hisaya Kurashige, 23 March 1998 << 27 // $Id: G4ParticleChangeForGamma.cc,v 1.3 2006/08/28 16:10:29 vnivanch Exp $ 29 // Revision: Vladimir Ivantchenko, 15 April 20 << 28 // GEANT4 tag $Name: geant4-08-02 $ 30 // ------------------------------------------- << 29 // 31 << 30 // >> 31 // -------------------------------------------------------------- >> 32 // GEANT 4 class implementation file >> 33 // >> 34 // ------------------------------------------------------------ >> 35 // 15 April 2005 V.Ivanchenko for gamma EM processes >> 36 // -------------------------------------------------------------- >> 37 // >> 38 // Modified:: >> 39 // 28.08.06 V.Ivanchenko Add access to current track and polarizaion >> 40 // >> 41 // ------------------------------------------------------------ >> 42 // 32 #include "G4ParticleChangeForGamma.hh" 43 #include "G4ParticleChangeForGamma.hh" 33 #include "G4SystemOfUnits.hh" << 34 #include "G4Track.hh" 44 #include "G4Track.hh" 35 #include "G4Step.hh" 45 #include "G4Step.hh" 36 #include "G4DynamicParticle.hh" 46 #include "G4DynamicParticle.hh" 37 #include "G4ExceptionSeverity.hh" 47 #include "G4ExceptionSeverity.hh" 38 48 39 // ------------------------------------------- << 49 G4ParticleChangeForGamma::G4ParticleChangeForGamma():G4VParticleChange() 40 G4ParticleChangeForGamma::G4ParticleChangeForG << 41 { 50 { 42 // Disable flag to avoid check of each secon << 51 theSteppingControlFlag = NormalCondition; 43 debugFlag = false; 52 debugFlag = false; 44 SetNumberOfSecondaries(2); << 53 #ifdef G4VERBOSE >> 54 if (verboseLevel>2) { >> 55 G4cout << "G4ParticleChangeForGamma::G4ParticleChangeForGamma() " << G4endl; >> 56 } >> 57 #endif 45 } 58 } 46 59 47 // ------------------------------------------- << 60 G4ParticleChangeForGamma::~G4ParticleChangeForGamma() 48 void G4ParticleChangeForGamma::AddSecondary(G4 << 49 { 61 { 50 // create track << 62 #ifdef G4VERBOSE 51 G4Track* aTrack = new G4Track(aParticle, the << 63 if (verboseLevel>2) { 52 theCurrentTrac << 64 G4cout << "G4ParticleChangeForGamma::~G4ParticleChangeForGamma() " << G4endl; 53 << 65 } 54 // touchable handle is copied to keep the po << 66 #endif 55 aTrack->SetTouchableHandle(theCurrentTrack-> << 56 << 57 // add a secondary << 58 G4VParticleChange::AddSecondary(aTrack); << 59 } 67 } 60 68 61 // ------------------------------------------- << 69 G4ParticleChangeForGamma::G4ParticleChangeForGamma( 62 G4Step* G4ParticleChangeForGamma::UpdateStepFo << 70 const G4ParticleChangeForGamma &right): G4VParticleChange(right) 63 { 71 { 64 pStep->AddTotalEnergyDeposit(theLocalEnergyD << 72 if (verboseLevel>1) 65 pStep->SetStepLength(0.0); << 73 G4cout << "G4ParticleChangeForGamma:: copy constructor is called " << G4endl; >> 74 >> 75 currentTrack = right.currentTrack; >> 76 proposedKinEnergy = right.proposedKinEnergy; >> 77 proposedMomentumDirection = right.proposedMomentumDirection; >> 78 proposedPolarization = right.proposedPolarization; >> 79 } 66 80 67 if(isParentWeightProposed) << 81 // assignment operator 68 { << 82 G4ParticleChangeForGamma & G4ParticleChangeForGamma::operator=( 69 pStep->GetPostStepPoint()->SetWeight(thePa << 83 const G4ParticleChangeForGamma &right) >> 84 { >> 85 if (verboseLevel>1) >> 86 G4cout << "G4ParticleChangeForGamma:: assignment operator is called " << G4endl; >> 87 >> 88 if (this != &right) { >> 89 theListOfSecondaries = right.theListOfSecondaries; >> 90 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; >> 91 theNumberOfSecondaries = right.theNumberOfSecondaries; >> 92 theStatusChange = right.theStatusChange; >> 93 theLocalEnergyDeposit = right.theLocalEnergyDeposit; >> 94 theSteppingControlFlag = right.theSteppingControlFlag; >> 95 theParentWeight = right.theParentWeight; >> 96 >> 97 currentTrack = right.currentTrack; >> 98 proposedKinEnergy = right.proposedKinEnergy; >> 99 proposedMomentumDirection = right.proposedMomentumDirection; >> 100 proposedPolarization = right.proposedPolarization; 70 } 101 } >> 102 return *this; >> 103 } 71 104 72 return pStep; << 105 //---------------------------------------------------------------- >> 106 // methods for printing messages >> 107 // >> 108 >> 109 void G4ParticleChangeForGamma::DumpInfo() const >> 110 { >> 111 // use base-class DumpInfo >> 112 G4VParticleChange::DumpInfo(); >> 113 >> 114 G4cout.precision(3); >> 115 G4cout << " Kinetic Energy (MeV): " >> 116 << std::setw(20) << proposedKinEnergy/MeV >> 117 << G4endl; >> 118 G4cout << " Momentum Direction: " >> 119 << std::setw(20) << proposedMomentumDirection >> 120 << G4endl; >> 121 G4cout << " Polarization: " >> 122 << std::setw(20) << proposedPolarization >> 123 << G4endl; 73 } 124 } 74 125 75 // ------------------------------------------- << 126 G4bool G4ParticleChangeForGamma::CheckIt(const G4Track& aTrack) 76 G4Step* G4ParticleChangeForGamma::UpdateStepFo << 77 { 127 { 78 G4StepPoint* pPostStepPoint = pStep->GetPost << 128 G4bool itsOK = true; >> 129 G4bool exitWithError = false; 79 130 80 pPostStepPoint->SetMomentumDirection(propose << 131 G4double accuracy; 81 pPostStepPoint->SetPolarization(proposedPola << 82 132 83 // update velocity for scattering process an << 133 // Energy should not be lager than initial value 84 if(proposedKinEnergy > 0.0) << 134 accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV; 85 { << 135 if (accuracy > accuracyForWarning) { 86 pPostStepPoint->SetKineticEnergy(proposedK << 136 #ifdef G4VERBOSE 87 G4double mass = theCurrentTrack->GetDefini << 137 G4cout << "G4ParticleChangeForGamma::CheckIt: "; 88 G4double v = CLHEP::c_light; << 138 G4cout << "KinEnergy become larger than the initial value!" << G4endl; 89 if(mass > 0.0) { << 139 G4cout << " Difference: " << accuracy << "[MeV] " <<G4endl; 90 v *= std::sqrt(proposedKinEnergy*(propos << 140 #endif 91 (proposedKinEnergy + mass); << 141 itsOK = false; 92 } << 142 if (accuracy > accuracyForException) exitWithError = true; 93 pPostStepPoint->SetVelocity(v); << 94 } << 95 else << 96 { << 97 pPostStepPoint->SetKineticEnergy(0.0); << 98 pPostStepPoint->SetVelocity(0.0); << 99 } 143 } 100 144 101 if(isParentWeightProposed) << 145 // dump out information of this particle change 102 { << 146 #ifdef G4VERBOSE 103 pPostStepPoint->SetWeight(theParentWeight) << 147 if (!itsOK) { >> 148 G4cout << "G4ParticleChangeForGamma::CheckIt " << G4endl; >> 149 DumpInfo(); 104 } 150 } >> 151 #endif 105 152 106 pStep->AddTotalEnergyDeposit(theLocalEnergyD << 153 // Exit with error 107 pStep->AddNonIonizingEnergyDeposit(theNonIon << 154 if (exitWithError) { 108 return pStep; << 155 G4Exception("G4ParticleChangeForGamma::CheckIt", 109 } << 156 "400", >> 157 EventMustBeAborted, >> 158 "energy was illegal"); >> 159 } 110 160 111 // ------------------------------------------- << 161 //correction 112 void G4ParticleChangeForGamma::DumpInfo() cons << 162 if (!itsOK) { 113 { << 163 proposedKinEnergy = aTrack.GetKineticEnergy(); 114 // use base-class DumpInfo << 164 } 115 G4VParticleChange::DumpInfo(); << 116 165 117 G4long oldprc = G4cout.precision(8); << 166 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); 118 G4cout << " --------------------------- << 167 return itsOK; 119 G4cout << " G4ParticleChangeForGamma << 120 G4cout << " Kinetic Energy (MeV): " < << 121 << proposedKinEnergy / MeV << G4endl; << 122 G4cout << " Momentum Direction: " << << 123 << proposedMomentumDirection << G4end << 124 G4cout << " Polarization: " << std::s << 125 << G4endl; << 126 G4cout.precision(oldprc); << 127 } 168 } 128 << 129 169