Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -23,15 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4FieldTrackUpdator class implementation
|
||||
//
|
||||
//
|
||||
// M. Asai - first implementation Apr/28/2006
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FieldTrackUpdator.cc
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// Author: M.Asai, 28 April 2006
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4FieldTrackUpdator.hh"
|
||||
@@ -41,52 +36,51 @@
|
||||
#include "G4TrackStatus.hh"
|
||||
#include "G4FieldTrack.hh"
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
G4FieldTrack* G4FieldTrackUpdator::CreateFieldTrack(const G4Track* trk)
|
||||
{
|
||||
G4FieldTrack* ftrk = new G4FieldTrack(
|
||||
trk->GetPosition(),
|
||||
trk->GetGlobalTime(),
|
||||
trk->GetMomentumDirection(),
|
||||
trk->GetKineticEnergy(),
|
||||
trk->GetDynamicParticle()->GetMass(),
|
||||
trk->GetPosition(), trk->GetGlobalTime(), trk->GetMomentumDirection(),
|
||||
trk->GetKineticEnergy(), trk->GetDynamicParticle()->GetMass(),
|
||||
trk->GetDynamicParticle()->GetCharge(),
|
||||
trk->GetDynamicParticle()->GetPolarization(),
|
||||
0.0 // magnetic dipole moment to be implemented
|
||||
);
|
||||
0.0 // magnetic dipole moment to be implemented
|
||||
);
|
||||
return ftrk;
|
||||
}
|
||||
|
||||
void G4FieldTrackUpdator::Update(G4FieldTrack* ftrk,const G4Track* trk)
|
||||
//---------------------------------------------------------------------
|
||||
void G4FieldTrackUpdator::Update(G4FieldTrack* ftrk, const G4Track* trk)
|
||||
{
|
||||
const G4DynamicParticle* ptDynamicParticle= trk->GetDynamicParticle();
|
||||
const G4DynamicParticle* ptDynamicParticle = trk->GetDynamicParticle();
|
||||
|
||||
// The following properties must be updated 1) for each new track, and
|
||||
ftrk->SetRestMass(ptDynamicParticle->GetMass());
|
||||
// The following properties must be updated 1) for each new track, and
|
||||
ftrk->SetRestMass(ptDynamicParticle->GetMass());
|
||||
// 2) Since ion can lose/gain electrons, this must be done at every step
|
||||
|
||||
ftrk->UpdateState(
|
||||
trk->GetPosition(),
|
||||
trk->GetGlobalTime(),
|
||||
trk->GetMomentumDirection(),
|
||||
trk->GetKineticEnergy()
|
||||
);
|
||||
|
||||
#ifdef G4CHECK
|
||||
if( ( trk->GetMomentum() - ftrk->GetMomentum()).mag2() > 1.e-16 * trk->GetMomentum().mag2() ){
|
||||
G4cerr << "ERROR> G4FieldTrackUpdator sees *Disagreement* in momentum " << G4endl;
|
||||
G4cout << " FTupdator: Tracking Momentum= " << trk->GetMomentum() << G4endl;
|
||||
G4cout << " FTupdator: FldTrack Momentum= " << ftrk->GetMomentum() << G4endl;
|
||||
G4cout << " FTupdator: FldTrack-Tracking= " << ftrk->GetMomentum() - trk->GetMomentum() << G4endl;
|
||||
ftrk->UpdateState(trk->GetPosition(), trk->GetGlobalTime(),
|
||||
trk->GetMomentumDirection(), trk->GetKineticEnergy());
|
||||
|
||||
#ifdef G4CHECK
|
||||
if((trk->GetMomentum() - ftrk->GetMomentum()).mag2() >
|
||||
1.e-16 * trk->GetMomentum().mag2())
|
||||
{
|
||||
G4cerr << "ERROR> G4FieldTrackUpdator sees *Disagreement* in momentum "
|
||||
<< G4endl;
|
||||
G4cout << " FTupdator: Tracking Momentum= " << trk->GetMomentum()
|
||||
<< G4endl;
|
||||
G4cout << " FTupdator: FldTrack Momentum= " << ftrk->GetMomentum()
|
||||
<< G4endl;
|
||||
G4cout << " FTupdator: FldTrack-Tracking= "
|
||||
<< ftrk->GetMomentum() - trk->GetMomentum() << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
ftrk->SetProperTimeOfFlight(trk->GetProperTime());
|
||||
|
||||
ftrk->SetChargeAndMoments( ptDynamicParticle->GetCharge(),
|
||||
ptDynamicParticle->GetMagneticMoment());
|
||||
ftrk->SetPDGSpin( ptDynamicParticle->GetParticleDefinition()->GetPDGSpin() );
|
||||
// The charge can change during tracking
|
||||
ftrk->SetSpin( ptDynamicParticle->GetPolarization() );
|
||||
ftrk->SetChargeAndMoments(ptDynamicParticle->GetCharge(),
|
||||
ptDynamicParticle->GetMagneticMoment());
|
||||
ftrk->SetPDGSpin(ptDynamicParticle->GetParticleDefinition()->GetPDGSpin());
|
||||
// The charge can change during tracking
|
||||
ftrk->SetSpin(ptDynamicParticle->GetPolarization());
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,18 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleChangeForDecay class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
|
||||
// Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige
|
||||
// --------------------------------------------------------------
|
||||
// Author: Hisaya Kurashige, 23 March 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ParticleChangeForDecay.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
@@ -44,208 +36,203 @@
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForDecay::G4ParticleChangeForDecay()
|
||||
: G4VParticleChange(),
|
||||
theGlobalTime0(0.),theLocalTime0(0.),theTimeChange(0.)
|
||||
: G4VParticleChange()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
G4ParticleChangeForDecay::~G4ParticleChangeForDecay()
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForDecay::~G4ParticleChangeForDecay()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForDecay::
|
||||
G4ParticleChangeForDecay(const G4ParticleChangeForDecay& right)
|
||||
: G4VParticleChange(right)
|
||||
{
|
||||
theGlobalTime0 = right.theGlobalTime0;
|
||||
theLocalTime0 = right.theLocalTime0;
|
||||
theTimeChange = right.theTimeChange;
|
||||
theGlobalTime0 = right.theGlobalTime0;
|
||||
theLocalTime0 = right.theLocalTime0;
|
||||
theTimeChange = right.theTimeChange;
|
||||
thePolarizationChange = right.thePolarizationChange;
|
||||
}
|
||||
|
||||
|
||||
G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForDecay&
|
||||
G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay& right)
|
||||
{
|
||||
if (this != &right){
|
||||
if (theNumberOfSecondaries>0) {
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4ParticleChangeForDecay: assignment operator Warning ";
|
||||
G4cout << "theListOfSecondaries is not empty ";
|
||||
}
|
||||
#endif
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
|
||||
if(this != &right)
|
||||
{
|
||||
if(theNumberOfSecondaries > 0)
|
||||
{
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
if((*theListOfSecondaries)[index])
|
||||
delete(*theListOfSecondaries)[index];
|
||||
}
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
delete theListOfSecondaries;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
for (G4int index = 0; index<theNumberOfSecondaries; index++){
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
|
||||
theListOfSecondaries->SetElement(index, newTrack); }
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
}
|
||||
|
||||
theStatusChange = right.theStatusChange;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theStatusChange = right.theStatusChange;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
|
||||
theGlobalTime0 = right.theGlobalTime0;
|
||||
theLocalTime0 = right.theLocalTime0;
|
||||
theTimeChange = right.theTimeChange;
|
||||
|
||||
theGlobalTime0 = right.theGlobalTime0;
|
||||
theLocalTime0 = right.theLocalTime0;
|
||||
theTimeChange = right.theTimeChange;
|
||||
thePolarizationChange = right.thePolarizationChange;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4ParticleChangeForDecay::operator==(
|
||||
const G4ParticleChangeForDecay& right) const
|
||||
{
|
||||
return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
|
||||
return ((G4VParticleChange*) this == (G4VParticleChange*) &right);
|
||||
}
|
||||
|
||||
G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4ParticleChangeForDecay::operator!=(
|
||||
const G4ParticleChangeForDecay& right) const
|
||||
{
|
||||
return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
|
||||
return ((G4VParticleChange*) this != (G4VParticleChange*) &right);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for Initialization
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForDecay::Initialize(const G4Track& track)
|
||||
{
|
||||
// use base class's method at first
|
||||
G4VParticleChange::Initialize(track);
|
||||
|
||||
const G4DynamicParticle* pParticle = track.GetDynamicParticle();
|
||||
const G4DynamicParticle* pParticle = track.GetDynamicParticle();
|
||||
|
||||
// set TimeChange equal to local time of the parent track
|
||||
theTimeChange = track.GetLocalTime();
|
||||
theTimeChange = track.GetLocalTime();
|
||||
|
||||
// set initial Local/Global time of the parent track
|
||||
theLocalTime0 = track.GetLocalTime();
|
||||
theGlobalTime0 = track.GetGlobalTime();
|
||||
theLocalTime0 = track.GetLocalTime();
|
||||
theGlobalTime0 = track.GetGlobalTime();
|
||||
|
||||
// set the Polarization equal to those of the parent track
|
||||
thePolarizationChange = pParticle->GetPolarization();
|
||||
thePolarizationChange = pParticle->GetPolarization();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for updating G4Step
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
{
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
pPostStepPoint->SetWeight(theParentWeight);
|
||||
}
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization( thePolarizationChange );
|
||||
pPostStepPoint->SetPolarization(thePolarizationChange);
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
// update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep)
|
||||
{
|
||||
{
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization( thePolarizationChange );
|
||||
|
||||
pPostStepPoint->SetPolarization(thePolarizationChange);
|
||||
|
||||
// update time
|
||||
pPostStepPoint->SetGlobalTime( GetGlobalTime() );
|
||||
pPostStepPoint->SetLocalTime( theTimeChange );
|
||||
pPostStepPoint->AddProperTime (theTimeChange-theLocalTime0);
|
||||
pPostStepPoint->SetGlobalTime(GetGlobalTime());
|
||||
pPostStepPoint->SetLocalTime(theTimeChange);
|
||||
pPostStepPoint->AddProperTime(theTimeChange - theLocalTime0);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
if(debugFlag) { CheckIt(*aTrack); }
|
||||
#endif
|
||||
|
||||
if (isParentWeightProposed )pPostStepPoint->SetWeight( theParentWeight );
|
||||
if(isParentWeightProposed)
|
||||
pPostStepPoint->SetWeight(theParentWeight);
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
// Update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForDecay::DumpInfo() const
|
||||
{
|
||||
// Show header
|
||||
// Show header
|
||||
G4VParticleChange::DumpInfo();
|
||||
|
||||
G4int oldprc = G4cout.precision(3);
|
||||
G4cout << " proposed local Time (ns) : "
|
||||
<< std::setw(20) << theTimeChange/ns << G4endl;
|
||||
G4cout << " initial local Time (ns) : "
|
||||
<< std::setw(20) << theLocalTime0/ns << G4endl;
|
||||
G4cout << " initial global Time (ns) : "
|
||||
<< std::setw(20) << theGlobalTime0/ns << G4endl;
|
||||
G4cout << " proposed local Time (ns) : " << std::setw(20)
|
||||
<< theTimeChange / ns << G4endl;
|
||||
G4cout << " initial local Time (ns) : " << std::setw(20)
|
||||
<< theLocalTime0 / ns << G4endl;
|
||||
G4cout << " initial global Time (ns) : " << std::setw(20)
|
||||
<< theGlobalTime0 / ns << G4endl;
|
||||
G4cout.precision(oldprc);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack)
|
||||
{
|
||||
G4bool exitWithError = false;
|
||||
G4bool exitWithError = false;
|
||||
|
||||
G4double accuracy;
|
||||
G4double accuracy;
|
||||
|
||||
// local time should not go back
|
||||
G4bool itsOK =true;
|
||||
accuracy = -1.0*(theTimeChange - theLocalTime0)/ns;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
itsOK = false;
|
||||
G4bool itsOK = true;
|
||||
accuracy = -1.0 * (theTimeChange - theLocalTime0) / ns;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOK = false;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChangeForDecay::CheckIt : ";
|
||||
G4cout << "the local time goes back !!"
|
||||
<< " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
G4cout << "initial local time "<< theLocalTime0/ns << "[ns] "
|
||||
<< "initial global time "<< theGlobalTime0/ns << "[ns] " <<G4endl;
|
||||
G4cout << "the local time goes back !!"
|
||||
<< " Difference: " << accuracy << "[ns] " << G4endl;
|
||||
G4cout << "initial local time " << theLocalTime0 / ns << "[ns] "
|
||||
<< "initial global time " << theGlobalTime0 / ns << "[ns] "
|
||||
<< G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// dump out information of this particle change
|
||||
#ifdef G4VERBOSE
|
||||
if (!itsOK) DumpInfo();
|
||||
if(!itsOK) { DumpInfo(); }
|
||||
#endif
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError) {
|
||||
G4Exception("G4ParticleChangeForDecay::CheckIt",
|
||||
"TRACK005",EventMustBeAborted,
|
||||
"time was illegal");
|
||||
}
|
||||
// exit with error
|
||||
if(exitWithError)
|
||||
{
|
||||
G4Exception("G4ParticleChangeForDecay::CheckIt()", "TRACK005",
|
||||
EventMustBeAborted, "time was illegal");
|
||||
}
|
||||
|
||||
// correction
|
||||
if (!itsOK) {
|
||||
if(!itsOK)
|
||||
{
|
||||
theTimeChange = aTrack.GetLocalTime();
|
||||
}
|
||||
|
||||
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
|
||||
return itsOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,21 +23,12 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleChangeForGamma class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// 15 April 2005 V.Ivanchenko for gamma EM processes
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Modified::
|
||||
// 28.08.06 V.Ivanchenko Add access to current track and polarizaion
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// Author: Hisaya Kurashige, 23 March 1998
|
||||
// Revision: Vladimir Ivantchenko, 15 April 2005
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ParticleChangeForGamma.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
@@ -45,195 +36,180 @@
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForGamma::G4ParticleChangeForGamma()
|
||||
: G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.)
|
||||
: G4VParticleChange()
|
||||
{
|
||||
theSteppingControlFlag = NormalCondition;
|
||||
debugFlag = false;
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForGamma::G4ParticleChangeForGamma() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
debugFlag = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForGamma::~G4ParticleChangeForGamma()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForGamma::~G4ParticleChangeForGamma() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
G4ParticleChangeForGamma::G4ParticleChangeForGamma(
|
||||
const G4ParticleChangeForGamma &right): G4VParticleChange(right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForGamma::
|
||||
G4ParticleChangeForGamma(const G4ParticleChangeForGamma& right)
|
||||
: G4VParticleChange(right)
|
||||
{
|
||||
if (verboseLevel>1)
|
||||
G4cout << "G4ParticleChangeForGamma:: copy constructor is called " << G4endl;
|
||||
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
proposedMomentumDirection = right.proposedMomentumDirection;
|
||||
proposedPolarization = right.proposedPolarization;
|
||||
proposedPolarization = right.proposedPolarization;
|
||||
}
|
||||
|
||||
// assignment operator
|
||||
G4ParticleChangeForGamma & G4ParticleChangeForGamma::operator=(
|
||||
const G4ParticleChangeForGamma &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForGamma&
|
||||
G4ParticleChangeForGamma::operator=(const G4ParticleChangeForGamma& right)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>1)
|
||||
G4cout << "G4ParticleChangeForGamma:: assignment operator is called " << G4endl;
|
||||
#endif
|
||||
|
||||
if (this != &right) {
|
||||
if (theNumberOfSecondaries>0) {
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4ParticleChangeForGamma: assignment operator Warning ";
|
||||
G4cout << "theListOfSecondaries is not empty ";
|
||||
}
|
||||
#endif
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
|
||||
}
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
if(this != &right)
|
||||
{
|
||||
if(theNumberOfSecondaries > 0)
|
||||
{
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
if((*theListOfSecondaries)[index])
|
||||
delete(*theListOfSecondaries)[index];
|
||||
}
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
for (G4int index = 0; index<theNumberOfSecondaries; index++){
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
|
||||
theListOfSecondaries->SetElement(index, newTrack); }
|
||||
|
||||
theStatusChange = right.theStatusChange;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theParentWeight = right.theParentWeight;
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
}
|
||||
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
theStatusChange = right.theStatusChange;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theParentWeight = right.theParentWeight;
|
||||
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
proposedMomentumDirection = right.proposedMomentumDirection;
|
||||
proposedPolarization = right.proposedPolarization;
|
||||
proposedPolarization = right.proposedPolarization;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForGamma::AddSecondary(G4DynamicParticle* aParticle)
|
||||
{
|
||||
// create track
|
||||
// create track
|
||||
G4Track* aTrack = new G4Track(aParticle, currentTrack->GetGlobalTime(),
|
||||
currentTrack->GetPosition());
|
||||
currentTrack->GetPosition());
|
||||
|
||||
// Touchable handle is copied to keep the pointer
|
||||
// touchable handle is copied to keep the pointer
|
||||
aTrack->SetTouchableHandle(currentTrack->GetTouchableHandle());
|
||||
|
||||
// add a secondary
|
||||
// add a secondary
|
||||
G4VParticleChange::AddSecondary(aTrack);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// method for updating G4Step
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForGamma::UpdateStepForAtRest(G4Step* pStep)
|
||||
{
|
||||
pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->SetStepLength( 0.0 );
|
||||
pStep->AddTotalEnergyDeposit(theLocalEnergyDeposit);
|
||||
pStep->SetStepLength(0.0);
|
||||
|
||||
if (isParentWeightProposed ){
|
||||
pStep->GetPostStepPoint()->SetWeight( theParentWeight );
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
pStep->GetPostStepPoint()->SetWeight(theParentWeight);
|
||||
}
|
||||
|
||||
return pStep;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForGamma::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* pTrack = pStep->GetTrack();
|
||||
G4Track* pTrack = pStep->GetTrack();
|
||||
|
||||
pPostStepPoint->SetKineticEnergy( proposedKinEnergy );
|
||||
pPostStepPoint->SetMomentumDirection( proposedMomentumDirection );
|
||||
pPostStepPoint->SetPolarization( proposedPolarization );
|
||||
pPostStepPoint->SetKineticEnergy(proposedKinEnergy);
|
||||
pPostStepPoint->SetMomentumDirection(proposedMomentumDirection);
|
||||
pPostStepPoint->SetPolarization(proposedPolarization);
|
||||
|
||||
// update velocity for scattering process and particles with mass
|
||||
if(proposedKinEnergy > 0.0) {
|
||||
if(pTrack->GetParticleDefinition()->GetPDGMass() > 0.0) {
|
||||
if(proposedKinEnergy > 0.0)
|
||||
{
|
||||
if(pTrack->GetParticleDefinition()->GetPDGMass() > 0.0)
|
||||
{
|
||||
pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
|
||||
}
|
||||
}
|
||||
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
}
|
||||
|
||||
pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
|
||||
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
pPostStepPoint->SetWeight(theParentWeight);
|
||||
}
|
||||
|
||||
pStep->AddTotalEnergyDeposit(theLocalEnergyDeposit);
|
||||
pStep->AddNonIonizingEnergyDeposit(theNonIonizingEnergyDeposit);
|
||||
return pStep;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForGamma::DumpInfo() const
|
||||
{
|
||||
// use base-class DumpInfo
|
||||
// use base-class DumpInfo
|
||||
G4VParticleChange::DumpInfo();
|
||||
|
||||
G4int oldprc = G4cout.precision(3);
|
||||
G4cout << " Kinetic Energy (MeV): "
|
||||
<< std::setw(20) << proposedKinEnergy/MeV
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direction: "
|
||||
<< std::setw(20) << proposedMomentumDirection
|
||||
<< G4endl;
|
||||
G4cout << " Polarization: "
|
||||
<< std::setw(20) << proposedPolarization
|
||||
<< G4endl;
|
||||
G4cout << " Kinetic Energy (MeV): " << std::setw(20)
|
||||
<< proposedKinEnergy / MeV << G4endl;
|
||||
G4cout << " Momentum Direction: " << std::setw(20)
|
||||
<< proposedMomentumDirection << G4endl;
|
||||
G4cout << " Polarization: " << std::setw(20) << proposedPolarization
|
||||
<< G4endl;
|
||||
G4cout.precision(oldprc);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4ParticleChangeForGamma::CheckIt(const G4Track& aTrack)
|
||||
{
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
|
||||
G4double accuracy;
|
||||
G4double accuracy;
|
||||
|
||||
// Energy should not be lager than initial value
|
||||
accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
itsOK = false;
|
||||
accuracy = (proposedKinEnergy - aTrack.GetKineticEnergy()) / MeV;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOK = false;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << "G4ParticleChangeForGamma::CheckIt: ";
|
||||
G4cout << "KinEnergy become larger than the initial value!"
|
||||
<< " Difference: " << accuracy << "[MeV] " <<G4endl;
|
||||
G4cout << "KinEnergy become larger than the initial value!"
|
||||
<< " Difference: " << accuracy << "[MeV] " << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<< G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// dump out information of this particle change
|
||||
#ifdef G4VERBOSE
|
||||
if (!itsOK) DumpInfo();
|
||||
if(!itsOK) { DumpInfo(); }
|
||||
#endif
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError) {
|
||||
G4Exception("G4ParticleChangeForGamma::CheckIt",
|
||||
"TRACK004",EventMustBeAborted,
|
||||
"energy was illegal");
|
||||
if(exitWithError)
|
||||
{
|
||||
G4Exception("G4ParticleChangeForGamma::CheckIt()", "TRACK004",
|
||||
EventMustBeAborted, "energy was illegal");
|
||||
}
|
||||
|
||||
//correction
|
||||
if (!itsOK) {
|
||||
// correction
|
||||
if(!itsOK)
|
||||
{
|
||||
proposedKinEnergy = aTrack.GetKineticEnergy();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,178 +23,144 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleChangeForLoss class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Modified:
|
||||
// 16.01.04 V.Ivanchenko update for model variant of energy loss
|
||||
// 15.04.05 V.Ivanchenko inline update methods
|
||||
// 28.08.06 V.Ivanchenko Add access to current track and polarizaion
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// Author: Hisaya Kurashige, 23 March 1998
|
||||
// Revision: Vladimir Ivantchenko, 16 January 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ParticleChangeForLoss.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
//#include "G4VelocityTable.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForLoss::G4ParticleChangeForLoss()
|
||||
: G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.),
|
||||
lowEnergyLimit(1.0*eV), currentCharge(0.)
|
||||
: G4VParticleChange()
|
||||
, lowEnergyLimit(1.0 * eV)
|
||||
{
|
||||
theSteppingControlFlag = NormalCondition;
|
||||
debugFlag = false;
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
debugFlag = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForLoss::~G4ParticleChangeForLoss()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
G4ParticleChangeForLoss::
|
||||
G4ParticleChangeForLoss(const G4ParticleChangeForLoss &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForLoss::G4ParticleChangeForLoss(
|
||||
const G4ParticleChangeForLoss& right)
|
||||
: G4VParticleChange(right)
|
||||
{
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "G4ParticleChangeForLoss:: copy constructor is called " << G4endl;
|
||||
}
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
lowEnergyLimit = right.lowEnergyLimit;
|
||||
currentCharge = right.currentCharge;
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
lowEnergyLimit = right.lowEnergyLimit;
|
||||
currentCharge = right.currentCharge;
|
||||
proposedMomentumDirection = right.proposedMomentumDirection;
|
||||
}
|
||||
|
||||
// assignment operator
|
||||
G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=(
|
||||
const G4ParticleChangeForLoss &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForLoss& G4ParticleChangeForLoss::operator=(
|
||||
const G4ParticleChangeForLoss& right)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this != &right) {
|
||||
if (theNumberOfSecondaries>0) {
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4ParticleChangeForLoss: assignment operator Warning ";
|
||||
G4cout << "theListOfSecondaries is not empty ";
|
||||
if(this != &right)
|
||||
{
|
||||
if(theNumberOfSecondaries > 0)
|
||||
{
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
if((*theListOfSecondaries)[index])
|
||||
delete(*theListOfSecondaries)[index];
|
||||
}
|
||||
#endif
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
|
||||
}
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
delete theListOfSecondaries;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
for (G4int index = 0; index<theNumberOfSecondaries; index++){
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
|
||||
theListOfSecondaries->SetElement(index, newTrack); }
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
}
|
||||
|
||||
theStatusChange = right.theStatusChange;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theParentWeight = right.theParentWeight;
|
||||
isParentWeightProposed = right.isParentWeightProposed;
|
||||
theStatusChange = right.theStatusChange;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theParentWeight = right.theParentWeight;
|
||||
isParentWeightProposed = right.isParentWeightProposed;
|
||||
fSetSecondaryWeightByProcess = right.fSetSecondaryWeightByProcess;
|
||||
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
currentCharge = right.currentCharge;
|
||||
currentTrack = right.currentTrack;
|
||||
proposedKinEnergy = right.proposedKinEnergy;
|
||||
currentCharge = right.currentCharge;
|
||||
proposedMomentumDirection = right.proposedMomentumDirection;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForLoss::DumpInfo() const
|
||||
{
|
||||
// use base-class DumpInfo
|
||||
// use base-class DumpInfo
|
||||
G4VParticleChange::DumpInfo();
|
||||
|
||||
G4int oldprc = G4cout.precision(3);
|
||||
G4cout << " Charge (eplus) : "
|
||||
<< std::setw(20) << currentCharge/eplus
|
||||
<< G4endl;
|
||||
G4cout << " Kinetic Energy (MeV): "
|
||||
<< std::setw(20) << proposedKinEnergy/MeV
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direct - x : "
|
||||
<< std::setw(20) << proposedMomentumDirection.x()
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direct - y : "
|
||||
<< std::setw(20) << proposedMomentumDirection.y()
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direct - z : "
|
||||
<< std::setw(20) << proposedMomentumDirection.z()
|
||||
<< G4endl;
|
||||
G4cout << " Charge (eplus) : " << std::setw(20)
|
||||
<< currentCharge / eplus << G4endl;
|
||||
G4cout << " Kinetic Energy (MeV): " << std::setw(20)
|
||||
<< proposedKinEnergy / MeV << G4endl;
|
||||
G4cout << " Momentum Direct - x : " << std::setw(20)
|
||||
<< proposedMomentumDirection.x() << G4endl;
|
||||
G4cout << " Momentum Direct - y : " << std::setw(20)
|
||||
<< proposedMomentumDirection.y() << G4endl;
|
||||
G4cout << " Momentum Direct - z : " << std::setw(20)
|
||||
<< proposedMomentumDirection.z() << G4endl;
|
||||
G4cout.precision(oldprc);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
|
||||
{
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
|
||||
G4double accuracy;
|
||||
G4double accuracy;
|
||||
|
||||
// Energy should not be lager than initial value
|
||||
accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
itsOK = false;
|
||||
accuracy = (proposedKinEnergy - aTrack.GetKineticEnergy()) / MeV;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOK = false;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << "G4ParticleChangeForLoss::CheckIt: ";
|
||||
G4cout << "KinEnergy become larger than the initial value!"
|
||||
<< " Difference: " << accuracy << "[MeV] " <<G4endl;
|
||||
G4cout << "KinEnergy become larger than the initial value!"
|
||||
<< " Difference: " << accuracy << "[MeV] " << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// dump out information of this particle change
|
||||
#ifdef G4VERBOSE
|
||||
if (!itsOK) DumpInfo();
|
||||
if(!itsOK) { DumpInfo(); }
|
||||
#endif
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError) {
|
||||
G4Exception("G4ParticleChangeForLoss::CheckIt",
|
||||
"TRACK004", EventMustBeAborted,
|
||||
"energy was illegal");
|
||||
// exit with error
|
||||
if(exitWithError)
|
||||
{
|
||||
G4Exception("G4ParticleChangeForLoss::CheckIt()", "TRACK004",
|
||||
EventMustBeAborted, "energy was illegal");
|
||||
}
|
||||
|
||||
//correction
|
||||
if (!itsOK) {
|
||||
// correction
|
||||
if(!itsOK)
|
||||
{
|
||||
proposedKinEnergy = aTrack.GetKineticEnergy();
|
||||
}
|
||||
|
||||
@@ -202,66 +168,71 @@ G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
|
||||
return itsOK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for updating G4Step
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep)
|
||||
{
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4Track* pTrack = pStep->GetTrack();
|
||||
G4Track* pTrack = pStep->GetTrack();
|
||||
|
||||
// accumulate change of the kinetic energy
|
||||
G4double preKinEnergy = pPreStepPoint->GetKineticEnergy();
|
||||
G4double kinEnergy = pPostStepPoint->GetKineticEnergy() +
|
||||
(proposedKinEnergy - preKinEnergy);
|
||||
G4double kinEnergy =
|
||||
pPostStepPoint->GetKineticEnergy() + (proposedKinEnergy - preKinEnergy);
|
||||
|
||||
// update kinetic energy and charge
|
||||
if (kinEnergy < lowEnergyLimit) {
|
||||
if(kinEnergy < lowEnergyLimit)
|
||||
{
|
||||
theLocalEnergyDeposit += kinEnergy;
|
||||
kinEnergy = 0.0;
|
||||
pPostStepPoint->SetVelocity(0.0);
|
||||
} else {
|
||||
pPostStepPoint->SetCharge( currentCharge );
|
||||
}
|
||||
else
|
||||
{
|
||||
pPostStepPoint->SetCharge(currentCharge);
|
||||
// calculate velocity
|
||||
pTrack->SetKineticEnergy(kinEnergy);
|
||||
pTrack->SetKineticEnergy(kinEnergy);
|
||||
pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
|
||||
pTrack->SetKineticEnergy(preKinEnergy);
|
||||
pTrack->SetKineticEnergy(preKinEnergy);
|
||||
}
|
||||
pPostStepPoint->SetKineticEnergy( kinEnergy );
|
||||
pPostStepPoint->SetKineticEnergy(kinEnergy);
|
||||
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
pPostStepPoint->SetWeight(theParentWeight);
|
||||
}
|
||||
|
||||
pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
|
||||
pStep->AddTotalEnergyDeposit(theLocalEnergyDeposit);
|
||||
pStep->AddNonIonizingEnergyDeposit(theNonIonizingEnergyDeposit);
|
||||
return pStep;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForLoss::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* pTrack = pStep->GetTrack();
|
||||
G4Track* pTrack = pStep->GetTrack();
|
||||
|
||||
pPostStepPoint->SetCharge( currentCharge );
|
||||
pPostStepPoint->SetMomentumDirection( proposedMomentumDirection );
|
||||
pPostStepPoint->SetKineticEnergy( proposedKinEnergy );
|
||||
pTrack->SetKineticEnergy( proposedKinEnergy );
|
||||
if(proposedKinEnergy > 0.0) {
|
||||
pPostStepPoint->SetCharge(currentCharge);
|
||||
pPostStepPoint->SetMomentumDirection(proposedMomentumDirection);
|
||||
pPostStepPoint->SetKineticEnergy(proposedKinEnergy);
|
||||
pTrack->SetKineticEnergy(proposedKinEnergy);
|
||||
if(proposedKinEnergy > 0.0)
|
||||
{
|
||||
pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
pPostStepPoint->SetVelocity(0.0);
|
||||
}
|
||||
pPostStepPoint->SetPolarization( proposedPolarization );
|
||||
pPostStepPoint->SetPolarization(proposedPolarization);
|
||||
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
pPostStepPoint->SetWeight(theParentWeight);
|
||||
}
|
||||
|
||||
pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
|
||||
pStep->AddTotalEnergyDeposit(theLocalEnergyDeposit);
|
||||
pStep->AddNonIonizingEnergyDeposit(theNonIonizingEnergyDeposit);
|
||||
return pStep;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,18 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleChangeForMSC class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
|
||||
// Update for model variant of msc 16 Jan 2004 V.Ivanchenko
|
||||
// --------------------------------------------------------------
|
||||
// Author: Hisaya Kurashige, 23 March 1998
|
||||
// Revision: Vladimir Ivantchenko, 16 January 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ParticleChangeForMSC.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
@@ -43,177 +36,148 @@
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForMSC::G4ParticleChangeForMSC()
|
||||
: G4VParticleChange()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForMSC::G4ParticleChangeForMSC() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForMSC::~G4ParticleChangeForMSC()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForMSC::~G4ParticleChangeForMSC() " << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForMSC::
|
||||
G4ParticleChangeForMSC(const G4ParticleChangeForMSC &right)
|
||||
G4ParticleChangeForMSC(const G4ParticleChangeForMSC& right)
|
||||
: G4VParticleChange(right)
|
||||
{
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "G4ParticleChangeForMSC:: copy constructor is called " << G4endl;
|
||||
}
|
||||
theMomentumDirection = right.theMomentumDirection;
|
||||
thePosition = right.thePosition;
|
||||
theMomentumDirection = right.theMomentumDirection;
|
||||
thePosition = right.thePosition;
|
||||
}
|
||||
|
||||
// assignment operator
|
||||
G4ParticleChangeForMSC & G4ParticleChangeForMSC::operator=(
|
||||
const G4ParticleChangeForMSC &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForMSC&
|
||||
G4ParticleChangeForMSC::operator=(const G4ParticleChangeForMSC& right)
|
||||
{
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "G4ParticleChangeForMSC:: assignment operator is called " << G4endl;
|
||||
}
|
||||
if (this != &right)
|
||||
{
|
||||
theListOfSecondaries = right.theListOfSecondaries;
|
||||
theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
theStatusChange = right.theStatusChange;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
if(this != &right)
|
||||
{
|
||||
theListOfSecondaries = right.theListOfSecondaries;
|
||||
theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
theStatusChange = right.theStatusChange;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
|
||||
theMomentumDirection = right.theMomentumDirection;
|
||||
thePosition = right.thePosition;
|
||||
}
|
||||
return *this;
|
||||
theMomentumDirection = right.theMomentumDirection;
|
||||
thePosition = right.thePosition;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for updating G4Step
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForMSC::UpdateStepForAlongStep(G4Step* pStep)
|
||||
{
|
||||
// Update the G4Step specific attributes
|
||||
// update the G4Step specific attributes
|
||||
pStep->SetStepLength(theTrueStepLength);
|
||||
theStatusChange = pStep->GetTrack()->GetTrackStatus();
|
||||
|
||||
// Multiple scattering calculates the final state of the particle
|
||||
// multiple scattering calculates the final state of the particle
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
|
||||
// update momentum direction
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumDirection);
|
||||
|
||||
// update position
|
||||
pPostStepPoint->SetPosition( thePosition );
|
||||
pPostStepPoint->SetPosition(thePosition);
|
||||
return pStep;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForMSC::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
// Multiple scattering calculates the final state of the particle
|
||||
// multiple scattering calculates the final state of the particle
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
|
||||
// update momentum direction
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumDirection);
|
||||
|
||||
// update position
|
||||
pPostStepPoint->SetPosition( thePosition );
|
||||
pPostStepPoint->SetPosition(thePosition);
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
// update the G4Step specific attributes
|
||||
return pStep;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForMSC::DumpInfo() const
|
||||
{
|
||||
// use base-class DumpInfo
|
||||
// use base-class DumpInfo
|
||||
G4VParticleChange::DumpInfo();
|
||||
|
||||
G4int oldprc = G4cout.precision(3);
|
||||
G4cout << " Position - x (mm) : "
|
||||
<< std::setw(20) << thePosition.x()/mm
|
||||
<< G4endl;
|
||||
G4cout << " Position - y (mm) : "
|
||||
<< std::setw(20) << thePosition.y()/mm
|
||||
<< G4endl;
|
||||
G4cout << " Position - z (mm) : "
|
||||
<< std::setw(20) << thePosition.z()/mm
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direct - x : "
|
||||
<< std::setw(20) << theMomentumDirection.x()
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direct - y : "
|
||||
<< std::setw(20) << theMomentumDirection.y()
|
||||
<< G4endl;
|
||||
G4cout << " Momentum Direct - z : "
|
||||
<< std::setw(20) << theMomentumDirection.z()
|
||||
<< G4endl;
|
||||
G4cout << " Position - x (mm) : " << std::setw(20)
|
||||
<< thePosition.x() / mm << G4endl;
|
||||
G4cout << " Position - y (mm) : " << std::setw(20)
|
||||
<< thePosition.y() / mm << G4endl;
|
||||
G4cout << " Position - z (mm) : " << std::setw(20)
|
||||
<< thePosition.z() / mm << G4endl;
|
||||
G4cout << " Momentum Direct - x : " << std::setw(20)
|
||||
<< theMomentumDirection.x() << G4endl;
|
||||
G4cout << " Momentum Direct - y : " << std::setw(20)
|
||||
<< theMomentumDirection.y() << G4endl;
|
||||
G4cout << " Momentum Direct - z : " << std::setw(20)
|
||||
<< theMomentumDirection.z() << G4endl;
|
||||
G4cout.precision(oldprc);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4ParticleChangeForMSC::CheckIt(const G4Track& aTrack)
|
||||
{
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
|
||||
G4double accuracy;
|
||||
G4double accuracy;
|
||||
|
||||
// check
|
||||
|
||||
// MomentumDirection should be unit vector
|
||||
accuracy = std::fabs(theMomentumDirection.mag2()-1.0);
|
||||
if (accuracy > accuracyForWarning) {
|
||||
itsOK = false;
|
||||
accuracy = std::fabs(theMomentumDirection.mag2() - 1.0);
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOK = false;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChangeForMSC::CheckIt : ";
|
||||
G4cout << "the Momentum Change is not unit vector !!"
|
||||
<< " Difference: " << accuracy << G4endl;
|
||||
<< " Difference: " << accuracy << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// dump out information of this particle change
|
||||
#ifdef G4VERBOSE
|
||||
if (!itsOK) DumpInfo();
|
||||
if(!itsOK) { DumpInfo(); }
|
||||
#endif
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError) {
|
||||
G4Exception("G4ParticleChangeForMSC::CheckIt",
|
||||
"300",
|
||||
EventMustBeAborted,
|
||||
"momentum direction was illegal");
|
||||
// exit with error
|
||||
if(exitWithError)
|
||||
{
|
||||
G4Exception("G4ParticleChangeForMSC::CheckIt()", "300", EventMustBeAborted,
|
||||
"momentum direction was illegal");
|
||||
}
|
||||
//correction
|
||||
if (!itsOK) {
|
||||
G4double vmag = theMomentumDirection.mag();
|
||||
theMomentumDirection = (1./vmag)*theMomentumDirection;
|
||||
// correction
|
||||
if(!itsOK)
|
||||
{
|
||||
G4double vmag = theMomentumDirection.mag();
|
||||
theMomentumDirection = (1. / vmag) * theMomentumDirection;
|
||||
}
|
||||
|
||||
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
|
||||
return itsOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,19 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleChangeForTransport class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// Implemented for the new scheme 10 May. 1998 H.Kurahige
|
||||
// Correct tratment of fpNextTouchable 12 May. 1998 H.Kurashige
|
||||
// Change to the next volume only if energy>0 19 Jan. 2004 V.Ivanchenko
|
||||
// --------------------------------------------------------------
|
||||
// Author: Hisaya Kurashige, 10 May 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ParticleChangeForTransport.hh"
|
||||
#include "G4TouchableHandle.hh"
|
||||
@@ -44,89 +35,64 @@
|
||||
#include "G4TrackFastVector.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForTransport::G4ParticleChangeForTransport()
|
||||
: G4ParticleChange(), isMomentumChanged(false), theMaterialChange(0),
|
||||
theMaterialCutsCoupleChange(0), theSensitiveDetectorChange(0),
|
||||
fpVectorOfAuxiliaryPointsPointer(0)
|
||||
: G4ParticleChange()
|
||||
{
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForTransport::G4ParticleChangeForTransport() "
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4ParticleChangeForTransport::~G4ParticleChangeForTransport()
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForTransport::~G4ParticleChangeForTransport()
|
||||
{
|
||||
if (verboseLevel>2) {
|
||||
G4cout << "G4ParticleChangeForTransport::~G4ParticleChangeForTransport() "
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForTransport::
|
||||
G4ParticleChangeForTransport(const G4ParticleChangeForTransport &r)
|
||||
: G4ParticleChange(r),
|
||||
fpVectorOfAuxiliaryPointsPointer(0)
|
||||
G4ParticleChangeForTransport(const G4ParticleChangeForTransport& r)
|
||||
: G4ParticleChange(r)
|
||||
{
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4ParticleChangeForTransport:: copy constructor is called "
|
||||
<< G4endl;
|
||||
}
|
||||
theTouchableHandle = r.theTouchableHandle;
|
||||
isMomentumChanged = r.isMomentumChanged;
|
||||
theMaterialChange = r.theMaterialChange;
|
||||
theTouchableHandle = r.theTouchableHandle;
|
||||
isMomentumChanged = r.isMomentumChanged;
|
||||
theMaterialChange = r.theMaterialChange;
|
||||
theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
|
||||
theSensitiveDetectorChange = r.theSensitiveDetectorChange;
|
||||
theSensitiveDetectorChange = r.theSensitiveDetectorChange;
|
||||
}
|
||||
|
||||
// assignemnt operator
|
||||
G4ParticleChangeForTransport &
|
||||
G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport &r)
|
||||
// --------------------------------------------------------------------
|
||||
G4ParticleChangeForTransport&
|
||||
G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport& r)
|
||||
{
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "G4ParticleChangeForTransport:: assignment operator is called "
|
||||
<< G4endl;
|
||||
}
|
||||
if (this != &r)
|
||||
{
|
||||
theListOfSecondaries = r.theListOfSecondaries;
|
||||
theSizeOftheListOfSecondaries = r.theSizeOftheListOfSecondaries;
|
||||
theNumberOfSecondaries = r.theNumberOfSecondaries;
|
||||
theStatusChange = r.theStatusChange;
|
||||
theTouchableHandle = r.theTouchableHandle;
|
||||
theMaterialChange = r.theMaterialChange;
|
||||
theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
|
||||
theSensitiveDetectorChange = r.theSensitiveDetectorChange;
|
||||
theMomentumDirectionChange = r.theMomentumDirectionChange;
|
||||
thePolarizationChange = r.thePolarizationChange;
|
||||
thePositionChange = r.thePositionChange;
|
||||
theTimeChange = r.theTimeChange;
|
||||
theEnergyChange = r.theEnergyChange;
|
||||
theVelocityChange = r.theVelocityChange;
|
||||
theTrueStepLength = r.theTrueStepLength;
|
||||
theLocalEnergyDeposit = r.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = r.theSteppingControlFlag;
|
||||
}
|
||||
return *this;
|
||||
if(this != &r)
|
||||
{
|
||||
theListOfSecondaries = r.theListOfSecondaries;
|
||||
theSizeOftheListOfSecondaries = r.theSizeOftheListOfSecondaries;
|
||||
theNumberOfSecondaries = r.theNumberOfSecondaries;
|
||||
theStatusChange = r.theStatusChange;
|
||||
theTouchableHandle = r.theTouchableHandle;
|
||||
theMaterialChange = r.theMaterialChange;
|
||||
theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
|
||||
theSensitiveDetectorChange = r.theSensitiveDetectorChange;
|
||||
theMomentumDirectionChange = r.theMomentumDirectionChange;
|
||||
thePolarizationChange = r.thePolarizationChange;
|
||||
thePositionChange = r.thePositionChange;
|
||||
theTimeChange = r.theTimeChange;
|
||||
theEnergyChange = r.theEnergyChange;
|
||||
theVelocityChange = r.theVelocityChange;
|
||||
theTrueStepLength = r.theTrueStepLength;
|
||||
theLocalEnergyDeposit = r.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = r.theSteppingControlFlag;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for updating G4Step
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep)
|
||||
{
|
||||
// Nothing happens for AtRestDoIt
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4ParticleChangeForTransport::UpdateStepForAtRest() is called"
|
||||
<< G4endl;
|
||||
G4cout << " Nothing happens for this method " << G4endl;
|
||||
}
|
||||
// Update the G4Step specific attributes
|
||||
// Update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
|
||||
{
|
||||
// Smooth curved tajectory representation: let the Step know about
|
||||
@@ -134,7 +100,7 @@ G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
|
||||
pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer);
|
||||
|
||||
// copy of G4ParticleChange::UpdateStepForAlongStep
|
||||
// i.e. no effect for touchable
|
||||
// i.e. no effect for touchable
|
||||
|
||||
// A physics process always calculates the final state of the
|
||||
// particle relative to the initial state at the beginning
|
||||
@@ -149,91 +115,97 @@ G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
|
||||
|
||||
G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
G4double mass = aTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
// uodate kinetic energy
|
||||
// now assume that no energy change in transportation
|
||||
// However it is not true in electric fields
|
||||
// Case for changing energy will be implemented in future
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
G4double mass = aTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
// update kinetic energy
|
||||
// now assume that no energy change in transportation
|
||||
// However it is not true in electric fields
|
||||
// Case for changing energy will be implemented in future
|
||||
|
||||
// update momentum direction and energy
|
||||
if (isMomentumChanged) {
|
||||
if(isMomentumChanged)
|
||||
{
|
||||
G4double energy;
|
||||
energy= pPostStepPoint->GetKineticEnergy()
|
||||
+ (theEnergyChange - pPreStepPoint->GetKineticEnergy());
|
||||
energy = pPostStepPoint->GetKineticEnergy() +
|
||||
(theEnergyChange - pPreStepPoint->GetKineticEnergy());
|
||||
|
||||
// calculate new momentum
|
||||
G4ThreeVector pMomentum = pPostStepPoint->GetMomentum()
|
||||
+ ( CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass)
|
||||
- pPreStepPoint->GetMomentum());
|
||||
G4double tMomentum = pMomentum.mag();
|
||||
G4ThreeVector direction(1.0,0.0,0.0);
|
||||
if( tMomentum > 0. ){
|
||||
G4double inv_Momentum= 1.0 / tMomentum;
|
||||
direction= pMomentum * inv_Momentum;
|
||||
G4ThreeVector pMomentum =
|
||||
pPostStepPoint->GetMomentum() +
|
||||
(CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass) -
|
||||
pPreStepPoint->GetMomentum());
|
||||
G4double tMomentum = pMomentum.mag();
|
||||
G4ThreeVector direction(1.0, 0.0, 0.0);
|
||||
if(tMomentum > 0.)
|
||||
{
|
||||
G4double inv_Momentum = 1.0 / tMomentum;
|
||||
direction = pMomentum * inv_Momentum;
|
||||
}
|
||||
pPostStepPoint->SetMomentumDirection(direction);
|
||||
pPostStepPoint->SetKineticEnergy( energy );
|
||||
pPostStepPoint->SetKineticEnergy(energy);
|
||||
}
|
||||
if (isVelocityChanged) pPostStepPoint->SetVelocity(theVelocityChange);
|
||||
if(isVelocityChanged)
|
||||
pPostStepPoint->SetVelocity(theVelocityChange);
|
||||
|
||||
// stop case should not occur
|
||||
//pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
|
||||
|
||||
// pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->AddPolarization( thePolarizationChange
|
||||
- pPreStepPoint->GetPolarization());
|
||||
pPostStepPoint->AddPolarization(thePolarizationChange -
|
||||
pPreStepPoint->GetPolarization());
|
||||
|
||||
// update position and time
|
||||
pPostStepPoint->AddPosition( thePositionChange
|
||||
- pPreStepPoint->GetPosition() );
|
||||
pPostStepPoint->AddGlobalTime( theTimeChange
|
||||
- pPreStepPoint->GetLocalTime());
|
||||
pPostStepPoint->AddLocalTime( theTimeChange
|
||||
- pPreStepPoint->GetLocalTime());
|
||||
pPostStepPoint->AddProperTime( theProperTimeChange
|
||||
- pPreStepPoint->GetProperTime());
|
||||
pPostStepPoint->AddPosition(thePositionChange - pPreStepPoint->GetPosition());
|
||||
pPostStepPoint->AddGlobalTime(theTimeChange - pPreStepPoint->GetLocalTime());
|
||||
pPostStepPoint->AddLocalTime(theTimeChange - pPreStepPoint->GetLocalTime());
|
||||
pPostStepPoint->AddProperTime(theProperTimeChange -
|
||||
pPreStepPoint->GetProperTime());
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
if(debugFlag) { CheckIt(*aTrack); }
|
||||
#endif
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
//pStep->SetStepLength( theTrueStepLength );
|
||||
// pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->SetControlFlag( theSteppingControlFlag );
|
||||
// Update the G4Step specific attributes
|
||||
// pStep->SetStepLength( theTrueStepLength );
|
||||
// pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->SetControlFlag(theSteppingControlFlag);
|
||||
|
||||
return pStep;
|
||||
// return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
// Change volume only if some kinetic energy remains
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
if(pPostStepPoint->GetKineticEnergy() > 0.0) {
|
||||
|
||||
if(pPostStepPoint->GetKineticEnergy() > 0.0)
|
||||
{
|
||||
// update next touchable
|
||||
// (touchable can be changed only at PostStepDoIt)
|
||||
pPostStepPoint->SetTouchableHandle( theTouchableHandle );
|
||||
pPostStepPoint->SetTouchableHandle(theTouchableHandle);
|
||||
|
||||
pPostStepPoint->SetMaterial( theMaterialChange );
|
||||
pPostStepPoint->SetMaterialCutsCouple( theMaterialCutsCoupleChange );
|
||||
pPostStepPoint->SetSensitiveDetector( theSensitiveDetectorChange );
|
||||
pPostStepPoint->SetMaterial(theMaterialChange);
|
||||
pPostStepPoint->SetMaterialCutsCouple(theMaterialCutsCoupleChange);
|
||||
pPostStepPoint->SetSensitiveDetector(theSensitiveDetectorChange);
|
||||
}
|
||||
if( this->GetFirstStepInVolume() ){
|
||||
if(this->GetFirstStepInVolume())
|
||||
{
|
||||
pStep->SetFirstStepFlag();
|
||||
}else{
|
||||
pStep->ClearFirstStepFlag();
|
||||
}
|
||||
if( this->GetLastStepInVolume() ){
|
||||
}
|
||||
else
|
||||
{
|
||||
pStep->ClearFirstStepFlag();
|
||||
}
|
||||
if(this->GetLastStepInVolume())
|
||||
{
|
||||
pStep->SetLastStepFlag();
|
||||
}else{
|
||||
pStep->ClearLastStepFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
pStep->ClearLastStepFlag();
|
||||
}
|
||||
// It used to call base class's method
|
||||
// - but this would copy uninitialised data members
|
||||
@@ -246,19 +218,14 @@ G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
|
||||
return pStep;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4ParticleChangeForTransport::DumpInfo() const
|
||||
{
|
||||
// use base-class DumpInfo
|
||||
// use base-class DumpInfo
|
||||
G4ParticleChange::DumpInfo();
|
||||
|
||||
G4int oldprc = G4cout.precision(3);
|
||||
G4cout << " Touchable (pointer) : "
|
||||
<< std::setw(20) << theTouchableHandle() << G4endl;
|
||||
G4cout << " Touchable (pointer) : " << std::setw(20)
|
||||
<< theTouchableHandle() << G4endl;
|
||||
G4cout.precision(oldprc);
|
||||
}
|
||||
|
||||
|
||||
+114
-116
@@ -23,52 +23,28 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4Step class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4Step.cc
|
||||
//
|
||||
// Description:
|
||||
// This class represents the Step of a particle tracked.
|
||||
// It includes information of
|
||||
// 1) List of Step points which compose the Step,
|
||||
// 2) static information of particle which generated the
|
||||
// Step,
|
||||
// 3) trackID and parent particle ID of the Step,
|
||||
// 4) termination condition of the Step,
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Authors:
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
// Revisions:
|
||||
// Hisaya Kurashige, 1998-2007
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Step.hh"
|
||||
|
||||
////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Step::G4Step()
|
||||
////////////////
|
||||
: fTotalEnergyDeposit(0.0),fNonIonizingEnergyDeposit(0.0),
|
||||
fStepLength(0.), fpTrack(0),
|
||||
fpSteppingControlFlag(NormalCondition),
|
||||
fFirstStepInVolume(false),
|
||||
fLastStepInVolume(false),
|
||||
fSecondary(nullptr),
|
||||
nSecondaryByLastStep(0), secondaryInCurrentStep(nullptr),
|
||||
fpVectorOfAuxiliaryPointsPointer(nullptr)
|
||||
{
|
||||
fpPreStepPoint = new G4StepPoint();
|
||||
fpPostStepPoint = new G4StepPoint();
|
||||
|
||||
secondaryInCurrentStep = new std::vector<CT>;
|
||||
secondaryInCurrentStep = new std::vector<const G4Track*>;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Step::~G4Step()
|
||||
/////////////////
|
||||
{
|
||||
delete fpPreStepPoint;
|
||||
fpPreStepPoint = nullptr;
|
||||
@@ -79,142 +55,164 @@ G4Step::~G4Step()
|
||||
delete secondaryInCurrentStep;
|
||||
secondaryInCurrentStep = nullptr;
|
||||
|
||||
if (fSecondary != nullptr ) {
|
||||
if(fSecondary != nullptr)
|
||||
{
|
||||
fSecondary->clear();
|
||||
delete fSecondary;
|
||||
}
|
||||
fSecondary = nullptr;
|
||||
}
|
||||
|
||||
// Copy Counstructor and assignment operator
|
||||
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Step::G4Step(const G4Step& right)
|
||||
/////////////////
|
||||
: fTotalEnergyDeposit(right.fTotalEnergyDeposit),
|
||||
fNonIonizingEnergyDeposit(right.fNonIonizingEnergyDeposit),
|
||||
fStepLength(right.fStepLength),
|
||||
fpTrack(right.fpTrack),
|
||||
fpSteppingControlFlag(right.fpSteppingControlFlag),
|
||||
fFirstStepInVolume(right.fFirstStepInVolume),
|
||||
fLastStepInVolume(right.fLastStepInVolume),
|
||||
nSecondaryByLastStep(right.nSecondaryByLastStep),
|
||||
secondaryInCurrentStep(right.secondaryInCurrentStep),
|
||||
fpVectorOfAuxiliaryPointsPointer(right.fpVectorOfAuxiliaryPointsPointer)
|
||||
: fTotalEnergyDeposit(right.fTotalEnergyDeposit)
|
||||
, fNonIonizingEnergyDeposit(right.fNonIonizingEnergyDeposit)
|
||||
, fStepLength(right.fStepLength)
|
||||
, fpTrack(right.fpTrack)
|
||||
, fpSteppingControlFlag(right.fpSteppingControlFlag)
|
||||
, fFirstStepInVolume(right.fFirstStepInVolume)
|
||||
, fLastStepInVolume(right.fLastStepInVolume)
|
||||
, nSecondaryByLastStep(right.nSecondaryByLastStep)
|
||||
, secondaryInCurrentStep(right.secondaryInCurrentStep)
|
||||
, fpVectorOfAuxiliaryPointsPointer(right.fpVectorOfAuxiliaryPointsPointer)
|
||||
{
|
||||
if (right.fpPreStepPoint != nullptr) {
|
||||
fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
|
||||
} else {
|
||||
fpPreStepPoint = new G4StepPoint();
|
||||
if(right.fpPreStepPoint != nullptr)
|
||||
{
|
||||
fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
|
||||
}
|
||||
if (right.fpPostStepPoint != nullptr) {
|
||||
fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
|
||||
} else {
|
||||
fpPostStepPoint = new G4StepPoint();
|
||||
else
|
||||
{
|
||||
fpPreStepPoint = new G4StepPoint();
|
||||
}
|
||||
|
||||
if (right.fSecondary != nullptr) {
|
||||
if(right.fpPostStepPoint != nullptr)
|
||||
{
|
||||
fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
|
||||
}
|
||||
else
|
||||
{
|
||||
fpPostStepPoint = new G4StepPoint();
|
||||
}
|
||||
|
||||
if(right.fSecondary != nullptr)
|
||||
{
|
||||
fSecondary = new G4TrackVector(*(right.fSecondary));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fSecondary = new G4TrackVector();
|
||||
}
|
||||
|
||||
// secondaryInCurrentStep is cleared
|
||||
secondaryInCurrentStep = new std::vector<CT>;
|
||||
// secondaryInCurrentStep is cleared
|
||||
secondaryInCurrentStep = new std::vector<const G4Track*>;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
G4Step& G4Step::operator=(const G4Step & right)
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Step& G4Step::operator=(const G4Step& right)
|
||||
{
|
||||
if (this != &right){
|
||||
fTotalEnergyDeposit = right.fTotalEnergyDeposit;
|
||||
fNonIonizingEnergyDeposit = right.fNonIonizingEnergyDeposit;
|
||||
fStepLength = right.fStepLength;
|
||||
fpTrack = right.fpTrack;
|
||||
fpSteppingControlFlag = right.fpSteppingControlFlag;
|
||||
fFirstStepInVolume = right.fFirstStepInVolume;
|
||||
fLastStepInVolume = right.fLastStepInVolume;
|
||||
nSecondaryByLastStep = right.nSecondaryByLastStep;
|
||||
secondaryInCurrentStep = right.secondaryInCurrentStep;
|
||||
if(this != &right)
|
||||
{
|
||||
fTotalEnergyDeposit = right.fTotalEnergyDeposit;
|
||||
fNonIonizingEnergyDeposit = right.fNonIonizingEnergyDeposit;
|
||||
fStepLength = right.fStepLength;
|
||||
fpTrack = right.fpTrack;
|
||||
fpSteppingControlFlag = right.fpSteppingControlFlag;
|
||||
fFirstStepInVolume = right.fFirstStepInVolume;
|
||||
fLastStepInVolume = right.fLastStepInVolume;
|
||||
nSecondaryByLastStep = right.nSecondaryByLastStep;
|
||||
secondaryInCurrentStep = right.secondaryInCurrentStep;
|
||||
fpVectorOfAuxiliaryPointsPointer = right.fpVectorOfAuxiliaryPointsPointer;
|
||||
|
||||
if (fpPreStepPoint != nullptr ) delete fpPreStepPoint;
|
||||
if (right.fpPreStepPoint != nullptr) {
|
||||
fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
|
||||
} else {
|
||||
fpPreStepPoint = new G4StepPoint();
|
||||
if(fpPreStepPoint != nullptr)
|
||||
{
|
||||
delete fpPreStepPoint;
|
||||
}
|
||||
if (fpPostStepPoint !=nullptr ) delete fpPostStepPoint;
|
||||
if (right.fpPostStepPoint != nullptr) {
|
||||
fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
|
||||
} else {
|
||||
fpPostStepPoint = new G4StepPoint();
|
||||
if(right.fpPreStepPoint != nullptr)
|
||||
{
|
||||
fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
|
||||
}
|
||||
|
||||
if (fSecondary != nullptr ) {
|
||||
else
|
||||
{
|
||||
fpPreStepPoint = new G4StepPoint();
|
||||
}
|
||||
if(fpPostStepPoint != nullptr)
|
||||
{
|
||||
delete fpPostStepPoint;
|
||||
}
|
||||
if(right.fpPostStepPoint != nullptr)
|
||||
{
|
||||
fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
|
||||
}
|
||||
else
|
||||
{
|
||||
fpPostStepPoint = new G4StepPoint();
|
||||
}
|
||||
|
||||
if(fSecondary != nullptr)
|
||||
{
|
||||
fSecondary->clear();
|
||||
delete fSecondary;
|
||||
}
|
||||
if (right.fSecondary != nullptr) {
|
||||
if(right.fSecondary != nullptr)
|
||||
{
|
||||
fSecondary = new G4TrackVector(*(right.fSecondary));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fSecondary = new G4TrackVector();
|
||||
}
|
||||
|
||||
// secondaryInCurrentStep is not copied
|
||||
if ( secondaryInCurrentStep != nullptr ) {
|
||||
|
||||
// secondaryInCurrentStep is not copied
|
||||
if(secondaryInCurrentStep != nullptr)
|
||||
{
|
||||
secondaryInCurrentStep->clear();
|
||||
delete secondaryInCurrentStep;
|
||||
}
|
||||
secondaryInCurrentStep = new std::vector<CT>;
|
||||
}
|
||||
secondaryInCurrentStep = new std::vector<const G4Track*>;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4ThreeVector G4Step::GetDeltaMomentum() const
|
||||
/////////////////
|
||||
{
|
||||
{
|
||||
static G4ThreadLocal G4bool isFirstTime = true;
|
||||
if (isFirstTime) {
|
||||
if(isFirstTime)
|
||||
{
|
||||
isFirstTime = false;
|
||||
#ifdef G4VERBOSE
|
||||
G4Exception( "G4Step::GetDeltaMomentum()","Warning", JustWarning,
|
||||
"This method is obsolete and will be removed soon");
|
||||
G4Exception("G4Step::GetDeltaMomentum()", "Warning", JustWarning,
|
||||
"This method is obsolete and will be removed soon");
|
||||
#endif
|
||||
}
|
||||
|
||||
return fpPostStepPoint->GetMomentum()
|
||||
- fpPreStepPoint->GetMomentum();
|
||||
return fpPostStepPoint->GetMomentum() - fpPreStepPoint->GetMomentum();
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4Step::GetDeltaEnergy() const
|
||||
/////////////////
|
||||
{
|
||||
{
|
||||
static G4ThreadLocal G4bool isFirstTime = true;
|
||||
if (isFirstTime) {
|
||||
if(isFirstTime)
|
||||
{
|
||||
isFirstTime = false;
|
||||
#ifdef G4VERBOSE
|
||||
G4Exception( "G4Step::GetDeltaEnergy()","Warning", JustWarning,
|
||||
"This method is obsolete and will be removed soon");
|
||||
G4Exception("G4Step::GetDeltaEnergy()", "Warning", JustWarning,
|
||||
"This method is obsolete and will be removed soon");
|
||||
#endif
|
||||
}
|
||||
|
||||
return fpPostStepPoint->GetKineticEnergy()
|
||||
- fpPreStepPoint->GetKineticEnergy();
|
||||
return fpPostStepPoint->GetKineticEnergy() -
|
||||
fpPreStepPoint->GetKineticEnergy();
|
||||
}
|
||||
|
||||
/////////////////
|
||||
const std::vector<const G4Track*>* G4Step::GetSecondaryInCurrentStep() const
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
const std::vector<const G4Track*>* G4Step::GetSecondaryInCurrentStep() const
|
||||
{
|
||||
secondaryInCurrentStep->clear();
|
||||
G4int nSecondary = fSecondary->size();
|
||||
for (G4int i=nSecondaryByLastStep; i<nSecondary; i++) {
|
||||
for(G4int i = nSecondaryByLastStep; i < nSecondary; ++i)
|
||||
{
|
||||
secondaryInCurrentStep->push_back((*fSecondary)[i]);
|
||||
}
|
||||
return secondaryInCurrentStep;
|
||||
return secondaryInCurrentStep;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,88 +23,64 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4StepPoint class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4StepPoint.cc
|
||||
//
|
||||
// Description:
|
||||
// This class represents information associated with the
|
||||
// each end of a Step like the space/time data of the
|
||||
// particle.
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Hisaya Kurashige
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Author: Hisaya Kurashige, 16 February 2000
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4StepPoint.hh"
|
||||
|
||||
//////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4StepPoint::G4StepPoint()
|
||||
//////////////////////////
|
||||
: fGlobalTime(0.), fLocalTime(0.), fProperTime(0.),
|
||||
fKineticEnergy(0.), fVelocity(0.),
|
||||
fpTouchable(0), fpMaterial(nullptr), fpMaterialCutsCouple(nullptr),
|
||||
fpSensitiveDetector(nullptr),
|
||||
fSafety(0.),
|
||||
fStepStatus(fUndefined), fpProcessDefinedStep(nullptr),
|
||||
fMass(0.), fCharge(0.), fMagneticMoment(0.),
|
||||
fWeight(0.)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
//////////////////////////
|
||||
G4StepPoint::G4StepPoint(const G4StepPoint &right) :
|
||||
//////////////////////////
|
||||
fPosition(right.fPosition),
|
||||
fGlobalTime(right.fGlobalTime),
|
||||
fLocalTime(right.fLocalTime),
|
||||
fProperTime(right.fProperTime),
|
||||
fMomentumDirection(right.fMomentumDirection),
|
||||
fKineticEnergy(right.fKineticEnergy),
|
||||
fVelocity(right.fVelocity),
|
||||
fpTouchable(right.fpTouchable),
|
||||
fpMaterial(right.fpMaterial),
|
||||
fpMaterialCutsCouple(right.fpMaterialCutsCouple),
|
||||
fpSensitiveDetector(right.fpSensitiveDetector),
|
||||
fSafety(right.fSafety),
|
||||
fPolarization(right.fPolarization),
|
||||
fStepStatus(right.fStepStatus),
|
||||
fpProcessDefinedStep(right.fpProcessDefinedStep),
|
||||
fMass(right.fMass),
|
||||
fCharge(right.fCharge),
|
||||
fMagneticMoment(right.fMagneticMoment),
|
||||
fWeight(right.fWeight)
|
||||
{
|
||||
}
|
||||
// --------------------------------------------------------------------
|
||||
G4StepPoint::G4StepPoint(const G4StepPoint& right)
|
||||
: fPosition(right.fPosition)
|
||||
, fGlobalTime(right.fGlobalTime)
|
||||
, fLocalTime(right.fLocalTime)
|
||||
, fProperTime(right.fProperTime)
|
||||
, fMomentumDirection(right.fMomentumDirection)
|
||||
, fKineticEnergy(right.fKineticEnergy)
|
||||
, fVelocity(right.fVelocity)
|
||||
, fpTouchable(right.fpTouchable)
|
||||
, fpMaterial(right.fpMaterial)
|
||||
, fpMaterialCutsCouple(right.fpMaterialCutsCouple)
|
||||
, fpSensitiveDetector(right.fpSensitiveDetector)
|
||||
, fSafety(right.fSafety)
|
||||
, fPolarization(right.fPolarization)
|
||||
, fStepStatus(right.fStepStatus)
|
||||
, fpProcessDefinedStep(right.fpProcessDefinedStep)
|
||||
, fMass(right.fMass)
|
||||
, fCharge(right.fCharge)
|
||||
, fMagneticMoment(right.fMagneticMoment)
|
||||
, fWeight(right.fWeight)
|
||||
{}
|
||||
|
||||
//////////////////////////
|
||||
G4StepPoint & G4StepPoint::operator=(const G4StepPoint &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4StepPoint& G4StepPoint::operator=(const G4StepPoint& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
fPosition = right.fPosition;
|
||||
fGlobalTime = right.fGlobalTime;
|
||||
fLocalTime = right.fLocalTime;
|
||||
fProperTime = right.fProperTime;
|
||||
fMomentumDirection = right.fMomentumDirection;
|
||||
fKineticEnergy = right.fKineticEnergy;
|
||||
fVelocity = right.fVelocity;
|
||||
fpTouchable = right.fpTouchable;
|
||||
fpMaterial = right.fpMaterial;
|
||||
if(this != &right)
|
||||
{
|
||||
fPosition = right.fPosition;
|
||||
fGlobalTime = right.fGlobalTime;
|
||||
fLocalTime = right.fLocalTime;
|
||||
fProperTime = right.fProperTime;
|
||||
fMomentumDirection = right.fMomentumDirection;
|
||||
fKineticEnergy = right.fKineticEnergy;
|
||||
fVelocity = right.fVelocity;
|
||||
fpTouchable = right.fpTouchable;
|
||||
fpMaterial = right.fpMaterial;
|
||||
fpMaterialCutsCouple = right.fpMaterialCutsCouple;
|
||||
fpSensitiveDetector = right.fpSensitiveDetector;
|
||||
fSafety = right.fSafety;
|
||||
fPolarization = right.fPolarization;
|
||||
fStepStatus = right.fStepStatus;
|
||||
fSafety = right.fSafety;
|
||||
fPolarization = right.fPolarization;
|
||||
fStepStatus = right.fStepStatus;
|
||||
fpProcessDefinedStep = right.fpProcessDefinedStep;
|
||||
fMass = right.fMass;
|
||||
fCharge = right.fCharge;
|
||||
fMagneticMoment = right.fMagneticMoment;
|
||||
fWeight = right.fWeight;
|
||||
fMass = right.fMass;
|
||||
fCharge = right.fCharge;
|
||||
fMagneticMoment = right.fMagneticMoment;
|
||||
fWeight = right.fWeight;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
+135
-188
@@ -23,20 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4Track class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4Track.cc
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// Add copy constructor Hisaya Feb. 07 01
|
||||
// Fix GetVelocity Hisaya Feb. 17 01
|
||||
// Modification for G4TouchableHandle 22 Oct. 2001 R.Chytracek//
|
||||
// Fix GetVelocity (bug report #741) Horton-Smith Apr 14 2005
|
||||
// Remove massless check in GetVelocity 02 Apr. 09 H.Kurashige
|
||||
// Use G4VelocityTable 17 AUg. 2011 H.Kurashige
|
||||
// Author: Katsuya Amako, KEK - 1996
|
||||
// Revisions: Hisaya Kurashige, 1998-2011
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Track.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
@@ -46,269 +37,225 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Allocator<G4Track>*& aTrackAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4Track>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4Track>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Track::G4Track(G4DynamicParticle* apValueDynamicParticle,
|
||||
G4double aValueTime,
|
||||
const G4ThreeVector& aValuePosition)
|
||||
///////////////////////////////////////////////////////////
|
||||
: fCurrentStepNumber(0), fPosition(aValuePosition),
|
||||
fGlobalTime(aValueTime), fLocalTime(0.),
|
||||
fTrackLength(0.),
|
||||
fParentID(0), fTrackID(0),
|
||||
fVelocity(c_light),
|
||||
fTrackStatus(fAlive),
|
||||
fBelowThreshold(false), fGoodForTracking(false),
|
||||
fStepLength(0.0), fWeight(1.0),
|
||||
fpStep(nullptr),
|
||||
fVtxKineticEnergy(0.0),
|
||||
fpLVAtVertex(nullptr), fpCreatorProcess(nullptr),
|
||||
fCreatorModelIndex(-1),
|
||||
fpUserInformation(nullptr),
|
||||
prev_mat(nullptr), groupvel(nullptr),
|
||||
prev_velocity(0.0), prev_momentum(0.0),
|
||||
is_OpticalPhoton(false),
|
||||
useGivenVelocity(false),
|
||||
fpAuxiliaryTrackInformationMap(nullptr)
|
||||
: fPosition(aValuePosition)
|
||||
, fGlobalTime(aValueTime)
|
||||
, fVelocity(c_light)
|
||||
{
|
||||
fpDynamicParticle = (apValueDynamicParticle) ? apValueDynamicParticle : new G4DynamicParticle();
|
||||
fpDynamicParticle = (apValueDynamicParticle)
|
||||
? apValueDynamicParticle : new G4DynamicParticle();
|
||||
// check if the particle type is Optical Photon
|
||||
is_OpticalPhoton = (fpDynamicParticle->GetDefinition()->GetPDGEncoding() == -22);
|
||||
is_OpticalPhoton =
|
||||
(fpDynamicParticle->GetDefinition()->GetPDGEncoding() == -22);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Track::G4Track()
|
||||
//////////////////
|
||||
: fCurrentStepNumber(0),
|
||||
fGlobalTime(0), fLocalTime(0.),
|
||||
fTrackLength(0.),
|
||||
fParentID(0), fTrackID(0),
|
||||
fVelocity(c_light),
|
||||
fpDynamicParticle(new G4DynamicParticle()),
|
||||
fTrackStatus(fAlive),
|
||||
fBelowThreshold(false), fGoodForTracking(false),
|
||||
fStepLength(0.0), fWeight(1.0),
|
||||
fpStep(nullptr),
|
||||
fVtxKineticEnergy(0.0),
|
||||
fpLVAtVertex(nullptr), fpCreatorProcess(nullptr),
|
||||
fCreatorModelIndex(-1),
|
||||
fpUserInformation(nullptr),
|
||||
prev_mat(nullptr), groupvel(nullptr),
|
||||
prev_velocity(0.0), prev_momentum(0.0),
|
||||
is_OpticalPhoton(false),
|
||||
useGivenVelocity(false),
|
||||
fpAuxiliaryTrackInformationMap(nullptr)
|
||||
{
|
||||
}
|
||||
: fVelocity(c_light)
|
||||
, fpDynamicParticle(new G4DynamicParticle())
|
||||
{}
|
||||
|
||||
//////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Track::G4Track(const G4Track& right)
|
||||
//////////////////
|
||||
: fCurrentStepNumber(0),
|
||||
fGlobalTime(0), fLocalTime(0.),
|
||||
fTrackLength(0.),
|
||||
fParentID(0), fTrackID(0),
|
||||
fVelocity(c_light),
|
||||
fpDynamicParticle(nullptr),
|
||||
fTrackStatus(fAlive),
|
||||
fBelowThreshold(false), fGoodForTracking(false),
|
||||
fStepLength(0.0), fWeight(1.0),
|
||||
fpStep(nullptr),
|
||||
fVtxKineticEnergy(0.0),
|
||||
fpLVAtVertex(nullptr), fpCreatorProcess(nullptr),
|
||||
fCreatorModelIndex(-1),
|
||||
fpUserInformation(nullptr),
|
||||
prev_mat(nullptr), groupvel(nullptr),
|
||||
prev_velocity(0.0), prev_momentum(0.0),
|
||||
is_OpticalPhoton(false),
|
||||
useGivenVelocity(false),
|
||||
fpAuxiliaryTrackInformationMap(nullptr)
|
||||
: fVelocity(c_light)
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Track::~G4Track()
|
||||
///////////////////
|
||||
{
|
||||
delete fpDynamicParticle;
|
||||
delete fpUserInformation;
|
||||
ClearAuxiliaryTrackInformation();
|
||||
delete fpDynamicParticle;
|
||||
delete fpUserInformation;
|
||||
ClearAuxiliaryTrackInformation();
|
||||
}
|
||||
|
||||
//////////////////
|
||||
G4Track & G4Track::operator=(const G4Track &right)
|
||||
//////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4Track& G4Track::operator=(const G4Track& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
fPosition = right.fPosition;
|
||||
fGlobalTime = right.fGlobalTime;
|
||||
fLocalTime = right.fLocalTime;
|
||||
fTrackLength = right.fTrackLength;
|
||||
fWeight = right.fWeight;
|
||||
fStepLength = right.fStepLength;
|
||||
if(this != &right)
|
||||
{
|
||||
fPosition = right.fPosition;
|
||||
fGlobalTime = right.fGlobalTime;
|
||||
fLocalTime = right.fLocalTime;
|
||||
fTrackLength = right.fTrackLength;
|
||||
fWeight = right.fWeight;
|
||||
fStepLength = right.fStepLength;
|
||||
|
||||
// Track ID (and Parent ID) is not copied and set to zero for new track
|
||||
fTrackID = 0;
|
||||
fParentID =0;
|
||||
// Track ID (and Parent ID) is not copied and set to zero for new track
|
||||
fTrackID = 0;
|
||||
fParentID = 0;
|
||||
|
||||
// CurrentStepNumber is set to be 0
|
||||
fCurrentStepNumber = 0;
|
||||
// CurrentStepNumber is set to be 0
|
||||
fCurrentStepNumber = 0;
|
||||
|
||||
// velocity information
|
||||
fVelocity = right.fVelocity;
|
||||
// velocity information
|
||||
fVelocity = right.fVelocity;
|
||||
|
||||
// dynamic particle information
|
||||
if ( fpDynamicParticle != nullptr ) delete fpDynamicParticle;
|
||||
fpDynamicParticle = new G4DynamicParticle(*(right.fpDynamicParticle));
|
||||
|
||||
// track status and flags for tracking
|
||||
fTrackStatus = right.fTrackStatus;
|
||||
fBelowThreshold = right.fBelowThreshold;
|
||||
fGoodForTracking = right.fGoodForTracking;
|
||||
|
||||
// Step information (Step Length, Step Number, pointer to the Step,)
|
||||
// are not copied
|
||||
fpStep = nullptr;
|
||||
// dynamic particle information
|
||||
delete fpDynamicParticle;
|
||||
fpDynamicParticle = new G4DynamicParticle(*(right.fpDynamicParticle));
|
||||
|
||||
// vertex information
|
||||
fVtxPosition = right.fVtxPosition;
|
||||
fpLVAtVertex = right.fpLVAtVertex;
|
||||
fVtxKineticEnergy = right.fVtxKineticEnergy;
|
||||
fVtxMomentumDirection = right.fVtxMomentumDirection;
|
||||
// track status and flags for tracking
|
||||
fTrackStatus = right.fTrackStatus;
|
||||
fBelowThreshold = right.fBelowThreshold;
|
||||
fGoodForTracking = right.fGoodForTracking;
|
||||
|
||||
// CreatorProcess and UserInformation are not copied
|
||||
fpCreatorProcess = nullptr;
|
||||
if ( fpUserInformation != nullptr ) delete fpUserInformation;
|
||||
fpUserInformation = nullptr;
|
||||
// Step information (Step Length, Step Number, pointer to the Step,)
|
||||
// are not copied
|
||||
fpStep = nullptr;
|
||||
|
||||
prev_mat = right.prev_mat;
|
||||
groupvel = right.groupvel;
|
||||
prev_velocity = right.prev_velocity;
|
||||
prev_momentum = right.prev_momentum;
|
||||
// vertex information
|
||||
fVtxPosition = right.fVtxPosition;
|
||||
fpLVAtVertex = right.fpLVAtVertex;
|
||||
fVtxKineticEnergy = right.fVtxKineticEnergy;
|
||||
fVtxMomentumDirection = right.fVtxMomentumDirection;
|
||||
|
||||
is_OpticalPhoton = right.is_OpticalPhoton;
|
||||
useGivenVelocity = right.useGivenVelocity;
|
||||
// CreatorProcess and UserInformation are not copied
|
||||
fpCreatorProcess = nullptr;
|
||||
delete fpUserInformation;
|
||||
fpUserInformation = nullptr;
|
||||
|
||||
ClearAuxiliaryTrackInformation();
|
||||
prev_mat = right.prev_mat;
|
||||
groupvel = right.groupvel;
|
||||
prev_velocity = right.prev_velocity;
|
||||
prev_momentum = right.prev_momentum;
|
||||
|
||||
is_OpticalPhoton = right.is_OpticalPhoton;
|
||||
useGivenVelocity = right.useGivenVelocity;
|
||||
|
||||
ClearAuxiliaryTrackInformation();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4Track::CopyTrackInfo(const G4Track& right)
|
||||
//////////////////
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4Track::CalculateVelocityForOpticalPhoton() const
|
||||
///////////////////
|
||||
{
|
||||
G4double velocity = c_light ;
|
||||
|
||||
G4Material* mat = nullptr;
|
||||
{
|
||||
G4double velocity = c_light;
|
||||
|
||||
G4Material* mat = nullptr;
|
||||
G4bool update_groupvel = false;
|
||||
if ( fpStep !=0 ){
|
||||
mat= this->GetMaterial(); // Fix for repeated volumes
|
||||
}else{
|
||||
if (fpTouchable!=0){
|
||||
mat=fpTouchable->GetVolume()->GetLogicalVolume()->GetMaterial();
|
||||
if(fpStep != nullptr)
|
||||
{
|
||||
mat = this->GetMaterial(); // Fix for repeated volumes
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fpTouchable != 0)
|
||||
{
|
||||
mat = fpTouchable->GetVolume()->GetLogicalVolume()->GetMaterial();
|
||||
}
|
||||
}
|
||||
// check if previous step is in the same volume
|
||||
// and get new GROUPVELOCITY table if necessary
|
||||
if ((mat != nullptr) && ((mat != prev_mat)||(groupvel==nullptr))) {
|
||||
// and get new GROUPVELOCITY table if necessary
|
||||
if((mat != nullptr) && ((mat != prev_mat) || (groupvel == nullptr)))
|
||||
{
|
||||
groupvel = nullptr;
|
||||
if(mat->GetMaterialPropertiesTable() != nullptr)
|
||||
groupvel = mat->GetMaterialPropertiesTable()->GetProperty("GROUPVEL");
|
||||
update_groupvel = true;
|
||||
}
|
||||
prev_mat = mat;
|
||||
|
||||
if (groupvel != nullptr ) {
|
||||
|
||||
if(groupvel != nullptr)
|
||||
{
|
||||
// light velocity = c/(rindex+d(rindex)/d(log(E_phot)))
|
||||
// values stored in GROUPVEL material properties vector
|
||||
velocity = prev_velocity;
|
||||
|
||||
velocity = prev_velocity;
|
||||
|
||||
// check if momentum is same as in the previous step
|
||||
// and calculate group velocity if necessary
|
||||
// and calculate group velocity if necessary
|
||||
G4double current_momentum = fpDynamicParticle->GetTotalMomentum();
|
||||
if( update_groupvel || (current_momentum != prev_momentum) ) {
|
||||
velocity =
|
||||
groupvel->Value(current_momentum);
|
||||
if(update_groupvel || (current_momentum != prev_momentum))
|
||||
{
|
||||
velocity = groupvel->Value(current_momentum);
|
||||
prev_velocity = velocity;
|
||||
prev_momentum = current_momentum;
|
||||
}
|
||||
}
|
||||
|
||||
return velocity ;
|
||||
}
|
||||
|
||||
return velocity;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
void G4Track::SetAuxiliaryTrackInformation(G4int idx, G4VAuxiliaryTrackInformation* info) const
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4Track::SetAuxiliaryTrackInformation(G4int idx,
|
||||
G4VAuxiliaryTrackInformation* info) const
|
||||
{
|
||||
if(!fpAuxiliaryTrackInformationMap)
|
||||
{ fpAuxiliaryTrackInformationMap = new std::map<G4int,G4VAuxiliaryTrackInformation*>; }
|
||||
if(idx<0 || idx>=G4PhysicsModelCatalog::Entries())
|
||||
if(fpAuxiliaryTrackInformationMap == nullptr)
|
||||
{
|
||||
fpAuxiliaryTrackInformationMap =
|
||||
new std::map<G4int, G4VAuxiliaryTrackInformation*>;
|
||||
}
|
||||
if(idx < 0 || idx >= G4PhysicsModelCatalog::Entries())
|
||||
{
|
||||
G4ExceptionDescription ED;
|
||||
ED << "Process/model index <" << idx << "> is invalid.";
|
||||
G4Exception("G4VAuxiliaryTrackInformation::G4VAuxiliaryTrackInformation()","TRACK0982",
|
||||
FatalException, ED);
|
||||
G4Exception("G4VAuxiliaryTrackInformation::G4VAuxiliaryTrackInformation()",
|
||||
"TRACK0982", FatalException, ED);
|
||||
}
|
||||
(*fpAuxiliaryTrackInformationMap)[idx] = info;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
G4VAuxiliaryTrackInformation* G4Track::GetAuxiliaryTrackInformation(G4int idx) const
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4VAuxiliaryTrackInformation*
|
||||
G4Track::GetAuxiliaryTrackInformation(G4int idx) const
|
||||
{
|
||||
if(!fpAuxiliaryTrackInformationMap) return nullptr;
|
||||
std::map<G4int,G4VAuxiliaryTrackInformation*>::iterator itr
|
||||
= fpAuxiliaryTrackInformationMap->find(idx);
|
||||
if(itr==fpAuxiliaryTrackInformationMap->end()) return nullptr;
|
||||
else return (*itr).second;
|
||||
if(fpAuxiliaryTrackInformationMap == nullptr)
|
||||
return nullptr;
|
||||
auto itr = fpAuxiliaryTrackInformationMap->find(idx);
|
||||
if(itr == fpAuxiliaryTrackInformationMap->cend())
|
||||
return nullptr;
|
||||
else
|
||||
return (*itr).second;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4Track::RemoveAuxiliaryTrackInformation(G4int idx)
|
||||
///////////////////
|
||||
{
|
||||
if( fpAuxiliaryTrackInformationMap != nullptr
|
||||
&& idx>=0 && idx<G4PhysicsModelCatalog::Entries()){
|
||||
if(fpAuxiliaryTrackInformationMap != nullptr
|
||||
&& idx >= 0 && idx < G4PhysicsModelCatalog::Entries())
|
||||
{
|
||||
fpAuxiliaryTrackInformationMap->erase(idx);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4Track::RemoveAuxiliaryTrackInformation(G4String& name)
|
||||
///////////////////
|
||||
{
|
||||
if(fpAuxiliaryTrackInformationMap != nullptr) {
|
||||
if(fpAuxiliaryTrackInformationMap != nullptr)
|
||||
{
|
||||
G4int idx = G4PhysicsModelCatalog::GetIndex(name);
|
||||
RemoveAuxiliaryTrackInformation(idx);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4Track::ClearAuxiliaryTrackInformation()
|
||||
///////////////////
|
||||
{
|
||||
if( fpAuxiliaryTrackInformationMap == nullptr) return;
|
||||
for(std::map<G4int,G4VAuxiliaryTrackInformation*>::iterator itr=fpAuxiliaryTrackInformationMap->begin();
|
||||
itr!=fpAuxiliaryTrackInformationMap->end(); itr++)
|
||||
{ delete (*itr).second; }
|
||||
if(fpAuxiliaryTrackInformationMap == nullptr)
|
||||
return;
|
||||
for(auto itr = fpAuxiliaryTrackInformationMap->cbegin();
|
||||
itr != fpAuxiliaryTrackInformationMap->cend(); ++itr)
|
||||
{
|
||||
delete(*itr).second;
|
||||
}
|
||||
delete fpAuxiliaryTrackInformationMap;
|
||||
fpAuxiliaryTrackInformationMap = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,19 +23,20 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VAuxiliaryTrackInformation class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// Author: Makoto Asai, 3 June 2005
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VAuxiliaryTrackInformation.hh"
|
||||
|
||||
G4VAuxiliaryTrackInformation::G4VAuxiliaryTrackInformation()
|
||||
{;}
|
||||
G4VAuxiliaryTrackInformation::G4VAuxiliaryTrackInformation() { ; }
|
||||
|
||||
G4VAuxiliaryTrackInformation::~G4VAuxiliaryTrackInformation()
|
||||
{;}
|
||||
G4VAuxiliaryTrackInformation::~G4VAuxiliaryTrackInformation() { ; }
|
||||
|
||||
void G4VAuxiliaryTrackInformation::Print() const
|
||||
{ G4cout<<"G4VAuxiliaryTrackInformation base class -- no concrete information available"<<G4endl; }
|
||||
|
||||
{
|
||||
G4cout << "G4VAuxiliaryTrackInformation base class -- no concrete "
|
||||
"information available"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
@@ -23,16 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VParticleChange class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
|
||||
// --------------------------------------------------------------
|
||||
// Author: Hisaya Kurashige, 23 March 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VParticleChange.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
@@ -41,26 +35,12 @@
|
||||
#include "G4TrackFastVector.hh"
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
|
||||
const G4double G4VParticleChange::accuracyForWarning = 1.0e-9;
|
||||
const G4double G4VParticleChange::accuracyForWarning = 1.0e-9;
|
||||
const G4double G4VParticleChange::accuracyForException = 0.001;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4VParticleChange::G4VParticleChange()
|
||||
:theListOfSecondaries(0),
|
||||
theNumberOfSecondaries(0),
|
||||
theSizeOftheListOfSecondaries(G4TrackFastVectorSize),
|
||||
theStatusChange(fAlive),
|
||||
theSteppingControlFlag(NormalCondition),
|
||||
theLocalEnergyDeposit(0.0),
|
||||
theNonIonizingEnergyDeposit(0.0),
|
||||
theTrueStepLength(0.0),
|
||||
theFirstStepInVolume(false),
|
||||
theLastStepInVolume(false),
|
||||
theParentWeight(1.0),
|
||||
isParentWeightProposed(false),
|
||||
fSetSecondaryWeightByProcess(false),
|
||||
theParentGlobalTime(0.0),
|
||||
verboseLevel(1),
|
||||
debugFlag(false)
|
||||
: theSizeOftheListOfSecondaries(G4TrackFastVectorSize)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
// activate CHeckIt if in VERBOSE mode
|
||||
@@ -69,461 +49,468 @@ G4VParticleChange::G4VParticleChange()
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
}
|
||||
|
||||
G4VParticleChange::~G4VParticleChange() {
|
||||
// --------------------------------------------------------------------
|
||||
G4VParticleChange::~G4VParticleChange()
|
||||
{
|
||||
// check if tracks still exist in theListOfSecondaries
|
||||
if (theNumberOfSecondaries>0) {
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4VParticleChange::~G4VParticleChange() Warning ";
|
||||
G4cout << "theListOfSecondaries is not empty ";
|
||||
}
|
||||
#endif
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
delete (*theListOfSecondaries)[index] ;
|
||||
if(theNumberOfSecondaries > 0)
|
||||
{
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
delete(*theListOfSecondaries)[index];
|
||||
}
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
delete theListOfSecondaries;
|
||||
}
|
||||
|
||||
G4VParticleChange::G4VParticleChange(const G4VParticleChange &right)
|
||||
:theListOfSecondaries(0),
|
||||
theNumberOfSecondaries(0),
|
||||
theSizeOftheListOfSecondaries(G4TrackFastVectorSize),
|
||||
theStatusChange( right.theStatusChange),
|
||||
theSteppingControlFlag(right.theSteppingControlFlag),
|
||||
theLocalEnergyDeposit(right.theLocalEnergyDeposit),
|
||||
theNonIonizingEnergyDeposit(right.theNonIonizingEnergyDeposit),
|
||||
theTrueStepLength(right.theTrueStepLength),
|
||||
theFirstStepInVolume( right.theFirstStepInVolume),
|
||||
theLastStepInVolume(right.theLastStepInVolume),
|
||||
theParentWeight(right.theParentWeight),
|
||||
isParentWeightProposed(false),
|
||||
fSetSecondaryWeightByProcess(right.fSetSecondaryWeightByProcess),
|
||||
theParentGlobalTime(0.0),
|
||||
verboseLevel(right.verboseLevel),
|
||||
debugFlag(right.debugFlag)
|
||||
// --------------------------------------------------------------------
|
||||
G4VParticleChange::G4VParticleChange(const G4VParticleChange& right)
|
||||
: theStatusChange(right.theStatusChange)
|
||||
, theSteppingControlFlag(right.theSteppingControlFlag)
|
||||
, theLocalEnergyDeposit(right.theLocalEnergyDeposit)
|
||||
, theNonIonizingEnergyDeposit(right.theNonIonizingEnergyDeposit)
|
||||
, theTrueStepLength(right.theTrueStepLength)
|
||||
, theParentWeight(right.theParentWeight)
|
||||
, theSizeOftheListOfSecondaries(G4TrackFastVectorSize)
|
||||
, verboseLevel(right.verboseLevel)
|
||||
, theFirstStepInVolume(right.theFirstStepInVolume)
|
||||
, theLastStepInVolume(right.theLastStepInVolume)
|
||||
, fSetSecondaryWeightByProcess(right.fSetSecondaryWeightByProcess)
|
||||
, debugFlag(right.debugFlag)
|
||||
{
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
for (G4int index = 0; index<theNumberOfSecondaries; index++){
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4VParticleChange & G4VParticleChange::operator=(const G4VParticleChange &right)
|
||||
// --------------------------------------------------------------------
|
||||
G4VParticleChange& G4VParticleChange::operator=(const G4VParticleChange& right)
|
||||
{
|
||||
if (this != &right){
|
||||
if (theNumberOfSecondaries>0) {
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4VParticleChange: assignment operator Warning ";
|
||||
G4cout << "theListOfSecondaries is not empty ";
|
||||
}
|
||||
#endif
|
||||
for (G4int index = 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) delete ((*theListOfSecondaries)[index]) ;
|
||||
if(this != &right)
|
||||
{
|
||||
if(theNumberOfSecondaries > 0)
|
||||
{
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
if((*theListOfSecondaries)[index])
|
||||
delete((*theListOfSecondaries)[index]);
|
||||
}
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
for (G4int index = 0; index<theNumberOfSecondaries; index++){
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
}
|
||||
theStatusChange = right.theStatusChange;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theNonIonizingEnergyDeposit = right.theNonIonizingEnergyDeposit;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
|
||||
theFirstStepInVolume = right.theFirstStepInVolume;
|
||||
theLastStepInVolume = right.theLastStepInVolume;
|
||||
delete theListOfSecondaries;
|
||||
|
||||
theParentWeight = right.theParentWeight;
|
||||
isParentWeightProposed = right.isParentWeightProposed;
|
||||
theListOfSecondaries = new G4TrackFastVector();
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
|
||||
{
|
||||
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
|
||||
theListOfSecondaries->SetElement(index, newTrack);
|
||||
}
|
||||
theStatusChange = right.theStatusChange;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theNonIonizingEnergyDeposit = right.theNonIonizingEnergyDeposit;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
|
||||
theFirstStepInVolume = right.theFirstStepInVolume;
|
||||
theLastStepInVolume = right.theLastStepInVolume;
|
||||
|
||||
theParentWeight = right.theParentWeight;
|
||||
isParentWeightProposed = right.isParentWeightProposed;
|
||||
fSetSecondaryWeightByProcess = right.fSetSecondaryWeightByProcess;
|
||||
|
||||
theParentGlobalTime = right.theParentGlobalTime;
|
||||
|
||||
verboseLevel = right.verboseLevel;
|
||||
debugFlag = right.debugFlag;
|
||||
|
||||
debugFlag = right.debugFlag;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4bool G4VParticleChange::operator==(const G4VParticleChange &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4VParticleChange::operator==(const G4VParticleChange& right) const
|
||||
{
|
||||
return (this == (G4VParticleChange *) &right);
|
||||
return (this == (G4VParticleChange*) &right);
|
||||
}
|
||||
|
||||
|
||||
G4bool G4VParticleChange::operator!=(const G4VParticleChange &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4VParticleChange::operator!=(const G4VParticleChange& right) const
|
||||
{
|
||||
return (this != (G4VParticleChange *) &right);
|
||||
return (this != (G4VParticleChange*) &right);
|
||||
}
|
||||
|
||||
void G4VParticleChange::AddSecondary(G4Track *aTrack)
|
||||
// --------------------------------------------------------------------
|
||||
void G4VParticleChange::AddSecondary(G4Track* aTrack)
|
||||
{
|
||||
if (debugFlag) CheckSecondary(*aTrack);
|
||||
if(debugFlag)
|
||||
CheckSecondary(*aTrack);
|
||||
|
||||
// add a secondary after size check
|
||||
if (theSizeOftheListOfSecondaries > theNumberOfSecondaries) {
|
||||
// Set weight of secondary tracks
|
||||
if (!fSetSecondaryWeightByProcess) aTrack->SetWeight(theParentWeight);
|
||||
if(theSizeOftheListOfSecondaries > theNumberOfSecondaries)
|
||||
{
|
||||
// set weight of secondary tracks
|
||||
if(!fSetSecondaryWeightByProcess)
|
||||
aTrack->SetWeight(theParentWeight);
|
||||
theListOfSecondaries->SetElement(theNumberOfSecondaries, aTrack);
|
||||
theNumberOfSecondaries++;
|
||||
} else {
|
||||
++theNumberOfSecondaries;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete aTrack;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "G4VParticleChange::AddSecondary() Warning ";
|
||||
G4cout << "theListOfSecondaries is full !! " << G4endl;
|
||||
G4cout << " The track is deleted " << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4Exception("G4VParticleChange::AddSecondary",
|
||||
"TRACK101", JustWarning,
|
||||
"Secondary Bug is full. The track is deleted");
|
||||
G4Exception("G4VParticleChange::AddSecondary()", "TRACK101", JustWarning,
|
||||
"Secondary buffer is full. The track is deleted!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Virtual methods for updating G4Step
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4VParticleChange::UpdateStepInfo(G4Step* pStep)
|
||||
{
|
||||
// Update the G4Step specific attributes
|
||||
pStep->SetStepLength( theTrueStepLength );
|
||||
pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
||||
pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
|
||||
pStep->SetControlFlag( theSteppingControlFlag );
|
||||
pStep->SetStepLength(theTrueStepLength);
|
||||
pStep->AddTotalEnergyDeposit(theLocalEnergyDeposit);
|
||||
pStep->AddNonIonizingEnergyDeposit(theNonIonizingEnergyDeposit);
|
||||
pStep->SetControlFlag(theSteppingControlFlag);
|
||||
|
||||
if (theFirstStepInVolume) {pStep->SetFirstStepFlag();}
|
||||
else {pStep->ClearFirstStepFlag();}
|
||||
if (theLastStepInVolume) {pStep->SetLastStepFlag();}
|
||||
else {pStep->ClearLastStepFlag();}
|
||||
if(theFirstStepInVolume)
|
||||
{
|
||||
pStep->SetFirstStepFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
pStep->ClearFirstStepFlag();
|
||||
}
|
||||
if(theLastStepInVolume)
|
||||
{
|
||||
pStep->SetLastStepFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
pStep->ClearLastStepFlag();
|
||||
}
|
||||
|
||||
return pStep;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4VParticleChange::UpdateStepForAtRest(G4Step* Step)
|
||||
{
|
||||
if (isParentWeightProposed ){
|
||||
Step->GetPostStepPoint()->SetWeight( theParentWeight );
|
||||
{
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
Step->GetPostStepPoint()->SetWeight(theParentWeight);
|
||||
}
|
||||
return UpdateStepInfo(Step);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4VParticleChange::UpdateStepForAlongStep(G4Step* Step)
|
||||
{
|
||||
if (isParentWeightProposed ){
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
G4double initialWeight = Step->GetPreStepPoint()->GetWeight();
|
||||
G4double currentWeight = Step->GetPostStepPoint()->GetWeight();
|
||||
G4double finalWeight = (theParentWeight/initialWeight)*currentWeight;
|
||||
Step->GetPostStepPoint()->SetWeight( finalWeight );
|
||||
}
|
||||
G4double finalWeight = (theParentWeight / initialWeight) * currentWeight;
|
||||
Step->GetPostStepPoint()->SetWeight(finalWeight);
|
||||
}
|
||||
return UpdateStepInfo(Step);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4Step* G4VParticleChange::UpdateStepForPostStep(G4Step* Step)
|
||||
{
|
||||
if (isParentWeightProposed ){
|
||||
Step->GetPostStepPoint()->SetWeight( theParentWeight );
|
||||
if(isParentWeightProposed)
|
||||
{
|
||||
Step->GetPostStepPoint()->SetWeight(theParentWeight);
|
||||
}
|
||||
return UpdateStepInfo(Step);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4VParticleChange::DumpInfo() const
|
||||
{
|
||||
|
||||
// Show header
|
||||
// Show header
|
||||
G4int olprc = G4cout.precision(3);
|
||||
G4cout << " -----------------------------------------------"
|
||||
<< G4endl;
|
||||
G4cout << " -----------------------------------------------" << G4endl;
|
||||
G4cout << " G4ParticleChange Information " << std::setw(20) << G4endl;
|
||||
G4cout << " -----------------------------------------------"
|
||||
<< G4endl;
|
||||
G4cout << " -----------------------------------------------" << G4endl;
|
||||
|
||||
G4cout << " # of 2ndaries : "
|
||||
<< std::setw(20) << theNumberOfSecondaries
|
||||
<< G4endl;
|
||||
G4cout << " # of 2ndaries : " << std::setw(20)
|
||||
<< theNumberOfSecondaries << G4endl;
|
||||
|
||||
if (theNumberOfSecondaries >0) {
|
||||
G4cout << " Pointer to 2ndaries : "
|
||||
<< std::setw(20) << GetSecondary(0)
|
||||
<< G4endl;
|
||||
G4cout << " (Showed only 1st one)"
|
||||
<< G4endl;
|
||||
if(theNumberOfSecondaries > 0)
|
||||
{
|
||||
G4cout << " Pointer to 2ndaries : " << std::setw(20)
|
||||
<< GetSecondary(0) << G4endl;
|
||||
G4cout << " (Showed only 1st one)" << G4endl;
|
||||
}
|
||||
G4cout << " -----------------------------------------------"
|
||||
<< G4endl;
|
||||
G4cout << " -----------------------------------------------" << G4endl;
|
||||
|
||||
G4cout << " Energy Deposit (MeV): "
|
||||
<< std::setw(20) << theLocalEnergyDeposit/MeV
|
||||
<< G4endl;
|
||||
G4cout << " Energy Deposit (MeV): " << std::setw(20)
|
||||
<< theLocalEnergyDeposit / MeV << G4endl;
|
||||
|
||||
G4cout << " Non-ionizing Energy Deposit (MeV): "
|
||||
<< std::setw(20) << theNonIonizingEnergyDeposit/MeV
|
||||
<< G4endl;
|
||||
G4cout << " Non-ionizing Energy Deposit (MeV): " << std::setw(20)
|
||||
<< theNonIonizingEnergyDeposit / MeV << G4endl;
|
||||
|
||||
G4cout << " Track Status : "
|
||||
<< std::setw(20);
|
||||
if( theStatusChange == fAlive ){
|
||||
G4cout << " Alive";
|
||||
} else if( theStatusChange == fStopButAlive ){
|
||||
G4cout << " StopButAlive";
|
||||
} else if( theStatusChange == fStopAndKill ){
|
||||
G4cout << " StopAndKill";
|
||||
} else if( theStatusChange == fKillTrackAndSecondaries ){
|
||||
G4cout << " KillTrackAndSecondaries";
|
||||
} else if( theStatusChange == fSuspend ){
|
||||
G4cout << " Suspend";
|
||||
} else if( theStatusChange == fPostponeToNextEvent ){
|
||||
G4cout << " PostponeToNextEvent";
|
||||
}
|
||||
G4cout << G4endl;
|
||||
G4cout << " True Path Length (mm) : "
|
||||
<< std::setw(20) << theTrueStepLength/mm
|
||||
<< G4endl;
|
||||
G4cout << " Stepping Control : "
|
||||
<< std::setw(20) << theSteppingControlFlag
|
||||
<< G4endl;
|
||||
if (theFirstStepInVolume) {
|
||||
G4cout << " First Step In the voulme : " << G4endl;
|
||||
G4cout << " Track Status : " << std::setw(20);
|
||||
if(theStatusChange == fAlive)
|
||||
{
|
||||
G4cout << " Alive";
|
||||
}
|
||||
if (theLastStepInVolume) {
|
||||
G4cout << " Last Step In the voulme : " << G4endl;
|
||||
else if(theStatusChange == fStopButAlive)
|
||||
{
|
||||
G4cout << " StopButAlive";
|
||||
}
|
||||
else if(theStatusChange == fStopAndKill)
|
||||
{
|
||||
G4cout << " StopAndKill";
|
||||
}
|
||||
else if(theStatusChange == fKillTrackAndSecondaries)
|
||||
{
|
||||
G4cout << " KillTrackAndSecondaries";
|
||||
}
|
||||
else if(theStatusChange == fSuspend)
|
||||
{
|
||||
G4cout << " Suspend";
|
||||
}
|
||||
else if(theStatusChange == fPostponeToNextEvent)
|
||||
{
|
||||
G4cout << " PostponeToNextEvent";
|
||||
}
|
||||
G4cout << G4endl;
|
||||
G4cout << " True Path Length (mm) : " << std::setw(20)
|
||||
<< theTrueStepLength / mm << G4endl;
|
||||
G4cout << " Stepping Control : " << std::setw(20)
|
||||
<< theSteppingControlFlag << G4endl;
|
||||
if(theFirstStepInVolume)
|
||||
{
|
||||
G4cout << " First Step In the voulme : " << G4endl;
|
||||
}
|
||||
if(theLastStepInVolume)
|
||||
{
|
||||
G4cout << " Last Step In the voulme : " << G4endl;
|
||||
}
|
||||
G4cout.precision(olprc);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4VParticleChange::CheckIt(const G4Track&
|
||||
#ifdef G4VERBOSE
|
||||
aTrack
|
||||
aTrack
|
||||
#endif
|
||||
)
|
||||
{
|
||||
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
static G4ThreadLocal G4int nError = 0;
|
||||
#ifdef G4VERBOSE
|
||||
const G4int maxError = 30;
|
||||
const G4int maxError = 30;
|
||||
#endif
|
||||
|
||||
// Energy deposit should not be negative
|
||||
G4bool itsOKforEnergy = true;
|
||||
accuracy = -1.0*theLocalEnergyDeposit/MeV;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
accuracy = -1.0 * theLocalEnergyDeposit / MeV;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOKforEnergy = false;
|
||||
nError += 1;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
if(nError < maxError)
|
||||
{
|
||||
G4cout << " G4VParticleChange::CheckIt : ";
|
||||
G4cout << "the energy deposit is negative !!"
|
||||
<< " Difference: " << accuracy << "[MeV] " <<G4endl;
|
||||
G4cout << "the energy deposit is negative !!"
|
||||
<< " Difference: " << accuracy << "[MeV] " << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// true path length should not be negative
|
||||
G4bool itsOKforStepLength = true;
|
||||
accuracy = -1.0*theTrueStepLength/mm;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
accuracy = -1.0 * theTrueStepLength / mm;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOKforStepLength = false;
|
||||
nError += 1;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
if(nError < maxError)
|
||||
{
|
||||
G4cout << " G4VParticleChange::CheckIt : ";
|
||||
G4cout << "the true step length is negative !!"
|
||||
<< " Difference: " << accuracy << "[MeV] " <<G4endl;
|
||||
<< " Difference: " << accuracy << "[MeV] " << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if (!itsOKforStepLength || !itsOKforEnergy ){
|
||||
// dump out information of this particle change
|
||||
if(!itsOKforStepLength || !itsOKforEnergy)
|
||||
{
|
||||
// dump out information of this particle change
|
||||
DumpInfo();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError) {
|
||||
G4Exception("G4VParticleChange::CheckIt",
|
||||
"TRACK001", EventMustBeAborted,
|
||||
"Step length and/or energy deposit was illegal");
|
||||
if(exitWithError)
|
||||
{
|
||||
G4Exception("G4VParticleChange::CheckIt()", "TRACK001", EventMustBeAborted,
|
||||
"Step length and/or energy deposit was illegal");
|
||||
}
|
||||
|
||||
// correction
|
||||
if ( !itsOKforStepLength ) {
|
||||
theTrueStepLength = (1.e-12)*mm;
|
||||
}
|
||||
if ( !itsOKforEnergy ) {
|
||||
// correction
|
||||
if(!itsOKforStepLength)
|
||||
{
|
||||
theTrueStepLength = (1.e-12) * mm;
|
||||
}
|
||||
if(!itsOKforEnergy)
|
||||
{
|
||||
theLocalEnergyDeposit = 0.0;
|
||||
}
|
||||
return (itsOKforStepLength && itsOKforEnergy );
|
||||
return (itsOKforStepLength && itsOKforEnergy);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4VParticleChange::CheckSecondary(G4Track& aTrack)
|
||||
{
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
static G4ThreadLocal G4int nError = 0;
|
||||
#ifdef G4VERBOSE
|
||||
const G4int maxError = 30;
|
||||
const G4int maxError = 30;
|
||||
#endif
|
||||
|
||||
// MomentumDirection should be unit vector
|
||||
G4bool itsOKforMomentum = true;
|
||||
if (aTrack.GetKineticEnergy()>0.){
|
||||
accuracy = std::fabs((aTrack.GetMomentumDirection()).mag2()-1.0);
|
||||
if (accuracy > accuracyForWarning) {
|
||||
G4bool itsOKforMomentum = true;
|
||||
if(aTrack.GetKineticEnergy() > 0.)
|
||||
{
|
||||
accuracy = std::fabs((aTrack.GetMomentumDirection()).mag2() - 1.0);
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOKforMomentum = false;
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4VParticleChange::CheckSecondary : ";
|
||||
G4cout << "the Momentum direction is not unit vector !! "
|
||||
<< " Difference: " << accuracy << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
if(nError < maxError)
|
||||
{
|
||||
G4cout << " G4VParticleChange::CheckSecondary : ";
|
||||
G4cout << "the Momentum direction is not unit vector !! "
|
||||
<< " Difference: " << accuracy << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Kinetic Energy should not be negative
|
||||
G4bool itsOKforEnergy = true;
|
||||
accuracy = -1.0*(aTrack.GetKineticEnergy())/MeV;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
accuracy = -1.0 * (aTrack.GetKineticEnergy()) / MeV;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOKforEnergy = false;
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
if(nError < maxError)
|
||||
{
|
||||
G4cout << " G4VParticleChange::CheckSecondary : ";
|
||||
G4cout << "the kinetic energy is negative !!"
|
||||
<< " Difference: " << accuracy << "[MeV] " <<G4endl;
|
||||
G4cout << "the kinetic energy is negative !!"
|
||||
<< " Difference: " << accuracy << "[MeV] " << G4endl;
|
||||
G4cout << " G4VParticleChange::CheckSecondary : ";
|
||||
G4cout << "the global time of secondary is earlier than the parent !!"
|
||||
<< " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
G4cout << "the global time of secondary is earlier than the parent !!"
|
||||
<< " Difference: " << accuracy << "[ns] " << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// Check timing of secondaries
|
||||
G4bool itsOKforTiming = true;
|
||||
|
||||
accuracy = (theParentGlobalTime - aTrack.GetGlobalTime())/ns;
|
||||
if (accuracy > accuracyForWarning){
|
||||
accuracy = (theParentGlobalTime - aTrack.GetGlobalTime()) / ns;
|
||||
if(accuracy > accuracyForWarning)
|
||||
{
|
||||
itsOKforTiming = false;
|
||||
nError += 1;
|
||||
exitWithError = (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
if(nError < maxError)
|
||||
{
|
||||
G4cout << " G4VParticleChange::CheckSecondary : ";
|
||||
G4cout << "the global time of secondary goes back comapared to the parent !!"
|
||||
<< " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
G4cout
|
||||
<< "the global time of secondary goes back comapared to the parent !!"
|
||||
<< " Difference: " << accuracy << "[ns] " << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<< " time=" << aTrack.GetGlobalTime()/ns
|
||||
<< " parent time=" << theParentGlobalTime/ns
|
||||
<<G4endl;
|
||||
<< " E=" << aTrack.GetKineticEnergy() / MeV
|
||||
<< " pos=" << aTrack.GetPosition().x() / m << ", "
|
||||
<< aTrack.GetPosition().y() / m << ", "
|
||||
<< aTrack.GetPosition().z() / m
|
||||
<< " time=" << aTrack.GetGlobalTime() / ns
|
||||
<< " parent time=" << theParentGlobalTime / ns << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError) {
|
||||
G4Exception("G4VParticleChange::CheckSecondary",
|
||||
"TRACK001", EventMustBeAborted,
|
||||
"Secondary with illegal energy/momentum ");
|
||||
if(exitWithError)
|
||||
{
|
||||
G4Exception("G4VParticleChange::CheckSecondary()", "TRACK001",
|
||||
EventMustBeAborted, "Secondary with illegal energy/momentum ");
|
||||
}
|
||||
|
||||
G4bool itsOK = itsOKforMomentum && itsOKforEnergy && itsOKforTiming;
|
||||
|
||||
//correction
|
||||
if (!itsOKforMomentum) {
|
||||
// correction
|
||||
if(!itsOKforMomentum)
|
||||
{
|
||||
G4double vmag = (aTrack.GetMomentumDirection()).mag();
|
||||
aTrack.SetMomentumDirection((1./vmag)*aTrack.GetMomentumDirection());
|
||||
aTrack.SetMomentumDirection((1. / vmag) * aTrack.GetMomentumDirection());
|
||||
}
|
||||
if (!itsOKforEnergy) {
|
||||
if(!itsOKforEnergy)
|
||||
{
|
||||
aTrack.SetKineticEnergy(0.0);
|
||||
}
|
||||
|
||||
if (!itsOK) {
|
||||
this->DumpInfo();
|
||||
|
||||
}
|
||||
|
||||
if(!itsOK)
|
||||
{
|
||||
this->DumpInfo();
|
||||
}
|
||||
|
||||
return itsOK;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4VParticleChange::GetAccuracyForWarning() const
|
||||
{
|
||||
return accuracyForWarning;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4VParticleChange::GetAccuracyForException() const
|
||||
{
|
||||
return accuracyForException;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//Obsolete methods for parent weight
|
||||
/////////////////////
|
||||
void G4VParticleChange::SetParentWeightByProcess(G4bool )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
G4bool G4VParticleChange::IsParentWeightSetByProcess() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// --------------------------------------------------------------------
|
||||
// Obsolete methods for parent weight
|
||||
//
|
||||
void G4VParticleChange::SetParentWeightByProcess(G4bool) {}
|
||||
G4bool G4VParticleChange::IsParentWeightSetByProcess() const { return true; }
|
||||
|
||||
@@ -23,49 +23,60 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VUserTrackInformation class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// Author: Makoto Asai, 2 June 2000
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VUserTrackInformation.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4VUserTrackInformation::G4VUserTrackInformation()
|
||||
: pType(0)
|
||||
{;}
|
||||
{}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4VUserTrackInformation::G4VUserTrackInformation(const G4String& infoType)
|
||||
{
|
||||
pType = new G4String(infoType) ;
|
||||
{
|
||||
pType = new G4String(infoType);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4VUserTrackInformation::~G4VUserTrackInformation()
|
||||
{
|
||||
if (pType!=0) delete pType;
|
||||
if(pType != nullptr)
|
||||
delete pType;
|
||||
}
|
||||
|
||||
G4VUserTrackInformation::G4VUserTrackInformation(const G4VUserTrackInformation& right)
|
||||
:pType(0)
|
||||
// --------------------------------------------------------------------
|
||||
G4VUserTrackInformation::
|
||||
G4VUserTrackInformation(const G4VUserTrackInformation& right)
|
||||
{
|
||||
if (right.pType!=0) pType = new G4String(*(right.pType));
|
||||
if(right.pType != nullptr)
|
||||
pType = new G4String(*(right.pType));
|
||||
}
|
||||
|
||||
|
||||
G4VUserTrackInformation& G4VUserTrackInformation::operator=(const G4VUserTrackInformation& right)
|
||||
// --------------------------------------------------------------------
|
||||
G4VUserTrackInformation&
|
||||
G4VUserTrackInformation::operator=(const G4VUserTrackInformation& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
if (pType !=0) delete pType;
|
||||
if (right.pType) pType = new G4String(*(right.pType));
|
||||
else pType=0;
|
||||
if(this != &right)
|
||||
{
|
||||
if(pType != nullptr)
|
||||
delete pType;
|
||||
if(right.pType)
|
||||
pType = new G4String(*(right.pType));
|
||||
else
|
||||
pType = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
const G4String& G4VUserTrackInformation::GetType() const
|
||||
{
|
||||
static const G4String NOTYPE="NONE";
|
||||
if(pType!=0) return *pType;
|
||||
else return NOTYPE;
|
||||
static const G4String NOTYPE = "NONE";
|
||||
if(pType != nullptr)
|
||||
return *pType;
|
||||
else
|
||||
return NOTYPE;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,20 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VelocityTable class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4VelocityTable.cc
|
||||
//
|
||||
// class description:
|
||||
// This class keeps a table of velocity as a function of
|
||||
// the ratio kinetic erngy and mass
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// created 17.Aug. 2011 H.Kurashige
|
||||
//
|
||||
// Author: Hisaya Kurashige, 17 August 2011
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VelocityTable.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
@@ -45,40 +35,32 @@
|
||||
#include "G4Log.hh"
|
||||
#include "G4Exp.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4ThreadLocal G4VelocityTable* G4VelocityTable::theInstance = nullptr;
|
||||
|
||||
////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4VelocityTable::G4VelocityTable()
|
||||
////////////////
|
||||
: edgeMin(0.), edgeMax(0.), numberOfNodes(0),
|
||||
dBin(0.), baseBin(0.),
|
||||
lastEnergy(-DBL_MAX), lastValue(0.), lastBin(0),
|
||||
maxT( 1000.0 ), minT( 0.0001 ), NbinT( 500 )
|
||||
{
|
||||
PrepareVelocityTable();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4VelocityTable::~G4VelocityTable()
|
||||
/////////////////
|
||||
{
|
||||
dataVector.clear();
|
||||
binVector.clear();
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4VelocityTable::PrepareVelocityTable()
|
||||
///////////////////
|
||||
{
|
||||
//const G4double g4log10 = std::log(10.);
|
||||
|
||||
// const G4double g4log10 = std::log(10.);
|
||||
|
||||
dataVector.clear();
|
||||
binVector.clear();
|
||||
dBin = G4Log(maxT/minT)/NbinT;
|
||||
baseBin = G4Log(minT)/dBin;
|
||||
dBin = G4Log(maxT / minT) / NbinT;
|
||||
baseBin = G4Log(minT) / dBin;
|
||||
|
||||
numberOfNodes = NbinT + 1;
|
||||
dataVector.reserve(numberOfNodes);
|
||||
@@ -87,130 +69,140 @@ void G4VelocityTable::PrepareVelocityTable()
|
||||
binVector.push_back(minT);
|
||||
dataVector.push_back(0.0);
|
||||
|
||||
for (size_t i=1; i<numberOfNodes-1; i++){
|
||||
binVector.push_back(G4Exp((baseBin+i)*dBin));
|
||||
for(std::size_t i = 1; i < numberOfNodes - 1; ++i)
|
||||
{
|
||||
binVector.push_back(G4Exp((baseBin + i) * dBin));
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
binVector.push_back(maxT);
|
||||
dataVector.push_back(0.0);
|
||||
|
||||
edgeMin = binVector[0];
|
||||
edgeMax = binVector[numberOfNodes-1];
|
||||
|
||||
for (G4int i=0; i<=NbinT; i++){
|
||||
G4double T = binVector[i];
|
||||
dataVector[i]= c_light*std::sqrt(T*(T+2.))/(T+1.0);
|
||||
edgeMin = binVector[0];
|
||||
edgeMax = binVector[numberOfNodes - 1];
|
||||
|
||||
for(G4int i = 0; i <= NbinT; ++i)
|
||||
{
|
||||
G4double T = binVector[i];
|
||||
dataVector[i] = c_light * std::sqrt(T * (T + 2.)) / (T + 1.0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
size_t G4VelocityTable::FindBinLocation(G4double theEnergy) const
|
||||
// --------------------------------------------------------------------
|
||||
std::size_t G4VelocityTable::FindBinLocation(G4double theEnergy) const
|
||||
{
|
||||
// For G4PhysicsLogVector, FindBinLocation is implemented using
|
||||
// a simple arithmetic calculation.
|
||||
//
|
||||
// Because this is a virtual function, it is accessed through a
|
||||
// pointer to the G4PhyiscsVector object for most usages. In this
|
||||
// case, 'inline' will not be invoked. However, there is a possibility
|
||||
// that the user access to the G4PhysicsLogVector object directly and
|
||||
// pointer to the G4PhysicsVector object for most usages. In this
|
||||
// case, 'inline' will not be invoked. However, there is a possibility
|
||||
// that the user access to the G4PhysicsLogVector object directly and
|
||||
// not through pointers or references. In this case, the 'inline' will
|
||||
// be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
|
||||
|
||||
//const G4double g4log10 = G4Log(10.);
|
||||
return size_t( G4Log(theEnergy)/dBin - baseBin );
|
||||
// const G4double g4log10 = G4Log(10.);
|
||||
return std::size_t(G4Log(theEnergy) / dBin - baseBin);
|
||||
}
|
||||
|
||||
G4double G4VelocityTable::Value(G4double theEnergy)
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4VelocityTable::Value(G4double theEnergy)
|
||||
{
|
||||
// Use cache for speed up - check if the value 'theEnergy' is same as the
|
||||
// Use cache for speed up - check if the value 'theEnergy' is same as the
|
||||
// last call. If it is same, then use the last bin location. Also the
|
||||
// value 'theEnergy' lies between the last energy and low edge of of the
|
||||
// bin of last call, then the last bin location is used.
|
||||
// value 'theEnergy' lies between the last energy and low edge of of the
|
||||
// bin of last call, then the last bin location is used
|
||||
|
||||
if( theEnergy == lastEnergy ) {
|
||||
|
||||
} else if( theEnergy < lastEnergy
|
||||
&& theEnergy >= binVector[lastBin]) {
|
||||
lastEnergy = theEnergy;
|
||||
lastValue = Interpolation();
|
||||
|
||||
} else if( theEnergy <= edgeMin ) {
|
||||
lastBin = 0;
|
||||
lastEnergy = edgeMin;
|
||||
lastValue = dataVector[0];
|
||||
|
||||
} else if( theEnergy >= edgeMax ){
|
||||
lastBin = numberOfNodes-1;
|
||||
lastEnergy = edgeMax;
|
||||
lastValue = dataVector[lastBin];
|
||||
|
||||
} else {
|
||||
lastBin = (size_t)( G4Log(theEnergy)/dBin - baseBin );
|
||||
if(lastBin == numberOfNodes) { --lastBin; } // VI: fix possible precision lost
|
||||
lastEnergy = theEnergy;
|
||||
lastValue = Interpolation();
|
||||
|
||||
if(theEnergy == lastEnergy)
|
||||
{
|
||||
}
|
||||
return lastValue;
|
||||
else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin])
|
||||
{
|
||||
lastEnergy = theEnergy;
|
||||
lastValue = Interpolation();
|
||||
}
|
||||
else if(theEnergy <= edgeMin)
|
||||
{
|
||||
lastBin = 0;
|
||||
lastEnergy = edgeMin;
|
||||
lastValue = dataVector[0];
|
||||
}
|
||||
else if(theEnergy >= edgeMax)
|
||||
{
|
||||
lastBin = numberOfNodes - 1;
|
||||
lastEnergy = edgeMax;
|
||||
lastValue = dataVector[lastBin];
|
||||
}
|
||||
else
|
||||
{
|
||||
lastBin = (std::size_t)(G4Log(theEnergy) / dBin - baseBin);
|
||||
if(lastBin == numberOfNodes)
|
||||
{
|
||||
--lastBin;
|
||||
} // VI: fix possible precision lost
|
||||
lastEnergy = theEnergy;
|
||||
lastValue = Interpolation();
|
||||
}
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Static methods
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4VelocityTable* G4VelocityTable::GetVelocityTable()
|
||||
///////////////////
|
||||
{
|
||||
if (!theInstance) {
|
||||
if(theInstance == nullptr)
|
||||
{
|
||||
static G4ThreadLocalSingleton<G4VelocityTable> inst;
|
||||
theInstance = inst.Instance();
|
||||
}
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
void G4VelocityTable::SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4VelocityTable::
|
||||
SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
|
||||
{
|
||||
if (theInstance == nullptr) { GetVelocityTable(); }
|
||||
if(theInstance == nullptr)
|
||||
{
|
||||
GetVelocityTable();
|
||||
}
|
||||
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
|
||||
|
||||
// check if state is outside event loop
|
||||
if(!(currentState==G4State_Idle||currentState==G4State_PreInit)){
|
||||
G4Exception("G4VelocityTable::SetVelocityTableProperties",
|
||||
"Track101", JustWarning,
|
||||
if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
|
||||
{
|
||||
G4Exception("G4VelocityTable::SetVelocityTableProperties()", "Track101",
|
||||
JustWarning,
|
||||
"Can modify only in PreInit or Idle state : Method ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nbin > 100 ) theInstance->NbinT = nbin;
|
||||
if ((t_min < t_max)&&(t_min>0.)) {
|
||||
theInstance->minT = t_min;
|
||||
if(nbin > 100)
|
||||
theInstance->NbinT = nbin;
|
||||
if((t_min < t_max) && (t_min > 0.))
|
||||
{
|
||||
theInstance->minT = t_min;
|
||||
theInstance->maxT = t_max;
|
||||
}
|
||||
}
|
||||
theInstance->PrepareVelocityTable();
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4VelocityTable::GetMaxTOfVelocityTable()
|
||||
///////////////////
|
||||
{
|
||||
return GetVelocityTable()->maxT;
|
||||
return GetVelocityTable()->maxT;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
G4double G4VelocityTable::GetMinTOfVelocityTable()
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4VelocityTable::GetMinTOfVelocityTable()
|
||||
{
|
||||
return GetVelocityTable()->minT;
|
||||
return GetVelocityTable()->minT;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
G4int G4VelocityTable::GetNbinOfVelocityTable()
|
||||
///////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4VelocityTable::GetNbinOfVelocityTable()
|
||||
{
|
||||
return GetVelocityTable()->NbinT;
|
||||
return GetVelocityTable()->NbinT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user