Import Geant4 10.2.0 source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History 86757 2014-11-17 15:16:50Z gcosmo $
|
||||
$Id: History 94220 2015-11-09 08:26:57Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,24 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
November 6th, 2015, M. Verderi
|
||||
- fix non initialization of model IDs in MT mode.
|
||||
- prevent "over initialization" of operators (each
|
||||
first process of process managers were calling
|
||||
these initializations).
|
||||
- proc-biasgen-V10-01-01
|
||||
|
||||
November 6th, 2015, M. Verderi
|
||||
- adaptation to using G4VAuxuliaryTrackInformation:
|
||||
o creation of G4BOptrForceCollisionTrackData
|
||||
o quite rewriting of G4BOptrForceCollision biasing operator,
|
||||
removing many state variables used for bookeeping of tracks
|
||||
which is now achieved much simplier by the aux. track info.
|
||||
Comes together with related logic re-writting.
|
||||
o Removal of dependencies to management/G4BiasingTrackData
|
||||
now deleted since proc-biasmng-V10-01-00 .
|
||||
- proc-biasgen-V10-01-00
|
||||
|
||||
November 14th, 2014 M.Verderi
|
||||
- Serious fix in G4InteractionLawPhysical::
|
||||
UpdateInteractionLengthForStep(...)
|
||||
|
||||
@@ -76,9 +76,12 @@ public:
|
||||
// ----------------------------------------------
|
||||
void SetCloneWeights(G4double clone1Weight, G4double clone2Weight) {fClone1W = clone1Weight ; fClone2W = clone2Weight;}
|
||||
|
||||
G4Track* GetCloneTrack() const { return fCloneTrack; }
|
||||
|
||||
private:
|
||||
G4double fClone1W, fClone2W;
|
||||
G4ParticleChange fParticleChange;
|
||||
G4Track* fCloneTrack;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -99,14 +99,13 @@ public:
|
||||
void UpdateForStep( const G4Step* );
|
||||
void Sample();
|
||||
const G4ThreeVector& GetInitialMomentum() const { return fInitialMomentum; }
|
||||
G4double GetMaximumDistance() const { return fMaximumDistance;}
|
||||
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 PostStepInteractionOccured( const G4VProcess* );
|
||||
void SetInteractionOccured( G4bool b ) { fInteractionOccured = b; }
|
||||
G4bool GetInteractionOccured() const { return fInteractionOccured; }
|
||||
void SetInteractionOccured( G4bool b ) { fInteractionOccured = b; }
|
||||
G4bool GetInteractionOccured() const { return fInteractionOccured; }
|
||||
|
||||
private:
|
||||
G4ILawCommonTruncatedExp* fCommonTruncatedExpLaw;
|
||||
|
||||
@@ -86,11 +86,13 @@ public:
|
||||
}
|
||||
// -- 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;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,7 @@ class G4ParticleDefinition;
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "G4ThreeVector.hh"
|
||||
class G4BOptrForceCollisionTrackData;
|
||||
|
||||
class G4BOptrForceCollision : public G4VBiasingOperator {
|
||||
public:
|
||||
@@ -63,33 +64,36 @@ public:
|
||||
|
||||
private:
|
||||
// -- Mandatory from base class :
|
||||
virtual G4VBiasingOperation* ProposeNonPhysicsBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess);
|
||||
virtual G4VBiasingOperation* ProposeOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess);
|
||||
virtual G4VBiasingOperation* ProposeFinalStateBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess);
|
||||
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 StartRun();
|
||||
virtual void StartTracking( const G4Track* track );
|
||||
virtual void ExitBiasing( const G4Track*, const G4BiasingProcessInterface* );
|
||||
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;
|
||||
|
||||
using G4VBiasingOperator::OperationApplied; // -- informs compiler of multiple OperationApplied symbols
|
||||
// -- in base class, to avoid warning messages for hidden functions
|
||||
// -- in case only one function if overloaded.
|
||||
// -- single operation applied (whatever operation):
|
||||
virtual void OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
|
||||
G4VBiasingOperation* operationApplied, const G4VParticleChange* particleChangeProduced );
|
||||
// -- 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:
|
||||
G4int fForceCollisionModelID;
|
||||
const G4Track* fCurrentTrack;
|
||||
G4BOptrForceCollisionTrackData* fCurrentTrackData;
|
||||
std::map< const G4BiasingProcessInterface*, G4BOptnForceFreeFlight* > fFreeFlightOperations;
|
||||
G4BOptnForceCommonTruncatedExp* fSharedForceInteractionOperation;
|
||||
G4BOptnCloning* fCloningOperation;
|
||||
G4double fInitialTrackWeight;
|
||||
G4bool fSetup;
|
||||
const G4ParticleDefinition* fParticleToBias;
|
||||
G4VBiasingOperation* fPreviousOperationApplied;
|
||||
G4ThreeVector fPreviousMomentum;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef G4BOptrForceCollisionTrackData_hh
|
||||
#define G4BOptrForceCollisionTrackData_hh
|
||||
|
||||
class G4BOptrForceCollision;
|
||||
#include "G4VAuxiliaryTrackInformation.hh"
|
||||
|
||||
enum class ForceCollisionState { free, toBeCloned, toBeForced, toBeFreeFlight };
|
||||
|
||||
class G4BOptrForceCollisionTrackData : public G4VAuxiliaryTrackInformation {
|
||||
|
||||
friend class G4BOptrForceCollision;
|
||||
|
||||
public:
|
||||
G4BOptrForceCollisionTrackData( const G4BOptrForceCollision* );
|
||||
~G4BOptrForceCollisionTrackData();
|
||||
|
||||
// -- 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;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
fForceCollisionOperator = nullptr;
|
||||
fForceCollisionState = ForceCollisionState::free;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -268,7 +268,8 @@ private:
|
||||
static G4Cache<G4bool> fResetInteractionLaws;
|
||||
static G4Cache<G4bool> fCommonStart;
|
||||
static G4Cache<G4bool> fCommonEnd;
|
||||
|
||||
static G4Cache<G4bool> fDoCommonConfigure;
|
||||
|
||||
const G4ProcessManager* fProcessManager;
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: sources.cmake 86197 2014-11-07 15:09:00Z gcosmo $
|
||||
# $Id: sources.cmake 94220 2015-11-09 08:26:57Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@@ -52,6 +52,7 @@ GEANT4_DEFINE_MODULE(NAME G4biasing_gen
|
||||
G4BOptnForceCommonTruncatedExp.hh
|
||||
G4BOptnForceFreeFlight.hh
|
||||
G4BOptrForceCollision.hh
|
||||
G4BOptrForceCollisionTrackData.hh
|
||||
G4ILawCommonTruncatedExp.hh
|
||||
G4ILawForceFreeFlight.hh
|
||||
G4ILawTruncatedExp.hh
|
||||
@@ -66,6 +67,7 @@ GEANT4_DEFINE_MODULE(NAME G4biasing_gen
|
||||
G4BOptnForceCommonTruncatedExp.cc
|
||||
G4BOptnForceFreeFlight.cc
|
||||
G4BOptrForceCollision.cc
|
||||
G4BOptrForceCollisionTrackData.cc
|
||||
G4ILawCommonTruncatedExp.cc
|
||||
G4ILawForceFreeFlight.cc
|
||||
G4ILawTruncatedExp.cc
|
||||
|
||||
@@ -28,21 +28,22 @@
|
||||
|
||||
G4BOptnCloning::G4BOptnCloning(G4String name)
|
||||
: G4VBiasingOperation(name),
|
||||
fParticleChange()
|
||||
fParticleChange(),
|
||||
fCloneTrack(nullptr)
|
||||
{}
|
||||
|
||||
G4BOptnCloning::~G4BOptnCloning()
|
||||
{}
|
||||
|
||||
G4VParticleChange* G4BOptnCloning::GenerateBiasingFinalState( const G4Track* track,
|
||||
const G4Step* )
|
||||
const G4Step* )
|
||||
{
|
||||
fParticleChange.Initialize(*track);
|
||||
fParticleChange.ProposeParentWeight( fClone1W );
|
||||
fParticleChange.SetSecondaryWeightByProcess(true);
|
||||
fParticleChange.SetNumberOfSecondaries(1);
|
||||
G4Track* clone = new G4Track( *track );
|
||||
clone->SetWeight( fClone2W );
|
||||
fParticleChange.AddSecondary( clone );
|
||||
fCloneTrack = new G4Track( *track );
|
||||
fCloneTrack->SetWeight( fClone2W );
|
||||
fParticleChange.AddSecondary( fCloneTrack );
|
||||
return &fParticleChange;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ G4VParticleChange* G4BOptnForceCommonTruncatedExp::ApplyFinalStateBiasing( const
|
||||
fDummyParticleChange.Initialize( *track );
|
||||
return &fDummyParticleChange;
|
||||
}
|
||||
|
||||
|
||||
// -- checks if process won the GPIL race:
|
||||
G4double processGPIL = callingProcess->GetPostStepGPIL() < callingProcess->GetAlongStepGPIL() ?
|
||||
callingProcess->GetPostStepGPIL() : callingProcess->GetAlongStepGPIL() ;
|
||||
@@ -109,11 +109,6 @@ G4VParticleChange* G4BOptnForceCommonTruncatedExp::ApplyFinalStateBiasing( const
|
||||
}
|
||||
|
||||
|
||||
void G4BOptnForceCommonTruncatedExp::PostStepInteractionOccured( const G4VProcess* )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void G4BOptnForceCommonTruncatedExp::AddCrossSection( const G4VProcess* process, G4double crossSection )
|
||||
{
|
||||
fTotalCrossSection += crossSection;
|
||||
@@ -128,6 +123,7 @@ void G4BOptnForceCommonTruncatedExp::Initialize( const G4Track* track )
|
||||
fTotalCrossSection = 0.0;
|
||||
fNumberOfSharing = 0;
|
||||
fProcessToApply = 0;
|
||||
fInteractionOccured = false;
|
||||
fInitialMomentum = track->GetMomentum();
|
||||
|
||||
G4VSolid* currentSolid = track->GetVolume()->GetLogicalVolume()->GetSolid();
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
|
||||
G4BOptnForceFreeFlight::G4BOptnForceFreeFlight(G4String name)
|
||||
: G4VBiasingOperation(name)
|
||||
: G4VBiasingOperation(name),
|
||||
fOperationComplete(true)
|
||||
{
|
||||
fForceFreeFlightInteractionLaw = new G4ILawForceFreeFlight("LawForOperation"+name);
|
||||
}
|
||||
@@ -43,6 +44,7 @@ G4BOptnForceFreeFlight::~G4BOptnForceFreeFlight()
|
||||
|
||||
const G4VBiasingInteractionLaw* G4BOptnForceFreeFlight::ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface*, G4ForceCondition& proposeForceCondition )
|
||||
{
|
||||
fOperationComplete = false;
|
||||
proposeForceCondition = Forced;
|
||||
return fForceFreeFlightInteractionLaw;
|
||||
}
|
||||
@@ -88,9 +90,9 @@ G4VParticleChange* G4BOptnForceFreeFlight::ApplyFinalStateBiasing( const G4Biasi
|
||||
// -- ApplyFinalStateBiasing operation called, and the weight for force free flight is applied
|
||||
// -- is applied by each operation.
|
||||
// -- If the track is not reaching the volume boundary, it zero weight flight continues.
|
||||
|
||||
|
||||
fParticleChange.Initialize( *track );
|
||||
forceFinalState = true;
|
||||
forceFinalState = true;
|
||||
if ( step->GetPostStepPoint()->GetStepStatus() == fGeomBoundary )
|
||||
{
|
||||
// -- Sanity checks:
|
||||
@@ -117,6 +119,7 @@ G4VParticleChange* G4BOptnForceFreeFlight::ApplyFinalStateBiasing( const G4Biasi
|
||||
if ( callingProcess->GetIsFirstPostStepDoItInterface() ) proposedWeight = fCumulatedWeightChange * fInitialTrackWeight;
|
||||
else proposedWeight *= fCumulatedWeightChange;
|
||||
fParticleChange.ProposeWeight(proposedWeight);
|
||||
fOperationComplete = true;
|
||||
}
|
||||
|
||||
return &fParticleChange;
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
#include "G4BOptrForceCollision.hh"
|
||||
#include "G4BOptrForceCollisionTrackData.hh"
|
||||
#include "G4BiasingProcessInterface.hh"
|
||||
#include "G4PhysicsModelCatalog.hh"
|
||||
|
||||
#include "G4BOptnForceCommonTruncatedExp.hh"
|
||||
#include "G4ILawCommonTruncatedExp.hh"
|
||||
@@ -40,9 +42,11 @@
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
|
||||
// -- §§ consider calling other constructor, thanks to C++11
|
||||
G4BOptrForceCollision::G4BOptrForceCollision(G4String particleName, G4String name)
|
||||
: G4VBiasingOperator(name),
|
||||
fForceCollisionModelID(-1),
|
||||
fCurrentTrackData(nullptr),
|
||||
fSetup(true)
|
||||
{
|
||||
fSharedForceInteractionOperation = new G4BOptnForceCommonTruncatedExp("SharedForceInteraction");
|
||||
@@ -63,6 +67,8 @@ G4BOptrForceCollision::G4BOptrForceCollision(G4String particleName, G4String nam
|
||||
|
||||
G4BOptrForceCollision::G4BOptrForceCollision(const G4ParticleDefinition* particle, G4String name)
|
||||
: G4VBiasingOperator(name),
|
||||
fForceCollisionModelID(-1),
|
||||
fCurrentTrackData(nullptr),
|
||||
fSetup(true)
|
||||
{
|
||||
fSharedForceInteractionOperation = new G4BOptnForceCommonTruncatedExp("SharedForceInteraction");
|
||||
@@ -81,20 +87,33 @@ G4BOptrForceCollision::~G4BOptrForceCollision()
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::StartRun()
|
||||
void G4BOptrForceCollision::Configure()
|
||||
{
|
||||
// -- Create ID for force collision:
|
||||
fForceCollisionModelID = G4PhysicsModelCatalog::Register("GenBiasForceCollision");
|
||||
|
||||
// -- build free flight operations:
|
||||
ConfigureForWorker();
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::ConfigureForWorker()
|
||||
{
|
||||
// -- start by remembering processes under biasing, and create needed biasing operations:
|
||||
if ( fSetup )
|
||||
{
|
||||
// -- get back ID created in master thread in case of MT (or reget just created ID in sequential mode):
|
||||
fForceCollisionModelID = G4PhysicsModelCatalog::Register("GenBiasForceCollision");
|
||||
|
||||
const G4ProcessManager* processManager = fParticleToBias->GetProcessManager();
|
||||
const G4BiasingProcessSharedData* sharedData =
|
||||
G4BiasingProcessInterface::GetSharedData( processManager );
|
||||
if (sharedData ) // -- sharedData tested, as is can happen a user attaches an operator to a volume but without defined BiasingProcessInterface processes.
|
||||
const G4BiasingProcessSharedData* interfaceProcessSharedData = G4BiasingProcessInterface::GetSharedData( processManager );
|
||||
if ( interfaceProcessSharedData ) // -- sharedData tested, as is can happen a user attaches an operator
|
||||
// -- to a volume but without defining BiasingProcessInterface processes.
|
||||
{
|
||||
for ( size_t i = 0 ; i < (sharedData->GetPhysicsBiasingProcessInterfaces()).size(); i++ )
|
||||
for ( size_t i = 0 ; i < (interfaceProcessSharedData->GetPhysicsBiasingProcessInterfaces()).size(); i++ )
|
||||
{
|
||||
const G4BiasingProcessInterface* wrapperProcess =
|
||||
(sharedData->GetPhysicsBiasingProcessInterfaces())[i];
|
||||
(interfaceProcessSharedData->GetPhysicsBiasingProcessInterfaces())[i];
|
||||
G4String operationName = "FreeFlight-"+wrapperProcess->GetWrappedProcess()->GetProcessName();
|
||||
fFreeFlightOperations[wrapperProcess] = new G4BOptnForceFreeFlight(operationName);
|
||||
}
|
||||
@@ -104,24 +123,58 @@ void G4BOptrForceCollision::StartRun()
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::StartRun()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
G4VBiasingOperation* G4BOptrForceCollision::ProposeOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
|
||||
{
|
||||
// -- does nothing if particle is not of requested type:
|
||||
if ( track->GetDefinition() != fParticleToBias ) return 0;
|
||||
|
||||
// -- trying to get auxiliary track data...
|
||||
if ( fCurrentTrackData == nullptr )
|
||||
{
|
||||
// ... and if the track has no aux. track data, it means its biasing is not started yet (note that cloning is to happen first):
|
||||
fCurrentTrackData = (G4BOptrForceCollisionTrackData*)(track->GetAuxiliaryTrackInformation(fForceCollisionModelID));
|
||||
if ( fCurrentTrackData == nullptr ) return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Send force free flight to the callingProcess:
|
||||
// ------------------------------------------------
|
||||
// -- The track has been cloned in the previous step, it has now to be
|
||||
// -- forced for a free flight.
|
||||
// -- This track will fly with 0.0 weight during its forced flight:
|
||||
// -- it is to forbid the double counting with the force interaction track.
|
||||
// -- Its weight is restored at the end of its free flight, this weight
|
||||
// -- being its initial weight * the weight for the free flight travel,
|
||||
// -- this last one being per process. The initial weight is common, and is
|
||||
// -- arbitrary asked to the first operation to take care of it.
|
||||
if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeFreeFlight )
|
||||
{
|
||||
G4BOptnForceFreeFlight* operation = fFreeFlightOperations[callingProcess];
|
||||
if ( callingProcess->GetWrappedProcess()->GetCurrentInteractionLength() < DBL_MAX/10. )
|
||||
{
|
||||
// -- the initial track weight will be restored only by the first DoIt free flight:
|
||||
operation->ResetInitialTrackWeight(fInitialTrackWeight);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- Send force interaction operation to the callingProcess:
|
||||
// ----------------------------------------------------------
|
||||
// -- at this level, a copy of the track entering the volume was
|
||||
// -- generated (borned) earlier. This copy will make the forced
|
||||
// -- interaction in the volume.
|
||||
if ( GetBirthOperation( track ) == fCloningOperation )
|
||||
if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeForced )
|
||||
{
|
||||
// -- forced interaction already occured, abort.
|
||||
// -- [Note that if ones would redo a forced interaction, it
|
||||
// -- would require an other cloning before, if one wants to conserve
|
||||
// -- the weight.]
|
||||
if ( fSharedForceInteractionOperation->GetInteractionOccured() ) return 0;
|
||||
|
||||
// -- Remember if this calling process is the first of the physics wrapper in
|
||||
// -- the PostStepGPIL loop (using default argument of method below):
|
||||
G4bool isFirstPhysGPIL = callingProcess-> GetIsFirstPostStepGPILInterface();
|
||||
@@ -152,8 +205,13 @@ G4VBiasingOperation* G4BOptrForceCollision::ProposeOccurenceBiasingOperation(con
|
||||
}
|
||||
|
||||
// -- [*all processes*] Sanity check : it may happen in limit cases that distance to
|
||||
// -- out is zero, weight would be infinite in this case: abort forced interaction.
|
||||
if ( fSharedForceInteractionOperation->GetMaximumDistance() < DBL_MIN ) return 0;
|
||||
// -- out is zero, weight would be infinite in this case: abort forced interaction
|
||||
// -- and abandon biasing.
|
||||
if ( fSharedForceInteractionOperation->GetMaximumDistance() < DBL_MIN )
|
||||
{
|
||||
fCurrentTrackData->Reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -- [* first process*] collect cross-sections and sample force law to determine interaction length
|
||||
// -- and winning process:
|
||||
@@ -167,55 +225,23 @@ G4VBiasingOperation* G4BOptrForceCollision::ProposeOccurenceBiasingOperation(con
|
||||
{
|
||||
const G4BiasingProcessInterface* wrapperProcess = ( sharedData->GetPhysicsBiasingProcessInterfaces() )[i];
|
||||
G4double interactionLength = wrapperProcess->GetWrappedProcess()->GetCurrentInteractionLength();
|
||||
// -- keep only well defined cross-section (*§*):
|
||||
// -- keep only well defined cross-sections, other processes are ignored. These are not pathological cases
|
||||
// -- but cases where a threhold effect par example (eg pair creation) may be at play. (**!**)
|
||||
if ( interactionLength < DBL_MAX/10. )
|
||||
fSharedForceInteractionOperation->AddCrossSection( wrapperProcess->GetWrappedProcess(), 1.0/interactionLength );
|
||||
}
|
||||
// -- sample the shared law (interaction length, and winning process:
|
||||
// -- sample the shared law (interaction length, and winning process):
|
||||
if ( fSharedForceInteractionOperation->GetNumberOfSharing() > 0 ) fSharedForceInteractionOperation->Sample();
|
||||
}
|
||||
|
||||
// -- [*all processes*] Send operation, after sanity check (same criterium than (*§*) !):
|
||||
G4double currentInteractionLength = callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
|
||||
G4VBiasingOperation* operationToReturn = 0;
|
||||
if ( currentInteractionLength < DBL_MAX/10. ) operationToReturn = fSharedForceInteractionOperation;
|
||||
|
||||
|
||||
// -- [*all processes*] Send operation for processes with well defined XS (see "**!**" above):
|
||||
G4VBiasingOperation* operationToReturn = nullptr;
|
||||
if ( callingProcess->GetWrappedProcess()->GetCurrentInteractionLength() < DBL_MAX/10. ) operationToReturn = fSharedForceInteractionOperation;
|
||||
return operationToReturn;
|
||||
|
||||
} // -- end of " if ( GetBirthOperation( track ) == fCloningOperation ) "
|
||||
|
||||
|
||||
|
||||
// -- Send force free flight to the callingProcess:
|
||||
// ------------------------------------------------
|
||||
// -- At this point a track cloning happened in the previous step,
|
||||
// -- we request the continuing/current track to be forced flight.
|
||||
// -- Note this track will fly with 0.0 weight during its forced flight:
|
||||
// -- it is to forbid the double counting with the force interaction track.
|
||||
// -- Its weight is restored at the end of its free flight, this weight
|
||||
// -- being its initial weight * the weight for the free flight travel,
|
||||
// -- this last one being per process. The initial weight is common, and is
|
||||
// -- arbitrary asked to the first operation to take care of it.
|
||||
if ( fPreviousOperationApplied == fCloningOperation )
|
||||
{
|
||||
G4BOptnForceFreeFlight* operation = fFreeFlightOperations[callingProcess];
|
||||
if ( callingProcess->GetWrappedProcess()->GetCurrentInteractionLength() < DBL_MAX/10. )
|
||||
{
|
||||
// -- the initial track weight will be restored only by the first DoIt free flight:
|
||||
operation->ResetInitialTrackWeight(fInitialTrackWeight);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
// -- If forced flight was already requested for the calling process, this flight
|
||||
// -- may have been interupted by some other non-physics process : request
|
||||
// -- process to continue with same forced flight:
|
||||
// -- ** ?? ** Incorrect here in case of flight interrupted by a *physics process*. Ie case
|
||||
// -- ** ?? ** of a subset of physics processes forced is not treated correctly here ** ?? **
|
||||
else if ( callingProcess->GetPreviousOccurenceBiasingOperation() == fFreeFlightOperations[callingProcess] )
|
||||
{
|
||||
return fFreeFlightOperations[callingProcess];
|
||||
}
|
||||
|
||||
} // -- end of "if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeForced )"
|
||||
|
||||
|
||||
// -- other cases here: particle appearing in the volume by some
|
||||
// -- previous interaction : we decide to not bias these.
|
||||
@@ -227,23 +253,43 @@ G4VBiasingOperation* G4BOptrForceCollision::ProposeOccurenceBiasingOperation(con
|
||||
G4VBiasingOperation* G4BOptrForceCollision::ProposeNonPhysicsBiasingOperation(const G4Track* track,
|
||||
const G4BiasingProcessInterface* /* callingProcess */)
|
||||
{
|
||||
if ( track->GetDefinition() != fParticleToBias ) return 0;
|
||||
if ( track->GetDefinition() != fParticleToBias ) return nullptr;
|
||||
|
||||
// -- bias only tracks entering the volume.
|
||||
// -- Apply biasing scheme only to tracks entering the volume.
|
||||
// -- A "cloning" is done:
|
||||
// -- - the primary will be forced flight under a zero weight up to volume exit,
|
||||
// -- where the weight will be restored with proper weight for free flight
|
||||
// -- - the clone will be forced to interact in the volume.
|
||||
if ( track->GetStep()->GetPreStepPoint()->GetStepStatus() == fGeomBoundary )
|
||||
if ( track->GetStep()->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ) // -- §§§ extent to case of a track shoot on the boundary ?
|
||||
{
|
||||
fSharedForceInteractionOperation->SetInteractionOccured( false );
|
||||
// -- check that track is free of undergoing biasing scheme ( no biasing data, or no active active )
|
||||
// -- Get possible track data:
|
||||
fCurrentTrackData = (G4BOptrForceCollisionTrackData*)(track->GetAuxiliaryTrackInformation(fForceCollisionModelID));
|
||||
if ( fCurrentTrackData != nullptr )
|
||||
{
|
||||
if ( fCurrentTrackData->IsFreeFromBiasing() )
|
||||
{
|
||||
// -- takes "ownership" (some track data created before, left free, reuse it):
|
||||
fCurrentTrackData->fForceCollisionOperator = this ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// §§§ Would something be really wrong in this case ? Could this be that a process made a zero step ?
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fCurrentTrackData = new G4BOptrForceCollisionTrackData( this );
|
||||
track->SetAuxiliaryTrackInformation(fForceCollisionModelID, fCurrentTrackData);
|
||||
}
|
||||
fCurrentTrackData->fForceCollisionState = ForceCollisionState::toBeCloned;
|
||||
fInitialTrackWeight = track->GetWeight();
|
||||
fCloningOperation->SetCloneWeights(0.0, fInitialTrackWeight);
|
||||
return fCloningOperation;
|
||||
}
|
||||
|
||||
// -- for all other cases: does nothing
|
||||
return 0;
|
||||
|
||||
// --
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,24 +302,131 @@ G4VBiasingOperation* G4BOptrForceCollision::ProposeFinalStateBiasingOperation(co
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::StartTracking( const G4Track* )
|
||||
void G4BOptrForceCollision::StartTracking( const G4Track* track )
|
||||
{
|
||||
fPreviousOperationApplied = 0;
|
||||
fCurrentTrack = track;
|
||||
fCurrentTrackData = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::ExitBiasing( const G4Track* track, const G4BiasingProcessInterface* /*callingProcess*/ )
|
||||
void G4BOptrForceCollision::EndTracking()
|
||||
{
|
||||
fPreviousOperationApplied = 0;
|
||||
// -- clean-up track for what happens with this operator:
|
||||
ForgetTrack ( track );
|
||||
// -- check for consistency, operator should have cleaned the track:
|
||||
if ( fCurrentTrackData != nullptr )
|
||||
{
|
||||
if ( !fCurrentTrackData->IsFreeFromBiasing() )
|
||||
{
|
||||
if ( (fCurrentTrack->GetTrackStatus() == fStopAndKill) || (fCurrentTrack->GetTrackStatus() == fKillTrackAndSecondaries) )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Current track deleted while under biasing by " << GetName() << ". Will result in inconsistencies.";
|
||||
G4Exception(" G4BOptrForceCollision::EndTracking()",
|
||||
"BIAS.GEN.18",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase,
|
||||
G4VBiasingOperation* operationApplied, const G4VParticleChange* particleChangeProduced )
|
||||
void G4BOptrForceCollision::OperationApplied( const G4BiasingProcessInterface* callingProcess,
|
||||
G4BiasingAppliedCase BAC,
|
||||
G4VBiasingOperation* operationApplied,
|
||||
const G4VParticleChange* )
|
||||
{
|
||||
fPreviousOperationApplied = operationApplied;
|
||||
if ( operationApplied == fCloningOperation )
|
||||
RememberSecondaries( callingProcess, operationApplied, particleChangeProduced );
|
||||
|
||||
if ( fCurrentTrackData == nullptr )
|
||||
{
|
||||
if ( BAC != BAC_None )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << " Internal inconsistency : please submit bug report. " << G4endl;
|
||||
G4Exception(" G4BOptrForceCollision::OperationApplied(...)",
|
||||
"BIAS.GEN.20.1",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeCloned )
|
||||
{
|
||||
fCurrentTrackData->fForceCollisionState = ForceCollisionState::toBeFreeFlight;
|
||||
auto cloneData = new G4BOptrForceCollisionTrackData( this );
|
||||
cloneData->fForceCollisionState = ForceCollisionState::toBeForced;
|
||||
fCloningOperation->GetCloneTrack()->SetAuxiliaryTrackInformation(fForceCollisionModelID, cloneData);
|
||||
}
|
||||
else if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeFreeFlight )
|
||||
{
|
||||
if ( fFreeFlightOperations[callingProcess]->OperationComplete() ) fCurrentTrackData->Reset(); // -- off biasing for this track
|
||||
}
|
||||
else if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeForced )
|
||||
{
|
||||
if ( operationApplied != fSharedForceInteractionOperation )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << " Internal inconsistency : please submit bug report. " << G4endl;
|
||||
G4Exception(" G4BOptrForceCollision::OperationApplied(...)",
|
||||
"BIAS.GEN.20.2",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
if ( fSharedForceInteractionOperation->GetInteractionOccured() )
|
||||
{
|
||||
if ( operationApplied != fSharedForceInteractionOperation )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << " Internal inconsistency : please submit bug report. " << G4endl;
|
||||
G4Exception(" G4BOptrForceCollision::OperationApplied(...)",
|
||||
"BIAS.GEN.20.3",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fCurrentTrackData->fForceCollisionState != ForceCollisionState::free )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << " Internal inconsistency : please submit bug report. " << G4endl;
|
||||
G4Exception(" G4BOptrForceCollision::OperationApplied(...)",
|
||||
"BIAS.GEN.20.4",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4BOptrForceCollision::OperationApplied( const G4BiasingProcessInterface* /*callingProcess*/, G4BiasingAppliedCase /*biasingCase*/,
|
||||
G4VBiasingOperation* /*occurenceOperationApplied*/, G4double /*weightForOccurenceInteraction*/,
|
||||
G4VBiasingOperation* finalStateOperationApplied, const G4VParticleChange* /*particleChangeProduced*/ )
|
||||
{
|
||||
|
||||
if ( fCurrentTrackData->fForceCollisionState == ForceCollisionState::toBeForced )
|
||||
{
|
||||
if ( finalStateOperationApplied != fSharedForceInteractionOperation )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << " Internal inconsistency : please submit bug report. " << G4endl;
|
||||
G4Exception(" G4BOptrForceCollision::OperationApplied(...)",
|
||||
"BIAS.GEN.20.5",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
if ( fSharedForceInteractionOperation->GetInteractionOccured() ) fCurrentTrackData->Reset(); // -- off biasing for this track
|
||||
}
|
||||
else
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << " Internal inconsistency : please submit bug report. " << G4endl;
|
||||
G4Exception(" G4BOptrForceCollision::OperationApplied(...)",
|
||||
"BIAS.GEN.20.6",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
#include "G4BOptrForceCollisionTrackData.hh"
|
||||
#include "G4BOptrForceCollision.hh"
|
||||
|
||||
G4BOptrForceCollisionTrackData::G4BOptrForceCollisionTrackData( const G4BOptrForceCollision* optr )
|
||||
: G4VAuxiliaryTrackInformation(),
|
||||
fForceCollisionOperator( optr )
|
||||
{
|
||||
fForceCollisionState = ForceCollisionState::free;
|
||||
}
|
||||
|
||||
G4BOptrForceCollisionTrackData::~G4BOptrForceCollisionTrackData()
|
||||
{
|
||||
if ( fForceCollisionState != ForceCollisionState::free )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Track deleted while under G4BOptrForceCollision biasing scheme of operator `";
|
||||
if ( fForceCollisionOperator == nullptr ) ed << "(none)"; else ed << fForceCollisionOperator->GetName();
|
||||
ed <<"'. Will result in inconsistencies.";
|
||||
G4Exception(" G4BOptrForceCollisionTrackData::~G4BOptrForceCollisionTrackData()",
|
||||
"BIAS.GEN.19",
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
}
|
||||
|
||||
void G4BOptrForceCollisionTrackData::Print() const
|
||||
{
|
||||
G4cout << " G4BOptrForceCollisionTrackData object : " << this << G4endl;
|
||||
G4cout << " Force collision operator : "; if ( fForceCollisionOperator == nullptr ) G4cout << "(none)"; else G4cout << fForceCollisionOperator->GetName(); G4cout << G4endl;
|
||||
G4cout << " Force collision state : ";
|
||||
switch ( fForceCollisionState )
|
||||
{
|
||||
case ForceCollisionState::free :
|
||||
G4cout << "free from biasing ";
|
||||
break;
|
||||
case ForceCollisionState::toBeCloned :
|
||||
G4cout << "to be cloned ";
|
||||
break;
|
||||
case ForceCollisionState::toBeForced :
|
||||
G4cout << "to be interaction forced ";
|
||||
break;
|
||||
case ForceCollisionState::toBeFreeFlight :
|
||||
G4cout << "to be free flight forced (under weight = 0) ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
@@ -32,13 +32,12 @@
|
||||
#include "G4VBiasingInteractionLaw.hh"
|
||||
#include "G4InteractionLawPhysical.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4BiasingTrackData.hh"
|
||||
#include "G4BiasingTrackDataStore.hh"
|
||||
#include "G4BiasingAppliedCase.hh"
|
||||
|
||||
G4Cache<G4bool> G4BiasingProcessInterface::fResetInteractionLaws;// = true;
|
||||
G4Cache<G4bool> G4BiasingProcessInterface::fCommonStart;// = true;
|
||||
G4Cache<G4bool> G4BiasingProcessInterface::fCommonEnd;// = true;
|
||||
G4Cache<G4bool> G4BiasingProcessInterface::fDoCommonConfigure;
|
||||
G4MapCache< const G4ProcessManager*, G4BiasingProcessSharedData* > G4BiasingProcessInterface::fSharedDataMap;
|
||||
|
||||
|
||||
@@ -61,6 +60,7 @@ G4BiasingProcessInterface::G4BiasingProcessInterface(G4String name)
|
||||
fResetInteractionLaws.Put( true );
|
||||
fCommonStart.Put(true);
|
||||
fCommonEnd.Put(true);
|
||||
fDoCommonConfigure.Put(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ G4BiasingProcessInterface::G4BiasingProcessInterface(G4VProcess* wrappedProcess,
|
||||
fResetInteractionLaws.Put( true );
|
||||
fCommonStart.Put(true);
|
||||
fCommonEnd.Put(true);
|
||||
fDoCommonConfigure.Put(true);
|
||||
|
||||
SetProcessSubType(fWrappedProcess->GetProcessSubType());
|
||||
|
||||
@@ -159,11 +160,8 @@ void G4BiasingProcessInterface::EndTracking()
|
||||
if ( fIsPhysicsBasedBiasing ) fWrappedProcess->EndTracking();
|
||||
if ( fSharedData->fCurrentBiasingOperator) (fSharedData->fCurrentBiasingOperator)->ExitingBiasing( fCurrentTrack, this );
|
||||
fBiasingInteractionLaw = 0;
|
||||
|
||||
|
||||
// -- !! this part might have to be improved : could be time consuming
|
||||
// -- !! and assumes all tracks are killed during tracking, which is
|
||||
// -- !! not true : stacking operations may kill tracks
|
||||
// -- Inform operators of end of tracking:
|
||||
if ( fCommonEnd.Get() )
|
||||
{
|
||||
fCommonEnd.Put( false );// = false;
|
||||
@@ -173,21 +171,6 @@ void G4BiasingProcessInterface::EndTracking()
|
||||
( G4VBiasingOperator::GetBiasingOperators() )[optr]->EndTracking( );
|
||||
|
||||
// -- §§ for above loop, do as in StartTracking.
|
||||
|
||||
if ( ( fCurrentTrack->GetTrackStatus() == fStopAndKill ) || ( fCurrentTrack->GetTrackStatus() == fKillTrackAndSecondaries ) )
|
||||
{
|
||||
G4BiasingTrackData* biasingData = G4BiasingTrackDataStore::GetInstance()->GetBiasingTrackData( fCurrentTrack );
|
||||
if ( biasingData ) delete biasingData; // -- this also deregisters the biasing data from the track data store
|
||||
if ( fCurrentTrack->GetTrackStatus() == fKillTrackAndSecondaries )
|
||||
{
|
||||
const G4TrackVector* secondaries = fCurrentTrack->GetStep()->GetSecondary();
|
||||
for ( size_t i2nd = 0 ; i2nd < secondaries->size() ; i2nd++ )
|
||||
{
|
||||
biasingData = G4BiasingTrackDataStore::GetInstance()->GetBiasingTrackData( (*secondaries)[i2nd] );
|
||||
if ( biasingData ) delete biasingData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +299,7 @@ G4double G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength( const
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// -- An biasing operator exists. Proceed with
|
||||
// -- A biasing operator exists. Proceed with
|
||||
// -- treating non-physics and physics biasing cases:
|
||||
//---------------------------------------------------
|
||||
|
||||
@@ -434,6 +417,7 @@ G4VParticleChange* G4BiasingProcessInterface::PostStepDoIt(const G4Track& track,
|
||||
return finalStateParticleChange;
|
||||
}
|
||||
|
||||
|
||||
// -- If occurence biasing, applies the occurence biasing weight correction on top of final state (biased or not):
|
||||
G4double weightForInteraction = 1.0;
|
||||
if ( !fBiasingInteractionLaw->IsSingular() ) weightForInteraction =
|
||||
@@ -475,7 +459,8 @@ G4VParticleChange* G4BiasingProcessInterface::PostStepDoIt(const G4Track& track,
|
||||
|
||||
(fSharedData->fCurrentBiasingOperator)->ReportOperationApplied( this, BAC,
|
||||
fOccurenceBiasingOperation, weightForInteraction,
|
||||
fFinalStateBiasingOperation, finalStateParticleChange );
|
||||
fFinalStateBiasingOperation, finalStateParticleChange );
|
||||
|
||||
|
||||
fOccurenceBiasingParticleChange->SetOccurenceWeightForInteraction( weightForInteraction );
|
||||
fOccurenceBiasingParticleChange->SetSecondaryWeightByProcess( true );
|
||||
@@ -662,6 +647,9 @@ void G4BiasingProcessInterface::SetMasterProcess(G4VProcess* masterP)
|
||||
|
||||
void G4BiasingProcessInterface::BuildPhysicsTable(const G4ParticleDefinition& pd)
|
||||
{
|
||||
// -- Sequential mode : called second (after PreparePhysicsTable(..))
|
||||
// -- MT mode : called second (after PreparePhysicsTable(..)) by master thread.
|
||||
// -- Corresponding process instance not used then by tracking.
|
||||
// -- PreparePhysicsTable(...) has been called first for all processes,
|
||||
// -- so the first/last flags and G4BiasingProcessInterface vector of processes have
|
||||
// -- been properly setup, fIamFirstGPIL is valid.
|
||||
@@ -669,21 +657,36 @@ void G4BiasingProcessInterface::BuildPhysicsTable(const G4ParticleDefinitio
|
||||
{
|
||||
fWrappedProcess->BuildPhysicsTable(pd);
|
||||
}
|
||||
|
||||
// -- Re-order vector of processes to match that of the GPIL
|
||||
// -- (made for fIamFirstGPIL, but important is to have it made once):
|
||||
if ( fIamFirstGPIL ) ReorderBiasingVectorAsGPIL();
|
||||
|
||||
if ( fIamFirstGPIL )
|
||||
{
|
||||
// -- Re-order vector of processes to match that of the GPIL
|
||||
// -- (made for fIamFirstGPIL, but important is to have it made once):
|
||||
ReorderBiasingVectorAsGPIL();
|
||||
// -- Let operators to configure themselves for the master thread or for sequential mode.
|
||||
// -- Intended here is in particular the registration to physics model catalog.
|
||||
// -- The fDoCommonConfigure is to ensure that this Configure is made by only one process (othewise each first process makes the call):
|
||||
if ( fDoCommonConfigure.Get() )
|
||||
{
|
||||
for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
|
||||
( G4VBiasingOperator::GetBiasingOperators() )[optr]->Configure( );
|
||||
fDoCommonConfigure.Put(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4BiasingProcessInterface::PreparePhysicsTable(const G4ParticleDefinition& pd)
|
||||
{
|
||||
// -- Sequential mode : called first (before BuildPhysicsTable(..))
|
||||
// -- MT mode : called first (before BuildPhysicsTable(..)) by master thread.
|
||||
// -- Corresponding process instance not used then by tracking.
|
||||
// -- Let process finding its first/last position in the process manager:
|
||||
SetUpFirstLastFlags();
|
||||
if ( fWrappedProcess != 0 )
|
||||
{
|
||||
fWrappedProcess->PreparePhysicsTable(pd);
|
||||
fWrappedProcess->PreparePhysicsTable(pd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,6 +744,8 @@ const G4ProcessManager* G4BiasingProcessInterface::GetProcessManager()
|
||||
|
||||
void G4BiasingProcessInterface::BuildWorkerPhysicsTable(const G4ParticleDefinition& pd)
|
||||
{
|
||||
// -- Sequential mode : not called
|
||||
// -- MT mode : called after PrepareWorkerPhysicsTable(..)
|
||||
// -- PrepareWorkerPhysicsTable(...) has been called first for all processes,
|
||||
// -- so the first/last flags and G4BiasingProcessInterface vector of processes have
|
||||
// -- been properly setup, fIamFirstGPIL is valid.
|
||||
@@ -749,15 +754,29 @@ void G4BiasingProcessInterface::BuildWorkerPhysicsTable(const G4ParticleDefiniti
|
||||
fWrappedProcess->BuildWorkerPhysicsTable(pd);
|
||||
}
|
||||
|
||||
// -- Re-order vector of processes to match that of the GPIL
|
||||
// -- (made for fIamFirstGPIL, but important is to have it made once):
|
||||
if ( fIamFirstGPIL ) ReorderBiasingVectorAsGPIL();
|
||||
if ( fIamFirstGPIL )
|
||||
{
|
||||
// -- Re-order vector of processes to match that of the GPIL
|
||||
// -- (made for fIamFirstGPIL, but important is to have it made once):
|
||||
ReorderBiasingVectorAsGPIL();
|
||||
// -- Let operators to configure themselves for the worker thread, if needed.
|
||||
// -- Registration to physics model catalog **IS NOT** to be made here, but in Configure().
|
||||
// -- The fDoCommonConfigure is to ensure that this Configure is made by only one process (othewise each first process makes the call):
|
||||
if ( fDoCommonConfigure.Get() )
|
||||
{
|
||||
for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
|
||||
( G4VBiasingOperator::GetBiasingOperators() )[optr]->ConfigureForWorker( );
|
||||
fDoCommonConfigure.Put(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4BiasingProcessInterface::PrepareWorkerPhysicsTable(const G4ParticleDefinition& pd)
|
||||
{
|
||||
// -- Let process finding its first/last position in the process manager:
|
||||
// -- Sequential mode : not called
|
||||
// -- MT mode : called first, before BuildWorkerPhysicsTable(..)
|
||||
// -- Let process finding its first/last position in the process manager:
|
||||
SetUpFirstLastFlags();
|
||||
|
||||
if ( fWrappedProcess != 0 )
|
||||
@@ -807,14 +826,11 @@ G4bool G4BiasingProcessInterface::IsFirstPostStepGPILInterface(G4bool physOnly)
|
||||
const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeGPIL);
|
||||
G4int thisIdx(-1);
|
||||
for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
|
||||
// for ( size_t i = 0; i < fCoInterfaces->size(); i++ )
|
||||
for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
|
||||
{
|
||||
// if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
|
||||
if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
|
||||
{
|
||||
G4int thatIdx(-1);
|
||||
// for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
|
||||
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
|
||||
if ( thisIdx > thatIdx )
|
||||
{
|
||||
@@ -833,14 +849,11 @@ G4bool G4BiasingProcessInterface::IsLastPostStepGPILInterface(G4bool physOnly) c
|
||||
const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeGPIL);
|
||||
G4int thisIdx(-1);
|
||||
for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
|
||||
// for ( size_t i = 0; i < fCoInterfaces->size(); i++ )
|
||||
for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
|
||||
{
|
||||
// if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
|
||||
if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
|
||||
{
|
||||
G4int thatIdx(-1);
|
||||
// for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
|
||||
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
|
||||
if ( thisIdx < thatIdx )
|
||||
{
|
||||
@@ -859,14 +872,11 @@ G4bool G4BiasingProcessInterface::IsFirstPostStepDoItInterface(G4bool physOnly)
|
||||
const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeDoIt);
|
||||
G4int thisIdx(-1);
|
||||
for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
|
||||
// for ( size_t i = 0; i < fCoInterfaces->size(); i++ )
|
||||
for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
|
||||
{
|
||||
// if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
|
||||
if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
|
||||
{
|
||||
G4int thatIdx(-1);
|
||||
// for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
|
||||
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
|
||||
if ( thisIdx > thatIdx )
|
||||
{
|
||||
@@ -885,14 +895,11 @@ G4bool G4BiasingProcessInterface::IsLastPostStepDoItInterface(G4bool physOnly) c
|
||||
const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeDoIt);
|
||||
G4int thisIdx(-1);
|
||||
for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
|
||||
// for ( size_t i = 0; i < fCoInterfaces->size(); i++ )
|
||||
for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
|
||||
{
|
||||
// if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
|
||||
if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
|
||||
{
|
||||
G4int thatIdx(-1);
|
||||
// for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
|
||||
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
|
||||
if ( thisIdx < thatIdx )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user