Import Geant4 11.3.0 source tree
This commit is contained in:
@@ -23,64 +23,56 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VBiasingOperator
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VBiasingOperator.hh"
|
||||
#include "G4VBiasingOperation.hh"
|
||||
#include "G4VParticleChange.hh"
|
||||
|
||||
|
||||
G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* > G4VBiasingOperator::fLogicalToSetupMap;
|
||||
G4VectorCache< G4VBiasingOperator* > G4VBiasingOperator::fOperators;
|
||||
G4Cache< G4BiasingOperatorStateNotifier* > G4VBiasingOperator::fStateNotifier(0);
|
||||
G4VectorCache< G4VBiasingOperator* > G4VBiasingOperator::fOperators;
|
||||
G4Cache< G4BiasingOperatorStateNotifier* > G4VBiasingOperator::fStateNotifier(nullptr);
|
||||
|
||||
|
||||
G4VBiasingOperator::G4VBiasingOperator(G4String name)
|
||||
: fName ( name ),
|
||||
fOccurenceBiasingOperation ( nullptr ),
|
||||
fFinalStateBiasingOperation ( nullptr ),
|
||||
fNonPhysicsBiasingOperation ( nullptr ),
|
||||
fPreviousProposedOccurenceBiasingOperation ( nullptr ),
|
||||
fPreviousProposedFinalStateBiasingOperation( nullptr ),
|
||||
fPreviousProposedNonPhysicsBiasingOperation( nullptr ),
|
||||
fPreviousAppliedOccurenceBiasingOperation ( nullptr ),
|
||||
fPreviousAppliedFinalStateBiasingOperation ( nullptr ),
|
||||
fPreviousAppliedNonPhysicsBiasingOperation ( nullptr ),
|
||||
fPreviousBiasingAppliedCase ( BAC_None )
|
||||
G4VBiasingOperator::G4VBiasingOperator(const G4String& name)
|
||||
: fName( name )
|
||||
{
|
||||
fOperators.Push_back(this);
|
||||
|
||||
if ( fStateNotifier.Get() == 0 ) fStateNotifier.Put( new G4BiasingOperatorStateNotifier() );
|
||||
|
||||
}
|
||||
|
||||
G4VBiasingOperator::~G4VBiasingOperator()
|
||||
{
|
||||
if ( fStateNotifier.Get() == nullptr )
|
||||
fStateNotifier.Put( new G4BiasingOperatorStateNotifier() );
|
||||
}
|
||||
|
||||
void G4VBiasingOperator::AttachTo(const G4LogicalVolume* logical)
|
||||
{
|
||||
G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* >::iterator it;
|
||||
it = fLogicalToSetupMap.Find(logical);
|
||||
if ( it == fLogicalToSetupMap.End() ) fLogicalToSetupMap[logical] = this;
|
||||
auto it = fLogicalToSetupMap.Find(logical);
|
||||
if ( it == fLogicalToSetupMap.End() )
|
||||
{
|
||||
fLogicalToSetupMap[logical] = this;
|
||||
}
|
||||
else if ( (*it).second != this )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Biasing operator `" << GetName()
|
||||
<< "' can not be attached to Logical volume `"
|
||||
<< logical->GetName() << "' which is already used by another operator !" << G4endl;
|
||||
G4Exception("G4VBiasingOperator::AttachTo(...)",
|
||||
"BIAS.MNG.01",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Biasing operator `" << GetName()
|
||||
<< "' can not be attached to Logical volume `"
|
||||
<< logical->GetName() << "' which is already used by another operator !"
|
||||
<< G4endl;
|
||||
G4Exception("G4VBiasingOperator::AttachTo(...)",
|
||||
"BIAS.MNG.01", JustWarning, ed);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector < G4VBiasingOperator* >&
|
||||
G4VBiasingOperator::GetBiasingOperators()
|
||||
{
|
||||
return fOperators.Get();
|
||||
}
|
||||
|
||||
G4VBiasingOperator* G4VBiasingOperator::GetBiasingOperator(const G4LogicalVolume* logical)
|
||||
{
|
||||
G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* >::iterator it;
|
||||
it = fLogicalToSetupMap.Find(logical);
|
||||
if ( it == fLogicalToSetupMap.End() ) return nullptr;
|
||||
else return (*it).second;
|
||||
auto it = fLogicalToSetupMap.Find(logical);
|
||||
if ( it == fLogicalToSetupMap.End() ) { return nullptr; }
|
||||
else { return (*it).second; }
|
||||
}
|
||||
|
||||
G4VBiasingOperation* G4VBiasingOperator::GetProposedOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
|
||||
@@ -101,17 +93,18 @@ G4VBiasingOperation* G4VBiasingOperator::GetProposedNonPhysicsBiasingOperation(c
|
||||
return fNonPhysicsBiasingOperation;
|
||||
}
|
||||
|
||||
void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface* callingProcess,
|
||||
G4BiasingAppliedCase biasingCase,
|
||||
G4VBiasingOperation* operationApplied,
|
||||
const G4VParticleChange* particleChangeProduced )
|
||||
void G4VBiasingOperator::
|
||||
ReportOperationApplied( const G4BiasingProcessInterface* callingProcess,
|
||||
G4BiasingAppliedCase biasingCase,
|
||||
G4VBiasingOperation* operationApplied,
|
||||
const G4VParticleChange* particleChangeProduced )
|
||||
{
|
||||
fPreviousBiasingAppliedCase = biasingCase;
|
||||
fPreviousAppliedOccurenceBiasingOperation = nullptr;
|
||||
fPreviousAppliedFinalStateBiasingOperation = nullptr;
|
||||
fPreviousAppliedNonPhysicsBiasingOperation = nullptr;
|
||||
switch ( biasingCase )
|
||||
{
|
||||
{
|
||||
case BAC_None:
|
||||
break;
|
||||
case BAC_NonPhysics:
|
||||
@@ -122,34 +115,33 @@ void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface
|
||||
break;
|
||||
case BAC_Occurence:
|
||||
G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
|
||||
"BIAS.MNG.02",
|
||||
JustWarning,
|
||||
"Internal logic error, please report !");
|
||||
"BIAS.MNG.02", JustWarning,
|
||||
"Internal logic error, please report !");
|
||||
break;
|
||||
default:
|
||||
G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
|
||||
"BIAS.MNG.03",
|
||||
JustWarning,
|
||||
"Internal logic error, please report !");
|
||||
}
|
||||
"BIAS.MNG.03", JustWarning,
|
||||
"Internal logic error, please report !");
|
||||
}
|
||||
OperationApplied( callingProcess, biasingCase, operationApplied, particleChangeProduced );
|
||||
}
|
||||
|
||||
void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface* callingProcess,
|
||||
G4BiasingAppliedCase biasingCase,
|
||||
G4VBiasingOperation* occurenceOperationApplied,
|
||||
G4double weightForOccurenceInteraction,
|
||||
G4VBiasingOperation* finalStateOperationApplied,
|
||||
const G4VParticleChange* particleChangeProduced )
|
||||
void G4VBiasingOperator::
|
||||
ReportOperationApplied( const G4BiasingProcessInterface* callingProcess,
|
||||
G4BiasingAppliedCase biasingCase,
|
||||
G4VBiasingOperation* occurenceOperationApplied,
|
||||
G4double weightForOccurenceInteraction,
|
||||
G4VBiasingOperation* finalStateOperationApplied,
|
||||
const G4VParticleChange* particleChangeProduced )
|
||||
{
|
||||
fPreviousBiasingAppliedCase = biasingCase;
|
||||
fPreviousAppliedOccurenceBiasingOperation = occurenceOperationApplied;
|
||||
fPreviousAppliedOccurenceBiasingOperation = occurenceOperationApplied;
|
||||
fPreviousAppliedFinalStateBiasingOperation = finalStateOperationApplied;
|
||||
OperationApplied( callingProcess, biasingCase, occurenceOperationApplied, weightForOccurenceInteraction, finalStateOperationApplied, particleChangeProduced );
|
||||
}
|
||||
|
||||
|
||||
void G4VBiasingOperator::ExitingBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess )
|
||||
void G4VBiasingOperator::
|
||||
ExitingBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess )
|
||||
{
|
||||
ExitBiasing( track, callingProcess );
|
||||
|
||||
@@ -166,23 +158,24 @@ void G4VBiasingOperator::ExitingBiasing( const G4Track* track, const G4BiasingPr
|
||||
fPreviousBiasingAppliedCase = BAC_None ;
|
||||
}
|
||||
|
||||
|
||||
// -- dummy empty implementations to allow letting arguments visible in the .hh
|
||||
// -- but avoiding annoying warning messages about unused variables
|
||||
// -- methods to inform operator that its biasing control is over:
|
||||
void G4VBiasingOperator::ExitBiasing( const G4Track*, const G4BiasingProcessInterface*)
|
||||
void G4VBiasingOperator::
|
||||
ExitBiasing( const G4Track*, const G4BiasingProcessInterface*)
|
||||
{}
|
||||
void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
|
||||
G4VBiasingOperation*, const G4VParticleChange* )
|
||||
void G4VBiasingOperator::
|
||||
OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
|
||||
G4VBiasingOperation*, const G4VParticleChange* )
|
||||
{
|
||||
}
|
||||
void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
|
||||
G4VBiasingOperation*, G4double,
|
||||
G4VBiasingOperation*, const G4VParticleChange* )
|
||||
void G4VBiasingOperator::
|
||||
OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
|
||||
G4VBiasingOperation*, G4double,
|
||||
G4VBiasingOperation*, const G4VParticleChange* )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// -- state machine to get biasing operators messaged at the beginning of runs:
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -193,17 +186,17 @@ G4BiasingOperatorStateNotifier::G4BiasingOperatorStateNotifier()
|
||||
fPreviousState = G4State_PreInit;
|
||||
}
|
||||
|
||||
G4BiasingOperatorStateNotifier::~G4BiasingOperatorStateNotifier()
|
||||
{}
|
||||
|
||||
G4bool G4BiasingOperatorStateNotifier::Notify( G4ApplicationState requestedState )
|
||||
G4bool G4BiasingOperatorStateNotifier::
|
||||
Notify( G4ApplicationState requestedState )
|
||||
{
|
||||
if ( ( fPreviousState == G4State_Idle ) && ( requestedState == G4State_GeomClosed ) )
|
||||
if ( ( fPreviousState == G4State_Idle )
|
||||
&& ( requestedState == G4State_GeomClosed ) )
|
||||
{
|
||||
for ( auto i = 0; i < (G4int)G4VBiasingOperator::fOperators.Size(); ++i )
|
||||
{
|
||||
for ( G4int i = 0; i < (G4int)G4VBiasingOperator::fOperators.Size(); ++i )
|
||||
G4VBiasingOperator::fOperators[i]->StartRun();
|
||||
G4VBiasingOperator::fOperators[i]->StartRun();
|
||||
}
|
||||
|
||||
}
|
||||
fPreviousState = requestedState;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user