Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -23,73 +23,66 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//---------------------------------------------------------------
//
// G4BOptnChangeCrossSection
//
// Class Description:
// A G4VBiasingOperation to change a process cross-section.
//
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingOperation to change a process cross-section.
//
// Author: Marc Verderi, November 2013
// --------------------------------------------------------------------
#ifndef G4BOptnChangeCrossSection_hh
#define G4BOptnChangeCrossSection_hh 1
#include "G4VBiasingOperation.hh"
class G4InteractionLawPhysical;
class G4BOptnChangeCrossSection : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnChangeCrossSection(G4String name);
// -- destructor:
virtual ~G4BOptnChangeCrossSection();
public:
// -- Methods from G4VBiasingOperation interface:
// ----------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*,
G4ForceCondition& proposeForceCondition );
// -- Unused:
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step*,
G4bool& ) {return 0;}
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double,
G4ForceCondition*) {return DBL_MAX;}
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* ) {return 0;}
public:
// -- Additional methods, specific to this class:
// ----------------------------------------------
// -- return concrete type of interaction law:
G4InteractionLawPhysical* GetBiasedExponentialLaw() {return fBiasedExponentialLaw;}
// -- set biased cross-section:
void SetBiasedCrossSection(G4double xst, bool updateInteractionLength = false);
G4double GetBiasedCrossSection() const;
// -- Sample underneath distribution:
void Sample();
// -- Update for a made step, without resampling:
void UpdateForStep( G4double stepLength );
// -- set/get if interaction occured.
// -- Interaction flag turned off in "Sample()" method.
G4bool GetInteractionOccured() const { return fInteractionOccured; }
void SetInteractionOccured() { fInteractionOccured = true; }
class G4BOptnChangeCrossSection : public G4VBiasingOperation
{
public:
// -- Constructor :
G4BOptnChangeCrossSection(const G4String& name);
// -- destructor:
virtual ~G4BOptnChangeCrossSection();
// -- Methods from G4VBiasingOperation interface:
// ----------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw*
ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*,
G4ForceCondition& proposeForceCondition );
// -- Unused:
virtual G4VParticleChange*
ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*, const G4Step*, G4bool& ) { return nullptr; }
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double, G4ForceCondition* ) { return DBL_MAX; }
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* ) { return nullptr; }
// -- Additional methods, specific to this class:
// ----------------------------------------------
// -- return concrete type of interaction law:
G4InteractionLawPhysical* GetBiasedExponentialLaw() { return fBiasedExponentialLaw; }
// -- set biased cross-section:
void SetBiasedCrossSection(G4double xst, G4bool updateInteractionLength=false);
G4double GetBiasedCrossSection() const;
// -- Sample underneath distribution:
void Sample();
// -- Update for a made step, without resampling:
void UpdateForStep( G4double stepLength );
// -- set/get if interaction occured.
// -- Interaction flag turned off in "Sample()" method.
G4bool GetInteractionOccured() const { return fInteractionOccured; }
void SetInteractionOccured() { fInteractionOccured = true; }
private:
G4InteractionLawPhysical* fBiasedExponentialLaw;
G4bool fInteractionOccured;
private:
G4InteractionLawPhysical* fBiasedExponentialLaw = nullptr;
G4bool fInteractionOccured = false;
};
#endif
@@ -23,65 +23,64 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//---------------------------------------------------------------
//
// G4BOptnCloning
//
// Class Description:
// A G4VBiasingOperation to clone a track, allowing to set
// weight arbitrary weights.
//
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingOperation to clone a track, allowing to set
// weight arbitrary weights.
//
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4BOptnCloning_hh
#define G4BOptnCloning_hh 1
#include "G4VBiasingOperation.hh"
#include "G4ParticleChange.hh"
class G4BOptnCloning : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnCloning(G4String name);
// -- destructor:
virtual ~G4BOptnCloning();
public:
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Unsed:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*, G4ForceCondition& ) {return 0;}
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step*,
G4bool& ) {return 0;}
// -- Used:
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double,
G4ForceCondition* condition)
{
*condition = NotForced; return 0; // -- acts immediately
}
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* );
public:
// -- Additional methods, specific to this class:
// ----------------------------------------------
void SetCloneWeights(G4double clone1Weight, G4double clone2Weight) {fClone1W = clone1Weight ; fClone2W = clone2Weight;}
class G4BOptnCloning : public G4VBiasingOperation
{
public:
G4Track* GetCloneTrack() const { return fCloneTrack; }
// -- Constructor :
G4BOptnCloning(const G4String& name);
// -- destructor:
virtual ~G4BOptnCloning();
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Unsed:
virtual const G4VBiasingInteractionLaw*
ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*,
G4ForceCondition& ) { return nullptr; }
virtual G4VParticleChange*
ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*, const G4Step*, G4bool& ) { return nullptr; }
// -- Used:
virtual G4double
DistanceToApplyOperation( const G4Track*,
G4double, G4ForceCondition* condition )
{
*condition = NotForced; return 0.; // -- acts immediately
}
virtual G4VParticleChange*
GenerateBiasingFinalState( const G4Track*, const G4Step* );
private:
G4double fClone1W,
fClone2W;
G4ParticleChange fParticleChange;
G4Track* fCloneTrack;
// -- Additional methods, specific to this class:
// ----------------------------------------------
void SetCloneWeights( G4double clone1Weight, G4double clone2Weight )
{
fClone1W = clone1Weight;
fClone2W = clone2Weight;
}
G4Track* GetCloneTrack() const { return fCloneTrack; }
private:
G4double fClone1W = -1.0, fClone2W = -1.0;
G4ParticleChange fParticleChange;
G4Track* fCloneTrack = nullptr;
};
#endif
@@ -23,100 +23,99 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//---------------------------------------------------------------
//
// G4BOptnForceCommonTruncatedExp
//
// Class Description:
// A G4VBiasingOperation physics-based biasing operation. It
// handles several processes together, biasing on the total
// cross-section of these processes (instead of biasing them
// individually).
// The biasing interaction law is a truncated exponential
// one, driven by the total cross-section and which extends
// in the range [0,L].
// Process are registered with the AddCrossSection method.
// As cross-sections are all known at the end of the
// PostStepGPIL loop, the step limitation is made at the
// AlongStepGPIL level.
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingOperation physics-based biasing operation. It
// handles several processes together, biasing on the total
// cross-section of these processes (instead of biasing them
// individually).
// The biasing interaction law is a truncated exponential
// one, driven by the total cross-section and which extends
// in the range [0,L].
// Process are registered with the AddCrossSection() method.
// As cross-sections are all known at the end of the
// PostStepGPIL loop, the step limitation is made at the
// AlongStepGPIL level.
//
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4BOptnForceCommonTruncatedExp_hh
#define G4BOptnForceCommonTruncatedExp_hh 1
#include "G4VBiasingOperation.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleChangeForNothing.hh"
class G4ILawCommonTruncatedExp;
class G4ILawForceFreeFlight;
#include <map>
class G4BOptnForceCommonTruncatedExp : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnForceCommonTruncatedExp(G4String name);
// -- destructor:
virtual ~G4BOptnForceCommonTruncatedExp();
class G4ILawCommonTruncatedExp;
class G4ILawForceFreeFlight;
class G4BOptnForceCommonTruncatedExp : public G4VBiasingOperation
{
public:
// -- Constructor :
G4BOptnForceCommonTruncatedExp(const G4String& name);
// -- destructor:
virtual ~G4BOptnForceCommonTruncatedExp();
public:
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*, G4ForceCondition& );
virtual G4double ProposeAlongStepLimit( const G4BiasingProcessInterface* ) { return DBL_MAX; }
virtual G4GPILSelection ProposeGPILSelection( const G4GPILSelection processSelection );
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step*,
G4bool& );
// -- Unused:
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double,
G4ForceCondition*) {return DBL_MAX;}
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* ) {return 0;}
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw*
ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*, G4ForceCondition& );
virtual G4double
ProposeAlongStepLimit( const G4BiasingProcessInterface* ) { return DBL_MAX; }
virtual G4GPILSelection
ProposeGPILSelection( const G4GPILSelection processSelection );
virtual G4VParticleChange*
ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*, const G4Step*, G4bool& );
// -- Unused:
virtual G4double
DistanceToApplyOperation( const G4Track*,
G4double, G4ForceCondition* ) { return DBL_MAX; }
virtual G4VParticleChange*
GenerateBiasingFinalState(const G4Track*, const G4Step*) { return nullptr; }
public:
// -- Additional methods, specific to this class:
// ----------------------------------------------
// -- return concrete type of interaction laws:
G4ILawCommonTruncatedExp* GetCommonTruncatedExpLaw()
{
return fCommonTruncatedExpLaw;
}
G4ILawForceFreeFlight* GetForceFreeFlightLaw()
{
return fForceFreeFlightLaw;
}
// -- Additional methods, specific to this class:
// ----------------------------------------------
// -- return concrete type of interaction laws:
G4ILawCommonTruncatedExp* GetCommonTruncatedExpLaw()
{
return fCommonTruncatedExpLaw;
}
G4ILawForceFreeFlight* GetForceFreeFlightLaw()
{
return fForceFreeFlightLaw;
}
void Initialize( const G4Track* );
void UpdateForStep( const G4Step* );
void Sample();
const G4ThreeVector& GetInitialMomentum() const { return fInitialMomentum; }
G4double GetMaximumDistance() const { return fMaximumDistance; }
void ChooseProcessToApply();
const G4VProcess* GetProcessToApply() const { return fProcessToApply; }
void AddCrossSection( const G4VProcess*, G4double );
std::size_t GetNumberOfSharing() const { return fNumberOfSharing; }
void SetInteractionOccured( G4bool b ) { fInteractionOccured = b; }
G4bool GetInteractionOccured() const { return fInteractionOccured; }
void Initialize( const G4Track* );
void UpdateForStep( const G4Step* );
void Sample();
const G4ThreeVector& GetInitialMomentum() const { return fInitialMomentum; }
G4double GetMaximumDistance() const { return fMaximumDistance; }
void ChooseProcessToApply();
const G4VProcess* GetProcessToApply() const { return fProcessToApply; }
void AddCrossSection( const G4VProcess*, G4double );
size_t GetNumberOfSharing() const { return fNumberOfSharing;}
void SetInteractionOccured( G4bool b ) { fInteractionOccured = b; }
G4bool GetInteractionOccured() const { return fInteractionOccured; }
private:
G4ILawCommonTruncatedExp* fCommonTruncatedExpLaw;
G4ILawForceFreeFlight* fForceFreeFlightLaw;
G4double fTotalCrossSection;
std::map < const G4VProcess*, G4double > fCrossSections;
size_t fNumberOfSharing;
const G4VProcess* fProcessToApply;
G4bool fInteractionOccured;
G4ThreeVector fInitialMomentum;
G4double fMaximumDistance;
G4ParticleChangeForNothing fDummyParticleChange;
private:
G4ILawCommonTruncatedExp* fCommonTruncatedExpLaw = nullptr;
G4ILawForceFreeFlight* fForceFreeFlightLaw = nullptr;
G4double fTotalCrossSection = 0.0;
std::map < const G4VProcess*, G4double > fCrossSections;
std::size_t fNumberOfSharing = 0;
const G4VProcess* fProcessToApply = nullptr;
G4bool fInteractionOccured = false;
G4ThreeVector fInitialMomentum;
G4double fMaximumDistance = -1.0;
G4ParticleChangeForNothing fDummyParticleChange;
};
#endif
@@ -23,75 +23,83 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//---------------------------------------------------------------
//
// G4BOptnForceFreeFlight
//
// Class Description:
// A G4VBiasingOperation physics-based biasing operation.
// If forces the physics process to not act on the track.
// In this implementation (meant for the ForceCollision
// operator) the free flight is done under zero weight for
// the track, and the action is meant to accumulate the weight
// change for making this uninteracting flight,
// cumulatedWeightChange.
// When the track reaches the current volume boundary, its
// weight is restored with value :
// initialWeight * cumulatedWeightChange
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingOperation physics-based biasing operation.
// If forces the physics process to not act on the track.
// In this implementation (meant for the ForceCollision
// operator) the free flight is done under zero weight for
// the track, and the action is meant to accumulate the weight
// change for making this uninteracting flight,
// cumulatedWeightChange.
// When the track reaches the current volume boundary, its
// weight is restored with value: initialWeight * cumulatedWeightChange
//
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4BOptnForceFreeFlight_hh
#define G4BOptnForceFreeFlight_hh 1
#include "G4VBiasingOperation.hh"
#include "G4ForceCondition.hh"
#include "G4ParticleChange.hh" // -- §§ should add a dedicated "weight change only" particle change
#include "G4ParticleChange.hh" // Should add a dedicated "weight change only"
// particle change
class G4ILawForceFreeFlight;
class G4BOptnForceFreeFlight : public G4VBiasingOperation
{
public:
class G4BOptnForceFreeFlight : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnForceFreeFlight(G4String name);
// -- destructor:
virtual ~G4BOptnForceFreeFlight();
// -- Constructor :
G4BOptnForceFreeFlight(const G4String& name);
// -- destructor:
virtual ~G4BOptnForceFreeFlight();
public:
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*, G4ForceCondition& );
virtual void AlongMoveBy( const G4BiasingProcessInterface*, const G4Step*, G4double );
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*, const G4Track*, const G4Step*, G4bool&);
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw*
ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*,
G4ForceCondition& );
virtual void AlongMoveBy( const G4BiasingProcessInterface*,
const G4Step*, G4double );
virtual G4VParticleChange*
ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*, const G4Step*, G4bool& );
// -- Unused:
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double,
G4ForceCondition*) {return DBL_MAX;}
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* ) {return 0;}
// -- Unused:
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double, G4ForceCondition* ) { return DBL_MAX; }
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* ) { return nullptr; }
// -- Additional methods, specific to this class:
// ----------------------------------------------
// -- return concrete type of interaction law:
G4ILawForceFreeFlight* GetForceFreeFlightLaw()
{
return fForceFreeFlightInteractionLaw;
}
// -- initialization for weight:
void ResetInitialTrackWeight(G4double w)
{
fInitialTrackWeight = w;
fCumulatedWeightChange = 1.0;
}
G4bool OperationComplete() const
{
return fOperationComplete;
}
public:
// -- Additional methods, specific to this class:
// ----------------------------------------------
// -- return concrete type of interaction law:
G4ILawForceFreeFlight* GetForceFreeFlightLaw() {
return fForceFreeFlightInteractionLaw;
}
// -- initialization for weight:
void ResetInitialTrackWeight(G4double w) {fInitialTrackWeight = w; fCumulatedWeightChange = 1.0;}
G4bool OperationComplete() const { return fOperationComplete; }
private:
G4ILawForceFreeFlight* fForceFreeFlightInteractionLaw;
G4double fCumulatedWeightChange,
fInitialTrackWeight;
G4ParticleChange fParticleChange;
G4bool fOperationComplete;
private:
G4ILawForceFreeFlight* fForceFreeFlightInteractionLaw = nullptr;
G4double fCumulatedWeightChange = -1.0,
fInitialTrackWeight = -1.0;
G4ParticleChange fParticleChange;
G4bool fOperationComplete = true;
};
#endif
@@ -23,27 +23,24 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//---------------------------------------------------------------------
//
// G4BOptnLeadingParticle
//
// Class Description:
// A G4VBiasingOperation that implements the so-called "Leading
// particle biasing scheme". It is of interest in the shield problem
// to estimate the flux leaking from the shield.
// It works as follows:
// - it is intented for hadronic inelastic interaction
// - at each interaction, are kept:
// - the most energetic particle (the leading particle)
// - with unmodified weight
// - randomly one particle of each species
// - with this particle weight = n * primary_weight where
// n is the number of particles of this species
//---------------------------------------------------------------------
// Initial version Nov. 2019 M. Verderi
//
// A G4VBiasingOperation that implements the so-called "Leading
// particle biasing scheme". It is of interest in the shield problem
// to estimate the flux leaking from the shield.
// It works as follows:
// - it is intented for hadronic inelastic interaction
// - at each interaction, are kept:
// - the most energetic particle (the leading particle)
// - with unmodified weight
// - randomly one particle of each species
// - with this particle weight = n * primary_weight where
// n is the number of particles of this species
//
// Author: Marc Verderi, November 2019.
// --------------------------------------------------------------------
#ifndef G4BOptnLeadingParticle_hh
#define G4BOptnLeadingParticle_hh 1
@@ -51,46 +48,53 @@
#include "G4VBiasingOperation.hh"
#include "G4ParticleChange.hh"
class G4BOptnLeadingParticle : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnLeadingParticle(G4String name);
// -- destructor:
virtual ~G4BOptnLeadingParticle();
public:
// -- Methods from G4VBiasingOperation interface:
// ----------------------------------------------
// -- Unused:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*, G4ForceCondition& ) {return nullptr;}
// -- Used:
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*, // -- Method used for this biasing. The related biasing operator
const G4Track*, // -- returns this biasing operation at the post step do it level
const G4Step*, // -- when the wrapped process has won the interaction length race.
G4bool& ); // -- The wrapped process final state is then trimmed.
// -- Unused:
virtual G4double DistanceToApplyOperation( const G4Track*,
G4double,
G4ForceCondition*) {return 0;}
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track*,
const G4Step* ) {return nullptr;}
class G4BOptnLeadingParticle : public G4VBiasingOperation
{
public:
public:
// -- The possibility is given to further apply a Russian roulette on tracks that are accompagnying the leading particle
// -- after the classical leading particle biasing algorithm has been applied.
// -- This is of interest when applying the technique to e+ -> gamma gamma for example. Given one gamma is leading,
// -- the second one is alone in its category, hence selected. With the Russian roulette it is then possible to keep
// -- this one randomly. This is also of interest for pi0 decays, or for brem. e- -> e- gamma where the e- or gamma
// -- are alone in their category.
void SetFurtherKillingProbability( G4double p ) { fRussianRouletteKillingProbability = p; } // -- if p <= 0.0 the killing is ignored.
G4double GetFurtherKillingProbability() const { return fRussianRouletteKillingProbability; }
// -- Constructor :
G4BOptnLeadingParticle(const G4String& name);
// -- destructor:
virtual ~G4BOptnLeadingParticle();
private:
// -- Particle change used to return the trimmed final state:
G4ParticleChange fParticleChange;
G4double fRussianRouletteKillingProbability;
// -- Methods from G4VBiasingOperation interface:
// ----------------------------------------------
// -- Unused:
virtual const G4VBiasingInteractionLaw*
ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*,
G4ForceCondition& ) { return nullptr; }
// -- Used:
virtual G4VParticleChange*
ApplyFinalStateBiasing( const G4BiasingProcessInterface*, // -- Method used for this biasing. The related biasing operator
const G4Track*, // -- returns this biasing operation at the post step do it level
const G4Step*, // -- when the wrapped process has won the interaction length race.
G4bool& ); // -- The wrapped process final state is then trimmed.
// -- Unused:
virtual G4double
DistanceToApplyOperation( const G4Track*, G4double, G4ForceCondition* ) { return 0.0; }
virtual G4VParticleChange*
GenerateBiasingFinalState( const G4Track*, const G4Step* ) { return nullptr; }
// -- The possibility is given to further apply a Russian roulette on tracks that are accompagnying the leading particle
// -- after the classical leading particle biasing algorithm has been applied.
// -- This is of interest when applying the technique to e+ -> gamma gamma for example. Given one gamma is leading,
// -- the second one is alone in its category, hence selected. With the Russian roulette it is then possible to keep
// -- this one randomly. This is also of interest for pi0 decays, or for brem. e- -> e- gamma where the e- or gamma
// -- are alone in their category.
void SetFurtherKillingProbability( G4double p ) // -- if p <= 0.0 the killing is ignored.
{
fRussianRouletteKillingProbability = p;
}
G4double GetFurtherKillingProbability() const
{
return fRussianRouletteKillingProbability;
}
private:
// -- Particle change used to return the trimmed final state:
G4ParticleChange fParticleChange;
G4double fRussianRouletteKillingProbability = -1.0;
};
#endif
@@ -23,76 +23,88 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4BOptrForceCollision
//
// Class Description:
// A G4VBiasingOperator that implements a "force collision" a la
//
// A G4VBiasingOperator that implements a "force collision" a la
// MCNP. This is meant for neutral particles.
// When the track enters the volume, it is cloned. One copy makes
// When the track enters the volume, it is cloned. One copy makes
// a forced free flight up to the volume exit. The other copy makes
// a forced collision inside the volume.
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4BOptrForceCollision_hh
#define G4BOptrForceCollision_hh 1
#include "G4VBiasingOperator.hh"
#include "G4ThreeVector.hh"
#include <vector>
#include <map>
class G4BOptnForceFreeFlight;
class G4BOptnForceCommonTruncatedExp;
class G4BOptnCloning;
class G4VProcess;
class G4BiasingProcessInterface;
class G4ParticleDefinition;
#include <vector>
#include <map>
#include "G4ThreeVector.hh"
class G4BOptrForceCollisionTrackData;
class G4BOptrForceCollision : public G4VBiasingOperator {
public:
G4BOptrForceCollision(G4String particleToForce, G4String name="ForceCollision");
G4BOptrForceCollision(const G4ParticleDefinition* particleToForce, G4String name="ForceCollision");
~G4BOptrForceCollision();
private:
// -- Mandatory from base class :
virtual G4VBiasingOperation* ProposeNonPhysicsBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess) final;
virtual G4VBiasingOperation* ProposeOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess) final;
virtual G4VBiasingOperation* ProposeFinalStateBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess) final;
// -- optional methods from base class:
public:
virtual void Configure() final;
virtual void ConfigureForWorker() final;
virtual void StartRun() final;
virtual void StartTracking( const G4Track* track ) final;
virtual void ExitBiasing( const G4Track*, const G4BiasingProcessInterface* ) final {};
virtual void EndTracking() final;
class G4BOptrForceCollision : public G4VBiasingOperator
{
public:
// -- operation applied:
void OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* operationApplied, const G4VParticleChange* particleChangeProduced ) final;
void OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* occurenceOperationApplied, G4double weightForOccurenceInteraction,
G4VBiasingOperation* finalStateOperationApplied, const G4VParticleChange* particleChangeProduced ) final;
G4BOptrForceCollision(const G4String& particleToForce,
const G4String& name="ForceCollision");
G4BOptrForceCollision(const G4ParticleDefinition* particleToForce,
const G4String& name="ForceCollision");
~G4BOptrForceCollision();
virtual void Configure() final;
virtual void ConfigureForWorker() final;
virtual void StartRun() final;
virtual void StartTracking( const G4Track* track ) final;
virtual void ExitBiasing( const G4Track*, const G4BiasingProcessInterface* ) final {};
virtual void EndTracking() final;
private:
G4int fForceCollisionModelID;
const G4Track* fCurrentTrack;
G4BOptrForceCollisionTrackData* fCurrentTrackData;
std::map< const G4BiasingProcessInterface*, G4BOptnForceFreeFlight* > fFreeFlightOperations;
G4BOptnForceCommonTruncatedExp* fSharedForceInteractionOperation;
G4BOptnCloning* fCloningOperation;
G4double fInitialTrackWeight;
G4bool fSetup;
const G4ParticleDefinition* fParticleToBias;
// -- operation applied:
void OperationApplied( const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* operationApplied,
const G4VParticleChange* particleChangeProduced ) final;
void OperationApplied( const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* occurenceOperationApplied,
G4double weightForOccurenceInteraction,
G4VBiasingOperation* finalStateOperationApplied,
const G4VParticleChange* particleChangeProduced ) final;
private:
// -- Mandatory from base class :
virtual G4VBiasingOperation*
ProposeNonPhysicsBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface* callingProcess) final;
virtual G4VBiasingOperation*
ProposeOccurenceBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface* callingProcess) final;
virtual G4VBiasingOperation*
ProposeFinalStateBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface* callingProcess) final;
private:
G4int fForceCollisionModelID = 0;
const G4Track* fCurrentTrack = nullptr;
G4BOptrForceCollisionTrackData* fCurrentTrackData = nullptr;
std::map< const G4BiasingProcessInterface*, G4BOptnForceFreeFlight* > fFreeFlightOperations;
G4BOptnForceCommonTruncatedExp* fSharedForceInteractionOperation = nullptr;
G4BOptnCloning* fCloningOperation = nullptr;
G4double fInitialTrackWeight = -1.0;
G4bool fSetup = true;
const G4ParticleDefinition* fParticleToBias = nullptr;
};
#endif
@@ -23,58 +23,60 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
// G4BOptrForceCollisionTrackData
//
// Class Description:
// Extends G4Track properties with information needed for the
// force collision biasing operator.
// The G4BOptrForceCollision class is made friend of this one in
// order to keep unexposed to public most of the data members, as
// they are used to control the logic.
//
// ------------------ G4BOptrForceCollisionTrackData ------------------
//
// Author: M.Verderi (LLR), October 2015
// Extends G4Track properties with information needed for the
// force collision biasing operator.
// The G4BOptrForceCollision class is made friend of this one in
// order to keep unexposed to public most of the data members, as
// they are used to control the logic.
//
// Author: M.Verderi (LLR), October 2015.
// --------------------------------------------------------------------
#ifndef G4BOptrForceCollisionTrackData_hh
#define G4BOptrForceCollisionTrackData_hh
#define G4BOptrForceCollisionTrackData_hh 1
#include "G4VAuxiliaryTrackInformation.hh"
class G4BOptrForceCollision;
#include "G4VAuxiliaryTrackInformation.hh"
enum class ForceCollisionState { free, toBeCloned, toBeForced, toBeFreeFlight };
class G4BOptrForceCollisionTrackData : public G4VAuxiliaryTrackInformation {
class G4BOptrForceCollisionTrackData : public G4VAuxiliaryTrackInformation
{
friend class G4BOptrForceCollision;
public:
friend class G4BOptrForceCollision;
G4BOptrForceCollisionTrackData( const G4BOptrForceCollision* );
~G4BOptrForceCollisionTrackData();
public:
G4BOptrForceCollisionTrackData( const G4BOptrForceCollision* );
~G4BOptrForceCollisionTrackData();
// -- from base class:
void Print() const;
// -- from base class:
void Print() const;
// -- Get methods:
G4bool IsFreeFromBiasing() const
{ return ( fForceCollisionState == ForceCollisionState::free);}
// -- no set methods are provided : sets are made under exclusive control of G4BOptrForceCollision objects through friendness.
private:
const G4BOptrForceCollision* fForceCollisionOperator;
ForceCollisionState fForceCollisionState;
// -- Get methods:
G4bool IsFreeFromBiasing() const
{
return ( fForceCollisionState == ForceCollisionState::free);
}
void Reset()
{
fForceCollisionOperator = nullptr;
fForceCollisionState = ForceCollisionState::free;
}
// -- no set methods are provided : sets are made under exclusive
// control of G4BOptrForceCollision objects through friendness.
private:
void Reset()
{
fForceCollisionOperator = nullptr;
fForceCollisionState = ForceCollisionState::free;
}
private:
const G4BOptrForceCollision* fForceCollisionOperator = nullptr;
ForceCollisionState fForceCollisionState;
};
#endif
@@ -23,56 +23,49 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//---------------------------------------------------------------
//
// G4BiasingHelper
//
// Class Description:
// A utility class to help configuring code for biasing.
//
//
//---------------------------------------------------------------
// Initial version Sep. 2013 M. Verderi
// A utility class to help configuring code for biasing.
//
// Author: Marc Verderi, September 2013.
// --------------------------------------------------------------------
#ifndef G4BiasingHelper_h
#define G4BiasingHelper_h 1
#include "globals.hh"
#include <vector>
class G4ProcessManager;
class G4ParallelGeometriesLimiterProcess;
#include <vector>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4BiasingHelper
{
public:
// -- Substitute, in the process manager passed, physics process "physicsProcessToBias"
// -- with a version wrapped by a G4BiasingProcessInterface wrapped, to put this physics
// -- process under biasing.
// -- Only processes of process type 2 (EM), 3 (Optical), 4 (Had.) and 6 (Decay) will be
// -- wrapped.
// -- A name for this wrapped process can be given (otherwise a default one is provided:
// -- e.g. for process "phot" this will be "biasWrapper(phot)").
static G4bool ActivatePhysicsBiasing(G4ProcessManager* pmanager, G4String physicsProcessToBias,
G4String wrappedName = "");
// -- Insert, in the process manager passed, a G4BiasingProcessInterface process that
// -- will deal with non-modifying physics biasing (splitting, killing). A name for
// -- this process can be passed, otherwise the default name "biasWrapper(0)" is used.
static void ActivateNonPhysicsBiasing(G4ProcessManager* pmanager,
G4String nonPhysicsProcessName = "");
// -- Add a G4ParallelGeometriesLimiterProcess instance to the given process manager
// -- The pointer of the added process is returned.
static G4ParallelGeometriesLimiterProcess* AddLimiterProcess(G4ProcessManager* pmanager,
const G4String& processName = "biasLimiter");
public:
// -- Substitute, in the process manager passed, physics process "physicsProcessToBias"
// -- with a version wrapped by a G4BiasingProcessInterface wrapped, to put this physics
// -- process under biasing.
// -- Only processes of process type 2 (EM), 3 (Optical), 4 (Had.) and 6 (Decay) will be
// -- wrapped.
// -- A name for this wrapped process can be given (otherwise a default one is provided:
// -- e.g. for process "phot" this will be "biasWrapper(phot)").
static G4bool ActivatePhysicsBiasing(G4ProcessManager* pmanager,
const G4String& physicsProcessToBias,
const G4String& wrappedName = "");
// -- Insert, in the process manager passed, a G4BiasingProcessInterface process that
// -- will deal with non-modifying physics biasing (splitting, killing). A name for
// -- this process can be passed, otherwise the default name "biasWrapper(0)" is used.
static void ActivateNonPhysicsBiasing(G4ProcessManager* pmanager,
const G4String& nonPhysicsProcessName = "");
// -- Add a G4ParallelGeometriesLimiterProcess instance to the given process manager
// -- The pointer of the added process is returned.
static G4ParallelGeometriesLimiterProcess*
AddLimiterProcess(G4ProcessManager* pmanager,
const G4String& processName = "biasLimiter");
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -23,36 +23,30 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//--------------------------------------------------------------------
//
// G4BiasingProcessInterface
//
// Class Description:
// A wrapper process making the interface between the tracking
// and the G4VBiasingOperator objects attached to volumes.
// If this process holds a physics process, it forwards
// tracking calls to this process in volume where not biasing
// occurs. In volumes with biasing (with a G4VBiasingOperator
// attached) the process gets what to do messaging the biasing
// operator :
// - at the PostStepGPIL level, for getting an occurrence biasing
// operation. If such an operation is returned to the process
// this operation will be messaged at several places.
// - at the PostStepDoIt level, to get a possible final state
// biasing operation
// If the process does not hold a physics process, it is meant
// as handling "non physics" biasing operations: pure splitting
// or pure kiling for example (ie not brem splitting).
//
//--------------------------------------------------------------------
// Initial version Sep. 2013 M. Verderi
// Use of "shared data" class Sep. 2014 M. Verderi
// A wrapper process making the interface between the tracking
// and the G4VBiasingOperator objects attached to volumes.
// If this process holds a physics process, it forwards
// tracking calls to this process in volume where not biasing
// occurs. In volumes with biasing (with a G4VBiasingOperator
// attached) the process gets what to do messaging the biasing
// operator :
// - at the PostStepGPIL level, for getting an occurrence biasing
// operation. If such an operation is returned to the process
// this operation will be messaged at several places.
// - at the PostStepDoIt level, to get a possible final state
// biasing operation
// If the process does not hold a physics process, it is meant
// as handling "non physics" biasing operations: pure splitting
// or pure kiling for example (ie not brem splitting).
//
// Author: Marc Verderi, September 2013.
// --------------------------------------------------------------------
#ifndef G4BiasingProcessInterface_h
#define G4BiasingProcessInterface_h
#define G4BiasingProcessInterface_h 1
#include "globals.hh"
#include "G4VProcess.hh"
@@ -66,213 +60,218 @@ class G4VBiasingOperation;
class G4ParticleChangeForOccurenceBiasing;
class G4ParticleChangeForNothing;
class G4BiasingProcessInterface : public G4VProcess {
public:
// --------------------------------------------------------------------------------
// -- constructor for dealing with biasing options not affecting physics processes:
// --------------------------------------------------------------------------------
G4BiasingProcessInterface( G4String name = "biasWrapper(0)" );
// ---------------------------------------------------------------
// -- constructor to transform the behaviour of a physics process:
// ---------------------------------------------------------------
// -- wrappedProcess pointer MUST NOT be null.
G4BiasingProcessInterface(G4VProcess* wrappedProcess,
G4bool wrappedIsAtRest, G4bool wrappedIsAlongStep, G4bool wrappedIsPostStep,
G4String useThisName = "");
~G4BiasingProcessInterface();
// -- pointer of wrapped physics process:
G4VProcess* GetWrappedProcess() const {return fWrappedProcess;}
class G4BiasingProcessInterface : public G4VProcess
{
public:
// --------------------------------------------------------------------------------
// -- constructor for dealing with biasing options not affecting physics processes:
// --------------------------------------------------------------------------------
G4BiasingProcessInterface( const G4String& name = "biasWrapper(0)" );
// ---------------------------------------------------------------
// -- constructor to transform the behaviour of a physics process:
// ---------------------------------------------------------------
// -- wrappedProcess pointer MUST NOT be null.
G4BiasingProcessInterface(G4VProcess* wrappedProcess,
G4bool wrappedIsAtRest,
G4bool wrappedIsAlongStep,
G4bool wrappedIsPostStep,
G4String useThisName = "");
~G4BiasingProcessInterface();
// -- pointer of wrapped physics process:
G4VProcess* GetWrappedProcess() const { return fWrappedProcess; }
// ---------------------
// -- Biasing interface:
// ---------------------
// -- Helper methods:
// ------------------
// -- Current step and previous step biasing operator, if any:
G4VBiasingOperator* GetCurrentBiasingOperator() const {return fSharedData-> fCurrentBiasingOperator; }
G4VBiasingOperator* GetPreviousBiasingOperator() const {return fSharedData->fPreviousBiasingOperator; }
// -- current and previous operation:
G4VBiasingOperation* GetCurrentNonPhysicsBiasingOperation() const { return fNonPhysicsBiasingOperation; }
G4VBiasingOperation* GetPreviousNonPhysicsBiasingOperation() const { return fPreviousNonPhysicsBiasingOperation; }
G4VBiasingOperation* GetCurrentOccurenceBiasingOperation() const { return fOccurenceBiasingOperation; }
G4VBiasingOperation* GetPreviousOccurenceBiasingOperation() const { return fPreviousOccurenceBiasingOperation; }
G4VBiasingOperation* GetCurrentFinalStateBiasingOperation() const { return fFinalStateBiasingOperation; }
G4VBiasingOperation* GetPreviousFinalStateBiasingOperation() const { return fPreviousFinalStateBiasingOperation; }
// ---------------------
// -- Biasing interface:
// ---------------------
// -- Helper methods:
// ------------------
// -- Current step and previous step biasing operator, if any:
G4VBiasingOperator* GetCurrentBiasingOperator() const
{ return fSharedData->fCurrentBiasingOperator; }
G4VBiasingOperator* GetPreviousBiasingOperator() const
{ return fSharedData->fPreviousBiasingOperator; }
// -- current and previous operation:
G4VBiasingOperation* GetCurrentNonPhysicsBiasingOperation() const
{ return fNonPhysicsBiasingOperation; }
G4VBiasingOperation* GetPreviousNonPhysicsBiasingOperation() const
{ return fPreviousNonPhysicsBiasingOperation; }
G4VBiasingOperation* GetCurrentOccurenceBiasingOperation() const
{ return fOccurenceBiasingOperation; }
G4VBiasingOperation* GetPreviousOccurenceBiasingOperation() const
{ return fPreviousOccurenceBiasingOperation; }
G4VBiasingOperation* GetCurrentFinalStateBiasingOperation() const
{ return fFinalStateBiasingOperation; }
G4VBiasingOperation* GetPreviousFinalStateBiasingOperation() const
{ return fPreviousFinalStateBiasingOperation; }
// -- Lists of processes cooperating under a same particle type/G4ProcessManager.
// -- The vector ordering is:
// -- - random, before first "run/beamOn"
// -- - that of the PostStepGetPhysicalInteractionLength() once "/run/beamOn" has been issued
const std::vector< const G4BiasingProcessInterface* >& GetBiasingProcessInterfaces() const
{return fSharedData-> fPublicBiasingProcessInterfaces;}
const std::vector< const G4BiasingProcessInterface* >& GetPhysicsBiasingProcessInterfaces() const
{return fSharedData-> fPublicPhysicsBiasingProcessInterfaces;}
const std::vector< const G4BiasingProcessInterface* >& GetNonPhysicsBiasingProcessInterfaces() const
{return fSharedData->fPublicNonPhysicsBiasingProcessInterfaces;}
// -- Lists of processes cooperating under a same particle type/G4ProcessManager.
// -- The vector ordering is:
// -- - random, before first "run/beamOn"
// -- - that of the PostStepGetPhysicalInteractionLength() once "/run/beamOn" has been issued
const std::vector< const G4BiasingProcessInterface* >& GetBiasingProcessInterfaces() const
{ return fSharedData->fPublicBiasingProcessInterfaces; }
const std::vector< const G4BiasingProcessInterface* >& GetPhysicsBiasingProcessInterfaces() const
{ return fSharedData->fPublicPhysicsBiasingProcessInterfaces; }
const std::vector< const G4BiasingProcessInterface* >& GetNonPhysicsBiasingProcessInterfaces() const
{ return fSharedData->fPublicNonPhysicsBiasingProcessInterfaces; }
// -- Get shared data for this process:
const G4BiasingProcessSharedData* GetSharedData() const { return fSharedData; }
// -- Get shared data associated to a G4ProcessManager:
static const G4BiasingProcessSharedData* GetSharedData( const G4ProcessManager* );
// -- Get shared data for this process:
const G4BiasingProcessSharedData* GetSharedData() const
{ return fSharedData; }
// -- Get shared data associated to a G4ProcessManager:
static const G4BiasingProcessSharedData* GetSharedData( const G4ProcessManager* );
// ------------------
// -- Helper methods:
// ------------------
// ---- Tell is this process is first/last in the PostStep GPIL and DoIt lists.
// ---- If physOnly is true, only wrapper for physics processes are considered,
// ---- otherwise all G4BiasingProcessInterface processes of this particle are
// ---- considered.
// ---- These methods just return the corresponding flag values setup at
// ---- initialization phase by the next four ones.
// ---- Will not be updated if processes are activate/unactivated on the fly.
// ---- Use next methods (less fast) instead in this case.
G4bool GetIsFirstPostStepGPILInterface(G4bool physOnly = true) const;
G4bool GetIsLastPostStepGPILInterface(G4bool physOnly = true) const;
G4bool GetIsFirstPostStepDoItInterface(G4bool physOnly = true) const;
G4bool GetIsLastPostStepDoItInterface(G4bool physOnly = true) const;
// ---- Determine if the process is first/last in the PostStep GPIL and DoIt lists.
G4bool IsFirstPostStepGPILInterface(G4bool physOnly = true) const;
G4bool IsLastPostStepGPILInterface(G4bool physOnly = true) const;
G4bool IsFirstPostStepDoItInterface(G4bool physOnly = true) const;
G4bool IsLastPostStepDoItInterface(G4bool physOnly = true) const;
// -- Information about wrapped process:
G4bool GetWrappedProcessIsAtRest() const { return fWrappedProcessIsAtRest; }
G4bool GetWrappedProcessIsAlong() const { return fWrappedProcessIsAlong; }
G4bool GetWrappedProcessIsPost() const { return fWrappedProcessIsPost; }
// -- Information methods:
G4double GetPreviousStepSize() const { return fPreviousStepSize; }
G4double GetCurrentMinimumStep() const { return fCurrentMinimumStep; }
G4double GetProposedSafety() const { return fProposedSafety; }
void SetProposedSafety(G4double sft) { fProposedSafety = sft; }
// -- return the actual PostStep and AlongStep limits returned by the process to the tracking :
G4double GetPostStepGPIL() const { return fBiasingPostStepGPIL; }
G4double GetAlongStepGPIL() const { return fWrappedProcessAlongStepGPIL; }
// --------------------------------------------------------------
// -- G4VProcess interface --
// --------------------------------------------------------------
// -- Start/End tracking:
void StartTracking(G4Track* track);
void EndTracking();
// ------------------
// -- Helper methods:
// ------------------
// ---- Tell is this process is first/last in the PostStep GPIL and DoIt lists.
// ---- If physOnly is true, only wrapper for physics processes are considered,
// ---- otherwise all G4BiasingProcessInterface processes of this particle are
// ---- considered.
// ---- These methods just return the corresponding flag values setup at
// ---- initialization phase by the next four ones.
// ---- Will not be updated if processes are activate/unactivated on the fly.
// ---- Use next methods (less fast) instead in this case.
G4bool GetIsFirstPostStepGPILInterface(G4bool physOnly = true) const;
G4bool GetIsLastPostStepGPILInterface(G4bool physOnly = true) const;
G4bool GetIsFirstPostStepDoItInterface(G4bool physOnly = true) const;
G4bool GetIsLastPostStepDoItInterface(G4bool physOnly = true) const;
// ---- Determine if the process is first/last in the PostStep GPIL and DoIt lists.
G4bool IsFirstPostStepGPILInterface(G4bool physOnly = true) const;
G4bool IsLastPostStepGPILInterface(G4bool physOnly = true) const;
G4bool IsFirstPostStepDoItInterface(G4bool physOnly = true) const;
G4bool IsLastPostStepDoItInterface(G4bool physOnly = true) const;
// -- Information about wrapped process:
G4bool GetWrappedProcessIsAtRest() const { return fWrappedProcessIsAtRest; }
G4bool GetWrappedProcessIsAlong() const { return fWrappedProcessIsAlong; }
G4bool GetWrappedProcessIsPost() const { return fWrappedProcessIsPost; }
// -- PostStep methods:
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition);
virtual G4VParticleChange* PostStepDoIt(const G4Track& track,
const G4Step& step);
// -- AlongStep methods:
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4double currentMinimumStep,
G4double& proposedSafety,
G4GPILSelection* selection);
virtual G4VParticleChange* AlongStepDoIt(const G4Track& track,
const G4Step& step);
// -- AtRest methods
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track&,
G4ForceCondition*);
virtual G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&);
// -- Information methods:
G4double GetPreviousStepSize() const { return fPreviousStepSize;}
G4double GetCurrentMinimumStep() const { return fCurrentMinimumStep;}
G4double GetProposedSafety() const { return fProposedSafety;}
void SetProposedSafety(G4double sft) { fProposedSafety = sft;}
// -- return the actual PostStep and AlongStep limits returned by the process to the tracking :
G4double GetPostStepGPIL() const { return fBiasingPostStepGPIL; }
G4double GetAlongStepGPIL() const { return fWrappedProcessAlongStepGPIL; }
// --------------------------------------------------------------
// -- G4VProcess interface --
// --------------------------------------------------------------
public:
// -- Start/End tracking:
void StartTracking(G4Track* track);
void EndTracking();
virtual G4bool IsApplicable(const G4ParticleDefinition& pd);
virtual void BuildPhysicsTable(const G4ParticleDefinition& pd);
virtual void PreparePhysicsTable(const G4ParticleDefinition& pd);
virtual G4bool StorePhysicsTable(const G4ParticleDefinition* pd,
const G4String& s, G4bool f);
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition* pd,
const G4String& s, G4bool f);
// --
virtual void SetProcessManager(const G4ProcessManager*);
virtual const G4ProcessManager* GetProcessManager();
// --
virtual void ResetNumberOfInteractionLengthLeft();
// -- PostStep methods:
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition);
virtual G4VParticleChange* PostStepDoIt(const G4Track& track,
const G4Step& step);
// -- AlongStep methods:
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4double currentMinimumStep,
G4double& proposedSafety,
G4GPILSelection* selection);
virtual G4VParticleChange* AlongStepDoIt(const G4Track& track,
const G4Step& step);
// -- AtRest methods
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track&,
G4ForceCondition*);
virtual G4VParticleChange* AtRestDoIt(const G4Track&,
const G4Step&);
virtual G4bool IsApplicable(const G4ParticleDefinition& pd);
virtual void BuildPhysicsTable(const G4ParticleDefinition& pd);
virtual void PreparePhysicsTable(const G4ParticleDefinition& pd);
virtual G4bool StorePhysicsTable(const G4ParticleDefinition* pd,
const G4String& s, G4bool f);
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition* pd,
const G4String& s, G4bool f);
// --
virtual void SetProcessManager(const G4ProcessManager*);
virtual const G4ProcessManager* GetProcessManager();
// --
virtual void ResetNumberOfInteractionLengthLeft();
// virtual void ClearNumberOfInteractionLengthLeft();
// --
// virtual void DumpInfo() const;
virtual void SetMasterProcess(G4VProcess* masterP);
virtual void BuildWorkerPhysicsTable(const G4ParticleDefinition& pd);
virtual void PrepareWorkerPhysicsTable(const G4ParticleDefinition& pd);
virtual void SetMasterProcess(G4VProcess* masterP);
virtual void BuildWorkerPhysicsTable(const G4ParticleDefinition& pd);
virtual void PrepareWorkerPhysicsTable(const G4ParticleDefinition& pd);
private:
private:
// ---- Internal utility methods:
void SetUpFirstLastFlags();
void ResetForUnbiasedTracking();
void ReorderBiasingVectorAsGPIL();
// ---- Internal utility methods:
void SetUpFirstLastFlags();
void ResetForUnbiasedTracking();
void ReorderBiasingVectorAsGPIL();
G4Track* fCurrentTrack;
G4double fPreviousStepSize;
G4double fCurrentMinimumStep;
G4double fProposedSafety;
G4int IdxFirstLast(G4int firstLast, G4int GPILDoIt, G4int physAll) const
{
// -- be careful : all arguments are *assumed* to be 0 or 1. No check
// -- for that is provided. Should be of pure internal usage.
return 4*firstLast + 2*GPILDoIt + physAll;
}
G4VBiasingOperation* fOccurenceBiasingOperation;
G4VBiasingOperation* fFinalStateBiasingOperation;
G4VBiasingOperation* fNonPhysicsBiasingOperation;
G4VBiasingOperation* fPreviousOccurenceBiasingOperation;
G4VBiasingOperation* fPreviousFinalStateBiasingOperation;
G4VBiasingOperation* fPreviousNonPhysicsBiasingOperation;
// -- method used to anticipate stepping manager calls to PostStepGPIL
// -- of wrapped processes : this method calls wrapped process PostStepGPIL
// -- and caches results for PostStepGPIL and condition.
void InvokeWrappedProcessPostStepGPIL( const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition );
private:
G4bool fResetWrappedProcessInteractionLength;
G4Track* fCurrentTrack = nullptr;
G4double fPreviousStepSize = -1.0;
G4double fCurrentMinimumStep = -1.0;
G4double fProposedSafety = -1.0;
G4VProcess* fWrappedProcess;
const G4bool fIsPhysicsBasedBiasing;
const G4bool fWrappedProcessIsAtRest;
const G4bool fWrappedProcessIsAlong;
const G4bool fWrappedProcessIsPost;
G4VBiasingOperation* fOccurenceBiasingOperation = nullptr;
G4VBiasingOperation* fFinalStateBiasingOperation = nullptr;
G4VBiasingOperation* fNonPhysicsBiasingOperation = nullptr;
G4VBiasingOperation* fPreviousOccurenceBiasingOperation = nullptr;
G4VBiasingOperation* fPreviousFinalStateBiasingOperation = nullptr;
G4VBiasingOperation* fPreviousNonPhysicsBiasingOperation = nullptr;
G4bool fResetWrappedProcessInteractionLength = false;
G4double fWrappedProcessPostStepGPIL;
G4double fBiasingPostStepGPIL;
G4double fWrappedProcessInteractionLength; // -- inverse of analog cross-section
G4ForceCondition fWrappedProcessForceCondition;
G4ForceCondition fBiasingForceCondition;
G4double fWrappedProcessAlongStepGPIL;
G4double fBiasingAlongStepGPIL;
G4GPILSelection fWrappedProcessGPILSelection;
G4GPILSelection fBiasingGPILSelection;
G4VProcess* fWrappedProcess = nullptr;
const G4bool fIsPhysicsBasedBiasing = false;
const G4bool fWrappedProcessIsAtRest = false;
const G4bool fWrappedProcessIsAlong = false;
const G4bool fWrappedProcessIsPost = false;
const G4VBiasingInteractionLaw* fBiasingInteractionLaw;
const G4VBiasingInteractionLaw* fPreviousBiasingInteractionLaw;
G4InteractionLawPhysical* fPhysicalInteractionLaw;
G4ParticleChangeForOccurenceBiasing* fOccurenceBiasingParticleChange;
G4ParticleChangeForNothing* fDummyParticleChange;
G4bool fFirstLastFlags[8];
G4int IdxFirstLast(G4int firstLast, G4int GPILDoIt, G4int physAll) const
{
// -- be careful : all arguments are *assumed* to be 0 or 1. No check
// -- for that is provided. Should be of pure internal usage.
return 4*firstLast + 2*GPILDoIt + physAll;
}
// -- method used to anticipate stepping manager calls to PostStepGPIL
// -- of wrapped processes : this method calls wrapped process PostStepGPIL
// -- and caches results for PostStepGPIL and condition.
void InvokeWrappedProcessPostStepGPIL( const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition );
// -- the instance being "firstGPIL" does work shared by other instances:
G4bool fIamFirstGPIL;
G4double fWrappedProcessPostStepGPIL = -1.0;
G4double fBiasingPostStepGPIL = -1.0;
G4double fWrappedProcessInteractionLength = -1.0; // -- inverse of analog cross-section
G4ForceCondition fWrappedProcessForceCondition = NotForced;
G4ForceCondition fBiasingForceCondition = NotForced;
G4double fWrappedProcessAlongStepGPIL = -1.0;
G4double fBiasingAlongStepGPIL = -1.0;
G4GPILSelection fWrappedProcessGPILSelection = NotCandidateForSelection;
G4GPILSelection fBiasingGPILSelection = NotCandidateForSelection;
const G4VBiasingInteractionLaw* fBiasingInteractionLaw = nullptr;
const G4VBiasingInteractionLaw* fPreviousBiasingInteractionLaw = nullptr;
G4InteractionLawPhysical* fPhysicalInteractionLaw = nullptr;
G4ParticleChangeForOccurenceBiasing* fOccurenceBiasingParticleChange = nullptr;
G4ParticleChangeForNothing* fDummyParticleChange = nullptr;
G4bool fFirstLastFlags[8];
// -- MUST be **thread local**:
static G4Cache<G4bool> fResetInteractionLaws;
static G4Cache<G4bool> fCommonStart;
static G4Cache<G4bool> fCommonEnd;
static G4Cache<G4bool> fDoCommonConfigure;
// -- the instance being "firstGPIL" does work shared by other instances:
G4bool fIamFirstGPIL = false;
const G4ProcessManager* fProcessManager;
// -- MUST be **thread local**:
static G4Cache<G4bool> fResetInteractionLaws;
static G4Cache<G4bool> fCommonStart;
static G4Cache<G4bool> fCommonEnd;
static G4Cache<G4bool> fDoCommonConfigure;
const G4ProcessManager* fProcessManager = nullptr;
// -- the data shared among processes attached to a same process manager:
G4BiasingProcessSharedData* fSharedData;
// -- the data shared among processes attached to a same process manager:
G4BiasingProcessSharedData* fSharedData = nullptr;
};
#endif
@@ -23,30 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//--------------------------------------------------------------------------
//
// G4BiasingProcessSharedData
//
// Class Description:
// This class represents the data that the G4BiasingProcessInterface
// objects attached to a same particle / hold by a same G4ProcessManager
// share. It allows the active G4BiasingProcessInterface objects to share
// information on operations that are common the these instances:
// - the current and previous G4VBiasingOperator objects (their
// pointers are collected once, at the beginning of the PostStepGPIL
// by the first interface invoked)
// - add the list of cooperating G4BiasingProcessInterface objects,
// acting on a same particle type.
// G4BiasingProcessInterface is friend class of this one.
//---------------------------------------------------------------------------
// Initial version Sep. 2014 M. Verderi
//
// This class represents the data that the G4BiasingProcessInterface
// objects attached to a same particle / hold by a same G4ProcessManager
// share. It allows the active G4BiasingProcessInterface objects to share
// information on operations that are common the these instances:
// - the current and previous G4VBiasingOperator objects (their
// pointers are collected once, at the beginning of the PostStepGPIL
// by the first interface invoked)
// - add the list of cooperating G4BiasingProcessInterface objects,
// acting on a same particle type.
// G4BiasingProcessInterface is friend class of this one.
//
// Author: Marc Verderi, September 2014.
// --------------------------------------------------------------------
#ifndef G4BiasingProcessSharedData_h
#define G4BiasingProcessSharedData_h
#define G4BiasingProcessSharedData_h 1
#include "globals.hh"
#include "G4Cache.hh"
#include <vector>
class G4VBiasingOperator;
@@ -54,81 +53,72 @@ class G4BiasingProcessInterface;
class G4ProcessManager;
class G4ParallelGeometriesLimiterProcess;
class G4BiasingProcessSharedData {
class G4BiasingProcessSharedData
{
friend class G4BiasingProcessInterface;
friend class G4ParallelGeometriesLimiterProcess;
friend class G4BiasingProcessInterface;
friend class G4ParallelGeometriesLimiterProcess;
public:
public:
// -------------------------
// -- Public access methods:
// -------------------------
// -- The biasing process interface objects sharing this shared data class:
const std::vector< const G4BiasingProcessInterface* >& GetBiasingProcessInterfaces() const
{ return fPublicBiasingProcessInterfaces; }
const std::vector< const G4BiasingProcessInterface* >& GetPhysicsBiasingProcessInterfaces() const
{ return fPublicPhysicsBiasingProcessInterfaces; }
const std::vector< const G4BiasingProcessInterface* >& GetNonPhysicsBiasingProcessInterfaces() const
{ return fPublicNonPhysicsBiasingProcessInterfaces; }
// -------------------------
// -- Public access methods:
// -------------------------
// -- The biasing process interface objects sharing this shared data class:
const std::vector< const G4BiasingProcessInterface* >& GetBiasingProcessInterfaces() const
{ return fPublicBiasingProcessInterfaces; }
const std::vector< const G4BiasingProcessInterface* >& GetPhysicsBiasingProcessInterfaces() const
{ return fPublicPhysicsBiasingProcessInterfaces; }
const std::vector< const G4BiasingProcessInterface* >& GetNonPhysicsBiasingProcessInterfaces() const
{ return fPublicNonPhysicsBiasingProcessInterfaces; }
// -- The possible geometry limiter process:
const G4ParallelGeometriesLimiterProcess* GetParallelGeometriesLimiterProcess() const
{ return fParallelGeometriesLimiterProcess; }
// -- The possible geometry limiter process:
const G4ParallelGeometriesLimiterProcess* GetParallelGeometriesLimiterProcess() const
{ return fParallelGeometriesLimiterProcess; }
private:
// -- Methods used by the G4BiasingProcessInterface objects.
// -- Object is created by G4BiasingProcessInterface object:
G4BiasingProcessSharedData( const G4ProcessManager* mgr)
: fProcessManager(mgr) {}
~G4BiasingProcessSharedData() {}
// -- biasing operators:
void CurrentBiasingOperator( G4VBiasingOperator* );
G4VBiasingOperator* CurrentBiasingOperator() const;
void PreviousBiasingOperator( G4VBiasingOperator* );
G4VBiasingOperator* PreviousBiasingOperator() const;
private:
const G4ProcessManager* fProcessManager;
// -- biasing operators:
G4VBiasingOperator* fCurrentBiasingOperator = nullptr;
G4VBiasingOperator* fPreviousBiasingOperator = nullptr;
G4VBiasingOperator* fParallelGeometryOperator = nullptr;
G4VBiasingOperator* fMassGeometryOperator = nullptr;
// --
G4bool fIsNewOperator = true;
G4bool fLeavingPreviousOperator = false;
// -- biasing process interfaces sharing this object:
std::vector < G4BiasingProcessInterface* > fBiasingProcessInterfaces;
std::vector < G4BiasingProcessInterface* > fPhysicsBiasingProcessInterfaces;
std::vector < G4BiasingProcessInterface* > fNonPhysicsBiasingProcessInterfaces;
// -- the same ones, for public use:
std::vector < const G4BiasingProcessInterface* > fPublicBiasingProcessInterfaces;
std::vector < const G4BiasingProcessInterface* > fPublicPhysicsBiasingProcessInterfaces;
std::vector < const G4BiasingProcessInterface* > fPublicNonPhysicsBiasingProcessInterfaces;
// -- possible process limiting step on parallel geometries:
G4ParallelGeometriesLimiterProcess* fParallelGeometriesLimiterProcess = nullptr;
private:
// -- Methods used by the G4BiasingProcessInterface objects, thanks to class friendness.
// -- Object is created by G4BiasingProcessInterface object:
G4BiasingProcessSharedData( const G4ProcessManager* mgr)
: fProcessManager (mgr),
fCurrentBiasingOperator ( nullptr ),
fPreviousBiasingOperator ( nullptr ),
fParallelGeometryOperator ( nullptr ),
fMassGeometryOperator ( nullptr ),
fIsNewOperator (true),
fLeavingPreviousOperator (false),
fParallelGeometriesLimiterProcess( nullptr )
{}
~G4BiasingProcessSharedData() {}
// -- biasing operators:
void CurrentBiasingOperator( G4VBiasingOperator* );
G4VBiasingOperator* CurrentBiasingOperator() const;
void PreviousBiasingOperator( G4VBiasingOperator* );
G4VBiasingOperator* PreviousBiasingOperator() const;
private:
// --
const G4ProcessManager* fProcessManager;
// -- biasing operators:
G4VBiasingOperator* fCurrentBiasingOperator;
G4VBiasingOperator* fPreviousBiasingOperator;
G4VBiasingOperator* fParallelGeometryOperator;
G4VBiasingOperator* fMassGeometryOperator;
// --
G4bool fIsNewOperator;
G4bool fLeavingPreviousOperator;
// -- biasing process interfaces sharing this object:
std::vector < G4BiasingProcessInterface* > fBiasingProcessInterfaces;
std::vector < G4BiasingProcessInterface* > fPhysicsBiasingProcessInterfaces;
std::vector < G4BiasingProcessInterface* > fNonPhysicsBiasingProcessInterfaces;
// -- the same ones, for public use:
std::vector < const G4BiasingProcessInterface* > fPublicBiasingProcessInterfaces;
std::vector < const G4BiasingProcessInterface* > fPublicPhysicsBiasingProcessInterfaces;
std::vector < const G4BiasingProcessInterface* > fPublicNonPhysicsBiasingProcessInterfaces;
// -- possible process limiting step on parallel geometries:
G4ParallelGeometriesLimiterProcess* fParallelGeometriesLimiterProcess;
// -- thread local:
// -- Map between process managers and shared data. This map is made of
// -- pointers of G4BiasingSharedData instead of objects themselves :
// -- each process needs to keep a valid pointer of a shared data object
// -- but a map of object will make pointers invalid when map is increased.
static G4MapCache< const G4ProcessManager*,
G4BiasingProcessSharedData* > fSharedDataMap;
// -- thread local:
// -- Map between process managers and shared data. This map is made of
// -- pointers of G4BiasingSharedData instead of objects themselves :
// -- each process needs to keep a valid pointer of a shared data object
// -- but a map of object will make pointers invalid when map is increased.
static G4MapCache< const G4ProcessManager*, G4BiasingProcessSharedData* > fSharedDataMap;
};
#endif
@@ -23,23 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4ILawCommonTruncatedExp
//
// Class Description:
// A G4VBiasingInteractionLaw representing a truncated exponential
// law : an exponential law acting on [0,L] segment. This law is
// Common as it collects several process cross-sections, which sum
// is used to drive the law.
//
// ---------------------------------------------------------------
// Refactored version Oct. 2014 M. Verderi
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingInteractionLaw representing a truncated exponential
// law : an exponential law acting on [0,L] segment. This law is
// Common as it collects several process cross-sections, which sum
// is used to drive the law.
//
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4ILawCommonTruncatedExp_hh
#define G4ILawCommonTruncatedExp_hh 1
@@ -49,38 +43,46 @@
class G4ILawCommonTruncatedExp : public G4VBiasingInteractionLaw
{
public:
G4ILawCommonTruncatedExp(G4String name = "expSharedForceInteractionLaw");
virtual ~G4ILawCommonTruncatedExp();
public:
G4ILawCommonTruncatedExp(const G4String& name = "expSharedForceInteractionLaw");
virtual ~G4ILawCommonTruncatedExp();
public:
virtual G4bool IsSingular() const
{return fExpInteractionLaw.IsSingular();}
virtual G4bool IsEffectiveCrossSectionInfinite() const
{return fExpInteractionLaw.IsEffectiveCrossSectionInfinite();}
private:
// -- sample the distribution:
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
// -- in this case, cheat by returning DBL_MAX, to let operation proposing the
// -- step length in the alongGPIL
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
public:
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
virtual G4bool IsSingular() const
{ return fExpInteractionLaw.IsSingular(); }
virtual G4bool IsEffectiveCrossSectionInfinite() const
{ return fExpInteractionLaw.IsEffectiveCrossSectionInfinite(); }
public:
void SetForceCrossSection( G4double xs ) { fExpInteractionLaw.SetForceCrossSection( xs ); }
void SetSelectedProcessXSfraction( G4double fXS ) { fSelectedProcessXSfraction = fXS; }
G4double SetSelectedProcessXSfraction() const { return fSelectedProcessXSfraction; }
void SetMaximumDistance(G4double d) { fExpInteractionLaw.SetMaximumDistance(d); }
G4double GetMaximumDistance() const { return fExpInteractionLaw.GetMaximumDistance(); }
G4double GetInteractionDistance() const { return fExpInteractionLaw.GetInteractionDistance(); }
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
private:
G4ILawTruncatedExp fExpInteractionLaw;
G4double fSelectedProcessXSfraction;
G4double fInteractionDistance;
void SetForceCrossSection( G4double xs )
{ fExpInteractionLaw.SetForceCrossSection( xs ); }
void SetSelectedProcessXSfraction( G4double fXS )
{ fSelectedProcessXSfraction = fXS; }
G4double SetSelectedProcessXSfraction() const
{ return fSelectedProcessXSfraction; }
void SetMaximumDistance(G4double d)
{ fExpInteractionLaw.SetMaximumDistance(d); }
G4double GetMaximumDistance() const
{ return fExpInteractionLaw.GetMaximumDistance(); }
G4double GetInteractionDistance() const
{ return fExpInteractionLaw.GetInteractionDistance(); }
private:
// -- sample the distribution:
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
// -- in this case, cheat by returning DBL_MAX, to let operation proposing the
// -- step length in the alongGPIL
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
private:
G4ILawTruncatedExp fExpInteractionLaw;
G4double fSelectedProcessXSfraction = 0.0;
G4double fInteractionDistance = 0.0;
};
#endif
@@ -23,23 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4ILawForceFreeFlight
//
// Class Description:
// A G4VBiasingInteractionLaw representing the "interaction" law
// for a force free flight, ie, a particle which does not interact.
// It is a limit case for which the non-interaction probability over
// a segment is always 1, and the effective cross-section always
// zero.
// This singular behavior is signaled by the IsSingular()
// method returning always true.
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingInteractionLaw representing the "interaction" law
// for a force free flight, ie, a particle which does not interact.
// It is a limit case for which the non-interaction probability over
// a segment is always 1, and the effective cross-section always
// zero. This singular behavior is signaled by the IsSingular()
// method returning always true.
//
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4ILawForceFreeFlight_hh
#define G4ILawForceFreeFlight_hh 1
@@ -47,18 +43,19 @@
class G4ILawForceFreeFlight : public G4VBiasingInteractionLaw
{
public:
G4ILawForceFreeFlight(G4String name = "forceFreeFlightLaw");
virtual ~G4ILawForceFreeFlight();
public:
G4ILawForceFreeFlight(const G4String& name = "forceFreeFlightLaw");
virtual ~G4ILawForceFreeFlight();
public:
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
// -- sample the distribution
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
virtual G4bool IsSingular() const {return true;}
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
// -- sample the distribution
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
virtual G4bool IsSingular() const { return true; }
};
#endif
@@ -23,20 +23,16 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4ILawTruncatedExp
//
// Class Description:
// A G4VBiasingInteractionLaw representing a truncated exponential
// law : an exponential law acting on [0,L] segment. The law is
// driven by a cross-section.
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// A G4VBiasingInteractionLaw representing a truncated exponential
// law : an exponential law acting on [0,L] segment. The law is
// driven by a cross-section.
//
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4ILawTruncatedExp_hh
#define G4ILawTruncatedExp_hh 1
@@ -44,34 +40,32 @@
class G4ILawTruncatedExp : public G4VBiasingInteractionLaw
{
public:
G4ILawTruncatedExp(G4String name = "expForceInteractionLaw");
virtual ~G4ILawTruncatedExp();
public:
G4ILawTruncatedExp(const G4String& name = "expForceInteractionLaw");
virtual ~G4ILawTruncatedExp();
public:
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
// -- sample the distribution
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
virtual G4bool IsSingular() const {return fIsSingular;}
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
// -- sample the distribution
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
virtual G4bool IsSingular() const { return fIsSingular; }
public:
void SetForceCrossSection(G4double xs);
void SetForceCrossSection(G4double xs);
public:
void SetMaximumDistance(G4double d) { fMaximumDistance = d;}
G4double GetMaximumDistance() const { return fMaximumDistance;}
G4double GetInteractionDistance() const { return fInteractionDistance; }
void SetMaximumDistance(G4double d) { fMaximumDistance = d; }
G4double GetMaximumDistance() const { return fMaximumDistance; }
G4double GetInteractionDistance() const { return fInteractionDistance; }
private:
G4double fMaximumDistance;
G4double fCrossSection;
G4double fCrossSectionDefined;
G4bool fIsSingular;
G4double fInteractionDistance;
private:
G4double fMaximumDistance = 0.0;
G4double fCrossSection = 0.0;
G4bool fCrossSectionDefined = false;
G4bool fIsSingular = false;
G4double fInteractionDistance = 0.0;
};
#endif
@@ -23,19 +23,15 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4InteractionLawPhysical
//
// Class Description:
// A G4VBiasingInteractionLaw representing the usual
//
// A G4VBiasingInteractionLaw representing the usual
// physical exponential law, of constant cross-section of the step.
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// Author: Marc Verderi, November 2013.
// --------------------------------------------------------------------
#ifndef G4InteractionLawPhysical_hh
#define G4InteractionLawPhysical_hh 1
@@ -43,28 +39,26 @@
class G4InteractionLawPhysical : public G4VBiasingInteractionLaw
{
public:
G4InteractionLawPhysical(G4String name = "exponentialLaw");
virtual ~G4InteractionLawPhysical();
public:
public:
void SetPhysicalCrossSection(G4double crossSection);
G4double GetPhysicalCrossSection() const {return fCrossSection;}
G4InteractionLawPhysical(const G4String& name = "exponentialLaw");
virtual ~G4InteractionLawPhysical();
void SetPhysicalCrossSection(G4double crossSection);
G4double GetPhysicalCrossSection() const { return fCrossSection; }
public:
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
// -- sample the distribution
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const;
// -- sample the distribution
virtual G4double SampleInteractionLength();
// -- move by true path length, this position becomes the new initial point
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength);
private:
private:
G4double fCrossSection;
G4bool fCrossSectionDefined;
G4double fNumberOfInteractionLength;
G4double fCrossSection = 0.0;
G4bool fCrossSectionDefined = false;
G4double fNumberOfInteractionLength = -1.0;
};
#endif
@@ -23,25 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4ParallelGeometriesLimiterProcess
//
// Description:
//
//
//---------------------------------------------------------------
// Process dedicated to limiting the step on boudaries of
// parallel geometries used for the generic biasing.
//
// G4ParallelGeometriesLimiterProcess.hh
//
// Description:
// Process dedicated to limiting the step on boudaries of
// parallel geometries used for the generic biasing.
//
// History:
// Sep 16: Creation.
//
//---------------------------------------------------------------
// Author: Marc Verderi, September 2016.
// --------------------------------------------------------------------
#ifndef G4ParallelGeometriesLimiterProcess_hh
#define G4ParallelGeometriesLimiterProcess_hh
#define G4ParallelGeometriesLimiterProcess_hh 1
#include "globals.hh"
#include "G4VProcess.hh"
@@ -50,133 +42,130 @@
#include "G4VPhysicalVolume.hh"
#include "G4ParticleChangeForNothing.hh"
#include "G4FieldTrack.hh"
class G4PathFinder;
class G4TransportationManager;
// Class Description:
// -- G4VProcess limiting the step on parallel geometries used by generic biasing.
class G4ParallelGeometriesLimiterProcess : public G4VProcess
{
public:
// --------------------------
// -- Constructor/Destructor:
// --------------------------
G4ParallelGeometriesLimiterProcess(const G4String& processName = "biasLimiter");
public:
public:
virtual ~G4ParallelGeometriesLimiterProcess()
{}
// ----------------------------------------------------
// -- Registration / deregistration of parallel worlds.
// -- Access to the list of registered parallel worlds.
// ----------------------------------------------------
void AddParallelWorld(const G4String& parallelWorldName);
void RemoveParallelWorld(const G4String& parallelWorldName);
// -- The list of registered parallel worlds:
const std::vector< G4VPhysicalVolume* >& GetParallelWorlds() const { return fParallelWorlds; }
// --------------------------
// -- Constructor/Destructor:
// --------------------------
G4ParallelGeometriesLimiterProcess(const G4String& processName = "biasLimiter");
// -- Get the parallel world volume index in the list of world volumes handled
// -- by the process. This index can then be used to access current volume and step
// -- limitation status below.
// -- If the world passed is unknown to the process, -1 is returned.
G4int GetParallelWorldIndex( const G4VPhysicalVolume* parallelWorld ) const;
G4int GetParallelWorldIndex( G4String parallelWorldName ) const;
virtual ~G4ParallelGeometriesLimiterProcess() = default;
// ----------------------------------------------------
// -- Registration / deregistration of parallel worlds.
// -- Access to the list of registered parallel worlds.
// ----------------------------------------------------
void AddParallelWorld(const G4String& parallelWorldName);
void RemoveParallelWorld(const G4String& parallelWorldName);
// -- The list of registered parallel worlds:
const std::vector< G4VPhysicalVolume* >& GetParallelWorlds() const
{ return fParallelWorlds; }
// ---------------------
// -- Active navigators:
// ---------------------
// -- The list of navigators handled by the process:
const std::vector< G4Navigator* >& GetActiveNavigators() const { return fParallelWorldNavigators; }
// -- The navigator used for the passed parallel world index (obtained with GetParallelWorldIndex(...) above)
// -- Note that no boundary checks are done on the index passed.
const G4Navigator* GetNavigator( G4int worldIndex ) const { return fParallelWorldNavigators[size_t(worldIndex)]; }
// ---------------------------------------------------
// -- Previous and current steps geometry information:
// ---------------------------------------------------
// -- The "switch" between the previous and current step is done in the PostStepGPIL
// -- The update on the current step is done:
// -- - in the PostStepGPIL for the volumes
// -- - in the AlongStepGPIL for the step limitations
// --
// -- The list of previous step and current step volumes:
const std::vector< const G4VPhysicalVolume* >& GetCurrentVolumes() const { return fCurrentVolumes; }
const std::vector< const G4VPhysicalVolume* >& GetPreviousVolumes() const { return fPreviousVolumes; }
// -- The current and previous volume for the passed parallel world index (obtained with GetParallelWorldIndex(...) above)
// -- Note that no boundary checks are done on the index passed.
const G4VPhysicalVolume* GetCurrentVolume( G4int worldIndex ) const { return fCurrentVolumes[size_t(worldIndex)]; }
const G4VPhysicalVolume* GetPreviousVolume( G4int worldIndex ) const { return fPreviousVolumes[size_t(worldIndex)]; }
// -- Flags telling about step limitation in previous and current step:
const std::vector< G4bool >& GetIsLimiting() const { return fParallelWorldIsLimiting; }
const std::vector< G4bool >& GetWasLimiting() const { return fParallelWorldWasLimiting; }
// -- The current and previous step limitation status for the passed parallel world index (obtained with GetParallelWorldIndex(...) above)
// -- Note that no boundary checks are done on the index passed.
G4bool GetIsLimiting( G4int worldIndex ) const { return fParallelWorldIsLimiting[size_t(worldIndex)]; }
G4bool GetWasLimiting( G4int worldIndex ) const { return fParallelWorldWasLimiting[size_t(worldIndex)]; }
// --------------------------------------------------------------
// From process interface
// --------------------------------------------------------------
// -- Start/End tracking:
void StartTracking(G4Track*);
void EndTracking();
// -- Get the parallel world volume index in the list of world volumes handled
// -- by the process. This index can then be used to access current volume and step
// -- limitation status below.
// -- If the world passed is unknown to the process, -1 is returned.
G4int GetParallelWorldIndex( const G4VPhysicalVolume* parallelWorld ) const;
G4int GetParallelWorldIndex( const G4String& parallelWorldName ) const;
// --------------------
// -- PostStep methods:
// --------------------
// -- PostStepGPIL is used to collect up to date volumes in the parallel geometries:
G4double PostStepGetPhysicalInteractionLength(const G4Track&, G4double, G4ForceCondition*);
// -- PostStepDoIt is not used (never called):
G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step& )
{ return nullptr; }
// ---------------------
// -- Active navigators:
// ---------------------
// -- The list of navigators handled by the process:
const std::vector< G4Navigator* >& GetActiveNavigators() const
{ return fParallelWorldNavigators; }
// -- The navigator used for the passed parallel world index (obtained with GetParallelWorldIndex(...) above)
// -- Note that no boundary checks are done on the index passed.
const G4Navigator* GetNavigator( G4int worldIndex ) const
{ return fParallelWorldNavigators[std::size_t(worldIndex)]; }
// ---------------------------------------------------------------------------
// -- Along step used for limiting the step on parallel geometries boundaries:
// ---------------------------------------------------------------------------
G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4double currentMinimumStep,
G4double& proposedSafety,
G4GPILSelection* selection);
G4VParticleChange* AlongStepDoIt(const G4Track& track,
const G4Step& step);
// ---------------------------
// -- AtRest methods not used:
// ---------------------------
G4double AtRestGetPhysicalInteractionLength(const G4Track&,
G4ForceCondition*)
{ return DBL_MAX; }
G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&)
{ return nullptr; }
// ---------------------------------------------------
// -- Previous and current steps geometry information:
// ---------------------------------------------------
// -- The "switch" between the previous and current step is done in the PostStepGPIL
// -- The update on the current step is done:
// -- - in the PostStepGPIL for the volumes
// -- - in the AlongStepGPIL for the step limitations
// --
// -- The list of previous step and current step volumes:
const std::vector< const G4VPhysicalVolume* >& GetCurrentVolumes() const
{ return fCurrentVolumes; }
const std::vector< const G4VPhysicalVolume* >& GetPreviousVolumes() const
{ return fPreviousVolumes; }
// -- The current and previous volume for the passed parallel world index (obtained with GetParallelWorldIndex(...) above)
// -- Note that no boundary checks are done on the index passed.
const G4VPhysicalVolume* GetCurrentVolume( G4int worldIndex ) const
{ return fCurrentVolumes[std::size_t(worldIndex)]; }
const G4VPhysicalVolume* GetPreviousVolume( G4int worldIndex ) const
{ return fPreviousVolumes[std::size_t(worldIndex)]; }
// -- Flags telling about step limitation in previous and current step:
const std::vector< G4bool >& GetIsLimiting() const
{ return fParallelWorldIsLimiting; }
const std::vector< G4bool >& GetWasLimiting() const
{ return fParallelWorldWasLimiting; }
// -- The current and previous step limitation status for the passed parallel world index (obtained with GetParallelWorldIndex(...) above)
// -- Note that no boundary checks are done on the index passed.
G4bool GetIsLimiting( G4int worldIndex ) const
{ return fParallelWorldIsLimiting[std::size_t(worldIndex)]; }
G4bool GetWasLimiting( G4int worldIndex ) const
{ return fParallelWorldWasLimiting[std::size_t(worldIndex)]; }
// --
virtual void SetProcessManager(const G4ProcessManager*);
// --------------------------------------------------------------
// From process interface
// --------------------------------------------------------------
// -- Start/End tracking:
void StartTracking(G4Track*);
void EndTracking();
// --------------------
// -- PostStep methods:
// --------------------
// -- PostStepGPIL is used to collect up to date volumes in the parallel geometries:
G4double PostStepGetPhysicalInteractionLength(const G4Track&, G4double, G4ForceCondition*);
// -- PostStepDoIt is not used (never called):
G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step& ) { return nullptr; }
// ---------------------------------------------------------------------------
// -- Along step used for limiting the step on parallel geometries boundaries:
// ---------------------------------------------------------------------------
G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize, G4double currentMinimumStep,
G4double& proposedSafety, G4GPILSelection* selection);
G4VParticleChange* AlongStepDoIt(const G4Track& track, const G4Step& step);
private:
std::vector< G4VPhysicalVolume* > fParallelWorlds;
std::vector< G4Navigator* > fParallelWorldNavigators;
std::vector< G4int > fParallelWorldNavigatorIndeces;
std::vector< G4double > fParallelWorldSafeties;
std::vector< G4bool > fParallelWorldIsLimiting;
std::vector< G4bool > fParallelWorldWasLimiting;
std::vector< const G4VPhysicalVolume* > fCurrentVolumes;
std::vector< const G4VPhysicalVolume* > fPreviousVolumes;
G4double fParallelWorldSafety;
G4bool fIsTrackingTime;
G4FieldTrack fFieldTrack;
G4ParticleChangeForNothing fDummyParticleChange;
G4PathFinder* fPathFinder;
G4TransportationManager* fTransportationManager;
// ---------------------------
// -- AtRest methods not used:
// ---------------------------
G4double AtRestGetPhysicalInteractionLength(const G4Track&, G4ForceCondition*)
{ return DBL_MAX; }
G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&)
{ return nullptr; }
// --
virtual void SetProcessManager(const G4ProcessManager*);
private:
std::vector< G4VPhysicalVolume* > fParallelWorlds;
std::vector< G4Navigator* > fParallelWorldNavigators;
std::vector< G4int > fParallelWorldNavigatorIndeces;
std::vector< G4double > fParallelWorldSafeties;
std::vector< G4bool > fParallelWorldIsLimiting;
std::vector< G4bool > fParallelWorldWasLimiting;
std::vector< const G4VPhysicalVolume* > fCurrentVolumes;
std::vector< const G4VPhysicalVolume* > fPreviousVolumes;
G4double fParallelWorldSafety = 0.0;
G4bool fIsTrackingTime = false;
G4FieldTrack fFieldTrack = '0';
G4ParticleChangeForNothing fDummyParticleChange;
G4PathFinder* fPathFinder = nullptr;
G4TransportationManager* fTransportationManager = nullptr;
};
#endif
@@ -23,38 +23,36 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4ParticleChangeForNothing
//
// Class Description:
// A G4VParticleChange used in case of no interaction.
//
// A G4VParticleChange used in case of no interaction.
//
// Author: Marc Verderi, November 2013.
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
#ifndef G4ParticleChangeForNothing_hh
#define G4ParticleChangeForNothing_hh 1
#include "G4VParticleChange.hh"
class G4ParticleChangeForNothing : public G4VParticleChange {
public:
G4ParticleChangeForNothing() : G4VParticleChange() {}
~G4ParticleChangeForNothing() {}
class G4ParticleChangeForNothing : public G4VParticleChange
{
public:
public:
// -- from base class G4VParticleChange:
virtual void Initialize(const G4Track &track)
{
theStatusChange = track.GetTrackStatus();
theNumberOfSecondaries = 0;
}
virtual G4Step* UpdateStepForAtRest (G4Step* step) {return step;}
virtual G4Step* UpdateStepForAlongStep(G4Step* step) {return step;}
virtual G4Step* UpdateStepForPostStep (G4Step* step) {return step;}
G4ParticleChangeForNothing() = default;
~G4ParticleChangeForNothing() = default;
// -- from base class G4VParticleChange:
virtual void Initialize(const G4Track& track)
{
theStatusChange = track.GetTrackStatus();
theNumberOfSecondaries = 0;
}
virtual G4Step* UpdateStepForAtRest (G4Step* step) { return step; }
virtual G4Step* UpdateStepForAlongStep(G4Step* step) { return step; }
virtual G4Step* UpdateStepForPostStep (G4Step* step) { return step; }
};
#endif
@@ -23,62 +23,63 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------
//
// G4ParticleChangeForOccurenceBiasing
//
// Class Description:
// A G4VParticleChange dedicated to occurrence biasing : it
//
// A G4VParticleChange dedicated to occurrence biasing : it
// applies weights for non-interaction over a step, and for
// interaction at the end of the step (if interaction occurs) on
// top of a given particle change, that is the one produced by a
// physics process (biased in its final state or not).
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// Author: Marc Verderi, November 2013.
//
// --------------------------------------------------------------------
#ifndef G4ParticleChangeForOccurenceBiasing_hh
#define G4ParticleChangeForOccurenceBiasing_hh 1
#include "G4VParticleChange.hh"
class G4ParticleChangeForOccurenceBiasing : public G4VParticleChange {
public:
G4ParticleChangeForOccurenceBiasing(G4String name);
~G4ParticleChangeForOccurenceBiasing();
class G4ParticleChangeForOccurenceBiasing : public G4VParticleChange
{
public:
public:
void SetOccurenceWeightForNonInteraction(G4double w) {fOccurenceWeightForNonInteraction = w;}
G4double GetOccurenceWeightForNonInteraction() const {return fOccurenceWeightForNonInteraction;}
void SetOccurenceWeightForInteraction(G4double w) {fOccurenceWeightForInteraction = w;}
G4double GetOccurenceWeightForInteraction() const {return fOccurenceWeightForInteraction;}
G4ParticleChangeForOccurenceBiasing(const G4String& name);
~G4ParticleChangeForOccurenceBiasing() = default;
public:
// -- set a wrapped particle change AND USE IT TO UPDATE this occurrence particle change state:
void SetWrappedParticleChange(G4VParticleChange* wpc);
G4VParticleChange* GetWrappedParticleChange() const {return fWrappedParticleChange;}
public:
// -- collect the secondaries from the wrapped particle change, apply weight correction, and clear wrapped particle change:
void StealSecondaries();
void SetOccurenceWeightForNonInteraction(G4double w)
{ fOccurenceWeightForNonInteraction = w; }
G4double GetOccurenceWeightForNonInteraction() const
{ return fOccurenceWeightForNonInteraction; }
void SetOccurenceWeightForInteraction(G4double w)
{ fOccurenceWeightForInteraction = w; }
G4double GetOccurenceWeightForInteraction() const
{ return fOccurenceWeightForInteraction; }
// -- set a wrapped particle change AND USE IT TO UPDATE this occurrence
// particle change state:
void SetWrappedParticleChange(G4VParticleChange* wpc);
G4VParticleChange* GetWrappedParticleChange() const
{ return fWrappedParticleChange; }
// -- collect the secondaries from the wrapped particle change,
// apply weight correction, and clear wrapped particle change:
void StealSecondaries();
public:
// -- from base class G4VParticleChange:
virtual G4Step* UpdateStepForAtRest (G4Step* step);
virtual G4Step* UpdateStepForAlongStep(G4Step* step);
virtual G4Step* UpdateStepForPostStep (G4Step* step);
// -- from base class G4VParticleChange:
virtual G4Step* UpdateStepForAtRest (G4Step* step);
virtual G4Step* UpdateStepForAlongStep(G4Step* step);
virtual G4Step* UpdateStepForPostStep (G4Step* step);
public:
const G4String& GetName() const {return fName;}
const G4String& GetName() const { return fName; }
private:
G4String fName;
G4VParticleChange* fWrappedParticleChange;
G4double fOccurenceWeightForNonInteraction;
G4double fOccurenceWeightForInteraction;
private:
G4String fName;
G4VParticleChange* fWrappedParticleChange = nullptr;
G4double fOccurenceWeightForNonInteraction = -1.0;
G4double fOccurenceWeightForInteraction = -1.0;
};
#endif