Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
+9 -13
View File
@@ -8,8 +8,9 @@
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.3 2010-11-23 13:29:25 gcosmo Exp $
# $Id: CMakeLists.txt 76305 2013-11-08 13:38:31Z gcosmo $
#
# 20130225 M. Kelsey -- Remove cascade/evaporation, cascade/utils
#------------------------------------------------------------------------------
# Add allocation export symbol for the EM category
@@ -25,6 +26,7 @@ add_subdirectory(electromagnetic)
add_subdirectory(hadronic)
add_subdirectory(management)
add_subdirectory(optical)
add_subdirectory(phonon)
add_subdirectory(parameterisation)
add_subdirectory(scoring)
add_subdirectory(transportation)
@@ -33,7 +35,9 @@ if(NOT GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GLOBAL_LIBRARY_TARGET(NAME G4processes
COMPONENTS
biasing/sources.cmake
biasing/management/sources.cmake
biasing/generic/sources.cmake
biasing/importance/sources.cmake
cuts/sources.cmake
decay/sources.cmake
electromagnetic/adjoint/sources.cmake
@@ -53,16 +57,10 @@ if(NOT GEANT4_BUILD_GRANULAR_LIBS)
electromagnetic/xrays/sources.cmake
hadronic/cross_sections/sources.cmake
hadronic/management/sources.cmake
hadronic/models/abla/sources.cmake
hadronic/models/abrasion/sources.cmake
hadronic/models/binary_cascade/sources.cmake
hadronic/models/cascade/cascade/sources.cmake
hadronic/models/cascade/evaporation/sources.cmake
hadronic/models/cascade/utils/sources.cmake
hadronic/models/chiral_inv_phase_space/body/sources.cmake
hadronic/models/chiral_inv_phase_space/cross_sections/sources.cmake
hadronic/models/chiral_inv_phase_space/fragmentation/sources.cmake
hadronic/models/chiral_inv_phase_space/interface/sources.cmake
hadronic/models/chiral_inv_phase_space/processes/sources.cmake
hadronic/models/coherent_elastic/sources.cmake
hadronic/models/de_excitation/ablation/sources.cmake
hadronic/models/de_excitation/evaporation/sources.cmake
@@ -75,16 +73,13 @@ if(NOT GEANT4_BUILD_GRANULAR_LIBS)
hadronic/models/de_excitation/photon_evaporation/sources.cmake
hadronic/models/de_excitation/util/sources.cmake
hadronic/models/em_dissociation/sources.cmake
hadronic/models/high_energy/sources.cmake
hadronic/models/fission/sources.cmake
hadronic/models/im_r_matrix/sources.cmake
hadronic/models/inclxx/utils/sources.cmake
hadronic/models/inclxx/incl_physics/sources.cmake
hadronic/models/inclxx/interface/sources.cmake
hadronic/models/isotope_production/sources.cmake
hadronic/models/lend/sources.cmake
hadronic/models/lepto_nuclear/sources.cmake
hadronic/models/lll_fission/sources.cmake
hadronic/models/low_energy/sources.cmake
hadronic/models/management/sources.cmake
hadronic/models/neutron_hp/sources.cmake
hadronic/models/parton_string/diffraction/sources.cmake
@@ -103,6 +98,7 @@ if(NOT GEANT4_BUILD_GRANULAR_LIBS)
hadronic/util/sources.cmake
management/sources.cmake
optical/sources.cmake
phonon/sources.cmake
parameterisation/sources.cmake
scoring/sources.cmake
transportation/sources.cmake
+13 -25
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.49 2010-11-23 13:29:25 gcosmo Exp $
# $Id: GNUmakefile 76305 2013-11-08 13:38:31Z gcosmo $
# ----------------------------------------------------------------------
# GNUmakefile for processes library, Gabriele Cosmo 27-Jun-1998
# ----------------------------------------------------------------------
@@ -8,9 +8,12 @@ name := G4processes
SUBDIRS = management
SUBDIRS += cuts
SUBDIRS += optical
SUBDIRS += phonon
SUBDIRS += decay
SUBDIRS += scoring
SUBDIRS += biasing
SUBDIRS += biasing/management
SUBDIRS += biasing/generic
SUBDIRS += biasing/importance
SUBDIRS += transportation
SUBDIRS += parameterisation
SUBDIRS += electromagnetic/adjoint
@@ -32,9 +35,12 @@ SUBDIRS += electromagnetic/polarisation
SUBLIBS = G4procman
SUBLIBS += G4cuts
SUBLIBS += G4optical
SUBLIBS += G4phonon
SUBLIBS += G4decay
SUBLIBS += G4scoring
SUBLIBS += G4biasing
SUBLIBS += G4biasing_mgt
SUBLIBS += G4biasing_gen
SUBLIBS += G4biasing_imp
SUBLIBS += G4transportation
SUBLIBS += G4parameterisation
SUBLIBS += G4muons
@@ -62,16 +68,10 @@ endif
SUBDIRS += hadronic/cross_sections
SUBDIRS += hadronic/management
SUBDIRS += hadronic/models/abla
SUBDIRS += hadronic/models/abrasion
SUBDIRS += hadronic/models/binary_cascade
SUBDIRS += hadronic/models/cascade/cascade
SUBDIRS += hadronic/models/cascade/evaporation
SUBDIRS += hadronic/models/cascade/utils
SUBDIRS += hadronic/models/chiral_inv_phase_space/body
SUBDIRS += hadronic/models/chiral_inv_phase_space/cross_sections
SUBDIRS += hadronic/models/chiral_inv_phase_space/fragmentation
SUBDIRS += hadronic/models/chiral_inv_phase_space/interface
SUBDIRS += hadronic/models/chiral_inv_phase_space/processes
SUBDIRS += hadronic/models/coherent_elastic
SUBDIRS += hadronic/models/de_excitation/ablation
SUBDIRS += hadronic/models/de_excitation/evaporation
@@ -84,15 +84,12 @@ SUBDIRS += hadronic/models/de_excitation/multifragmentation
SUBDIRS += hadronic/models/de_excitation/photon_evaporation
SUBDIRS += hadronic/models/de_excitation/util
SUBDIRS += hadronic/models/em_dissociation
SUBDIRS += hadronic/models/high_energy
SUBDIRS += hadronic/models/fission
SUBDIRS += hadronic/models/im_r_matrix
SUBDIRS += hadronic/models/inclxx/utils
SUBDIRS += hadronic/models/inclxx/incl_physics
SUBDIRS += hadronic/models/inclxx/interface
SUBDIRS += hadronic/models/isotope_production
SUBDIRS += hadronic/models/lend
SUBDIRS += hadronic/models/lll_fission
SUBDIRS += hadronic/models/low_energy
SUBDIRS += hadronic/models/management
SUBDIRS += hadronic/models/neutron_hp
SUBDIRS += hadronic/models/parton_string/diffraction
@@ -111,6 +108,7 @@ SUBDIRS += hadronic/processes
SUBDIRS += hadronic/stopping
SUBDIRS += hadronic/util
SUBLIBS += G4hadronic_abla_abla
SUBLIBS += G4hadronic_abrasion
SUBLIBS += G4hadronic_xsect
SUBLIBS += G4hadronic_mgt
@@ -119,30 +117,20 @@ SUBLIBS += G4hadronic_stop
SUBLIBS += G4hadronic_util
SUBLIBS += G4hadronic_binary
SUBLIBS += G4hadronic_coherent_elastic
SUBLIBS += G4hadronic_HE
SUBLIBS += G4had_im_r_matrix
SUBLIBS += G4hadronic_iso
SUBLIBS += G4hadronic_LE
SUBLIBS += G4hadronic_RPG
SUBLIBS += G4hadronic_qmd
SUBLIBS += G4had_lend
SUBLIBS += G4had_lll_fis
SUBLIBS += G4had_fission
SUBLIBS += G4had_mod_man
SUBLIBS += G4had_neu_hp
SUBLIBS += G4hadronic_radioactivedecay
SUBLIBS += G4had_theo_max
SUBLIBS += G4had_mod_util
SUBLIBS += G4hadronic_bert_cascade
SUBLIBS += G4hadronic_hetcpp_evaporation
SUBLIBS += G4hadronic_hetcpp_utils
SUBLIBS += G4hadronic_inclxx_utils
SUBLIBS += G4hadronic_inclxx_physics
SUBLIBS += G4hadronic_inclxx_interface
SUBLIBS += G4hadronic_body_ci
SUBLIBS += G4hadronic_crosec_ci
SUBLIBS += G4hadronic_fragm_ci
SUBLIBS += G4hadronic_interface_ci
SUBLIBS += G4hadronic_proc_ci
SUBLIBS += G4hadronic_deex_evaporation
SUBLIBS += G4hadronic_deex_fermi_breakup
SUBLIBS += G4hadronic_deex_fission
+1 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.7 2007-10-10 14:39:00 gunter Exp $
$Id: History 66892 2013-01-17 10:57:59Z gunter $
-------------------------------------------------------------------
=========================================================
+7 -8
View File
@@ -1,18 +1,17 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4biasing
# Package: Geant4.src.G4processes.G4biasing
# Module : G4hadronic
# Package: Geant4.src.G4processes.G4hadronic
#
# CMakeLists.txt for building a single granular library.
# Intermediate level CMakeLists.txt - just process subdirectories
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010-09-29 18:51:35 bmorgan Exp $
# $Id: CMakeLists.txt 75716 2013-11-05 15:18:03Z gcosmo $
#
#------------------------------------------------------------------------------
if(GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
endif()
add_subdirectory(management)
add_subdirectory(generic)
add_subdirectory(importance)
+7 -24
View File
@@ -1,7 +1,7 @@
# $Id: GNUmakefile,v 1.2 2007-05-30 17:58:37 ahoward Exp $
# ------------------------------------------------------------
# GNUmakefile for biasing process library.
# ------------------------------------------------------------
# $Id: GNUmakefile 75716 2013-11-05 15:18:03Z gcosmo $
# ----------------------------------------------------------------
# GNUmakefile for biasing processes library.
# ----------------------------------------------------------------
name := G4biasing
@@ -11,25 +11,8 @@ endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/navigation/include \
-I$(G4BASE)/geometry/magneticfield/include \
-I$(G4BASE)/geometry/biasing/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/cuts/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/digits_hits/detector/include \
-I$(G4BASE)/digits_hits/hits/include \
-I$(G4BASE)/processes/transportation/include
SUBDIRS = management generic importance
SUBLIBS = G4biasing_mgt G4biasing_gen G4biasing_imp
include $(G4INSTALL)/config/common.gmk
include $(G4INSTALL)/config/globlib.gmk
+90 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.20 2010-07-02 11:02:40 gcosmo Exp $
$Id: History 78011 2013-12-02 11:32:48Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,95 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Nov 30th, 2013 Alex Howard (procbiasing-V09-06-18)
- Moved static methods in the initialiser to the body for G4GeometrySampler
and G4ImportanceConfigurator
Nov 30th, 2013 Alex Howard (procbiasing-V09-06-17)
- Fixed coverity errors (uninitialised variables),
EXCEPT for fGhostStep in G4ImportanceProcess, G4WeightWindowProcess
and G4WeightCutOffProcess
Nov 29th, 2013 Alex Howard (procbiasing-V09-06-16)
- Put back RemoveProcess for both G4WeightWindowConfigurator and
G4ImportanceConfigurator - makes test33 work.
Nov 28th, 2013 Marc Verderi (procbiasing-V09-06-15)
- include license/disclaimer in headers in generic and management
- include comments and description
- change G4cout in G4Exception when appropriate
Nov 28th, 2013 Alex Howard (procbiasing-V09-06-14)
- Put back RemoveProcess for G4WeightCutOffConfigurator since it is not
associated with a store singleton.
Nov 26th, 2013 Alex Howard (procbiasing-V09-06-13)
- Fixing history file for actual tag names - which have probiasing instead
of procbiasing!!
Nov 24th, 2013 Alex Howard (procbiasing-V09-06-12)
- Fixed segmentation fault in mass only case (deleted non-existent objects)
Nov 24th, 2013 Alex Howard (probiasing-V09-06-11)
- Fixed segmentation fault at the end of an MT run
- caused by deleting fGhostStep in the destructor
- removed RemoveProcess from the destructor (ClearSampling) of configurators
- also caused an out of range index with MT
Nov 22nd, 2013 Alex Howard (probiasing-V09-06-10)
- Included guard for single threaded backward compatability
- except for singleton instantiation
Nov 22nd, 2013 Alex Howard (probiasing-V09-06-09 also procbiasing-V09-06-09)
- Migration of WeightWindow importance biasing to MT
Nov 22nd, 2013 Alex Howard (probiasing-V09-06-08)
- Migration of geometrical importance biasing to MT
- moved G4VProcessPlacer and G4ProcessPlacer to management (from importance)
Nov 9th, 2013 Andrea Dotti (probiasing-V09-06-07)
- Bug fixing for unused data members identified by clang 3.2
Nov 8th, 2013 Marc Verderi (probiasing-V09-06-06)
- Migration to MT
- Adding force collision operator G4BOptrForceCollision and related classes
Nov 6th, 2013 Marc Verderi (probiasing-V09-06-05)
- Introduce physics list configuration helper G4BiasingHelper
- Introduce cross section change operation G4BOptnChangeCrossSection
Nov 5th, 2013 Marc Verderi (probiasing-V09-06-04)
- fix compilation warnings in G4BiasingProcessInterface.hh
for unused fWrappedProcessIsAtRest and fWrappedProcessIsPost
- fix warning on windows in G4VBiasingOperation.cc constructor
- fix error on void G4VBiasingOperator::ForgetTrack which
was returning a value.
Nov 5th, 2013 Marc Verderi (probiasing-V09-06-03)
- add classes to generic and management to unblock other dev in process:
- generic:
G4BiasingProcessInterface
G4InteractionLawPhysical
G4ParticleChangeForNothing
G4ParticleChangeForOccurenceBiasing
- management:
G4BiasingAppliedCase
G4BiasingOperationManager
G4BiasingTrackData
G4BiasingTrackDataStore
G4VBiasingInteractionLaw
G4VBiasingOperation
G4VBiasingOperator
Oct 9th, 2013 Alex Howard (procbiasing-V09-06-02)
- fixed sources.cmake for looking for non-existent files
Oct 9th, 2013 Alex Howard (procbiasing-V09-06-01)
- Added cmake and gnumake and sources.cmake files to new directory structure
Oct 9th, 2013 Alex Howard (procbiasing-V09-06-00)
- Re-ordered directory structure for generic physics biasing
June 7th, 2012 Gabriele Cosmo (procbiasing-V09-05-00)
- Fixed spurious cases of hidden variable visibility, detected with
'-Wshadow' compilation option on gcc compiler.
@@ -1,13 +1,13 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4hadronic_HE
# Package: Geant4.src.G4processes.G4hadronic.G4hadronic_models.G4hadronic_HE
# Module : G4biasing
# Package: Geant4.src.G4processes.G4biasing.G4biasing_gen
#
# CMakeLists.txt for building a single granular library.
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010-09-29 19:02:02 bmorgan Exp $
# $Id: CMakeLists.txt 74802 2013-10-22 08:58:21Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -0,0 +1,35 @@
# $Id: GNUmakefile 74802 2013-10-22 08:58:21Z gcosmo $
# ------------------------------------------------------------
# GNUmakefile for biasing process library.
# ------------------------------------------------------------
name := G4biasing_gen
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/navigation/include \
-I$(G4BASE)/geometry/magneticfield/include \
-I$(G4BASE)/geometry/biasing/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/biasing/management/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/cuts/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/digits_hits/detector/include \
-I$(G4BASE)/digits_hits/hits/include \
-I$(G4BASE)/processes/transportation/include
include $(G4INSTALL)/config/common.gmk
+23
View File
@@ -0,0 +1,23 @@
$Id: History 74497 2013-10-10 11:40:16Z ahoward $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
October 10th, 2013 A.Howard
- Subdirectory and history file created.
@@ -0,0 +1,94 @@
//
// ********************************************************************
// * 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: $
//
//---------------------------------------------------------------
//
// G4BOptnChangeCrossSection
//
// Class Description:
// A G4VBiasingOperation to change a process cross-section.
//
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
#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* );
// -- Unused:
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step* ) {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);
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;
};
#endif
@@ -0,0 +1,83 @@
//
// ********************************************************************
// * 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: $
//
//---------------------------------------------------------------
//
// G4BOptnCloning
//
// Class Description:
// A G4VBiasingOperation to clone a track, allowing to set
// weight arbitrary weights.
//
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
#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* ) {return 0;}
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step* ) {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;}
private:
G4double fClone1W, fClone2W;
G4ParticleChange fParticleChange;
};
#endif
@@ -0,0 +1,118 @@
//
// ********************************************************************
// * 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: $
//
//---------------------------------------------------------------
//
// 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
#ifndef G4BOptnForceCommonTruncatedExp_hh
#define G4BOptnForceCommonTruncatedExp_hh 1
#include "G4VBiasingOperation.hh"
#include "G4ThreeVector.hh"
class G4ILawCommonTruncatedExp;
#include <map>
class G4BOptnForceCommonTruncatedExp : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnForceCommonTruncatedExp(G4String name);
// -- destructor:
virtual ~G4BOptnForceCommonTruncatedExp();
public:
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface* );
virtual G4ForceCondition ProposeForceCondition( const G4ForceCondition processCondition );
virtual G4bool DenyProcessPostStepDoIt( const G4BiasingProcessInterface*, const G4Track*, const G4Step*, G4double& );
virtual G4double ProposeAlongStepLimit( const G4BiasingProcessInterface* );
virtual G4GPILSelection ProposeGPILSelection( const G4GPILSelection processSelection );
// -- Unused:
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step* ) {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:
G4ILawCommonTruncatedExp* GetCommonTruncatedExpLaw()
{
return fCommonTruncatedExpLaw;
}
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 );
G4double GetTriggeredProcessXSfraction();
void PostStepInteractionOccured( const G4VProcess* );
void SetInteractionOccured( G4bool b ) { fInteractionOccured = b; }
G4bool GetInteractionOccured() const { return fInteractionOccured; }
private:
G4ILawCommonTruncatedExp* fCommonTruncatedExpLaw;
G4double fTotalCrossSection;
std::map < const G4VProcess*, G4double > fCrossSections;
size_t fNumberOfSharing;
//G4bool fFirstCallToDeny;
const G4VProcess* fProcessToApply;
G4bool fInteractionOccured;
G4ThreeVector fInitialMomentum;
G4double fMaximumDistance;
};
#endif
@@ -0,0 +1,96 @@
//
// ********************************************************************
// * 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: $
//
//---------------------------------------------------------------
//
// 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 restore with value :
// initialWeight * cumulatedWeightChange
//
//---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
#ifndef G4BOptnForceFreeFlight_hh
#define G4BOptnForceFreeFlight_hh 1
#include "G4VBiasingOperation.hh"
#include "G4ForceCondition.hh"
class G4ILawForceFreeFlight;
class G4BOptnForceFreeFlight : public G4VBiasingOperation {
public:
// -- Constructor :
G4BOptnForceFreeFlight(G4String name);
// -- destructor:
virtual ~G4BOptnForceFreeFlight();
public:
// -- Methods from G4VBiasingOperation interface:
// -------------------------------------------
// -- Used:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface* );
virtual G4ForceCondition ProposeForceCondition( const G4ForceCondition ) {return Forced;}
virtual G4bool DenyProcessPostStepDoIt( const G4BiasingProcessInterface*, const G4Track*, const G4Step*, G4double& );
virtual void AlongMoveBy( const G4BiasingProcessInterface*, const G4Step*, G4double );
// -- Unused:
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface*,
const G4Track*,
const G4Step* ) {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:
G4ILawForceFreeFlight* GetForceFreeFlightLaw() {
return fForceFreeFlightInteractionLaw;
}
// -- initialization for weight:
void ResetInitialTrackWeight(G4double w) {fInitialTrackWeight = w; fCumulatedWeightChange = 1.0;}
private:
G4ILawForceFreeFlight* fForceFreeFlightInteractionLaw;
G4double fCumulatedWeightChange, fInitialTrackWeight;
};
#endif
@@ -0,0 +1,97 @@
//
// ********************************************************************
// * 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: $
//
// ---------------------------------------------------------------
//
// G4BOptrForceCollision
//
// Class Description:
// 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
// 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
#ifndef G4BOptrForceCollision_hh
#define G4BOptrForceCollision_hh 1
#include "G4VBiasingOperator.hh"
class G4BOptnForceFreeFlight;
class G4BOptnForceCommonTruncatedExp;
class G4BOptnCloning;
class G4VProcess;
class G4BiasingProcessInterface;
class G4ParticleDefinition;
#include <vector>
#include <map>
#include "G4ThreeVector.hh"
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* ProposeOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess);
virtual G4VBiasingOperation* ProposeFinalStateBiasingOperation(const G4Track*, const G4BiasingProcessInterface*) {return 0;}
virtual G4VBiasingOperation* ProposeNonPhysicsBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess);
// -- optional methods from base class:
public:
virtual void StartTracking( const G4Track* track );
virtual void ExitBiasing( const G4Track*, const G4BiasingProcessInterface* );
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 );
private:
std::map< const G4BiasingProcessInterface*, G4BOptnForceFreeFlight* > fFreeFlightOperations;
G4BOptnForceCommonTruncatedExp* fSharedForceInteractionOperation;
G4BOptnCloning* fCloningOperation;
G4double fInitialTrackWeight;
//G4double fWeightToRestore;
std::vector < const G4VProcess* > fProcesses;
const G4VProcess *fFirstProcess, *fLastProcess;
G4bool fSetup;
const G4ParticleDefinition* fParticle;
G4VBiasingOperation* fPreviousOperationApplied;
G4ThreeVector fPreviousMomentum;
};
#endif
@@ -23,58 +23,51 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
//
// Hadronic Process: Low Energy KaonZeroS Inelastic Process
// J.L. Chuma, TRIUMF, 12-Feb-1997
#ifndef G4LEKaonZeroInelastic_h
#define G4LEKaonZeroInelastic_h 1
// Class Description
// Final state production model for KaonZeroShost inelastic scattering below 20 GeV;
// To be used in your physics list in case you need this physics.
// In this case you want to register an object of this class with
// the corresponding process.
// Class Description - End
// $Id: $
//
//---------------------------------------------------------------
//
// G4BiasingHelper
//
// Class Description:
// A utility class to help configuring code for biasing.
//
//
//---------------------------------------------------------------
// Initial version Sep. 2013 M. Verderi
#include <CLHEP/Units/SystemOfUnits.h>
#include "G4InelasticInteraction.hh"
class G4LEKaonZeroInelastic : public G4InelasticInteraction
#ifndef G4BiasingHelper_h
#define G4BiasingHelper_h 1
#include "globals.hh"
class G4ProcessManager;
#include <vector>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4BiasingHelper
{
public:
G4LEKaonZeroInelastic() : G4InelasticInteraction("G4LEKaonZeroInelastic")
{
SetMinEnergy( 0.0 );
SetMaxEnergy( 25.*CLHEP::GeV );
G4cout << "WARNING: model G4LEKaonZeroInelastic is being deprecated and will\n"
<< "disappear in Geant4 version 10.0" << G4endl;
}
~G4LEKaonZeroInelastic()
{ }
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack,
G4Nucleus &targetNucleus);
virtual void ModelDescription(std::ostream& outFile) const;
private:
void Cascade( // derived from CASK0
G4FastVector<G4ReactionProduct,GHADLISTSIZE> &vec,
G4int &vecLen,
const G4HadProjectile *originalIncident,
G4ReactionProduct &currentParticle,
G4ReactionProduct &targetParticle,
G4bool &incidentHasChanged,
G4bool &targetHasChanged,
G4bool &quasiElastic );
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 = "");
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,268 @@
//
// ********************************************************************
// * 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: $
//
//--------------------------------------------------------------------
//
// 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 occurence 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
#ifndef G4BiasingProcessInterface_h
#define G4BiasingProcessInterface_h
#include "globals.hh"
#include "G4VProcess.hh"
#include "G4Cache.hh"
class G4VBiasingInteractionLaw;
class G4InteractionLawPhysical;
class G4VBiasingOperator;
class G4VBiasingOperation;
class G4ParticleChangeForOccurenceBiasing;
class G4ParticleChange;
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;}
// ---------------------
// -- Biasing interface:
// ---------------------
// -- Helper methods:
// ------------------
// -- Current step and previous step biasing operator, if any:
G4VBiasingOperator* GetCurrentBiasingOperator() const {return fCurrentBiasingOperator; }
G4VBiasingOperator* GetPreviousBiasingOperator() const {return fPreviousBiasingOperator; }
// -- current and previous operation:
G4VBiasingOperation* GetCurrentOccurenceBiasingOperation() const { return fOccurenceBiasingOperation; }
G4VBiasingOperation* GetPreviousOccurenceBiasingOperation() const { return fPreviousOccurenceBiasingOperation; }
G4VBiasingOperation* GetCurrentFinalStateBiasingOperation() const { return fFinalStateBiasingOperation; }
G4VBiasingOperation* GetPreviousFinalStateBiasingOperation() const { return fPreviousFinalStateBiasingOperation; }
G4VBiasingOperation* GetCurrentNonPhysicsBiasingOperation() const { return fNonPhysicsBiasingOperation; }
G4VBiasingOperation* GetPreviousNonPhysicsBiasingOperation() const { return fPreviousNonPhysicsBiasingOperation; }
// ------------------
// -- 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 --
// --------------------------------------------------------------
public:
// -- Start/End tracking:
void StartTracking(G4Track* track);
void EndTracking();
// -- 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);
private:
// ---- Setup first/last flags:
void SetUpFirstLastFlags();
void ResetForUnbiasedTracking();
G4Track* fCurrentTrack;
G4double fPreviousStepSize;
G4double fCurrentMinimumStep;
G4double fProposedSafety;
G4VBiasingOperator* fCurrentBiasingOperator;
G4VBiasingOperator* fPreviousBiasingOperator;
G4VBiasingOperation* fOccurenceBiasingOperation;
G4VBiasingOperation* fFinalStateBiasingOperation;
G4VBiasingOperation* fNonPhysicsBiasingOperation;
G4VBiasingOperation* fPreviousOccurenceBiasingOperation;
G4VBiasingOperation* fPreviousFinalStateBiasingOperation;
G4VBiasingOperation* fPreviousNonPhysicsBiasingOperation;
G4bool fResetWrappedProcessInteractionLength;
G4VProcess* fWrappedProcess;
const G4bool fIsPhysicsBasedBiasing;
const G4bool fWrappedProcessIsAtRest;
const G4bool fWrappedProcessIsAlong;
const G4bool fWrappedProcessIsPost;
G4double fWrappedProcessPostStepGPIL;
G4double fBiasingPostStepGPIL;
G4double fWrappedProcessInteractionLength; // -- inverse of analog cross-section
G4ForceCondition fWrappedProcessForceCondition;
G4ForceCondition fBiasingForceCondition;
G4double fWrappedProcessAlongStepGPIL;
G4double fBiasingAlongStepGPIL;
G4GPILSelection fWrappedProcessGPILSelection;
G4GPILSelection fBiasingGPILSelection;
const G4VBiasingInteractionLaw* fBiasingInteractionLaw;
const G4VBiasingInteractionLaw* fPreviousBiasingInteractionLaw;
G4InteractionLawPhysical* fPhysicalInteractionLaw;
G4ParticleChangeForOccurenceBiasing* fOccurenceBiasingParticleChange;
G4ParticleChange* fParticleChange; // -- to be changed with a light version for weight only
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;
}
// -- TO DO : let some common operation be done only once, by the first
// -- process in GPIL. Nothing done yet, may help to reduce overhead.
// -- For example each process instance fetch for the current operator,
// -- which could be done once, and with pointer shared.
// -- Idea is to have a class containing the data members shared among
// -- the instances.
// -- Could make these shared data members shared only per particle type
// -- (at present, with a single static, any instance of a process shares
// -- its members with any other instance, regardless of particle type.)
G4bool fIamFirstGPIL;
// -- MUST be **thread local**:
static G4Cache<G4bool> fResetInteractionLaws;
static G4Cache<G4bool> fCommonStart;
static G4Cache<G4bool> fCommonEnd;
// -- Maintain lists of interfaces attached to a same particle (ie
// -- to a same G4ProcessManager ).
// -- This is used when biasing operations in different processes need to
// -- cooperate (like for knowing the total cross-section for example).
std::vector< G4BiasingProcessInterface* >* fCoInterfaces;
// -- thread local:
static G4MapCache< const G4ProcessManager*,
std::vector< G4BiasingProcessInterface* > > fManagerInterfaceMap;
const G4ProcessManager* fProcessManager;
};
#endif
@@ -0,0 +1,97 @@
//
// ********************************************************************
// * 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: $
//
// ---------------------------------------------------------------
//
// 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.
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
#ifndef G4ILawCommonTruncatedExp_hh
#define G4ILawCommonTruncatedExp_hh 1
#include "G4VBiasingInteractionLaw.hh"
#include "G4ILawTruncatedExp.hh"
#include "G4ThreeVector.hh"
class G4BOptnForceCommonTruncatedExp;
class G4ILawCommonTruncatedExp : public G4VBiasingInteractionLaw
{
public:
G4ILawCommonTruncatedExp(G4String name = "expSharedForceInteractionLaw");
virtual ~G4ILawCommonTruncatedExp();
public:
virtual G4bool IsSingular() const
{return fExpInteractionLaw.IsSingular();}
virtual G4bool IsEffectiveCrossSectionInfinite() const
{return fExpInteractionLaw.IsEffectiveCrossSectionInfinite();}
private:
// -- sample the distribution:
// -- in this case, cheat by returning DBL_MAX, to let operation proposing the
// -- step length in the alongGPIL
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;
public:
void SetNumberOfSharing(G4int n) { fNumberOfSharing = n; }
G4int GetNumberOfSharing() const { return fNumberOfSharing; }
void SetForceCrossSection( G4double xs ) { fExpInteractionLaw.SetForceCrossSection( xs ); }
void reset();
void SetMaximumDistance(G4double d) { fExpInteractionLaw.SetMaximumDistance(d); }
G4double GetMaximumDistance() const {return fExpInteractionLaw.GetMaximumDistance();}
G4double GetInteractionDistance() const {return fExpInteractionLaw.GetInteractionDistance();}
void SetOperation( G4BOptnForceCommonTruncatedExp* operation) {fOperation = operation;}
private:
G4ILawTruncatedExp fExpInteractionLaw;
//G4bool fIsSingular;
G4int fNumberOfSharing;
//G4bool fFirstInitializationCall;
G4bool fFirstUpdateCall;
G4bool fFirstSamplingCall;
G4double fInteractionDistance;
// TRICKY
G4BOptnForceCommonTruncatedExp* fOperation;
};
#endif
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * 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: $
//
// ---------------------------------------------------------------
//
// 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
#ifndef G4ILawForceFreeFlight_hh
#define G4ILawForceFreeFlight_hh 1
#include "G4VBiasingInteractionLaw.hh"
class G4ILawForceFreeFlight : public G4VBiasingInteractionLaw
{
public:
G4ILawForceFreeFlight(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;}
};
#endif
@@ -24,61 +24,55 @@
// ********************************************************************
//
//
// -------------------------------------------------------------------
// $Id: $
//
// GEANT4 Class file
// ---------------------------------------------------------------
//
// G4ILawTruncatedExp
//
// File name: G4VPhotoElectricAngularDistribution
// 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.
//
// Author: Pedro Rodrigues (psilva@lip.pt)
// Andreia Trindade (andreia@lip.pt)
//
// Creation date: 10 May 2004
//
// Modifications:
// 10 May 2004 A. Trindade First implementation acording with new design
//
// Class Description:
//
// Abstract class for PhotoElectricsstrahlung Angular Distribution Generation
// Further documentation available from http://www.ge.infn.it/geant4/lowE
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// -------------------------------------------------------------------
//
#ifndef G4ILawTruncatedExp_hh
#define G4ILawTruncatedExp_hh 1
#ifndef G4VPhotoElectricAngularDistribution_h
#define G4VPhotoElectricAngularDistribution_h 1
#include "G4VBiasingInteractionLaw.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4ThreeVector.hh"
class G4VPhotoElectricAngularDistribution
class G4ILawTruncatedExp : public G4VBiasingInteractionLaw
{
public:
G4ILawTruncatedExp(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;}
public:
void SetForceCrossSection(G4double xs);
G4VPhotoElectricAngularDistribution(const G4String& name);
virtual ~G4VPhotoElectricAngularDistribution();
virtual G4ThreeVector GetPhotoElectronDirection(const G4ThreeVector& direction,
const G4double kineticEnergy,
const G4ThreeVector& polarization,
const G4int shellID) const = 0;
virtual void PrintGeneratorInformation() const = 0;
protected:
public:
void SetMaximumDistance(G4double d) { fMaximumDistance = d;}
G4double GetMaximumDistance() const { return fMaximumDistance;}
G4double GetInteractionDistance() const { return fInteractionDistance; }
private:
// hide assignment operator
G4VPhotoElectricAngularDistribution & operator=(const G4VPhotoElectricAngularDistribution &right);
G4VPhotoElectricAngularDistribution(const G4VPhotoElectricAngularDistribution&);
G4double fMaximumDistance;
G4double fCrossSection;
G4double fCrossSectionDefined;
G4bool fIsSingular;
G4double fInteractionDistance;
};
#endif
@@ -24,59 +24,47 @@
// ********************************************************************
//
//
// -------------------------------------------------------------------
// $Id: $
//
// GEANT4 Class file
// ---------------------------------------------------------------
//
// G4InteractionLawPhysical
//
// File name: G4hZiegler1977p
// Class Description:
// A G4VBiasingInteractionLaw representing the usual
// physical exponential law, of constant cross-section of the step.
//
// Author: V.Ivanchenko (Vladimir.Ivanchenko@cern.ch)
//
// Creation date: 20 July 2000
//
// Modifications:
// 20/07/2000 V.Ivanchenko First implementation
//
// Class Description:
//
// Electronic stopping power parametrised according to
// H.H.Andersen & J.F.Ziegler, Hydrogen Stopping Powers and
// Ranges in All Elements, Vol.3, Pergamon Press, 1977
// Further documentation available from http://www.ge.infn.it/geant4/lowE//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
// -------------------------------------------------------------------
//
#ifndef G4InteractionLawPhysical_hh
#define G4InteractionLawPhysical_hh 1
#ifndef G4hZiegler1977p_h
#define G4hZiegler1977p_h 1
#include "G4VBiasingInteractionLaw.hh"
#include "globals.hh"
#include "G4VhElectronicStoppingPower.hh"
class G4Material;
class G4hZiegler1977p : public G4VhElectronicStoppingPower
class G4InteractionLawPhysical : public G4VBiasingInteractionLaw
{
public:
G4InteractionLawPhysical(G4String name = "exponentialLaw");
virtual ~G4InteractionLawPhysical();
public:
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);
G4hZiegler1977p();
~G4hZiegler1977p();
G4bool HasMaterial(const G4Material* material);
G4double StoppingPower(const G4Material* material,
G4double kineticEnergy);
G4double ElectronicStoppingPower(G4double z,
G4double kineticEnergy) const;
protected:
private:
const G4double protonMassAMU;
G4double fCrossSection;
G4bool fCrossSectionDefined;
G4double fNumberOfInteractionLength;
};
@@ -24,41 +24,38 @@
// ********************************************************************
//
//
// $Id$
// $Id: $
//
// ---------------- G4QBesIKJY ----------------
// by Mikhail Kossov, Sept 2000.
// class header for Bessel I0/I1 and K0/K1 functions in CHIPS Model
// --------------------------------------------------------------------
// Short description: CHIPS bessel functions for mass and scattering
// integrals.
// --------------------------------------------------------------------
#ifndef G4QBesIKJY_h
#define G4QBesIKJY_h 1
// ---------------------------------------------------------------
//
// G4ParticleChangeForNothing
//
// Class Description:
// A G4VParticleChange used in case of no interaction.
//
// ---------------------------------------------------------------
// Initial version Nov. 2013 M. Verderi
#include <iostream>
#include "globals.hh"
#ifndef G4ParticleChangeForNothing_hh
#define G4ParticleChangeForNothing_hh 1
// Ennumerated type
enum G4QBIType {BessI0, BessI1, EBessI0, EBessI1, BessJ0, BessJ1,
BessK0, BessK1, EBessK0, EBessK1, BessY0, BessY1};
class G4QBesIKJY
{
#include "G4VParticleChange.hh"
class G4ParticleChangeForNothing : public G4VParticleChange {
public:
// Constructor/Destructor
G4QBesIKJY(G4QBIType type = BessI0); // the Default Construction is for BesselI0
~G4QBesIKJY();
G4ParticleChangeForNothing() : G4VParticleChange() {}
~G4ParticleChangeForNothing() {}
public:
// Member Functions
G4double operator ()(G4double x) const;
private:
// Body
G4bool ex;
G4bool ij;
G4bool ik;
G4int nu;
// -- 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
@@ -0,0 +1,84 @@
//
// ********************************************************************
// * 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: $
//
// ---------------------------------------------------------------
//
// G4ParticleChangeForOccurenceBiasing
//
// Class Description:
// A G4VParticleChange dedicated to occurence 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
#ifndef G4ParticleChangeForOccurenceBiasing_hh
#define G4ParticleChangeForOccurenceBiasing_hh 1
#include "G4VParticleChange.hh"
class G4ParticleChangeForOccurenceBiasing : public G4VParticleChange {
public:
G4ParticleChangeForOccurenceBiasing(G4String name);
~G4ParticleChangeForOccurenceBiasing();
public:
void SetOccurenceWeightForNonInteraction(G4double w) {fOccurenceWeightForNonInteraction = w;}
G4double GetOccurenceWeightForNonInteraction() const {return fOccurenceWeightForNonInteraction;}
void SetOccurenceWeightForInteraction(G4double w) {fOccurenceWeightForInteraction = w;}
G4double GetOccurenceWeightForInteraction() const {return fOccurenceWeightForInteraction;}
public:
// -- set a wrapped particle change AND USE IT TO UPDATE this occurence 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();
public:
// -- 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;}
private:
G4String fName;
G4VParticleChange* fWrappedParticleChange;
G4double fOccurenceWeightForNonInteraction;
G4double fOccurenceWeightForInteraction;
};
#endif
@@ -0,0 +1,103 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4biasing_gen
# Package: Geant4.src.G4processes.G4biasing_gen
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 76470 2013-11-11 10:31:24Z gcosmo $
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/detector/include)
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/hits/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/biasing/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/navigation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/cuts/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/electromagnetic/utils/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/transportation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4biasing_gen
HEADERS
G4BiasingHelper.hh
G4BiasingProcessInterface.hh
G4BOptnChangeCrossSection.hh
G4BOptnCloning.hh
G4BOptnForceCommonTruncatedExp.hh
G4BOptnForceFreeFlight.hh
G4BOptrForceCollision.hh
G4ILawCommonTruncatedExp.hh
G4ILawForceFreeFlight.hh
G4ILawTruncatedExp.hh
G4InteractionLawPhysical.hh
G4ParticleChangeForNothing.hh
G4ParticleChangeForOccurenceBiasing.hh
SOURCES
G4BiasingHelper.cc
G4BiasingProcessInterface.cc
G4BOptnChangeCrossSection.cc
G4BOptnCloning.cc
G4BOptnForceCommonTruncatedExp.cc
G4BOptnForceFreeFlight.cc
G4BOptrForceCollision.cc
G4ILawCommonTruncatedExp.cc
G4ILawForceFreeFlight.cc
G4ILawTruncatedExp.cc
G4InteractionLawPhysical.cc
G4ParticleChangeForOccurenceBiasing.cc
GRANULAR_DEPENDENCIES
G4cuts
G4detector
G4emutils
G4geombias
G4geometrymng
G4globman
G4hits
G4intercoms
G4magneticfield
G4materials
G4navigation
G4partman
G4procman
G4track
G4transportation
G4volumes
G4biasing_mgt
GLOBAL_DEPENDENCIES
G4digits_hits
G4geometry
G4global
G4intercoms
G4materials
G4particles
G4track
LINK_LIBRARIES
)
# List any source specific properties here
@@ -23,52 +23,42 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Implementation of the HETC88 code into Geant4.
// Evaporation and De-excitation parts
// T. Lampen, Helsinki Institute of Physics, May-2000
#include "G4BOptnChangeCrossSection.hh"
#include "G4InteractionLawPhysical.hh"
#include "G4BEHe3Channel.hh"
#include "G4He3.hh"
G4BEHe3Channel::G4BEHe3Channel()
G4BOptnChangeCrossSection::G4BOptnChangeCrossSection(G4String name)
: G4VBiasingOperation(name)
{
name = "He3";
verboseLevel = 0;
particleA = 3;
particleZ = 2;
rho = 0.70588;
A=3;
spin = 0.5;
fBiasedExponentialLaw = new G4InteractionLawPhysical("LawForOperation"+name);
}
G4BOptnChangeCrossSection::~G4BOptnChangeCrossSection()
{}
G4BEHe3Channel::~G4BEHe3Channel()
const G4VBiasingInteractionLaw* G4BOptnChangeCrossSection::ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface* )
{
return fBiasedExponentialLaw;
}
G4DynamicParticle* G4BEHe3Channel::emit()
void G4BOptnChangeCrossSection::SetBiasedCrossSection(G4double xst)
{
G4double u , v , w;
G4DynamicParticle * pParticle = new G4DynamicParticle;
pParticle -> SetDefinition( G4He3::He3() );
pParticle -> SetKineticEnergy( sampleKineticEnergy() );
isotropicCosines( u, v, w);
pParticle -> SetMomentumDirection( u, v, w);
return pParticle;
fBiasedExponentialLaw->SetPhysicalCrossSection( xst );
}
G4double G4BEHe3Channel::coulombFactor()
G4double G4BOptnChangeCrossSection::GetBiasedCrossSection() const
{
return 0;
return fBiasedExponentialLaw->GetPhysicalCrossSection();
}
G4double G4BEHe3Channel::qmFactor()
void G4BOptnChangeCrossSection::Sample()
{
// Coefficient representing the quantum mechanical barrier
// penetration, see Dostrovsky, Phys. Rev. 116, 1959.
return qmFactorForAlpha() - 0.06;
fInteractionOccured = false;
fBiasedExponentialLaw->Sample();
}
void G4BOptnChangeCrossSection::UpdateForStep( G4double truePathLength )
{
fBiasedExponentialLaw->UpdateForStep( truePathLength );
}
@@ -0,0 +1,48 @@
//
// ********************************************************************
// * 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 "G4BOptnCloning.hh"
G4BOptnCloning::G4BOptnCloning(G4String name)
: G4VBiasingOperation(name),
fParticleChange()
{}
G4BOptnCloning::~G4BOptnCloning()
{}
G4VParticleChange* G4BOptnCloning::GenerateBiasingFinalState( const G4Track* track,
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 );
return &fParticleChange;
}
@@ -0,0 +1,156 @@
//
// ********************************************************************
// * 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 "G4BOptnForceCommonTruncatedExp.hh"
#include "G4ILawCommonTruncatedExp.hh"
#include "G4TransportationManager.hh"
#include "Randomize.hh"
#include "G4BiasingProcessInterface.hh"
G4BOptnForceCommonTruncatedExp::G4BOptnForceCommonTruncatedExp(G4String name)
: G4VBiasingOperation(name),
fInteractionOccured(false)
{
fCommonTruncatedExpLaw = new G4ILawCommonTruncatedExp("ExpLawForOperation"+name);
fCommonTruncatedExpLaw->SetOperation( this );
fTotalCrossSection = 0.0;
}
G4BOptnForceCommonTruncatedExp::~G4BOptnForceCommonTruncatedExp()
{}
const G4VBiasingInteractionLaw* G4BOptnForceCommonTruncatedExp::ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface* )
{
return fCommonTruncatedExpLaw;
}
G4ForceCondition G4BOptnForceCommonTruncatedExp::ProposeForceCondition( const G4ForceCondition )
{
return Forced;
}
G4double G4BOptnForceCommonTruncatedExp::ProposeAlongStepLimit( const G4BiasingProcessInterface* callingProcess )
{
if ( callingProcess->GetWrappedProcess() == fProcessToApply )
return fCommonTruncatedExpLaw->GetInteractionDistance();
else return DBL_MAX;
}
G4GPILSelection G4BOptnForceCommonTruncatedExp::ProposeGPILSelection( const G4GPILSelection )
{
return CandidateForSelection;
}
G4bool G4BOptnForceCommonTruncatedExp::DenyProcessPostStepDoIt( const G4BiasingProcessInterface* callingProcess,
const G4Track*, const G4Step* step, G4double& )
{
G4double processGPIL = callingProcess->GetPostStepGPIL() < callingProcess->GetAlongStepGPIL() ?
callingProcess->GetPostStepGPIL() : callingProcess->GetAlongStepGPIL() ;
if ( processGPIL <= step->GetStepLength() )
{
G4bool denyProcess = (callingProcess->GetWrappedProcess() != fProcessToApply );
fInteractionOccured = (fInteractionOccured || !denyProcess);
return denyProcess;
}
else return true;
}
G4double G4BOptnForceCommonTruncatedExp::GetTriggeredProcessXSfraction()
{
return fCrossSections[fProcessToApply] / fTotalCrossSection;
}
void G4BOptnForceCommonTruncatedExp::PostStepInteractionOccured( const G4VProcess* )
{
}
void G4BOptnForceCommonTruncatedExp::AddCrossSection( const G4VProcess* process, G4double crossSection )
{
fTotalCrossSection += crossSection;
fCrossSections[process] = crossSection;
fNumberOfSharing = fCrossSections.size();
fCommonTruncatedExpLaw->SetNumberOfSharing ( fNumberOfSharing );
fCommonTruncatedExpLaw->SetForceCrossSection( fTotalCrossSection );
}
void G4BOptnForceCommonTruncatedExp::Initialize( const G4Track* track )
{
fCrossSections.clear();
fTotalCrossSection = 0.0;
fNumberOfSharing = 0;
fProcessToApply = 0;
fInitialMomentum = track->GetMomentum();
fCommonTruncatedExpLaw->reset();
G4VSolid* currentSolid = track->GetVolume()->GetLogicalVolume()->GetSolid();
G4ThreeVector localPosition = (G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->
GetGlobalToLocalTransform()).TransformPoint(track->GetPosition());
G4ThreeVector localDirection = (G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->
GetGlobalToLocalTransform()).TransformAxis(track->GetMomentumDirection());
fMaximumDistance = currentSolid->DistanceToOut(localPosition, localDirection);
if ( fMaximumDistance <= DBL_MIN ) fMaximumDistance = 0.0;
fCommonTruncatedExpLaw->SetMaximumDistance( fMaximumDistance );
}
void G4BOptnForceCommonTruncatedExp::UpdateForStep( const G4Step* step )
{
fCrossSections.clear();
fTotalCrossSection = 0.0;
fNumberOfSharing = 0;
fProcessToApply = 0;
fCommonTruncatedExpLaw->UpdateForStep( step->GetStepLength() );
fMaximumDistance = fCommonTruncatedExpLaw->GetMaximumDistance();
}
void G4BOptnForceCommonTruncatedExp::Sample()
{
fCommonTruncatedExpLaw->reset();
fCommonTruncatedExpLaw->Sample();
ChooseProcessToApply();
}
void G4BOptnForceCommonTruncatedExp::ChooseProcessToApply()
{
G4double sigmaRand = G4UniformRand() * fTotalCrossSection;
G4double sigmaSelect = 0.0;
for ( std::map< const G4VProcess*, G4double>::const_iterator it = fCrossSections.begin();
it != fCrossSections.end();
it++)
{
sigmaSelect += (*it).second;
if ( sigmaRand <= sigmaSelect )
{
fProcessToApply = (*it).first;
break;
}
}
}
@@ -0,0 +1,80 @@
//
// ********************************************************************
// * 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 "G4BOptnForceFreeFlight.hh"
#include "G4ILawForceFreeFlight.hh"
#include "G4Step.hh"
G4BOptnForceFreeFlight::G4BOptnForceFreeFlight(G4String name)
: G4VBiasingOperation(name)
{
fForceFreeFlightInteractionLaw = new G4ILawForceFreeFlight("LawForOperation"+name);
}
G4BOptnForceFreeFlight::~G4BOptnForceFreeFlight()
{}
const G4VBiasingInteractionLaw* G4BOptnForceFreeFlight::ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface* )
{
return fForceFreeFlightInteractionLaw;
}
G4bool G4BOptnForceFreeFlight::DenyProcessPostStepDoIt( const G4BiasingProcessInterface*, const G4Track*, const G4Step* step, G4double& proposedWeight )
{
// -- force free flight always deny process to apply its doit.
// -- if reaching boundary, track is restored with non-zero weight
if ( fInitialTrackWeight <= DBL_MIN )
{
G4ExceptionDescription ed;
ed << " Initial track weight is null ! " << G4endl;
G4Exception(" G4BOptnForceFreeFlight::DenyProcessPostStepDoIt(...)",
"BIAS.GEN.05",
JustWarning,
ed);
}
if ( fCumulatedWeightChange <= DBL_MIN )
{
G4ExceptionDescription ed;
ed << " Cumulated weight is null ! " << G4endl;
G4Exception(" G4BOptnForceFreeFlight::DenyProcessPostStepDoIt(...)",
"BIAS.GEN.06",
JustWarning,
ed);
}
if ( step->GetPostStepPoint()->GetStepStatus() == fGeomBoundary )
{
if ( proposedWeight <= DBL_MIN ) proposedWeight = fCumulatedWeightChange * fInitialTrackWeight;
else proposedWeight *= fCumulatedWeightChange;
}
return true;
}
void G4BOptnForceFreeFlight::AlongMoveBy( const G4BiasingProcessInterface*, const G4Step*, G4double weightChange )
{
fCumulatedWeightChange *= weightChange;
}
@@ -0,0 +1,248 @@
//
// ********************************************************************
// * 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 "G4BOptrForceCollision.hh"
#include "G4BiasingProcessInterface.hh"
#include "G4BOptnForceCommonTruncatedExp.hh"
#include "G4ILawCommonTruncatedExp.hh"
#include "G4BOptnForceFreeFlight.hh"
#include "G4BOptnCloning.hh"
#include "G4Step.hh"
#include "G4StepPoint.hh"
#include "G4VProcess.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
G4BOptrForceCollision::G4BOptrForceCollision(G4String particleName, G4String name)
: G4VBiasingOperator(name),
fFirstProcess(0), fLastProcess(0),
fSetup(true)
{
fSharedForceInteractionOperation = new G4BOptnForceCommonTruncatedExp("SharedForceInteraction");
fCloningOperation = new G4BOptnCloning("Cloning");
fParticle = G4ParticleTable::GetParticleTable()->FindParticle(particleName);
if ( fParticle == 0 )
{
G4ExceptionDescription ed;
ed << " Particle `" << particleName << "' not found !" << G4endl;
G4Exception(" G4BOptrForceCollision::G4BOptrForceCollision(...)",
"BIAS.GEN.07",
JustWarning,
ed);
}
}
G4BOptrForceCollision::G4BOptrForceCollision(const G4ParticleDefinition* particle, G4String name)
: G4VBiasingOperator(name),
fFirstProcess(0), fLastProcess(0),
fSetup(true)
{
fSharedForceInteractionOperation = new G4BOptnForceCommonTruncatedExp("SharedForceInteraction");
fCloningOperation = new G4BOptnCloning("Cloning");
fParticle = particle;
}
G4BOptrForceCollision::~G4BOptrForceCollision()
{
for ( std::map< const G4BiasingProcessInterface*, G4BOptnForceFreeFlight* >::iterator it = fFreeFlightOperations.begin() ;
it != fFreeFlightOperations.end() ;
it++ ) delete (*it).second;
delete fSharedForceInteractionOperation;
delete fCloningOperation;
}
G4VBiasingOperation* G4BOptrForceCollision::ProposeOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
{
if ( track->GetDefinition() != fParticle ) return 0;
// -- start by remembering processes under biasing, and create needed biasing operations:
// -- ( Might consider moving this in a less called method. )
if ( fSetup )
{
if ( ( fFirstProcess == 0 ) && ( callingProcess->GetIsFirstPostStepGPILInterface() ) ) fFirstProcess = callingProcess;
if ( fLastProcess == 0 )
{
fProcesses.push_back(callingProcess);
G4String operationName = "FreeFlight-"+callingProcess->GetWrappedProcess()->GetProcessName();
fFreeFlightOperations[callingProcess] = new G4BOptnForceFreeFlight(operationName);
if ( callingProcess->GetIsLastPostStepGPILInterface() )
{
fLastProcess = callingProcess;
fSetup = false;
}
}
}
// -- 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 )
{
// -- 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;
if ( callingProcess == fFirstProcess )
{
// -- first step of cloned track, initialize the forced interaction operation:
if ( track->GetCurrentStepNumber() == 1 ) fSharedForceInteractionOperation->Initialize( track );
else
{
if ( fSharedForceInteractionOperation->GetInitialMomentum() != track->GetMomentum() )
{
// -- means that some other physics process, not under control of the forced interaction operation,
// -- has occured, need to re-initialize the operation as distance to boundary has changed.
// -- [ Note the re-initialization is only possible for a Markovian law. ]
fSharedForceInteractionOperation->Initialize( track );
}
else
{
// -- means that some other non-physics process (biasing or not, like step limit), has occured,
// -- but track conserves its momentum direction, only need to reduced the maximum distance for
// -- forced interaction.
// -- [ Note the update is only possible for a Markovian law. ]
fSharedForceInteractionOperation->UpdateForStep( track->GetStep() );
}
}
}
// -- 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;
// -- conditions to apply forced interaction are met, set up physics:
// -- Collects well-defined cross-sections...
G4double currentInteractionLength = callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
G4VBiasingOperation* operationToReturn = 0;
if ( currentInteractionLength < DBL_MAX/10. )
{
fSharedForceInteractionOperation->AddCrossSection( callingProcess->GetWrappedProcess(), 1.0/currentInteractionLength );
operationToReturn = fSharedForceInteractionOperation;
}
// -- ... if current process is the last one, cross-section collection is finished.
// -- Operation is ready to sample the force interaction law and to randomly select
// -- the process to be applied.
if ( ( callingProcess == fLastProcess ) &&
( fSharedForceInteractionOperation->GetCommonTruncatedExpLaw()->GetNumberOfSharing() > 0 ) )
fSharedForceInteractionOperation->Sample();
// -- back to current process (last one or not), if meaningful cross section, bias it returning the force operation:
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];
// -- other cases here: particle appearing in the volume by some
// -- previous interaction : we decide to not bias these.
return 0;
}
G4VBiasingOperation* G4BOptrForceCollision::ProposeNonPhysicsBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface*)
{
if ( track->GetDefinition() != fParticle ) return 0;
// -- bias only 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 )
{
fSharedForceInteractionOperation->SetInteractionOccured( false );
fInitialTrackWeight = track->GetWeight();
fCloningOperation->SetCloneWeights(0.0, fInitialTrackWeight);
return fCloningOperation;
}
// -- for all other cases: does nothing
return 0;
}
void G4BOptrForceCollision::StartTracking( const G4Track* )
{
fPreviousOperationApplied = 0;
}
void G4BOptrForceCollision::ExitBiasing( const G4Track* track, const G4BiasingProcessInterface* )
{
fPreviousOperationApplied = 0;
// -- clean-up track for what happens with this operator:
ForgetTrack ( track );
}
void G4BOptrForceCollision::OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase,
G4VBiasingOperation* operationApplied, const G4VParticleChange* particleChangeProduced )
{
fPreviousOperationApplied = operationApplied;
if ( operationApplied == fCloningOperation )
RememberSecondaries( callingProcess, operationApplied, particleChangeProduced );
}
@@ -0,0 +1,104 @@
//
// ********************************************************************
// * 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 "G4BiasingHelper.hh"
#include "G4ProcessManager.hh"
#include "G4BiasingProcessInterface.hh"
G4bool G4BiasingHelper::ActivatePhysicsBiasing(G4ProcessManager* pmanager,
G4String physicsProcessToBias,
G4String wrappedName)
{
G4VProcess* physicsProcess(0);
G4ProcessVector* vprocess = pmanager->GetProcessList();
for (G4int ip = 0 ; ip < vprocess->size() ; ip++)
{
if ( (*vprocess)[ip]->GetProcessName() == physicsProcessToBias )
{
physicsProcess = (*vprocess)[ip];
break;
}
}
// -- process not found, return "false" to tell about failure
if ( physicsProcess == 0 ) return false;
// -- process is not a physics one, return "false" to tell about failure
G4int processType = physicsProcess->GetProcessType();
if ( ( processType != 2 ) && // EM
( processType != 3 ) && // Optical
( processType != 4 ) && // Hadronic
( processType != 6 ) ) // Decay
return false;
// -- prevent wrapper of wrapper...
if ( dynamic_cast< G4BiasingProcessInterface* >( physicsProcess ) ) return false;
// -- remember process indeces:
G4int atRestIndex = pmanager->GetProcessOrdering(physicsProcess, idxAtRest );
G4int alongStepIndex = pmanager->GetProcessOrdering(physicsProcess, idxAlongStep);
G4int postStepIndex = pmanager->GetProcessOrdering(physicsProcess, idxPostStep );
// -- now remove the physic process, that will be replaced by a wrapped version:
G4VProcess* removed = pmanager->RemoveProcess(physicsProcess);
if ( removed != physicsProcess )
{
G4ExceptionDescription ed;
ed << "Internal inconsistency in processes handling. Please report !" << G4endl;
G4Exception("G4BiasingHelper::ActivatePhysicsBiasing(...)",
"BIAS.GEN.01",
FatalException,
ed);
}
G4BiasingProcessInterface* biasingWrapper = new G4BiasingProcessInterface( physicsProcess,
atRestIndex != ordInActive,
alongStepIndex != ordInActive,
postStepIndex != ordInActive,
wrappedName);
if ( alongStepIndex == -1 ) alongStepIndex = ordDefault;
pmanager->AddProcess( biasingWrapper,
atRestIndex,
alongStepIndex,
postStepIndex);
return true;
}
void G4BiasingHelper::ActivateNonPhysicsBiasing(G4ProcessManager* pmanager,
G4String nonPhysicsProcessName )
{
G4BiasingProcessInterface* biasingNonPhys(0);
if ( nonPhysicsProcessName == "" ) biasingNonPhys = new G4BiasingProcessInterface();
else biasingNonPhys = new G4BiasingProcessInterface(nonPhysicsProcessName );
pmanager->AddProcess( biasingNonPhys,
ordInActive,
ordInActive,
ordDefault);
}
@@ -0,0 +1,820 @@
//
// ********************************************************************
// * 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 "G4BiasingProcessInterface.hh"
#include "G4VBiasingOperator.hh"
#include "G4VBiasingOperation.hh"
#include "G4ParticleChangeForOccurenceBiasing.hh"
#include "G4ParticleChange.hh"
#include "G4ParticleChangeForNothing.hh"
#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;
G4MapCache< const G4ProcessManager*, std::vector< G4BiasingProcessInterface* > > G4BiasingProcessInterface::fManagerInterfaceMap;
G4BiasingProcessInterface::G4BiasingProcessInterface(G4String name)
: G4VProcess( name ),
fCurrentBiasingOperator ( 0 ),
fPreviousBiasingOperator( 0 ),
fWrappedProcess ( 0 ),
fIsPhysicsBasedBiasing ( false ),
fWrappedProcessIsAtRest( false ),
fWrappedProcessIsAlong ( false ),
fWrappedProcessIsPost ( false ),
fWrappedProcessInteractionLength( -1.0 ),
fBiasingInteractionLaw ( 0 ),
fPhysicalInteractionLaw( 0 ),
fOccurenceBiasingParticleChange( 0 ),
fIamFirstGPIL ( false )
{
for (G4int i = 0 ; i < 8 ; i++) fFirstLastFlags[i] = false;
fResetInteractionLaws.Put( true );
fCommonStart.Put(true);
fCommonEnd.Put(true);
}
G4BiasingProcessInterface::G4BiasingProcessInterface(G4VProcess* wrappedProcess,
G4bool wrappedIsAtRest, G4bool wrappedIsAlongStep, G4bool wrappedIsPostStep,
G4String useThisName)
: G4VProcess( useThisName != "" ? useThisName : "biasWrapper("+wrappedProcess->GetProcessName()+")",
wrappedProcess->GetProcessType()),
fCurrentBiasingOperator ( 0 ),
fPreviousBiasingOperator( 0 ),
fWrappedProcess ( wrappedProcess ),
fIsPhysicsBasedBiasing ( true ),
fWrappedProcessIsAtRest( wrappedIsAtRest ),
fWrappedProcessIsAlong ( wrappedIsAlongStep ),
fWrappedProcessIsPost ( wrappedIsPostStep ),
fWrappedProcessInteractionLength( -1.0 ),
fBiasingInteractionLaw ( 0 ),
fPhysicalInteractionLaw( 0 ),
fOccurenceBiasingParticleChange( 0 ),
fIamFirstGPIL ( false )
{
for (G4int i = 0 ; i < 8 ; i++) fFirstLastFlags[i] = false;
SetProcessSubType(fWrappedProcess->GetProcessSubType());
// -- create physical interaction law:
fPhysicalInteractionLaw = new G4InteractionLawPhysical("PhysicalInteractionLawFor("+GetProcessName()+")");
// -- instantiate particle change wrapper for occurence biaising:
fOccurenceBiasingParticleChange = new G4ParticleChangeForOccurenceBiasing("biasingPCfor"+GetProcessName());
fParticleChange = new G4ParticleChange();
// -- instantiate a "do nothing" particle change:
fDummyParticleChange = new G4ParticleChangeForNothing();
}
G4BiasingProcessInterface::~G4BiasingProcessInterface()
{
if ( fPhysicalInteractionLaw != 0 ) delete fPhysicalInteractionLaw;
if ( fOccurenceBiasingParticleChange ) delete fOccurenceBiasingParticleChange;
if ( fDummyParticleChange ) delete fDummyParticleChange;
}
void G4BiasingProcessInterface::StartTracking(G4Track* track)
{
fCurrentTrack = track;
if ( fIsPhysicsBasedBiasing ) fWrappedProcess->StartTracking(fCurrentTrack);
fCurrentBiasingOperator = 0;
fPreviousBiasingOperator = 0;
fOccurenceBiasingOperation = 0;
fPreviousOccurenceBiasingOperation = 0;
fFinalStateBiasingOperation = 0;
fPreviousFinalStateBiasingOperation = 0;
fNonPhysicsBiasingOperation = 0;
fPreviousNonPhysicsBiasingOperation = 0;
fBiasingInteractionLaw = 0;
fPreviousBiasingInteractionLaw = 0;
fPreviousStepSize = -1.0;
fResetWrappedProcessInteractionLength = false;
if ( fCommonStart.Get() )
{
fCommonStart.Put( false );// = false;
fCommonEnd.Put(true);// = true;
for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
( G4VBiasingOperator::GetBiasingOperators() )[optr]->StartTracking( fCurrentTrack );
}
}
void G4BiasingProcessInterface::EndTracking()
{
if ( fIsPhysicsBasedBiasing ) fWrappedProcess->EndTracking();
if ( fCurrentBiasingOperator) fCurrentBiasingOperator->ExitingBiasing( fCurrentTrack, this );
fCurrentBiasingOperator = 0;
fPreviousBiasingOperator = 0;
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
if ( fCommonEnd.Get() )
{
fCommonEnd.Put( false );// = false;
fCommonStart.Put( true );// = true;
for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
( G4VBiasingOperator::GetBiasingOperators() )[optr]->EndTracking( );
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;
}
}
}
}
}
G4double G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition)
{
// -- Remember previous operator and proposed operations, if any, and reset:
// -------------------------------------------------------------------------
// -- remember:
fPreviousBiasingOperator = fCurrentBiasingOperator;
fPreviousOccurenceBiasingOperation = fOccurenceBiasingOperation;
fPreviousFinalStateBiasingOperation = fFinalStateBiasingOperation;
fPreviousNonPhysicsBiasingOperation = fNonPhysicsBiasingOperation;
fPreviousBiasingInteractionLaw = fBiasingInteractionLaw;
// -- reset:
fOccurenceBiasingOperation = 0;
fFinalStateBiasingOperation = 0;
fNonPhysicsBiasingOperation = 0;
fBiasingInteractionLaw = 0;
// -- Physics PostStep and AlongStep GPIL
fWrappedProcessPostStepGPIL = DBL_MAX;
fBiasingPostStepGPIL = DBL_MAX;
fWrappedProcessInteractionLength = DBL_MAX; // -- inverse of analog cross-section, no biasing counter-part in general
fWrappedProcessForceCondition = NotForced;
fBiasingForceCondition = NotForced;
fWrappedProcessAlongStepGPIL = DBL_MAX;
fBiasingAlongStepGPIL = DBL_MAX;
fWrappedProcessGPILSelection = NotCandidateForSelection;
fBiasingGPILSelection = NotCandidateForSelection;
// -- for helper:
fPreviousStepSize = previousStepSize;
// -- If new volume, get possible new biasing operator:
// ----------------------------------------------------
// -- [Note : bug with this first step ! Does not work if previous step was concurrently limited with geometry]
G4bool firstStepInVolume = ( (track.GetStep()->GetPreStepPoint()->GetStepStatus() == fGeomBoundary) || (track.GetCurrentStepNumber() == 1) );
if ( firstStepInVolume ) fCurrentBiasingOperator = G4VBiasingOperator::GetBiasingOperator( track.GetVolume()->GetLogicalVolume() );
// -----------------------------------
// -- Previous step was under biasing:
// -----------------------------------
if ( fPreviousBiasingOperator != 0 )
{
// -- if current step not under same operator, let this operator knows:
if ( fPreviousBiasingOperator != fCurrentBiasingOperator ) fPreviousBiasingOperator->ExitingBiasing( &track, this );
// -- if biasing does not continue, set process behavior to standard tracking:
// -- ... and see [*] below...
if ( fCurrentBiasingOperator == 0 )
{
fResetWrappedProcessInteractionLength = true;
ResetForUnbiasedTracking();
}
}
// --------------------------------------------------------------
// -- no operator : analog tracking if physics-based, or nothing:
// --------------------------------------------------------------
if ( fCurrentBiasingOperator == 0 )
{
if ( fIsPhysicsBasedBiasing )
{
// -- [*] this wrapped process has just been ResetForUnbiasedTracking(), it has a fresh #int length, and is
// -- in a state where it believes it is starting tracking : let it believe hence the previous step
// -- length was 0.0, as for a normal first step:
if ( fResetWrappedProcessInteractionLength )
{
fResetWrappedProcessInteractionLength = false;
fWrappedProcess->ResetNumberOfInteractionLengthLeft();
return fWrappedProcess->PostStepGetPhysicalInteractionLength(track, 0.0, condition);
}
return fWrappedProcess->PostStepGetPhysicalInteractionLength(track, previousStepSize, condition);
}
else
{
*condition = NotForced;
return DBL_MAX;
}
}
// --------------------------------------------------
// -- An biasing operator exists. Proceed with
// -- treating non-physics and physics biasing cases:
//---------------------------------------------------
// -- non-physics-based biasing case:
// ----------------------------------
if ( !fIsPhysicsBasedBiasing )
{
fNonPhysicsBiasingOperation = fCurrentBiasingOperator->GetProposedNonPhysicsBiasingOperation( &track, this );
if ( fNonPhysicsBiasingOperation == 0 )
{
*condition = NotForced;
return DBL_MAX;
}
return fNonPhysicsBiasingOperation->DistanceToApplyOperation(&track, previousStepSize, condition);
}
// -- Physics based biasing case:
// ------------------------------
// -- call to underneath physics process PostStepGPIL to update it with current point:
fWrappedProcessPostStepGPIL = fWrappedProcess->PostStepGetPhysicalInteractionLength(track, previousStepSize, condition);
fWrappedProcessForceCondition = *condition;
// -- **! At this point, might have to be careful of previousStepSize being larger than the previous process
// -- **! PostStepGPIL proposed: as we disregard this PostStepGPIL value, such situation does happen. Does not
// -- **! look to have generated problems for now, but might be fragile.
// -- Ask for possible GPIL biasing operation:
fOccurenceBiasingOperation = fCurrentBiasingOperator->GetProposedOccurenceBiasingOperation( &track, this );
// -- no operation for occurence biasing, analog GPIL returns the wrapped process GPIL and condition values
// -- (note that condition was set above):
if ( fOccurenceBiasingOperation == 0 ) return fWrappedProcessPostStepGPIL;
// -- A valid GPIL biasing operation has been proposed:
// -- 0) remember wrapped process will need to be reset on biasing exit, if particle survives:
fResetWrappedProcessInteractionLength = true;
// -- 1) collect/update process interaction length for reference analog interaction law:
fWrappedProcessInteractionLength = fWrappedProcess->GetCurrentInteractionLength();
fPhysicalInteractionLaw->SetPhysicalCrossSection( 1.0 / fWrappedProcessInteractionLength );
// -- 2) Collect biasing interaction law:
// -- The interaction law pointer is collected as a const pointer to the interaction law object.
// -- This interaction law will be kept under control of the biasing operation, which is the only
// -- entity that will change the state of the biasing interaction law.
fBiasingInteractionLaw = fOccurenceBiasingOperation->ProvideOccurenceBiasingInteractionLaw( this );
// -- 3) Ask operation to sample the biasing interaction law:
fBiasingPostStepGPIL = fBiasingInteractionLaw->GetSampledInteractionLength();
fBiasingForceCondition = fOccurenceBiasingOperation->ProposeForceCondition( fWrappedProcessForceCondition );
// -- finish
*condition = fBiasingForceCondition;
return fBiasingPostStepGPIL;
}
G4VParticleChange* G4BiasingProcessInterface::PostStepDoIt(const G4Track& track,
const G4Step& step)
{
// ---------------------------------------
// -- case outside of volume with biasing:
// ---------------------------------------
if ( fCurrentBiasingOperator == 0 ) return fWrappedProcess->PostStepDoIt(track, step);
// ----------------------------
// -- non-physics biasing case:
// ----------------------------
if ( !fIsPhysicsBasedBiasing )
{
G4VParticleChange* particleChange = fNonPhysicsBiasingOperation->GenerateBiasingFinalState( &track, &step );
fCurrentBiasingOperator->ReportOperationApplied( this, BAC_NonPhysics, fNonPhysicsBiasingOperation, particleChange );
return particleChange;
}
// -- physics biasing case:
// ------------------------
// -- It proceeds with the following logic:
// -- 1) If an occurence biasing operation exists, it makes the
// -- decision about the interaction to happen or not.
// -- If the occurence operation refuses the interaction, it
// -- can only propose a new track weight.
// -- 2) The interaction is produced by the final state biasing
// -- operation, if it exists, or by the wrapped process in
// -- the other case.
// -- Hence 2) happens if 1) decides so
// 2) happens if there is no occurence biasing operation
if ( fOccurenceBiasingOperation != 0 )
{
G4double proposedTrackWeight = track.GetWeight();
if ( fOccurenceBiasingOperation->DenyProcessPostStepDoIt( this, &track, &step, proposedTrackWeight ) )
{
fParticleChange->Initialize( track ); // **??** <= might use a light version for particle change here
fParticleChange->ProposeParentWeight( proposedTrackWeight );
fCurrentBiasingOperator->ReportOperationApplied( this, BAC_DenyInteraction, fOccurenceBiasingOperation, fParticleChange );
return fParticleChange;
}
}
// -- usual case with generated final state:
G4VParticleChange* finalStateParticleChange;
G4BiasingAppliedCase BAC;
fFinalStateBiasingOperation = fCurrentBiasingOperator->GetProposedFinalStateBiasingOperation( &track, this );
if ( fFinalStateBiasingOperation != 0 )
{
finalStateParticleChange = fFinalStateBiasingOperation->ApplyFinalStateBiasing( this, &track, &step );
BAC = BAC_FinalState;
}
else
{
finalStateParticleChange = fWrappedProcess->PostStepDoIt(track, step);
BAC = BAC_None ;
}
// -- if no occurence biasing operation, we're done:
if ( fOccurenceBiasingOperation == 0 )
{
fCurrentBiasingOperator->ReportOperationApplied( this, BAC, fFinalStateBiasingOperation, finalStateParticleChange );
return finalStateParticleChange;
}
// -- If occurence biasing, applies on top of final state occurence biasing weight correction:
G4double weightForInteraction = 1.0;
if ( !fBiasingInteractionLaw->IsSingular() ) weightForInteraction =
fPhysicalInteractionLaw->ComputeEffectiveCrossSectionAt(step.GetStepLength()) /
fBiasingInteractionLaw ->ComputeEffectiveCrossSectionAt(step.GetStepLength());
else
{
// -- at this point effective XS can only be infinite, if not, there is a logic problem
if ( !fBiasingInteractionLaw->IsEffectiveCrossSectionInfinite() )
{
G4ExceptionDescription ed;
ed << "Internal inconsistency in cross-section handling. Please report !" << G4endl;
G4Exception(" G4BiasingProcessInterface::PostStepDoIt(...)",
"BIAS.GEN.02",
JustWarning,
ed);
// -- if XS is infinite, weight is zero (and will stay zero), but we'll do differently.
// -- Should foresee in addition something to remember that in case of singular
// -- distribution, weight can only be partly calculated
}
}
if ( weightForInteraction <= 0. )
{
G4ExceptionDescription ed;
ed << " Negative interaction weight : w_I = "
<< weightForInteraction <<
" XS_I(phys) = " << fBiasingInteractionLaw ->ComputeEffectiveCrossSectionAt(step.GetStepLength()) <<
" XS_I(bias) = " << fPhysicalInteractionLaw->ComputeEffectiveCrossSectionAt(step.GetStepLength()) <<
" step length = " << step.GetStepLength() <<
" Interaction law = `" << fBiasingInteractionLaw << "'" <<
G4endl;
G4Exception(" G4BiasingProcessInterface::PostStepDoIt(...)",
"BIAS.GEN.03",
JustWarning,
ed);
}
fCurrentBiasingOperator->ReportOperationApplied( this, BAC,
fOccurenceBiasingOperation, weightForInteraction,
fFinalStateBiasingOperation, finalStateParticleChange );
fOccurenceBiasingParticleChange->SetOccurenceWeightForInteraction( weightForInteraction );
fOccurenceBiasingParticleChange->SetSecondaryWeightByProcess( true );
fOccurenceBiasingParticleChange->SetWrappedParticleChange( finalStateParticleChange );
fOccurenceBiasingParticleChange->ProposeTrackStatus( finalStateParticleChange->GetTrackStatus() );
fOccurenceBiasingParticleChange->StealSecondaries(); // -- this also makes weightForInteraction applied to secondaries stolen
// -- finish:
return fOccurenceBiasingParticleChange;
}
// -- AlongStep methods:
G4double G4BiasingProcessInterface::AlongStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4double currentMinimumStep,
G4double& proposedSafety,
G4GPILSelection* selection)
{
// -- for helper methods:
fCurrentMinimumStep = currentMinimumStep;
fProposedSafety = proposedSafety;
// -- initialization default case:
fWrappedProcessAlongStepGPIL = DBL_MAX;
*selection = NotCandidateForSelection;
// ---------------------------------------
// -- case outside of volume with biasing:
// ---------------------------------------
if ( fCurrentBiasingOperator == 0 )
{
if ( fWrappedProcessIsAlong ) fWrappedProcessAlongStepGPIL =
fWrappedProcess->AlongStepGetPhysicalInteractionLength(track,
previousStepSize,
currentMinimumStep,
proposedSafety,
selection);
return fWrappedProcessAlongStepGPIL;
}
// --------------------------------------------------------------------
// -- non-physics based biasing: no along operation expected (for now):
// --------------------------------------------------------------------
if ( !fIsPhysicsBasedBiasing ) return fWrappedProcessAlongStepGPIL;
// ----------------------
// -- physics-based case:
// ----------------------
if ( fOccurenceBiasingOperation == 0 )
{
if ( fWrappedProcessIsAlong ) fWrappedProcessAlongStepGPIL =
fWrappedProcess->AlongStepGetPhysicalInteractionLength(track,
previousStepSize,
currentMinimumStep,
proposedSafety,
selection);
return fWrappedProcessAlongStepGPIL;
}
// ----------------------------------------------------------
// -- From here we have an valid occurence biasing operation:
// ----------------------------------------------------------
// -- Give operation opportunity to shorten step proposed by physics process:
fBiasingAlongStepGPIL = fOccurenceBiasingOperation->ProposeAlongStepLimit( this );
G4double minimumStep = fBiasingAlongStepGPIL < currentMinimumStep ? fBiasingAlongStepGPIL : currentMinimumStep ;
// -- wrapped process is called with minimum step ( <= currentMinimumStep passed ) : an along process can not
// -- have its operation stretched over what it expects:
if ( fWrappedProcessIsAlong )
{
fWrappedProcessAlongStepGPIL = fWrappedProcess->AlongStepGetPhysicalInteractionLength(track,
previousStepSize,
minimumStep,
proposedSafety,
selection);
fWrappedProcessGPILSelection = *selection;
fBiasingGPILSelection = fOccurenceBiasingOperation->ProposeGPILSelection( fWrappedProcessGPILSelection );
}
else
{
fBiasingGPILSelection = fOccurenceBiasingOperation->ProposeGPILSelection( NotCandidateForSelection );
fWrappedProcessAlongStepGPIL = fBiasingAlongStepGPIL;
}
*selection = fBiasingGPILSelection;
return fWrappedProcessAlongStepGPIL;
}
G4VParticleChange* G4BiasingProcessInterface::AlongStepDoIt(const G4Track& track,
const G4Step& step)
{
// ---------------------------------------
// -- case outside of volume with biasing:
// ---------------------------------------
if ( fCurrentBiasingOperator == 0 )
{
if ( fWrappedProcessIsAlong ) return fWrappedProcess->AlongStepDoIt(track, step);
else
{
fDummyParticleChange->Initialize( track );
return fDummyParticleChange;
}
}
// -----------------------------------
// -- case inside volume with biasing:
// -----------------------------------
if ( fWrappedProcessIsAlong ) fOccurenceBiasingParticleChange->SetWrappedParticleChange( fWrappedProcess->AlongStepDoIt(track, step) );
else
{
fOccurenceBiasingParticleChange->SetWrappedParticleChange ( 0 );
fOccurenceBiasingParticleChange->ProposeTrackStatus( track.GetTrackStatus() );
}
G4double weightForNonInteraction (1.0);
if ( fBiasingInteractionLaw != 0 )
{
weightForNonInteraction =
fPhysicalInteractionLaw->ComputeNonInteractionProbabilityAt(step.GetStepLength()) /
fBiasingInteractionLaw ->ComputeNonInteractionProbabilityAt(step.GetStepLength());
fOccurenceBiasingOperation->AlongMoveBy( this, &step, weightForNonInteraction );
if ( weightForNonInteraction <= 0. )
{
G4ExceptionDescription ed;
ed << " Negative non interaction weight : w_NI = " << weightForNonInteraction <<
" p_NI(phys) = " << fPhysicalInteractionLaw->ComputeNonInteractionProbabilityAt(step.GetStepLength()) <<
" p_NI(bias) = " << fBiasingInteractionLaw ->ComputeNonInteractionProbabilityAt(step.GetStepLength()) <<
" step length = " << step.GetStepLength() <<
" biasing interaction law = `" << fBiasingInteractionLaw->GetName() << "'" << G4endl;
G4Exception(" G4BiasingProcessInterface::AlongStepDoIt(...)",
"BIAS.GEN.04",
JustWarning,
ed);
}
}
fOccurenceBiasingParticleChange->SetOccurenceWeightForNonInteraction( weightForNonInteraction );
return fOccurenceBiasingParticleChange;
}
// -- AtRest methods
G4double G4BiasingProcessInterface::AtRestGetPhysicalInteractionLength(const G4Track& track,
G4ForceCondition* condition)
{
return fWrappedProcess->AtRestGetPhysicalInteractionLength(track, condition);
}
G4VParticleChange* G4BiasingProcessInterface::AtRestDoIt(const G4Track& track,
const G4Step& step)
{
return fWrappedProcess->AtRestDoIt(track, step);
}
G4bool G4BiasingProcessInterface::IsApplicable(const G4ParticleDefinition& pd)
{
if ( fWrappedProcess != 0 ) return fWrappedProcess->IsApplicable(pd);
else return true;
}
void G4BiasingProcessInterface::SetMasterProcess(G4VProcess* masterP)
{
// -- Master for this process:
G4VProcess::SetMasterProcess(masterP);
// -- Master for wrapped process:
if ( fWrappedProcess != 0 )
{
const G4BiasingProcessInterface* thisWrapperMaster = (const G4BiasingProcessInterface *)GetMasterProcess();
// -- paranoia check:
G4VProcess* wrappedMaster = 0;
wrappedMaster = thisWrapperMaster->GetWrappedProcess();
fWrappedProcess->SetMasterProcess( wrappedMaster );
}
}
void G4BiasingProcessInterface::BuildPhysicsTable(const G4ParticleDefinition& pd)
{
// -- Inform existing operators about start of the run.
// -- IMPORTANT : as PreparePhysicsTable(...) has been called first for all processes,
// -- the first/last flags and G4BiasingProcessInterface vector of processes have
// -- been properly setup.
if ( fIamFirstGPIL )
{
for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
( G4VBiasingOperator::GetBiasingOperators() )[optr]->StartRun( );
}
if ( fWrappedProcess != 0 )
{
fWrappedProcess->BuildPhysicsTable(pd);
}
}
void G4BiasingProcessInterface::PreparePhysicsTable(const G4ParticleDefinition& pd)
{
// -- Let process finding its first/last position in the process manager:
SetUpFirstLastFlags();
if ( fWrappedProcess != 0 )
{
fWrappedProcess->PreparePhysicsTable(pd);
}
}
G4bool G4BiasingProcessInterface::StorePhysicsTable(const G4ParticleDefinition* pd, const G4String& s, G4bool f)
{
if ( fWrappedProcess != 0 ) return fWrappedProcess->StorePhysicsTable(pd, s, f);
else return false;
}
G4bool G4BiasingProcessInterface::RetrievePhysicsTable(const G4ParticleDefinition* pd, const G4String& s, G4bool f)
{
if ( fWrappedProcess != 0 ) return fWrappedProcess->RetrievePhysicsTable(pd, s, f);
else return false;
}
void G4BiasingProcessInterface::SetProcessManager(const G4ProcessManager* mgr)
{
if ( fWrappedProcess != 0 ) fWrappedProcess->SetProcessManager(mgr);
else G4VProcess::SetProcessManager(mgr);
(fManagerInterfaceMap[mgr]).push_back(this);
fCoInterfaces = &(fManagerInterfaceMap[mgr]);
fProcessManager = mgr;
}
const G4ProcessManager* G4BiasingProcessInterface::GetProcessManager()
{
if ( fWrappedProcess != 0 ) return fWrappedProcess->GetProcessManager();
else return G4VProcess::GetProcessManager();
}
void G4BiasingProcessInterface::BuildWorkerPhysicsTable(const G4ParticleDefinition& pd)
{
// -- Inform existing operators about start of the run.
// -- IMPORTANT : as PreparePhysicsTable(...) has been called first for all processes,
// -- the first/last flags and G4BiasingProcessInterface vector of processes have
// -- been properly setup.
if ( fIamFirstGPIL )
{
for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
( G4VBiasingOperator::GetBiasingOperators() )[optr]->StartRun( );
}
if ( fWrappedProcess != 0 )
{
fWrappedProcess->BuildWorkerPhysicsTable(pd);
}
}
void G4BiasingProcessInterface::PrepareWorkerPhysicsTable(const G4ParticleDefinition& pd)
{
// -- Let process finding its first/last position in the process manager:
SetUpFirstLastFlags();
if ( fWrappedProcess != 0 )
{
fWrappedProcess->PrepareWorkerPhysicsTable(pd);
}
}
void G4BiasingProcessInterface::ResetNumberOfInteractionLengthLeft()
{
if ( fWrappedProcess != 0 ) fWrappedProcess->ResetNumberOfInteractionLengthLeft();
}
G4bool G4BiasingProcessInterface::GetIsFirstPostStepGPILInterface( G4bool physOnly ) const
{
G4int iPhys = ( physOnly ) ? 1 : 0;
return fFirstLastFlags[IdxFirstLast( 1, 1, iPhys)];
}
G4bool G4BiasingProcessInterface::GetIsLastPostStepGPILInterface( G4bool physOnly ) const
{
G4int iPhys = ( physOnly ) ? 1 : 0;
return fFirstLastFlags[IdxFirstLast( 0, 1, iPhys)];
}
G4bool G4BiasingProcessInterface::GetIsFirstPostStepDoItInterface( G4bool physOnly ) const
{
G4int iPhys = ( physOnly ) ? 1 : 0;
return fFirstLastFlags[IdxFirstLast( 1, 0, iPhys)];
}
G4bool G4BiasingProcessInterface::GetIsLastPostStepDoItInterface( G4bool physOnly ) const
{
G4int iPhys = ( physOnly ) ? 1 : 0;
return fFirstLastFlags[IdxFirstLast( 0, 0, iPhys)];
}
G4bool G4BiasingProcessInterface::IsFirstPostStepGPILInterface(G4bool physOnly) const
{
G4bool isFirst = true;
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++ )
{
if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
{
G4int thatIdx(-1);
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
if ( thisIdx > thatIdx )
{
isFirst = false;
break;
}
}
}
return isFirst;
}
G4bool G4BiasingProcessInterface::IsLastPostStepGPILInterface(G4bool physOnly) const
{
G4bool isLast = true;
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++ )
{
if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
{
G4int thatIdx(-1);
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
if ( thisIdx < thatIdx )
{
isLast = false;
break;
}
}
}
return isLast;
}
G4bool G4BiasingProcessInterface::IsFirstPostStepDoItInterface(G4bool physOnly) const
{
G4bool isFirst = true;
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++ )
{
if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
{
G4int thatIdx(-1);
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
if ( thisIdx > thatIdx )
{
isFirst = false;
break;
}
}
}
return isFirst;
}
G4bool G4BiasingProcessInterface::IsLastPostStepDoItInterface(G4bool physOnly) const
{
G4bool isLast = true;
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++ )
{
if ( ( (*fCoInterfaces)[i]->GetWrappedProcess() != 0 ) || !physOnly )
{
G4int thatIdx(-1);
for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (*fCoInterfaces)[i] ) { thatIdx = j; break; }
if ( thisIdx < thatIdx )
{
isLast = false;
break;
}
}
}
return isLast;
}
void G4BiasingProcessInterface::SetUpFirstLastFlags()
{
for ( G4int iPhys = 0; iPhys < 2; iPhys++ )
{
G4bool physOnly = ( iPhys == 1 );
fFirstLastFlags[IdxFirstLast( 1, 1, iPhys)] = IsFirstPostStepGPILInterface(physOnly);
fFirstLastFlags[IdxFirstLast( 0, 1, iPhys)] = IsLastPostStepGPILInterface(physOnly);
fFirstLastFlags[IdxFirstLast( 1, 0, iPhys)] = IsFirstPostStepDoItInterface(physOnly);
fFirstLastFlags[IdxFirstLast( 0, 0, iPhys)] = IsLastPostStepDoItInterface(physOnly);
}
// -- for itself, for optimization:
fIamFirstGPIL = GetIsFirstPostStepGPILInterface( false );
}
void G4BiasingProcessInterface::ResetForUnbiasedTracking()
{
fOccurenceBiasingOperation = 0;
fFinalStateBiasingOperation = 0;
fNonPhysicsBiasingOperation = 0;
fBiasingInteractionLaw = 0;
}
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * 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 "G4ILawCommonTruncatedExp.hh"
#include "G4Track.hh"
#include "G4BOptnForceCommonTruncatedExp.hh"
#include "G4BiasingProcessInterface.hh"
//#include "G4Exception.hh"
G4ILawCommonTruncatedExp::G4ILawCommonTruncatedExp(G4String name)
: G4VBiasingInteractionLaw(name),
fExpInteractionLaw("expLawFor"+name)
//fIsSingular(false)
{}
G4ILawCommonTruncatedExp::~G4ILawCommonTruncatedExp()
{}
G4double G4ILawCommonTruncatedExp::ComputeEffectiveCrossSectionAt(G4double distance) const
{
return fExpInteractionLaw.ComputeEffectiveCrossSectionAt( distance ) * fOperation->GetTriggeredProcessXSfraction();
}
G4double G4ILawCommonTruncatedExp::ComputeNonInteractionProbabilityAt(G4double distance) const
{
G4double niProba = fExpInteractionLaw.ComputeNonInteractionProbabilityAt( distance );
if ( niProba > 0.0 )
{
return std::exp( std::log(niProba) / fNumberOfSharing );
}
else
{
G4ExceptionDescription ed;
ed << " Negative probability for `" << GetName() << "' p = " << niProba << " distance = " << distance << " !!! " << G4endl;
G4Exception(" G4ILawCommonTruncatedExp::ComputeNonInteractionProbabilityAt(...)",
"BIAS.GEN.08",
JustWarning,
ed);
return niProba;
}
}
G4double G4ILawCommonTruncatedExp::SampleInteractionLength()
{
if ( fFirstSamplingCall ) fInteractionDistance = fExpInteractionLaw.SampleInteractionLength();
fFirstSamplingCall = false;
return DBL_MAX;
}
G4double G4ILawCommonTruncatedExp::UpdateInteractionLengthForStep(G4double truePathLength)
{
if ( fFirstUpdateCall )
fInteractionDistance = fExpInteractionLaw.UpdateInteractionLengthForStep(truePathLength);
fFirstUpdateCall = false;
return DBL_MAX;
}
void G4ILawCommonTruncatedExp::reset()
{
fFirstSamplingCall = true;
fFirstUpdateCall = true;
}
@@ -23,27 +23,31 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "G4IsoProdCrossSections.hh"
#include "G4SystemOfUnits.hh"
#include "G4ILawForceFreeFlight.hh"
void G4IsoProdCrossSections::
Init(std::ifstream & aDataSet)
G4ILawForceFreeFlight::G4ILawForceFreeFlight(G4String name)
: G4VBiasingInteractionLaw(name)
{}
G4ILawForceFreeFlight::~G4ILawForceFreeFlight()
{}
G4double G4ILawForceFreeFlight::ComputeEffectiveCrossSectionAt(G4double) const
{
G4int aNumberOfPoints;
aDataSet>>aNumberOfPoints;
theProductionCrossSections.Init(aDataSet, aNumberOfPoints, eV);
return 0.0;
}
G4double G4IsoProdCrossSections::
GetProductionCrossSection(G4double anEnergy)
G4double G4ILawForceFreeFlight::ComputeNonInteractionProbabilityAt(G4double) const
{
G4double result;
result = theProductionCrossSections.GetY(anEnergy);
return result;
return 1.0;
}
G4String G4IsoProdCrossSections::
GetProductIsotope()
G4double G4ILawForceFreeFlight::SampleInteractionLength()
{
return theProductName;
return DBL_MAX;
}
G4double G4ILawForceFreeFlight::UpdateInteractionLengthForStep(G4double)
{
return DBL_MAX;
}
@@ -0,0 +1,123 @@
//
// ********************************************************************
// * 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 "G4ILawTruncatedExp.hh"
#include "Randomize.hh"
#include "G4Track.hh"
//#include "G4Exception.hh"
G4ILawTruncatedExp::G4ILawTruncatedExp(G4String name)
: G4VBiasingInteractionLaw(name),
fMaximumDistance(0.0),
fCrossSection(0.0),
fCrossSectionDefined(false),
fIsSingular(false)
{}
G4ILawTruncatedExp::~G4ILawTruncatedExp()
{}
void G4ILawTruncatedExp::SetForceCrossSection(G4double crossSection)
{
if (crossSection < 0.0)
{
G4Exception("G4ILawTruncatedExp::SetForceCrossSection(..)",
"BIAS.GEN.09",
JustWarning,
"Cross-section value passed is negative. It is set to zero !");
fIsSingular = true;
crossSection = 0.0;
}
fIsSingular = false;
fCrossSectionDefined = true;
fCrossSection = crossSection;
}
G4double G4ILawTruncatedExp::ComputeEffectiveCrossSectionAt(G4double distance) const
{
if ( !fCrossSectionDefined )
{
G4Exception("G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
"BIAS.GEN.10",
JustWarning,
"Cross-section value requested, but has not been defined yet. Assumes 0 !");
// -- zero cross-section, returns the limit form of the effective cross-section:
return 1.0 / ( fMaximumDistance - distance );
}
G4double denum = 1.0 - std::exp( -fCrossSection * ( fMaximumDistance - distance) );
return fCrossSection / denum;
}
G4double G4ILawTruncatedExp::ComputeNonInteractionProbabilityAt(G4double distance) const
{
if (!fCrossSectionDefined)
{
G4Exception("G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
"BIAS.GEN.11",
JustWarning,
"Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
// -- return limit case of null cross-section:
return 1.0 - distance / fMaximumDistance;
}
G4double num = 1.0 - std::exp( -fCrossSection*distance);
G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance);
return 1.0 - num/denum;
}
G4double G4ILawTruncatedExp::SampleInteractionLength()
{
if ( !fCrossSectionDefined )
{
G4Exception("G4ILawTruncatedExp::Sample(..)",
"BIAS.GEN.12",
JustWarning,
"Trying to sample while cross-section is not defined, assuming 0 !");
fInteractionDistance = G4UniformRand() * fMaximumDistance;
return fInteractionDistance;
}
fInteractionDistance = -std::log(1.0 - G4UniformRand()* (1.0 - std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
return fInteractionDistance;
}
G4double G4ILawTruncatedExp::UpdateInteractionLengthForStep(G4double truePathLength)
{
fInteractionDistance -= truePathLength;
fMaximumDistance -= truePathLength;
if ( fInteractionDistance < 0 )
{
G4ExceptionDescription ed;
ed << " Negative number of interaction length for `" << GetName() << "' " << fInteractionDistance << ", set it to zero !" << G4endl;
G4Exception("G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
"BIAS.GEN.13",
JustWarning,
"Trying to sample while cross-section is not defined, assuming 0 !");
fInteractionDistance = 0.;
}
return fInteractionDistance;
}
@@ -0,0 +1,100 @@
//
// ********************************************************************
// * 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 "G4InteractionLawPhysical.hh"
#include "Randomize.hh"
G4InteractionLawPhysical::G4InteractionLawPhysical(G4String name)
: G4VBiasingInteractionLaw(name),
fCrossSection(0.0),
fCrossSectionDefined(false),
fNumberOfInteractionLength(-1.0)
{}
G4InteractionLawPhysical::~G4InteractionLawPhysical()
{}
void G4InteractionLawPhysical::SetPhysicalCrossSection(G4double crossSection)
{
if (crossSection < 0.0)
{
G4Exception("G4InteractionLawPhysical::SetPhysicalCrossSection(..)",
"BIAS.GEN.14",
JustWarning,
"Cross-section value passed is negative. It is set to zero !");
crossSection = 0.0;
}
fCrossSectionDefined = true;
fCrossSection = crossSection;
}
G4double G4InteractionLawPhysical::ComputeEffectiveCrossSectionAt(G4double) const
{
if (!fCrossSectionDefined) G4Exception("G4InteractionLawPhysical::ComputeEffectiveCrossSection(..)",
"BIAS.GEN.15",
JustWarning,
"Cross-section value requested, but has not been defined yet. Assumes 0 !");
return fCrossSection;
}
G4double G4InteractionLawPhysical::ComputeNonInteractionProbabilityAt(G4double stepLength) const
{
if (!fCrossSectionDefined) G4Exception("G4InteractionLawPhysical::ComputeNonInteractionProbability(..)",
"BIAS.GEN.16",
JustWarning,
"Non interaction probabitlity value requested, but cross section has not been defined yet. Assumes it to be 0 !");
// -- allows zero cross-section case, by convention:
if ( fCrossSection == 0.0 ) return 1.0;
else return std::exp(-fCrossSection*stepLength);
}
G4double G4InteractionLawPhysical::SampleInteractionLength()
{
if ( !fCrossSectionDefined || fCrossSection < 0.0 ) G4Exception("G4InteractionLawPhysical::Sample(..)",
"BIAS.GEN.17",
FatalException,
"Trying to sample while cross-section is not defined or < 0 !");
if ( fCrossSection == 0.0 ) return DBL_MAX;
fNumberOfInteractionLength = -std::log( G4UniformRand() );
return fNumberOfInteractionLength/fCrossSection;
}
G4double G4InteractionLawPhysical::UpdateInteractionLengthForStep(G4double truePathLength)
{
fNumberOfInteractionLength -= truePathLength*fCrossSection;
if ( fNumberOfInteractionLength < 0 )
{
G4ExceptionDescription ed;
ed << " Negative number of interaction length for `" << GetName() << "' " << fNumberOfInteractionLength << ", set it to zero !" << G4endl;
G4Exception("G4InteractionLawPhysical::UpdateInteractionLengthForStep(...)",
"BIAS.GEN.13",
JustWarning,
ed);
fNumberOfInteractionLength = 0.;
}
return fNumberOfInteractionLength;
}
@@ -0,0 +1,84 @@
//
// ********************************************************************
// * 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 "G4ParticleChangeForOccurenceBiasing.hh"
G4ParticleChangeForOccurenceBiasing::G4ParticleChangeForOccurenceBiasing(G4String name)
: G4VParticleChange(),
fName(name),
fWrappedParticleChange(0),
fOccurenceWeightForNonInteraction(-1.0),
fOccurenceWeightForInteraction(-1.0)
{}
G4ParticleChangeForOccurenceBiasing::~G4ParticleChangeForOccurenceBiasing()
{}
void G4ParticleChangeForOccurenceBiasing::SetWrappedParticleChange(G4VParticleChange* wpc)
{
fWrappedParticleChange = wpc;
}
void G4ParticleChangeForOccurenceBiasing::StealSecondaries()
{
SetNumberOfSecondaries( fWrappedParticleChange->GetNumberOfSecondaries() );
for (G4int isecond = 0; isecond < fWrappedParticleChange->GetNumberOfSecondaries(); isecond++)
{
G4Track* secondary = fWrappedParticleChange->GetSecondary(isecond);
secondary->SetWeight ( secondary->GetWeight() * fOccurenceWeightForInteraction );
AddSecondary( secondary );
}
fWrappedParticleChange->Clear();
}
G4Step* G4ParticleChangeForOccurenceBiasing::UpdateStepForAtRest(G4Step* step)
{
return step;
}
G4Step* G4ParticleChangeForOccurenceBiasing::UpdateStepForAlongStep(G4Step* step)
{
// -- make particle change of wrapped process to apply its changes:
if ( fWrappedParticleChange ) fWrappedParticleChange->UpdateStepForAlongStep( step );
// -- multiply parent weight by weight due to occurence biasing:
G4StepPoint* postStepPoint = step->GetPostStepPoint();
// G4cout << " part change along : w = " << postStepPoint->GetWeight() << " , wOcc = " << fOccurenceWeightForNonInteraction << G4endl; // !
postStepPoint->SetWeight( postStepPoint->GetWeight() * fOccurenceWeightForNonInteraction );
return step;
}
G4Step* G4ParticleChangeForOccurenceBiasing::UpdateStepForPostStep(G4Step* step)
{
// -- let make first wrapped process to apply its changes:
fWrappedParticleChange->UpdateStepForPostStep(step);
// -- then apply weight correction due to occurence biasing:
G4StepPoint* postStepPoint = step->GetPostStepPoint();
postStepPoint->SetWeight( postStepPoint->GetWeight() * fOccurenceWeightForInteraction );
return step;
}
@@ -1,13 +1,13 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4hadronic_LE
# Package: Geant4.src.G4processes.G4hadronic.G4hadronic_models.G4hadronic_LE
# Module : G4biasing
# Package: Geant4.src.G4processes.G4biasing.G4biasing_imp
#
# CMakeLists.txt for building a single granular library.
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010-09-29 19:03:31 bmorgan Exp $
# $Id: CMakeLists.txt 74802 2013-10-22 08:58:21Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -0,0 +1,35 @@
# $Id: GNUmakefile 74802 2013-10-22 08:58:21Z gcosmo $
# ------------------------------------------------------------
# GNUmakefile for biasing process library.
# ------------------------------------------------------------
name := G4biasing_imp
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/navigation/include \
-I$(G4BASE)/geometry/magneticfield/include \
-I$(G4BASE)/geometry/biasing/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/biasing/management/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/cuts/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/digits_hits/detector/include \
-I$(G4BASE)/digits_hits/hits/include \
-I$(G4BASE)/processes/transportation/include
include $(G4INSTALL)/config/common.gmk
@@ -0,0 +1,41 @@
$Id: History 78011 2013-12-02 11:32:48Z gcosmo $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
December 2nd, 2013 A.Howard
- Moved static methods in the initialiser to the body for G4GeometrySampler
and G4ImportanceConfigurator
November 30th, 2013 A.Howard
- Fixed coverity errors (uninitialised variables)
November 24th, 2013 A.Howard
- Fixed segmentation fault at the end of an MT run
- caused by deleting fGhostStep in the destructor
- removed RemoveProcess from the destructor (ClearSampling) of the configurators
- also caused an out of range index with MT
November 22nd, 2013 A.Howard
- Migrated to MT - changed design to physics list orientation
- kept backward compatability for single threaded use, except for singleton
- Moved G4VProcessPlacer and G4ProcessPlacer to management
October 10th, 2013 A.Howard
- Subdirectory and history file created.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4GeometrySampler.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4GeometrySampler
@@ -56,10 +56,11 @@ class G4GeometrySampler : public G4VSampler
public: // with description
explicit G4GeometrySampler(G4VPhysicalVolume *worldvolume, const G4String &particlename);
explicit G4GeometrySampler(G4String worldvolumeName, const G4String &particlename);
virtual ~G4GeometrySampler();
// virtual void PrepareScoring(G4VScorer *Scorer);
virtual void PrepareImportanceSampling(G4VIStore *istore,
virtual void PrepareImportanceSampling(G4VIStore* istore,
const G4VImportanceAlgorithm
*ialg);
virtual void PrepareWeightRoulett(G4double wsurvive,
@@ -71,12 +72,16 @@ public: // with description
G4PlaceOfAction placeOfAction);
virtual void Configure();
virtual void AddProcess();
virtual void ClearSampling();
virtual G4bool IsConfigured() const;
void SetParallel(G4bool paraflag);
void SetWorld(const G4VPhysicalVolume* world);
void SetParticle(const G4String &particlename);
inline G4String GetParticleName(){return fParticleName;};
private:
@@ -87,12 +92,13 @@ private:
private:
G4String fParticleName;
G4VPhysicalVolume* fWorld;
const G4VPhysicalVolume* fWorld;
G4String fWorldName;
G4ImportanceConfigurator *fImportanceConfigurator;
// G4ScoreConfigurator *fScoreConfigurator;
// G4VGCellFinder *fGCellFinder;
G4WeightCutOffConfigurator *fWeightCutOffConfigurator;
G4VIStore *fIStore;
G4VIStore* fIStore;
G4WeightWindowConfigurator *fWeightWindowConfigurator;
G4VWeightWindowStore *fWWStore;
G4bool fIsConfigured;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ImportanceConfigurator.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4ImportanceConfigurator
@@ -54,7 +54,13 @@ class G4ImportanceConfigurator : public G4VSamplerConfigurator
public: // with description
G4ImportanceConfigurator(G4VPhysicalVolume* worldvolume,
G4ImportanceConfigurator(const G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4VIStore &istore,
const G4VImportanceAlgorithm *ialg,
G4bool paraflag);
G4ImportanceConfigurator(const G4String worldvolumeName,
const G4String &particlename,
G4VIStore &istore,
const G4VImportanceAlgorithm *ialg,
@@ -64,13 +70,16 @@ public: // with description
virtual void Configure(G4VSamplerConfigurator *preConf);
virtual const G4VTrackTerminator *GetTrackTerminator() const;
void SetWorldName(G4String Name);
private:
G4ImportanceConfigurator(const G4ImportanceConfigurator &);
G4ImportanceConfigurator &
operator=(const G4ImportanceConfigurator &);
G4VPhysicalVolume* fWorld;
const G4VPhysicalVolume* fWorld;
G4String fWorldName;
G4ProcessPlacer fPlacer;
G4VIStore &fIStore;
G4bool fDeleteIalg;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ImportanceProcess.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4ImportanceProcess
@@ -78,7 +78,7 @@ public: // with description
//--------------------------------------------------------------
void SetParallelWorld(G4String parallelWorldName);
void SetParallelWorld(G4VPhysicalVolume* parallelWorld);
// void SetParallelWorld(const G4VPhysicalVolume* parallelWorld);
//--------------------------------------------------------------
// Process interface
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4PlaceOfAction.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4PlaceOfAction
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4SamplingPostStepAction.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4SamplingPostStepAction
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4TrackTerminator.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4TrackTerminator
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VSampler.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4VSampler
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VSamplerConfigurator.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4VSamplerConfigurator
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightCutOffConfigurator.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4WeightCutOffConfigurator
@@ -53,7 +53,7 @@ class G4WeightCutOffConfigurator : public G4VSamplerConfigurator
public: // with description
G4WeightCutOffConfigurator(G4VPhysicalVolume* worldvolume,
G4WeightCutOffConfigurator(const G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4double wsurvival,
G4double wlimit,
@@ -71,7 +71,7 @@ private:
G4WeightCutOffConfigurator(const G4WeightCutOffConfigurator&);
G4WeightCutOffConfigurator &
operator=(const G4WeightCutOffConfigurator&);
G4VPhysicalVolume* fWorld;
const G4VPhysicalVolume* fWorld;
G4ProcessPlacer fPlacer;
G4WeightCutOffProcess *fWeightCutOffProcess;
G4bool fPlaced;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightCutOffProcess.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4WeightCutOffProcess
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightWindowConfigurator.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4WeightWindowConfigurator
@@ -53,7 +53,7 @@ class G4WeightWindowConfigurator : public G4VSamplerConfigurator
public: // with description
G4WeightWindowConfigurator(G4VPhysicalVolume* worldvolume,
G4WeightWindowConfigurator(const G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4VWeightWindowStore &wwstore,
const G4VWeightWindowAlgorithm *wwAlg,
@@ -70,7 +70,7 @@ private:
G4WeightWindowConfigurator &
operator=(const G4WeightWindowConfigurator &);
G4VPhysicalVolume* fWorld;
const G4VPhysicalVolume* fWorld;
G4ProcessPlacer fPlacer;
G4VWeightWindowStore &fWeightWindowStore;
G4bool fDeleteWWalg;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightWindowProcess.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// Class G4MassWeioghtWindowProcess
@@ -1,7 +1,7 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4biasing
# Package: Geant4.src.G4processes.G4biasing
# Module : G4biasing_imp
# Package: Geant4.src.G4processes.G4biasing_imp
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake,v 1.1 2010-09-29 18:51:43 bmorgan Exp $
# $Id: sources.cmake 77477 2013-11-25 09:42:24Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -35,6 +35,7 @@ include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/cuts/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/electromagnetic/utils/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/biasing/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/transportation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
@@ -42,16 +43,14 @@ include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4biasing
GEANT4_DEFINE_MODULE(NAME G4biasing_imp
HEADERS
G4GeometrySampler.hh
G4ImportanceConfigurator.hh
G4ImportanceProcess.hh
G4PlaceOfAction.hh
G4ProcessPlacer.hh
G4SamplingPostStepAction.hh
G4TrackTerminator.hh
G4VProcessPlacer.hh
G4VSampler.hh
G4VSamplerConfigurator.hh
G4WeightCutOffConfigurator.hh
@@ -62,9 +61,7 @@ GEANT4_DEFINE_MODULE(NAME G4biasing
G4GeometrySampler.cc
G4ImportanceConfigurator.cc
G4ImportanceProcess.cc
G4ProcessPlacer.cc
G4SamplingPostStepAction.cc
G4VProcessPlacer.cc
G4VSampler.cc
G4VSamplerConfigurator.cc
G4WeightCutOffConfigurator.cc
@@ -88,6 +85,7 @@ GEANT4_DEFINE_MODULE(NAME G4biasing
G4track
G4transportation
G4volumes
G4biasing_mgt
GLOBAL_DEPENDENCIES
G4digits_hits
G4geometry
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4GeometrySampler.cc 78011 2013-12-02 11:32:48Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -45,11 +45,12 @@
#include "G4WeightWindowConfigurator.hh"
#include "G4WeightCutOffConfigurator.hh"
//#include "G4GCellFinder.hh"
#include "G4TransportationManager.hh"
G4GeometrySampler::
G4GeometrySampler(G4VPhysicalVolume *parallelworld, const G4String &particlename)
G4GeometrySampler(G4VPhysicalVolume *world, const G4String &particlename)
: fParticleName(particlename),
fWorld(parallelworld),
fWorld(world),
fImportanceConfigurator(0),
// fScoreConfigurator(0),
// fGCellFinder(0),
@@ -60,6 +61,29 @@
fIsConfigured(false)
{
paraflag = false;
// fWorldName = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetName();
// if(fWorld == G4TransportationManager::GetTransportationManager()->GetParallelWorld(fWorld->GetName())) paraflag = true;
// G4cout << "G4GeometrySampler:: Making geometry sampler with world: " << fWorld->GetName() << G4endl;
}
G4GeometrySampler::
G4GeometrySampler(G4String worldName, const G4String &particlename)
: fParticleName(particlename),
fWorldName(worldName),
fImportanceConfigurator(0),
// fScoreConfigurator(0),
// fGCellFinder(0),
fWeightCutOffConfigurator(0),
fIStore(0),
fWeightWindowConfigurator(0),
fWWStore(0),
fIsConfigured(false)
{
paraflag = false;
fWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
// fWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
// G4cout << "G4GeometrySampler:: Making geometry sampler with world: " << fWorld->GetName() << G4endl;
//G4TransportationManager::GetTransportationManager()->GetParallelWorld(parallelworldName)
}
G4GeometrySampler::~G4GeometrySampler()
@@ -133,17 +157,17 @@ G4bool G4GeometrySampler::IsConfigured() const
// }
void
G4GeometrySampler::PrepareImportanceSampling(G4VIStore *istore,
G4GeometrySampler::PrepareImportanceSampling(G4VIStore* istore,
const G4VImportanceAlgorithm *ialg)
{
G4cout << " preparing importance sampling " << G4endl;
G4cout << "G4GeometrySampler:: preparing importance sampling WorldName is " << fWorldName << G4endl;
fIStore = istore;
G4cout << " creating istore " << G4endl;
// G4cout << "G4GeometrySampler:: creating istore, worldVolume: " << fWorld->GetName() << G4endl;
fImportanceConfigurator =
new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
G4cout << " creating importance configurator " << G4endl;
new G4ImportanceConfigurator(&istore->GetWorldVolume(), fParticleName, *fIStore, ialg, paraflag);
// new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
fImportanceConfigurator->SetWorldName(fWorldName);
if (!fImportanceConfigurator)
{
@@ -159,7 +183,7 @@ G4GeometrySampler::PrepareWeightRoulett(G4double wsurvive,
G4double isource)
{
// fGCellFinder = new G4GCellFinder(fWorld);
G4cout << " preparing weight roulette" << G4endl;
G4cout << "G4GeometrySampler:: preparing weight roulette" << G4endl;
// fGCellFinder = new G4GCellFinder();
// if (!fGCellFinder)
// {
@@ -190,20 +214,26 @@ G4GeometrySampler::PrepareWeightWindow(G4VWeightWindowStore *wwstore,
G4PlaceOfAction placeOfAction)
{
G4cout << " preparing weight window" << G4endl;
G4cout << "G4GeometrySampler:: preparing weight window" << G4endl;
fWWStore = wwstore;
fWeightWindowConfigurator =
new G4WeightWindowConfigurator(fWorld, fParticleName,
new G4WeightWindowConfigurator(&wwstore->GetWorldVolume(), fParticleName,
*fWWStore,
wwAlg,
placeOfAction, paraflag);
// fWeightWindowConfigurator =
// new G4WeightWindowConfigurator(fWorld, fParticleName,
// *fWWStore,
// wwAlg,
// placeOfAction, paraflag);
}
void G4GeometrySampler::Configure()
{
G4cout << " entering configure " << G4endl;
if (!IsConfigured())
{
fIsConfigured = true;
@@ -216,38 +246,62 @@ void G4GeometrySampler::Configure()
// }
if (fImportanceConfigurator)
{
G4cout << " importance configurator push_back " << G4endl;
fConfigurators.push_back(fImportanceConfigurator);
G4cout << " pushed " << G4endl;
}
if (fWeightWindowConfigurator)
{
G4cout << " weight window configurator push_back " << G4endl;
fConfigurators.push_back(fWeightWindowConfigurator);
G4cout << " pushed " << G4endl;
}
G4cout << " vsampler configurator loop " << G4endl;
G4VSamplerConfigurator *preConf = 0;
G4int i = 0;
for (G4Configurators::iterator it = fConfigurators.begin();
it != fConfigurators.end(); it++)
// G4cout << " vsampler configurator loop " << G4endl;
// G4VSamplerConfigurator *preConf = 0;
// G4int i = 0;
// for (G4Configurators::iterator it = fConfigurators.begin();
// it != fConfigurators.end(); it++)
// {
// i++;
// G4cout << " looping " << i << G4endl;
// G4VSamplerConfigurator *currConf =*it;
// G4cout << " sampler configurator " << G4endl;
// currConf->Configure(preConf);
// G4cout << " configure preconf " << G4endl;
// preConf = *it;
// }
// if (fWeightCutOffConfigurator)
// {
// G4cout << " NEW weight window configure " << G4endl;
// fWeightCutOffConfigurator->Configure(0);
// G4cout << " configured " << G4endl;
// }
}
#ifdef G4MULTITHREADED
G4cout << " make sure AddProcess() is invoked for biasing!!! " << G4endl;
#else
AddProcess();
#endif
return;
}
void G4GeometrySampler::AddProcess()
{
G4VSamplerConfigurator *preConf = 0;
G4int i = 0;
for (G4Configurators::iterator it = fConfigurators.begin();
it != fConfigurators.end(); it++)
{
i++;
G4cout << " looping " << i << G4endl;
G4VSamplerConfigurator *currConf =*it;
G4cout << " sampler configurator " << G4endl;
currConf->Configure(preConf);
G4cout << " configure preconf " << G4endl;
preConf = *it;
}
if (fWeightCutOffConfigurator)
if (fWeightCutOffConfigurator)
{
G4cout << " NEW weight window configure " << G4endl;
fWeightCutOffConfigurator->Configure(0);
G4cout << " configured " << G4endl;
}
}
return;
}
@@ -256,6 +310,11 @@ void G4GeometrySampler::SetParallel(G4bool para)
paraflag = para;
}
void G4GeometrySampler::SetWorld(const G4VPhysicalVolume* World)
{
fWorld = World;
}
void G4GeometrySampler::SetParticle(const G4String &particlename)
{
fParticleName = particlename;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ImportanceConfigurator.cc 78011 2013-12-02 11:32:48Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4ImportanceConfigurator
@@ -38,12 +38,15 @@
#include "G4ProcessPlacer.hh"
#include "G4ImportanceAlgorithm.hh"
#include "G4TransportationManager.hh"
G4ImportanceConfigurator::
G4ImportanceConfigurator(G4VPhysicalVolume* worldvolume,
G4ImportanceConfigurator(const G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4VIStore &istore,
const G4VImportanceAlgorithm *ialg, G4bool para)
: fWorld(worldvolume),
fWorldName(worldvolume->GetName()),
fPlacer(particlename),
fIStore(istore),
fDeleteIalg( ( ! ialg) ),
@@ -51,7 +54,24 @@ G4ImportanceConfigurator(G4VPhysicalVolume* worldvolume,
new G4ImportanceAlgorithm : ialg)),
fImportanceProcess(0),
paraflag(para)
{;}
G4ImportanceConfigurator::
G4ImportanceConfigurator(G4String worldvolumeName,
const G4String &particlename,
G4VIStore &istore,
const G4VImportanceAlgorithm *ialg, G4bool para)
: fWorldName(worldvolumeName),
fPlacer(particlename),
fIStore(istore),
fDeleteIalg( ( ! ialg) ),
fIalgorithm(( (fDeleteIalg) ?
new G4ImportanceAlgorithm : ialg)),
fImportanceProcess(0),
paraflag(para)
{
fWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
if(paraflag) fWorld = G4TransportationManager::GetTransportationManager()->GetParallelWorld(fWorldName);
}
G4ImportanceConfigurator::~G4ImportanceConfigurator()
@@ -70,14 +90,13 @@ G4ImportanceConfigurator::~G4ImportanceConfigurator()
void
G4ImportanceConfigurator::Configure(G4VSamplerConfigurator *preConf)
{
G4cout << " entering importance configure, paraflag " << paraflag << G4endl;
G4cout << "G4ImportanceConfigurator:: entering importance configure, paraflag " << paraflag << G4endl;
const G4VTrackTerminator *terminator = 0;
if (preConf)
{
terminator = preConf->GetTrackTerminator();
};
G4cout << " creating importance process, paraflag is: " << paraflag << G4endl;
fImportanceProcess =
new G4ImportanceProcess(*fIalgorithm,
fIStore,
@@ -89,7 +108,11 @@ G4ImportanceConfigurator::Configure(G4VSamplerConfigurator *preConf)
"Failed allocation of G4ImportanceProcess !");
}
if(paraflag) fImportanceProcess->SetParallelWorld(fWorld);
// G4cout << "G4ImportanceConfigurator:: setting parallel World " << paraflag << G4endl;
if(paraflag) fImportanceProcess->SetParallelWorld(fWorld->GetName());
// if(paraflag) fImportanceProcess->SetParallelWorld(fWorldName);
// G4cout << "G4ImportanceConfigurator:: set " << paraflag << " name: " << fWorld->GetName() << G4endl;
// getchar();
fPlacer.AddProcessAsSecondDoIt(fImportanceProcess);
}
@@ -99,3 +122,8 @@ GetTrackTerminator() const
{
return fImportanceProcess;
}
void G4ImportanceConfigurator::SetWorldName(G4String name)
{
fWorldName = name;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ImportanceProcess.cc 77999 2013-12-02 08:18:01Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -61,10 +61,13 @@ G4ImportanceProcess(const G4VImportanceAlgorithm &aImportanceAlgorithm,
fImportanceAlgorithm(aImportanceAlgorithm),
fIStore(aIstore),
fPostStepAction(0),
fGhostWorldName("NoParallelWorld"),fGhostWorld(0),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0'),
paraflag(para)
{
G4cout << G4endl << G4endl << G4endl;
G4cout << "G4ImportanceProcess:: Creating " << G4endl;
if (TrackTerminator)
{
fPostStepAction = new G4SamplingPostStepAction(*TrackTerminator);
@@ -94,7 +97,7 @@ G4ImportanceProcess(const G4VImportanceAlgorithm &aImportanceAlgorithm,
G4cout << GetProcessName() << " is created " << G4endl;
}
G4cout << " importance process paraflag is: " << paraflag << G4endl;
G4cout << "G4ImportanceProcess:: importance process paraflag is: " << paraflag << G4endl;
}
@@ -103,7 +106,9 @@ G4ImportanceProcess::~G4ImportanceProcess()
delete fPostStepAction;
delete fParticleChange;
delete fGhostStep;
// delete fGhostStep;
// delete fGhostWorld;
// delete fGhostNavigator;
}
@@ -117,6 +122,8 @@ G4ImportanceProcess::~G4ImportanceProcess()
void G4ImportanceProcess::
SetParallelWorld(G4String parallelWorldName)
{
G4cout << G4endl << G4endl << G4endl;
G4cout << "G4ImportanceProcess:: SetParallelWorld name = " << parallelWorldName << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointers of the parallel world and its navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -126,17 +133,21 @@ SetParallelWorld(G4String parallelWorldName)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4ImportanceProcess::
SetParallelWorld(G4VPhysicalVolume* parallelWorld)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointer of navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorld->GetName();
fGhostWorld = parallelWorld;
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
// void G4ImportanceProcess::
// SetParallelWorld(const G4VPhysicalVolume* parallelWorld)
// {
// //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// // Get pointer of navigator
// //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// // G4cout << " G4ImportanceProcess:: Got here 1 " << G4endl;
// // fGhostWorldName = parallelWorld->GetName();
// // G4cout << " G4ImportanceProcess:: Got here 2 ghostName:" << fGhostWorldName << G4endl;
// fGhostWorld = parallelWorld;
// G4cout << " G4ImportanceProcess:: Got here 3 " << G4endl;
// fGhostNavigator = fTransportationManager->GetNavigator(parallelWorld);
// G4cout << " G4ImportanceProcess:: Got here 4 " << G4endl;
// //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// }
//------------------------------------------------------
//
@@ -352,8 +363,8 @@ AlongStepGetPhysicalInteractionLength(
//AH G4cout << " along step physical interaction length " << G4endl;
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ; if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new G4FieldTrack ('0') ; G4FieldTrack &endTrack = *endTrack_G4MT_TLS_;
static G4ThreadLocal ELimited *eLimited_G4MT_TLS_ = 0 ; if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ = new ELimited ; ELimited &eLimited = *eLimited_G4MT_TLS_;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4SamplingPostStepAction.cc 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VSampler.cc 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VSamplerConfigurator.cc 66241 2012-12-13 18:34:42Z gunter $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightCutOffConfigurator.cc 77779 2013-11-28 07:49:08Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4WeightCutOffConfigurator
@@ -36,7 +36,7 @@
#include "G4WeightCutOffProcess.hh"
G4WeightCutOffConfigurator::
G4WeightCutOffConfigurator(G4VPhysicalVolume* worldvolume,
G4WeightCutOffConfigurator(const G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4double wsurvival,
G4double wlimit,
@@ -73,7 +73,7 @@ void G4WeightCutOffConfigurator::Configure(G4VSamplerConfigurator *)
{
G4cout << " entering new weight window configure " << G4endl;
if(paraflag) fWeightCutOffProcess->SetParallelWorld(fWorld);
if(paraflag) fWeightCutOffProcess->SetParallelWorld(fWorld->GetName());
fPlacer.AddProcessAsLastDoIt(fWeightCutOffProcess);
fPlaced = true;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightCutOffProcess.cc 77999 2013-12-02 08:18:01Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -62,10 +62,11 @@ G4WeightCutOffProcess(G4double wsurvival,
fParticleChange(new G4ParticleChange),
fWeightSurvival(wsurvival),
fWeightLimit(wlimit),
fSourceImportance(isource),
fSourceImportance(isource),
fIStore(istore),
// fGCellFinder(aGCellFinder),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
fGhostWorldName("NoParallelWorld"), fGhostWorld(0),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
{
if (!fParticleChange)
{
@@ -95,7 +96,7 @@ G4WeightCutOffProcess(G4double wsurvival,
G4WeightCutOffProcess::~G4WeightCutOffProcess()
{
delete fParticleChange;
delete fGhostStep;
// delete fGhostStep;
}
@@ -300,8 +301,8 @@ AlongStepGetPhysicalInteractionLength(
G4double& proposedSafety, G4GPILSelection* selection)
{
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ; if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new G4FieldTrack ('0') ; G4FieldTrack &endTrack = *endTrack_G4MT_TLS_;
static G4ThreadLocal ELimited *eLimited_G4MT_TLS_ = 0 ; if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ = new ELimited ; ELimited &eLimited = *eLimited_G4MT_TLS_;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightWindowConfigurator.cc 77938 2013-11-29 15:07:30Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4WeightWindowConfigurator
@@ -37,7 +37,7 @@
#include "G4WeightWindowProcess.hh"
G4WeightWindowConfigurator::
G4WeightWindowConfigurator(G4VPhysicalVolume* worldvolume,
G4WeightWindowConfigurator(const G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4VWeightWindowStore &wwstore,
const G4VWeightWindowAlgorithm *wwAlg,
@@ -83,7 +83,7 @@ G4WeightWindowConfigurator::Configure(G4VSamplerConfigurator *preConf)
terminator,
fPlaceOfAction,"WeightWindowProcess",paraflag);
if(paraflag) fWeightWindowProcess->SetParallelWorld(fWorld);
if(paraflag) fWeightWindowProcess->SetParallelWorld(fWorld->GetName());
fPlacer.AddProcessAsSecondDoIt(fWeightWindowProcess);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4WeightWindowProcess.cc 77999 2013-12-02 08:18:01Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -64,6 +64,7 @@ G4WeightWindowProcess::G4WeightWindowProcess(
fWeightWindowStore(aWWStore),
fPostStepAction(0),
fPlaceOfAction(placeOfAction),
fGhostWorldName("NoParallelWorld"),fGhostWorld(0),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
{
if (TrackTerminator)
@@ -103,7 +104,7 @@ G4WeightWindowProcess::~G4WeightWindowProcess()
delete fPostStepAction;
delete fParticleChange;
delete fGhostStep;
// delete fGhostStep;
}
@@ -302,8 +303,8 @@ AlongStepGetPhysicalInteractionLength(
G4double& proposedSafety, G4GPILSelection* selection)
{
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ; if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new G4FieldTrack ('0') ; G4FieldTrack &endTrack = *endTrack_G4MT_TLS_;
static G4ThreadLocal ELimited *eLimited_G4MT_TLS_ = 0 ; if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ = new ELimited ; ELimited &eLimited = *eLimited_G4MT_TLS_;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
@@ -0,0 +1,18 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4biasing
# Package: Geant4.src.G4processes.G4biasing.G4biasing_mgt
#
# CMakeLists.txt for building a single granular library.
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt 74802 2013-10-22 08:58:21Z gcosmo $
#
#------------------------------------------------------------------------------
if(GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
endif()
@@ -0,0 +1,34 @@
# $Id: GNUmakefile 74802 2013-10-22 08:58:21Z gcosmo $
# ------------------------------------------------------------
# GNUmakefile for biasing process library.
# ------------------------------------------------------------
name := G4biasing_mgt
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/navigation/include \
-I$(G4BASE)/geometry/magneticfield/include \
-I$(G4BASE)/geometry/biasing/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/cuts/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/digits_hits/detector/include \
-I$(G4BASE)/digits_hits/hits/include \
-I$(G4BASE)/processes/transportation/include
include $(G4INSTALL)/config/common.gmk
@@ -0,0 +1,26 @@
$Id: History 77477 2013-11-25 09:42:24Z gcosmo $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
November 22nd, 2013 A.Howard
- Moved G4VProcessPlacer and G4ProcessPlacer from importance
October 10th, 2013 A.Howard
- Subdirectory and history file created.
@@ -24,33 +24,32 @@
// ********************************************************************
//
//
// $Id$
// $Id: $
//
// ---------------- G4QCandidateVector ----------------
// by Mikhail Kossov, Oct 2006.
// Type defenition for a Vector of Partons - output of CHIPS model
// ---------------------------------------------------------------
// Short description: The Quark-Gluon String consists of the partons, which
// are quarks and some times gluons.
// ------------------------------------------------------------------------
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description:
// A enumeration to communicate from the G4BiasingProcessInterface
// process to the current G4VBiasingOperator what case of biasing
// has been applied in the PostStepDoIt(...)
//
// ----------------G4BiasingAppliedCase ----------------
//
// Author: M.Verderi (LLR), November 2013
//
// --------------------------------------------------------------------
#ifndef G4QPartonVector_h
#define G4QPartonVector_h 1
//
// $Id$
//
// ------------------------------------------------------------
// GEANT 4 class implementation file
//
// ---------------- G4QParton ----------------
// by Mikhail Kossov, Oct 2006.
// class for PartonVector (string) used by Parton String Models
// ------------------------------------------------------------
#ifndef G4BiasingAppliedCase_hh
#define G4BiasingAppliedCase_hh
#include "G4QParton.hh"
#include <vector>
typedef std::vector<G4QParton *> G4QPartonVector;
struct DeleteQParton { void operator()(G4QParton* aQP){delete aQP;}};
enum G4BiasingAppliedCase
{
BAC_None, // -- not under biasing
BAC_NonPhysics, // -- splitting, killing (not a physics process biasing)
BAC_DenyInteraction, // -- physics process occurence biasing, denying production of physics process final state
BAC_FinalState, // -- physics process final state biasing only
BAC_Occurence // -- physics process occurence biasing; may come together with a final state biasing
};
#endif
@@ -24,63 +24,49 @@
// ********************************************************************
//
//
// $Id$
// $Id: $
//
// Created by Mikhail Kosov 6-Nov-2009
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// --------------------------------------------------------------
// Short description: Algorithm of Synchrotron Radiation from PDG
// Class Description:
// A singleton to maintain the list of G4VBiasingOperation objects.
//
// --------------------------------------------------------------
// ----------------G4BiasingOperationManager ----------------
//
// Author: M.Verderi (LLR), November 2013
//
// --------------------------------------------------------------------
#ifndef G4QSynchRad_h
#define G4QSynchRad_h 1
#ifndef G4BiasingOperationManager_hh
#define G4BiasingOperationManager_hh 1
#include "G4ios.hh"
#include "globals.hh"
#include "Randomize.hh"
#include "G4VDiscreteProcess.hh"
#include "G4FieldManager.hh"
#include "G4Field.hh"
#include "G4ThreeVector.hh"
#include "G4TransportationManager.hh"
#include "G4PropagatorInField.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4Gamma.hh"
class G4VBiasingOperation;
#include <map>
#include <vector>
#include "G4Cache.hh"
#include "G4ThreadLocalSingleton.hh"
class G4QSynchRad : public G4VDiscreteProcess
{
//This class is a thread-local singleton
class G4BiasingOperationManager {
friend class G4ThreadLocalSingleton<G4BiasingOperationManager>;
public:
G4QSynchRad(const G4String& processName = "CHIPS_SynchrotronRadiation",
G4ProcessType type = fElectromagnetic);
virtual ~G4QSynchRad(){;}
private:
G4QSynchRad& operator=(const G4QSynchRad &right);
G4QSynchRad(const G4QSynchRad&);
static G4BiasingOperationManager* GetInstance();
const std::vector< G4VBiasingOperation* > GetBiasingOperations() {return fBiasingOperationVector.Get();}
G4VBiasingOperation* GetBiasingOperation(std::size_t optionID);
public:
G4double GetMeanFreePath(const G4Track& track, G4double step, G4ForceCondition* fCond);
G4VParticleChange* PostStepDoIt(const G4Track& track, const G4Step& step);
G4bool IsApplicable(const G4ParticleDefinition& pd) { return (pd.GetPDGCharge() != 0.); }
void SetMinGamma(G4double ming) {minGamma = ming;}
G4double GetMinGamma() {return minGamma;}
G4double GetRadius(const G4Track& track); // Revolution Radius (independent units)
// Body
~G4BiasingOperationManager();
std::size_t Register(G4VBiasingOperation*);
private:
G4double minGamma;
G4ThreeVector Polarization;
G4BiasingOperationManager();
static G4VectorCache<G4VBiasingOperation*> fBiasingOperationVector;
static G4MapCache<G4VBiasingOperation*,std::size_t > fBiasingOperationIDtoPointerMap;
//static G4BiasingOperationManager* fInstance;
//static std::vector< G4VBiasingOperation* > fBiasingOperationVector;
//static std::map < G4VBiasingOperation*, std::size_t > fBiasingOperationIDtoPointerMap;
};
#endif
@@ -23,83 +23,56 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
//
// -------------------------------------------------------------------
// $Id: $
//
// GEANT4 Class header file
//
//
// File name: G4PEEffectModel
//
// Author: Vladimir Ivanchenko on base of Michel Maire code
//
// Creation date: 21.04.2005
//
// Modifications:
//
// 06.02.2006 : added ComputeMeanFreePath() (mma)
// 20.02.2009 : move virtual inline to .cc, substitute
// ComputeMeanFreePath() by CrossSectionPerVolume (VI)
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description:
// Extends G4Track properties with information needed for handling
// in biasing.
// These information regard at this point under what conditions
// the track was borned.
//
// Implementation of the photo-electric effect
// ----------------G4BiasingTrackData ----------------
//
// -------------------------------------------------------------------
// Author: M.Verderi (LLR), November 2013
//
// --------------------------------------------------------------------
#ifndef G4PEEffectModel_h
#define G4PEEffectModel_h 1
#ifndef G4BiasingTrackData_hh
#define G4BiasingTrackData_hh
#include "G4VEmModel.hh"
#include "G4PhysicsTable.hh"
class G4ParticleChangeForGamma;
class G4PEEffectModel : public G4VEmModel
{
class G4Track;
class G4VBiasingOperation;
class G4VBiasingOperator;
class G4BiasingProcessInterface;
class G4BiasingTrackData {
public:
G4PEEffectModel(const G4ParticleDefinition* p = 0,
const G4String& nam = "PhotoElectric");
virtual ~G4PEEffectModel();
virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
G4double kinEnergy,
G4double Z,
G4double A,
G4double, G4double);
virtual G4double CrossSectionPerVolume(const G4Material*,
const G4ParticleDefinition*,
G4double kineticEnergy,
G4double cutEnergy,
G4double maxEnergy);
virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
const G4MaterialCutsCouple*,
const G4DynamicParticle*,
G4double tmin,
G4double maxEnergy);
G4BiasingTrackData(const G4Track* track);
G4BiasingTrackData(const G4Track* track,
const G4VBiasingOperation* birthOperation,
const G4VBiasingOperator* birthOperator,
const G4BiasingProcessInterface* birthProcess);
~G4BiasingTrackData();
void SetBirthOperation( const G4VBiasingOperation* birthOperation ) { fBirthOperation = birthOperation; }
void SetBirthOperator ( const G4VBiasingOperator* birthOperator ) { fBirthOperator = birthOperator; }
void SetBirthProcess ( const G4BiasingProcessInterface* birthProcess ) { fBirthProcess = birthProcess; }
const G4Track* GetTrack() const { return fTrack; }
const G4VBiasingOperation* GetBirthOperation() const { return fBirthOperation; }
const G4VBiasingOperator* GetBirthOperator() const { return fBirthOperator; }
const G4BiasingProcessInterface* GetBirthProcess() const { return fBirthProcess; }
private:
G4PEEffectModel & operator=(const G4PEEffectModel &right);
G4PEEffectModel(const G4PEEffectModel&);
G4ParticleDefinition* theGamma;
G4ParticleDefinition* theElectron;
G4ParticleChangeForGamma* fParticleChange;
G4double fminimalEnergy;
const G4Track* fTrack;
const G4VBiasingOperation* fBirthOperation;
const G4VBiasingOperator* fBirthOperator;
const G4BiasingProcessInterface* fBirthProcess;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#endif
@@ -24,58 +24,46 @@
// ********************************************************************
//
//
// $Id$
// $Id: $
//
// Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// History:
// -----------
// 5 Oct 2001 MGP Created
// 22 Jan 2003 V.Ivanchenko Cut per region
// Class Description:
// A storage class for G4BiasingTrackData objects.
//
// -------------------------------------------------------------------
// Class description:
// Class for a strategy pattern encapsulating algorithms to test the range
// of a particle: no test is performed
// Further documentation available from http://www.ge.infn.it/geant4/lowE/index.html
// ----------------G4BiasingTrackDataStore ----------------
//
// Author: M.Verderi (LLR), November 2013
//
// ---------------------------------------------------------------------
// -------------------------------------------------------------------
#ifndef G4BiasingTrackDataStore_hh
#define G4BiasingTrackDataStore_hh
#ifndef G4RANGENOTEST_HH
#define G4RANGENOTEST_HH 1
#include "globals.hh"
#include "G4VRangeTest.hh"
class G4ParticleDefinition;
class G4MaterialCutsCouple;
class G4RangeNoTest : public G4VRangeTest {
// A singleton that must be *thread local*
class G4BiasingTrackData;
class G4Track;
#include <map>
#include "G4ThreadLocalSingleton.hh"
class G4BiasingTrackDataStore {
friend class G4ThreadLocalSingleton<G4BiasingTrackDataStore>;
public:
static G4BiasingTrackDataStore* GetInstance();
~G4BiasingTrackDataStore();
G4RangeNoTest() { }
void Register(G4BiasingTrackData*);
void DeRegister(G4BiasingTrackData*);
virtual ~G4RangeNoTest() { }
G4BiasingTrackData* GetBiasingTrackData( const G4Track* track ) {return fTrackDataStore[track]; }
virtual G4bool Escape(const G4ParticleDefinition*, // particle
const G4MaterialCutsCouple*, // couple,
G4double, // energy,
G4double ) const { return true; } // safety
const std::map < const G4Track*, G4BiasingTrackData* >& GetMap() const {return fTrackDataStore;}
private:
G4BiasingTrackDataStore();
//static G4BiasingTrackDataStore* fInstance;
std::map < const G4Track*, G4BiasingTrackData* > fTrackDataStore;
};
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ProcessPlacer.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4ProcessPlacer
@@ -0,0 +1,116 @@
//
// ********************************************************************
// * 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:
//
// An abstract class to model interaction laws, not necessarily.
// exponential ones.
// These laws, p(l), are caraterized by their:
// - non-interaction probability over l:
// P_NI(l) = 1 - integral(0,l) p(s) ds
// - effective cross-section at l:
// sigma_eff(l) = p(l)/P_NI(l) (several forms exist)
// If several laws compete, the resulting net law has:
// - an non-interaction probability over a lenght l which
// is the product of the individual non-interaction probabilities.
// - an effective cross-section which is the
// sum on the individual effective cross-sections.
//
// ----------------G4VBiasingInteractionLaw ----------------
//
// Author: M.Verderi (LLR), November 2013
// - 05/11/13 : First Implementation
// --------------------------------------------------------------------
#ifndef G4VBiasingInteractionLaw_hh
#define G4VBiasingInteractionLaw_hh 1
#include "globals.hh"
#include <vector>
class G4BiasingProcessInterface;
class G4VBiasingInteractionLaw {
public:
G4VBiasingInteractionLaw(G4String name) : fName(name), fSampledInteractionLength(DBL_MAX) {}
virtual ~G4VBiasingInteractionLaw() {}
public:
const G4String& GetName() const { return fName; }
// ----------------------------
// -- Interface to sub-classes:
// ----------------------------
protected:
// -- Sample the distribution for point like interaction (PostStep ones)
virtual G4double SampleInteractionLength() = 0;
public:
// -- Compute non-interaction probability and effective cross-section:
// -- (probability of interaction over dl = effective_cross-section* dl)
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const = 0;
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const = 0;
protected:
// -- Convenience method, used in many daughters classes :
// -- update the distribution for a made step of truePathLength size:
virtual G4double UpdateInteractionLengthForStep(G4double /* truePathLength */) { return DBL_MAX; }
public:
// -- Methods to deal with singularities : null cross sections or infinite ones.
// -- In such cases, weight can not always be computed.
// -- Tells if this interaction law has singularities:
virtual G4bool IsSingular() const {return false;}
// -- method interrogated only in case interaction law is IsSingular() == true:
virtual G4bool IsEffectiveCrossSectionInfinite() const {return false;}
// -----------------------------------------
// -- public interface to protected methods:
// -----------------------------------------
public:
G4double Sample()
{
fSampledInteractionLength = SampleInteractionLength();
return fSampledInteractionLength;
}
G4double UpdateForStep(G4double truePathLength)
{
fSampledInteractionLength = UpdateInteractionLengthForStep(truePathLength);
return fSampledInteractionLength;
}
G4double GetSampledInteractionLength() const { return fSampledInteractionLength; }
private:
G4String fName;
G4double fSampledInteractionLength;
};
#endif
@@ -0,0 +1,218 @@
//
// ********************************************************************
// * 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:
//
// An abstract class to model the behavior of any type of biasing :
// physics-based biasing (change of physics process behavior) or non-
// physics-based one, like splitting, killing.
//
// o The change of behavior of a physics process can be:
// - a change of the PostStep interaction probabilty, so-called
// occurence biasing
// - a change in final state production
// - both, provided above two are uncorrelated.
// o The change of occurence is driven by providing a biasing interaction
// law (G4VBiasingInteractionLaw) that is used in place of the analog
// exponential law.
// This change of occurence is controlled through many handles.
// o The change in final state production is made through one single
// method the user is fully responsible of.
//
// o Non-physics-based biasing is controlled by two methods : one to
// specify where this biasing should happen, and one for generating
// the related final-state.
//
// ----------------G4VBiasingOperation ----------------
//
// Author: M.Verderi (LLR), November 2013
// - 05/11/13 : first implementation
// ---------------------------------------------------------------------
#ifndef G4VBiasingOperation_hh
#define G4VBiasingOperation_hh 1
#include "globals.hh"
class G4VParticleChange;
class G4Track;
class G4Step;
class G4VBiasingInteractionLaw;
class G4VProcess;
class G4BiasingProcessInterface;
#include "G4ForceCondition.hh"
#include "G4GPILSelection.hh"
class G4VBiasingOperation {
public:
// ---------------
// -- Constructor:
// ---------------
//
// -- Constructor for biasing operations:
// -----------------------------------
// -- Operation is given a name.
G4VBiasingOperation(G4String name);
// -- destructor:
virtual ~G4VBiasingOperation();
public:
// -----------------------------
// -- Interface to sub-classes :
// -----------------------------
// --
// *************************************
// ** Methods for physics-based biasing:
// *************************************
// --
// ---- I. Biasing of the process occurence:
// -----------------------------------------
// ---- The biasing of the process occurence regards the occurence of the PostStepDoIt
// ---- behavior. But the weight is manipulated by both AlongStep methods (weight for
// ---- non-interaction) and PostStep methods (weight for interaction). For this
// ---- reason, occurence biasing is handled by both AlongStep and PostStep methods.
// ----
// ---- If the operation is returned to the G4BiasingProcessInterface process by the
// ---- ProposeOccurenceBiasingOperation(...)/GetProposedOccurenceBiasingOperation(...) method
// ---- of the biasing operator, all methods below will be called for this operation.
// ----
// ---- I.1) Methods called in at the PostStepGetPhysicalInteractionLength(...) level :
// ----
// ------ o Main and mandatory method for biasing of the PostStep process biasing occurence :
// ------ - propose an interaction law to be substituted to the process that is biased
// ------ - the operation is told which is the G4BiasingProcessInterface calling it with
// ------ callingProcess argument.
// ------ - the returned law will have to have been sampled prior to be returned as it will be
// ------ asked for its GetSampledInteractionLength() by the callingProcess.
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw( const G4BiasingProcessInterface* /* callingProcess */ ) = 0;
// ------ o Additionnal method for PostStep occurence:
// ------ - operation can propose a force condition in the PostStepGPIL
// ------ - this condition superseedes the wrapped process condition (taken as default condition)
// ------ - it is called after above ProvideOccurenceBiasingInteractionLaw(...) by the same calling process.
virtual G4ForceCondition ProposeForceCondition( const G4ForceCondition wrappedProcessCondition )
{
return wrappedProcessCondition;
}
// ----
// ---- I.2) Methods called in at the AlongStepGetPhysicalInteractionLength(...) level :
// ----
// ------ o Operation can optionnally limit GPIL Along Step:
virtual G4double ProposeAlongStepLimit( const G4BiasingProcessInterface* /* callingProcess */ ) { return DBL_MAX; }
// ------ o Operation can propose a GPILSelection in the AlongStepGPIL
// ------ this selection superseeded the wrapped process selection
// ------ if the wrapped process exists, and if has along methods:
virtual G4GPILSelection ProposeGPILSelection( const G4GPILSelection wrappedProcessSelection )
{return wrappedProcessSelection;}
// ----
// ---- I.3) Methods called in at the AlongStepDoIt(...) level :
// ----
// ------ o Helper method to inform the operation of the move made in the along, and related non-interaction weight
// ------ applied to the primary track for this move:
virtual void AlongMoveBy( const G4BiasingProcessInterface* /* callingProcess */,
const G4Step* /* step */,
G4double /* weightForNonInteraction */ ) {}
// ----
// ---- I.4) Methods called in at the PostStepDoIt(...) level :
// ----
// ------ o Method allowing the operation to prevent wrapped process interaction to happen:
// ------ - has to return true if interaction is denied by the operation
// ------ - the primary is left unchanged in this case
// ------ - but its weight becomes the one given by proposedTrackWeight.
virtual G4bool DenyProcessPostStepDoIt( const G4BiasingProcessInterface* /* callingProcess */,
const G4Track* /* track */,
const G4Step* /* step */,
G4double& /* proposedTrackWeight */ )
{return false;}
// ---- II. Biasing of the process post step final state:
// ------------------------------------------------------
// ------ Mandatory method for biasing of the PostStepDoIt of the wrapped process
// ------ holds by the G4BiasingProcessInterface callingProcess.
// ------ User has full freedom for the particle change returned, and is reponsible for
// ------ the correctness of weights set to tracks.
// ------ The wrappedProcess can be accessed through the G4BiasingProcessInterface if needed.
// ------ This can be used in conjonction with an occurence biasing, provided this final
// ------ state biasing is uncorrelated with the occurence biasing (as single multiplication
// ------ of weights occur between these two biasings).
virtual G4VParticleChange* ApplyFinalStateBiasing( const G4BiasingProcessInterface* /* callingProcess */,
const G4Track* /* track */,
const G4Step* /* step */) = 0;
// ---- III. Biasing of the process along step final state:
// --------------------------------------------------------
// ---- Unprovided for now : requires significant developments.
// ***************************************************
// -- Methods for non-physics-based biasing operation:
// ***************************************************
// ----
// ---- If the operation is returned to the G4BiasingProcessInterface process by the
// ---- ProposeNonPhysicsBiasingOperation(...)/GetProposedNonPhysicsBiasingOperation(...) method
// ---- of the biasing operator, all methods below will be called for this operation.
// -----
// ---- 1) Method called in at the PostStepGetPhysicalInteractionLength(...) level :
// ----
// ---- o Return to the distance at which the operation should be applied, or may
// ---- play with the force condition flags.
virtual G4double DistanceToApplyOperation( const G4Track* /* track */,
G4double /* previousStepSize */,
G4ForceCondition* /* condition */) = 0;
// ----
// ---- 2) Method called in at the PostStepDoIt(...) level :
// ----
// ---- o Generate the final state for biasing (eg: splitting, killing, etc.)
virtual G4VParticleChange* GenerateBiasingFinalState( const G4Track* /* track */,
const G4Step* /* step */) = 0;
// ----------------------------------------
// -- public interface and utility methods:
// ----------------------------------------
public:
const G4String& GetName() const {return fName;}
std::size_t GetUniqueID() const {return fUniqueID;}
private:
const G4String fName;
// -- better would be to have fUniqueID const, but pb on windows with constructor.
std::size_t fUniqueID;
};
#endif
@@ -0,0 +1,338 @@
//
// ********************************************************************
// * 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:
//
// An abstract class to pilot the biasing in a logical volume. This
// class is for *making decisions* on biasing operations to be applied.
// These ones are represented by the G4VBiasingOperation class.
// The volume in which biasing is applied is specified by the
// AttachTo(const G4LogicalVolume *) method. This has to be specified
// at detector construction time in the method ConstructSDandField() of
// G4VUsedDetectorConstruction.
//
// At tracking time the biasing operator is messaged by each
// G4BiasingProcessInterface object attached to the current track. For
// example, if three physics processes are under biasing, and if an
// additional G4BiasingProcessInterface is present to handle non-physics
// based biasing (splitting, killing), the operator will be messaged by
// these four G4BiasingProcessInterface objects.
// The idendity of the calling G4BiasingProcessInterface is known
// to the G4VBiasingOperator by passing this process pointer to the
// operator.
//
// ** Mandatory methods: **
//
// Three types of biasing are to be decided by the G4VBiasingOperator:
//
// 1) non-physics-based biasing:
// -----------------------------
// Meant for pure killing/splitting/etc. biasing operations, not
// associated to a physics process:
//
// virtual G4VBiasingOperation* ProposeNonPhysicsBiasingOperation( const G4Track* track,
// const G4BiasingProcessInterface* callingProcess ) = 0;
//
// Arguments are the current track, and the G4BiasingProcessInterface
// pointer making the call to the operator. In this case, this process
// does not wrap a physics process and
// callingProcess->GetWrappedProcess() == 0.
//
// The G4VBiasingOperation pointer returned is the operation to be
// applied. Zero can be returned. This operation will limit the
// step and propose a final state.
//
// This method is the first operator method called, it is called at the
// by the PostStepGetPhysicalInterationLenght(...) method of the
// G4BiasingProcessInterface.
//
// 2) physics-based biasing:
// -------------------------
// Physics-based biasing operations are of two types:
// - biasing of the physics process occurence interaction law
// - biasing of the physics process final state production
//
// a) The biasing of the occurence interaction law is proposed by:
//
// virtual G4VBiasingOperation* ProposeOccurenceBiasingOperation( const G4Track* track,
// const G4BiasingProcessInterface* callingProcess ) = 0;
// The current G4Track pointer and the G4BiasingProcessInterface
// pointer of the process calling the operator are passed. The
// G4BiasingProcessInterface process wraps an actual physics process
// which pointer can be obtained with
// callingProcess->GetWrappedProcess() .
//
// The biasing operation returned will be asked for its biasing
// interaction by the calling process, which will be a const object
// for the process. All setup and sampling regarding this law should be done
// in the operator before returning the related operation to the process.
//
// This method is the second operator one called in a step, it is called by
// the PostStepGetPhysicalInterationLenght(...) method of the
// G4BiasingProcessInterface.
//
// b) The biasing of the physics process final state is proposed by:
//
// virtual G4VBiasingOperation* ProposeFinalStateBiasingOperation( const G4Track* track,
// const G4BiasingProcessInterface* callingProcess ) = 0;
//
// The operator can propose a biasing operation that will handle the
// physic procsse final state biasing. As in previous case a) the
// G4BiasingProcessInterface process wraps an actual physics process
// which pointer can be obtained with:
// callingProcess->GetWrappedProcess() .
//
// Cases a) and b) are handled independently, and one or two of these
// biasing types can be provided in the same step.
//
// This method is the last operator one called in a step, it is called
// by the PostStepDoIt(...) method of the G4BiasingProcessInterface.
//
//
// ** Optional methods: **
//
// At the end of the step, the operator is messaged by the G4BiasingProcessInterface
// for operation(s) which have been applied during the step. One of the two following
// methods is called:
//
// - In case of at most a single biasing operation was applied by the process, report in cases of:
// - a non-physics biasing operation applied, biasingCase == BAC_NonPhysics ;
// - physics-based biasing:
// - the operator requested no occurence, nor final state biasing, and did let the
// physics process go : biasingCase == BAC_None;
// - an occurence biasing, where operation denied the application of the PostStepDoIt(..)
// of the physics process (proposing a weight for this),
// biasingCase == BAC_DenyInteraction ;
// -
//
// virtual void OperationApplied( const G4BiasingProcessInterface* callingProcess,
// G4BiasingAppliedCase biasingCase,
// G4VBiasingOperation* operationApplied,
// const G4VParticleChange* particleChangeProduced );
// At most a single biasing operation was applied by the process:
// - a non-physics biasing operation was applied, biasingCase == BAC_NonPhysics ;
// - physics-based biasing:
// - the operator requested no biasing operations, and did let the physics
// process go : biasingCase == BAC_None;
// - an occurence biasing was proposed, which operation purpose was to deny the
// application of the PostStepDoIt(..) of the physics process (proposing a
// weight for this) : biasingCase == BAC_DenyInteraction ;
// - a single final state biasing was proposed, with no concomittant occurence:
// biasingCase == BAC_FinalState;
// The operation applied and final state passed to the tracking (particleChangeProduced) are
// passed as information to the operator.
//
// virtual void OperationApplied( const G4BiasingProcessInterface* callingProcess,
// G4BiasingAppliedCase biasingCase,
// G4VBiasingOperation* occurenceOperationApplied,
// G4double weightForOccurenceInteraction,
// G4VBiasingOperation* finalStateOperationApplied,
// const G4VParticleChange* particleChangeProduced );
// This method is called in case an occurence biasing operation has been applied during the step.
// Depending on if the occurence operation was applied alone and together with a final state
// operation, the biasingCase will take values:
// - occurence biasing alone : biasingCase == BAC_None ;
// in which case finalStateOperationApplied == 0;
// - occurence biasing + final state biasing : biasingCase == BAC_FinalState;
// The particleChangeProduced is the one *before* application of the weight for occurence : hence
// either the particle change of the physics process, or the physics process one, biased the final
// state biasing operation.
//
//
// ----------------G4VBiasingOperation ----------------
//
// Author: M.Verderi (LLR), November 2013
//
// --------------------------------------------------------------------
#ifndef G4VBiasingOperator_hh
#define G4VBiasingOperator_hh 1
#include "globals.hh"
class G4VBiasingOperation;
class G4Track;
class G4BiasingProcessInterface;
class G4LogicalVolume;
class G4VParticleChange;
#include <map>
#include <vector>
#include "G4BiasingAppliedCase.hh"
#include "G4Cache.hh"
class G4VBiasingOperator {
public:
// ---------------
// -- Constructor:
// ---------------
G4VBiasingOperator(G4String name);
virtual ~G4VBiasingOperator();
// ----------------------------------------------
// -- abstract and user interface to sub-classes:
// ----------------------------------------------
protected:
// -- mandatory methods to let the operator tell about biasing operations to be applied:
// -------------------------------------------------------------------------------------
// -- These three methods have the same arguments passed : the current G4Track pointer, and the pointer of the
// -- G4BiasingProcessInterface instance calling this biasing operator. This same biasing operator will be called by each
// -- of the G4BiasingProcessInterface instances, meaning for example that:
// -- - if one G4BiasingProcessInterface with no wrapped physics process exits, ProposeNonPhysicsBiasingOperation(...)
// -- will be called one time at the beginning of the step,
// -- - if three G4BiasingProcessInterface instances exist, each of these one wrapping a physics process (eg
// -- conversion, Compton, photo-electric), ProposeOccurenceBiasingOperation(...) will be called three times,
// -- by each of these instances, at the beginning of the step and ProposeFinalStateBiasingOperation(...) will
// -- also be called by each of these instances, at the PostStepDoIt level.
// -- If a null pointer is returned, the analog -unbiased- behavior is adopted.
// -- non-physics-based biasing:
// -----------------------------
// -- [ First operator method called, at the PostStepGetPhysicalInterationLenght(...) level. ]
virtual G4VBiasingOperation* ProposeNonPhysicsBiasingOperation( const G4Track* track, const G4BiasingProcessInterface* callingProcess ) = 0;
// -- physics-based biasing:
// -------------------------
// -- Method to propose an occurence biasing operation : ie a change of the interaction length distribution. The proposed
// -- biasing operation will then be asked for its interaction law.
// -- Note that *** all sanity checks regarding the operation and its interaction law will have to have been performed
// -- before returning the biasing operation pointer *** as no corrective/aborting actions will be possible beyond this point.
// -- The informations provided by the G4BiasingProcessInterface calling process (previous occurence operation, previous step length,
// -- etc.) might be useful for doing this. They will be useful also to decide with continuing with a same operation proposed
// -- in the previous step, updating the interaction law taking into account the new G4Track state and the previous step size.
// -- [ Second operator method called, at the PostStepGetPhysicalInterationLenght(...) level. ]
virtual G4VBiasingOperation* ProposeOccurenceBiasingOperation( const G4Track* track, const G4BiasingProcessInterface* callingProcess ) = 0;
// -- [ Third operator method called, at the PostStepDoIt(...) level. ]
virtual G4VBiasingOperation* ProposeFinalStateBiasingOperation( const G4Track* track, const G4BiasingProcessInterface* callingProcess ) = 0;
protected:
// -- optionnal methods for further information passed to the operator:
// --------------------------------------------------------------------
// ---- report to operator about the operation applied, the biasingCase value provides what sort of biasing applied:
virtual void OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* operationApplied, const G4VParticleChange* particleChangeProduced );
// ---- same as above, report about the operation applied, for the case an occurence biasing was applied, together or not with a final state biasing.
// ---- The variable biasingCase tells if the final state is a biased one or not. **But in all cases**, this call happens only
// ---- for an occurence biaising : ie the occurence weight is applied on top of the particleChangeProduced, which is the particle
// ---- *before* the weight application for occurence biasing.
virtual void OperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* occurenceOperationApplied, G4double weightForOccurenceInteraction,
G4VBiasingOperation* finalStateOperationApplied, const G4VParticleChange* particleChangeProduced );
protected:
// ---- method to inform operator that its biasing control is over (exit volume, or end of tracking):
// ---- [Called at the beginning of next step, or at the end of tracking.]
virtual void ExitBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess );
protected:
// -- Utility:
// -----------
// ---- A utility method allowing to store secondaries produced by an operation.
// ---- The stored secondaries are the ones in the particle change
void RememberSecondaries( const G4BiasingProcessInterface* callingProcess,
const G4VBiasingOperation* operationApplied,
const G4VParticleChange* particleChangeProduced );
// ---- Informations about track is erased:
void ForgetTrack( const G4Track* track );
public:
// ---- inform the operator of the start of the run:
virtual void StartRun() {}
// ---- inform the operator of the start (end) of the tracking of a new track:
virtual void StartTracking( const G4Track* /* track */ ) {}
virtual void EndTracking() {}
// --------------------
// -- public interface:
// --------------------
// -- needed by user:
public:
const G4String GetName() const {return fName;}
void AttachTo( const G4LogicalVolume* ); // -- attach to single volume
G4BiasingAppliedCase GetPreviousBiasingAppliedCase() const {return fPreviousBiasingAppliedCase;}
// -- all operators (might got to a manager):
static const std::vector < G4VBiasingOperator* >& GetBiasingOperators() {return fOperators.Get();}
// -- get operator associated to a logical volume:
static G4VBiasingOperator* GetBiasingOperator( const G4LogicalVolume* ); // -- might go to a manager ; or moved to volume
// -- used by biasing process interface, or used by an other operator (not expected to be invoked differently than with these two cases):
public:
G4VBiasingOperation* GetProposedOccurenceBiasingOperation( const G4Track* track, const G4BiasingProcessInterface* callingProcess );
G4VBiasingOperation* GetProposedFinalStateBiasingOperation( const G4Track* track, const G4BiasingProcessInterface* callingProcess );
G4VBiasingOperation* GetProposedNonPhysicsBiasingOperation( const G4Track* track, const G4BiasingProcessInterface* callingProcess );
void ExitingBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess );
public:
void ReportOperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* operationApplied, const G4VParticleChange* particleChangeProduced );
void ReportOperationApplied( const G4BiasingProcessInterface* callingProcess, G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* occurenceOperationApplied, G4double weightForOccurenceInteraction,
G4VBiasingOperation* finalStateOperationApplied, const G4VParticleChange* particleChangeProduced );
public:
const G4VBiasingOperation* GetPreviousNonPhysicsAppliedOperation() {return fPreviousAppliedNonPhysicsBiasingOperation;}
const G4VBiasingOperation* GetBirthOperation( const G4Track* );
private:
const G4String fName;
// -- thread local:
// static std::map< const G4LogicalVolume*, G4VBiasingOperator* > fLogicalToSetupMap;
static G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* > fLogicalToSetupMap;
// -- thread local:
static G4VectorCache<G4VBiasingOperator* > fOperators;
// static std::vector < G4VBiasingOperator* > fOperators;
// -- For this operator:
std::vector< const G4LogicalVolume* > fRootVolumes;
std::map < const G4LogicalVolume*, G4int > fDepthInTree;
// -- current operation:
G4VBiasingOperation* fOccurenceBiasingOperation;
G4VBiasingOperation* fFinalStateBiasingOperation;
G4VBiasingOperation* fNonPhysicsBiasingOperation;
// -- previous operations:
const G4VBiasingOperation* fPreviousProposedOccurenceBiasingOperation;
const G4VBiasingOperation* fPreviousProposedFinalStateBiasingOperation;
const G4VBiasingOperation* fPreviousProposedNonPhysicsBiasingOperation;
const G4VBiasingOperation* fPreviousAppliedOccurenceBiasingOperation;
const G4VBiasingOperation* fPreviousAppliedFinalStateBiasingOperation;
const G4VBiasingOperation* fPreviousAppliedNonPhysicsBiasingOperation;
G4BiasingAppliedCase fPreviousBiasingAppliedCase;
};
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VProcessPlacer.hh 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// Class G4VProcessPlacer
@@ -0,0 +1,93 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4biasing_mgt
# Package: Geant4.src.G4processes.G4biasing_mgt
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 77477 2013-11-25 09:42:24Z gcosmo $
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/detector/include)
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/hits/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/biasing/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/navigation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/cuts/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/electromagnetic/utils/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/transportation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4biasing_mgt
HEADERS
G4VProcessPlacer.hh
G4ProcessPlacer.hh
G4BiasingAppliedCase.hh
G4BiasingOperationManager.hh
G4BiasingTrackData.hh
G4BiasingTrackDataStore.hh
G4VBiasingInteractionLaw.hh
G4VBiasingOperation.hh
G4VBiasingOperator.hh
SOURCES
G4VProcessPlacer.cc
G4ProcessPlacer.cc
G4BiasingOperationManager.cc
G4BiasingTrackData.cc
G4BiasingTrackDataStore.cc
G4VBiasingOperation.cc
G4VBiasingOperator.cc
GRANULAR_DEPENDENCIES
G4cuts
G4detector
G4emutils
G4geombias
G4geometrymng
G4globman
G4hits
G4intercoms
G4magneticfield
G4materials
G4navigation
G4partman
G4procman
G4track
G4transportation
G4volumes
GLOBAL_DEPENDENCIES
G4digits_hits
G4geometry
G4global
G4intercoms
G4materials
G4particles
G4track
LINK_LIBRARIES
)
# List any source specific properties here
@@ -23,52 +23,43 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Implementation of the HETC88 code into Geant4.
// Evaporation and De-excitation parts
// T. Lampen, Helsinki Institute of Physics, May-2000
#include "G4BiasingOperationManager.hh"
#include "G4BETritonChannel.hh"
#include "G4Triton.hh"
//G4BiasingOperationManager* G4BiasingOperationManager::fInstance = 0;
G4VectorCache< G4VBiasingOperation* > G4BiasingOperationManager::fBiasingOperationVector;
G4MapCache< G4VBiasingOperation*, std::size_t > G4BiasingOperationManager::fBiasingOperationIDtoPointerMap;
G4BETritonChannel::G4BETritonChannel()
G4BiasingOperationManager::G4BiasingOperationManager()
{}
G4BiasingOperationManager::~G4BiasingOperationManager()
{}
G4BiasingOperationManager* G4BiasingOperationManager::GetInstance()
{
name = "triton";
verboseLevel = 0;
particleA = 3;
particleZ = 1;
rho = 0.70588;
A=3;
spin = 0.5;
//Create an instance for each thread.
static G4ThreadLocalSingleton<G4BiasingOperationManager> instance;
return instance.Instance();
// if (fInstance == 0) fInstance = new G4BiasingOperationManager();
// return fInstance;
}
std::size_t G4BiasingOperationManager::Register(G4VBiasingOperation* option)
{
std::size_t optionUniqueID = fBiasingOperationVector.Size();
fBiasingOperationVector.Push_back(option);
fBiasingOperationIDtoPointerMap[option] = optionUniqueID;
return optionUniqueID;
}
G4VBiasingOperation* G4BiasingOperationManager::GetBiasingOperation(std::size_t optionID)
{
if (optionID < fBiasingOperationVector.Size()) return fBiasingOperationVector[optionID];
else return 0;
}
G4BETritonChannel::~G4BETritonChannel()
{
}
G4DynamicParticle* G4BETritonChannel::emit()
{
G4double u , v , w;
G4DynamicParticle * pParticle = new G4DynamicParticle;
pParticle -> SetDefinition( G4Triton::Triton() );
pParticle -> SetKineticEnergy( sampleKineticEnergy() );
isotropicCosines( u , v , w );
pParticle -> SetMomentumDirection( u , v , w );
return pParticle;
}
G4double G4BETritonChannel::coulombFactor()
{
return 0.333333*coulombFactorForProton();
}
G4double G4BETritonChannel::qmFactor()
{
// Coefficient representing the quantum mechanical barrier
// penetration, see Dostrovsky, Phys. Rev. 116, 1959.
return qmFactorForProton() + 0.12;
}
@@ -0,0 +1,55 @@
//
// ********************************************************************
// * 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 "G4BiasingTrackData.hh"
#include "G4BiasingTrackDataStore.hh"
G4BiasingTrackData::G4BiasingTrackData(const G4Track* track)
: fTrack(track),
fBirthOperation (0),
fBirthOperator (0),
fBirthProcess(0)
{
G4BiasingTrackDataStore::GetInstance()->Register( this );
}
G4BiasingTrackData::G4BiasingTrackData(const G4Track* track,
const G4VBiasingOperation* birthOperation,
const G4VBiasingOperator* birthOperator,
const G4BiasingProcessInterface* birthProcess)
: fTrack(track),
fBirthOperation (birthOperation),
fBirthOperator (birthOperator),
fBirthProcess(birthProcess)
{
G4BiasingTrackDataStore::GetInstance()->Register( this );
}
G4BiasingTrackData::~G4BiasingTrackData()
{
G4BiasingTrackDataStore::GetInstance()->DeRegister( this );
}
@@ -0,0 +1,60 @@
//
// ********************************************************************
// * 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 "G4BiasingTrackDataStore.hh"
#include "G4BiasingTrackData.hh"
//G4BiasingTrackDataStore* G4BiasingTrackDataStore::fInstance = 0;
G4BiasingTrackDataStore* G4BiasingTrackDataStore::GetInstance()
{
static G4ThreadLocalSingleton<G4BiasingTrackDataStore> instance;
return instance.Instance();
}
void G4BiasingTrackDataStore::Register(G4BiasingTrackData* data)
{
fTrackDataStore[data->GetTrack()] = data;
}
void G4BiasingTrackDataStore::DeRegister(G4BiasingTrackData* data)
{
fTrackDataStore[data->GetTrack()] = 0;
}
G4BiasingTrackDataStore::G4BiasingTrackDataStore()
{}
G4BiasingTrackDataStore::~G4BiasingTrackDataStore()
{
for ( std::map < const G4Track*, G4BiasingTrackData* >::iterator it = fTrackDataStore.begin() ;
it != fTrackDataStore.end() ; it++ )
{
G4BiasingTrackData* data = (*it).second;
if ( data != 0 ) delete data;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ProcessPlacer.cc 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -0,0 +1,37 @@
//
// ********************************************************************
// * 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 "G4VBiasingOperation.hh"
#include "G4BiasingOperationManager.hh"
G4VBiasingOperation::G4VBiasingOperation(G4String name)
: fName(name)
{
// -- have to move from initialization to here, as giving error on windows:
fUniqueID = G4BiasingOperationManager::GetInstance()->Register(this);
}
G4VBiasingOperation::~G4VBiasingOperation()
{}
@@ -0,0 +1,241 @@
//
// ********************************************************************
// * 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 "G4VBiasingOperator.hh"
#include "G4VBiasingOperation.hh"
#include "G4VParticleChange.hh"
#include "G4BiasingTrackData.hh"
#include "G4BiasingTrackDataStore.hh"
G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* > G4VBiasingOperator::fLogicalToSetupMap;
G4VectorCache< G4VBiasingOperator* > G4VBiasingOperator::fOperators;
G4VBiasingOperator::G4VBiasingOperator(G4String name)
: fName(name)
{
fOperators.Push_back(this);
}
G4VBiasingOperator::~G4VBiasingOperator()
{
}
void G4VBiasingOperator::AttachTo(const G4LogicalVolume* logical)
{
G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* >::iterator it;
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 an other operator !" << G4endl;
G4Exception("G4VBiasingOperator::AttachTo(...)",
"BIAS.MNG.01",
JustWarning,
ed);
}
}
G4VBiasingOperator* G4VBiasingOperator::GetBiasingOperator(const G4LogicalVolume* logical)
{
G4MapCache< const G4LogicalVolume*, G4VBiasingOperator* >::iterator it;
it = fLogicalToSetupMap.Find(logical);
if ( it == fLogicalToSetupMap.End() ) return 0;
else return (*it).second;
}
G4VBiasingOperation* G4VBiasingOperator::GetProposedOccurenceBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
{
fOccurenceBiasingOperation = ProposeOccurenceBiasingOperation(track, callingProcess);
// G4cout << GetName() << " Occurence : ";
// if ( fOccurenceBiasingOperation ) G4cout << fOccurenceBiasingOperation->GetName() << G4endl;
// else G4cout << " (none) " << G4endl;
return fOccurenceBiasingOperation;
}
G4VBiasingOperation* G4VBiasingOperator::GetProposedFinalStateBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
{
fFinalStateBiasingOperation = ProposeFinalStateBiasingOperation(track, callingProcess);
// G4cout << GetName() << " Final State : ";
// if ( fFinalStateBiasingOperation ) G4cout << fFinalStateBiasingOperation->GetName() << G4endl;
// else G4cout << " (none) " << G4endl;
return fFinalStateBiasingOperation;
}
G4VBiasingOperation* G4VBiasingOperator::GetProposedNonPhysicsBiasingOperation(const G4Track* track, const G4BiasingProcessInterface* callingProcess)
{
fNonPhysicsBiasingOperation = ProposeNonPhysicsBiasingOperation(track, callingProcess);
// G4cout << GetName() << " Non Physics : ";
// if ( fNonPhysicsBiasingOperation ) G4cout << fNonPhysicsBiasingOperation->GetName() << G4endl;
// else G4cout << " (none) " << G4endl;
return fNonPhysicsBiasingOperation;
}
// void G4VBiasingOperator::RegisterSecondariesBirth( G4VBiasingOperation* operation, const G4VParticleChange* pChange )
// {
// for (G4int i2nd = 0; i2nd < pChange->GetNumberOfSecondaries (); i2nd++)
// RegisterSecondaryBirth( operation, pChange->GetSecondary (i2nd) );
// }
// void G4VBiasingOperator::RegisterSecondaryBirth( G4VBiasingOperation* operation, const G4Track* track )
// {
// // G4cout << " --> Registering operation, track = " << operation->GetName() << " " << track << G4endl;
// fSecondaryBirthOperation[track] = operation;
// }
const G4VBiasingOperation* G4VBiasingOperator::GetBirthOperation( const G4Track* track )
{
const G4BiasingTrackData* biasingData = G4BiasingTrackDataStore::GetInstance()->GetBiasingTrackData(track);
if ( biasingData != 0 ) return biasingData->GetBirthOperation();
else return 0;
}
void G4VBiasingOperator::ReportOperationApplied( const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* operationApplied,
const G4VParticleChange* particleChangeProduced )
{
fPreviousBiasingAppliedCase = biasingCase;
// if ( operationApplied != 0 )
// {
// if ( operationApplied->GetRememberSecondaries() )
// {
// for (G4int i2nd = 0; i2nd < particleChangeProduced->GetNumberOfSecondaries (); i2nd++)
// new G4BiasingTrackData( particleChangeProduced->GetSecondary (i2nd),
// operationApplied,
// this,
// callingProcess);
// }
// }
fPreviousAppliedOccurenceBiasingOperation = 0;
fPreviousAppliedFinalStateBiasingOperation = 0;
fPreviousAppliedNonPhysicsBiasingOperation = 0;
switch ( biasingCase )
{
case BAC_None:
break;
case BAC_NonPhysics:
fPreviousAppliedNonPhysicsBiasingOperation = operationApplied ;
break;
case BAC_DenyInteraction:
fPreviousAppliedOccurenceBiasingOperation = operationApplied;
break;
case BAC_FinalState:
fPreviousAppliedFinalStateBiasingOperation = operationApplied;
break;
case BAC_Occurence:
G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
"BIAS.MNG.02",
JustWarning,
"Internal logic error, please report !");
break;
default:
G4Exception("G4VBiasingOperator::ReportOperationApplied(...)",
"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 )
{
fPreviousBiasingAppliedCase = biasingCase;
// G4VBiasingOperation* operation(finalStateOperationApplied != 0 ? finalStateOperationApplied : occurenceOperationApplied);
// G4bool remember = occurenceOperationApplied->GetRememberSecondaries();
// if ( finalStateOperationApplied != 0 ) remember = remember || finalStateOperationApplied->GetRememberSecondaries();
// if ( remember )
// {
// for (G4int i2nd = 0; i2nd < particleChangeProduced->GetNumberOfSecondaries (); i2nd++)
// new G4BiasingTrackData( particleChangeProduced->GetSecondary (i2nd),
// operation,
// this,
// callingProcess);
// }
fPreviousAppliedOccurenceBiasingOperation = occurenceOperationApplied;
fPreviousAppliedFinalStateBiasingOperation = finalStateOperationApplied;
OperationApplied( callingProcess, biasingCase, occurenceOperationApplied, weightForOccurenceInteraction, finalStateOperationApplied, particleChangeProduced );
}
void G4VBiasingOperator::ExitingBiasing( const G4Track* track, const G4BiasingProcessInterface* callingProcess )
{
ExitBiasing( track, callingProcess );
// -- reset all data members:
fOccurenceBiasingOperation = 0 ;
fFinalStateBiasingOperation = 0 ;
fNonPhysicsBiasingOperation = 0 ;
fPreviousProposedOccurenceBiasingOperation = 0 ;
fPreviousProposedFinalStateBiasingOperation = 0 ;
fPreviousProposedNonPhysicsBiasingOperation = 0 ;
fPreviousAppliedOccurenceBiasingOperation = 0 ;
fPreviousAppliedFinalStateBiasingOperation = 0 ;
fPreviousAppliedNonPhysicsBiasingOperation = 0 ;
fPreviousBiasingAppliedCase = BAC_None ;
}
void G4VBiasingOperator::RememberSecondaries( const G4BiasingProcessInterface* callingProcess,
const G4VBiasingOperation* operationApplied,
const G4VParticleChange* particleChangeProduced)
{
for (G4int i2nd = 0; i2nd < particleChangeProduced->GetNumberOfSecondaries (); i2nd++)
new G4BiasingTrackData( particleChangeProduced->GetSecondary (i2nd),
operationApplied,
this,
callingProcess);
}
void G4VBiasingOperator::ForgetTrack( const G4Track* track )
{
G4BiasingTrackData* biasingData = G4BiasingTrackDataStore::GetInstance()->GetBiasingTrackData(track);
if ( biasingData != 0 ) delete biasingData;
}
// -- 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::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
G4VBiasingOperation*, const G4VParticleChange* )
{}
void G4VBiasingOperator::OperationApplied( const G4BiasingProcessInterface*, G4BiasingAppliedCase,
G4VBiasingOperation*, G4double,
G4VBiasingOperation*, const G4VParticleChange* )
{}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VProcessPlacer.cc 77477 2013-11-25 09:42:24Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
+1 -1
View File
@@ -7,7 +7,7 @@
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010-09-29 18:51:51 bmorgan Exp $
# $Id: CMakeLists.txt 66892 2013-01-17 10:57:59Z gunter $
#
#------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.3 2003-09-19 14:49:21 gcosmo Exp $
# $Id: GNUmakefile 66892 2013-01-17 10:57:59Z gunter $
# --------------------------------------------------------------
# GNUmakefile for processes/decay library. G.Folger 9/12/97
# --------------------------------------------------------------
+41 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.36 2010-12-23 06:00:42 kurasige Exp $
$Id: History 77079 2013-11-21 10:32:34Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,46 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Nov. 21st, 2013 - H.Kurashige (procuts-V09-06-08)
- Fix Coverity defects in G4VRangeToEnergyConverter CTOR
July 21st, 2013 - H.Kurashige (procuts-V09-06-07)
- Fix the bug in G4ProductionCuts copy constructor
June 21st, 2013 - M.Asai (procuts-V09-06-06)
- G4ProductionCutstable: print out energy thresholds regardless of
G4MaterialCutsCouple::IsReCalcNeeded().
June 16th, 2013 - M.Asai (procuts-V09-06-05)
- G4VRangeToEnergyConverter: stop calling Reset() from its destructor.
June 5th, 2013 - V.Ivanchenko (procuts-V09-06-04)
G4VRangeToEnergyConverter: members LowestEnergy, HighestEnergy,
MaxEnergyCut become static and not G4ThreadLocal - this
is needed to fix FPE crash in MT mode; fixed all loops for
G4PhysicsLogVector - upper index is nbins+1
June 4th, 2013 - H.Kurashige (procuts-V09-06-03)
- Modify G4RToEConvForXXX to remove unnecessary static declaration
(Some static variables are moved to simple member of the class)
May. 30th, 2013 - G.Cosmo (procuts-V09-06-02)
- Added protection to initialisation of static data in
G4VRangeToEnergyConverter constructor.
NOTE: static data in G4VRangeToEnergyConverter should eventually NOT be
thread-local, as related modifiers should be called -only- at
initialisation phase (by physics-lists). This needs to be verified
so that thread-local specifications can be safely removed!
Is it also -bad- practice to have a -base- class like
G4VRangeToEnergyConverter containing static data that can be modified
through static methods, as these can be modified before the actual
constructor is called (as it is not a singleton)!! Needs to review
this as well!
May. 29th, 2013 - G.Cosmo (procuts-V09-06-01, procuts-V09-06-00)
- Cleanup from automatic MT changes in G4VRangeToEnergyConverter,
G4ProductionCuts and G4RToEConvForElectron.
Jul. 5th, 2012 - G.Cosmo (procuts-V09-05-04)
- Explicitly use inclusion of headers for system of units and physical
constants, in plan to remove implicit inclusion from globals.hh.
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4MCCIndexConversionTable.hh 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4MaterialCutsCouple.hh 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4PhysicsTableHelper.hh 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -84,20 +84,8 @@ class G4PhysicsTableHelper
protected:
static G4int verboseLevel;
static G4ThreadLocal G4int verboseLevel;
// controle flag for output message
};
inline
void G4PhysicsTableHelper::SetVerboseLevel(G4int value)
{
verboseLevel = value;
}
inline
G4int G4PhysicsTableHelper::GetVerboseLevel()
{
return verboseLevel;
}
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ProductionCuts.hh 70369 2013-05-29 14:59:24Z gcosmo $
// GEANT4 tag $Name: geant4-09-04-ref-00 $
//
//
@@ -114,11 +114,11 @@ class G4ProductionCuts
G4bool isModified;
private:
static const G4ParticleDefinition* gammaDef;
static const G4ParticleDefinition* electDef;
static const G4ParticleDefinition* positDef;
static G4ThreadLocal G4ParticleDefinition* gammaDef;
static G4ThreadLocal G4ParticleDefinition* electDef;
static G4ThreadLocal G4ParticleDefinition* positDef;
static const G4ParticleDefinition* protonDef; // for proton
static G4ThreadLocal G4ParticleDefinition* protonDef; // for proton
};
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ProductionCutsTable.hh 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ProductionCutsTableMessenger.hh 70369 2013-05-29 14:59:24Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4RToEConvForElectron.hh 70745 2013-06-05 10:54:00Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -61,9 +61,15 @@ class G4RToEConvForElectron : public G4VRangeToEnergyConverter
protected:
virtual G4double ComputeLoss(G4double AtomicNumber,
G4double KineticEnergy
) const;
) ;
protected:
G4double Mass;
G4double Z;
G4double taul;
G4double ionpot;
G4double ionpotlog;
G4double bremfactor;
};
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4RToEConvForGamma.hh 70745 2013-06-05 10:54:00Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -65,7 +65,7 @@ class G4RToEConvForGamma : public G4VRangeToEnergyConverter
protected:
virtual G4double ComputeLoss( G4double AtomicNumber,
G4double KineticEnergy
) const;
) ;
//-------------- Range Table ------------------------------------------
virtual void BuildRangeVector( const G4Material* aMaterial,
@@ -77,14 +77,19 @@ class G4RToEConvForGamma : public G4VRangeToEnergyConverter
G4double ComputeCrossSection( G4double AtomicNumber,
G4double KineticEnergy
) const;
);
G4double Z;
G4double s200keV, s1keV;
G4double tmin, tlow;
G4double smin, slow;
G4double cmin, clow, chigh;
};
inline
G4double G4RToEConvForGamma::ComputeLoss(G4double AtomicNumber,
G4double KineticEnergy) const
G4double KineticEnergy)
{
return ComputeCrossSection(AtomicNumber,KineticEnergy);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4RToEConvForPositron.hh 70745 2013-06-05 10:54:00Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -61,8 +61,15 @@ class G4RToEConvForPositron : public G4VRangeToEnergyConverter
protected:
virtual G4double ComputeLoss(G4double AtomicNumber,
G4double KineticEnergy
) const;
) ;
protected:
G4double Mass;
G4double Z;
G4double taul;
G4double ionpot;
G4double ionpotlog;
G4double bremfactor;
};
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4RToEConvForProton.hh 70745 2013-06-05 10:54:00Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -66,8 +66,18 @@ class G4RToEConvForProton : public G4VRangeToEnergyConverter
protected:
virtual G4double ComputeLoss(G4double AtomicNumber,
G4double KineticEnergy
) const;
) ;
protected:
G4double Mass;
G4double Z;
G4double tau0;
G4double taul;
G4double taum;
G4double ionpot;
G4double ca;
G4double cba;
G4double cc;
};
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VRangeToEnergyConverter.hh 70745 2013-06-05 10:54:00Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -106,6 +106,7 @@ class G4VRangeToEnergyConverter
virtual void Reset();
protected:
static G4double LowestEnergy, HighestEnergy;
static G4double MaxEnergyCut;
G4double fMaxEnergyCut;
@@ -123,7 +124,7 @@ class G4VRangeToEnergyConverter
virtual G4double ComputeLoss(G4double AtomicNumber,
G4double KineticEnergy
) const = 0;
) =0;
//-------------- Range Table ------------------------------------------
protected:
+1 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake,v 1.1 2010-09-29 18:52:00 bmorgan Exp $
# $Id: sources.cmake 66892 2013-01-17 10:57:59Z gunter $
#
#------------------------------------------------------------------------------
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4MCCIndexConversionTable.cc 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4MaterialCutsCouple.cc 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// --------------------------------------------------------------
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4PhysicsTableHelper.cc 70369 2013-05-29 14:59:24Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -41,7 +41,7 @@
#include "G4PhysicsTableHelper.hh"
#include "G4ProductionCutsTable.hh"
G4int G4PhysicsTableHelper::verboseLevel = 1;
G4ThreadLocal G4int G4PhysicsTableHelper::verboseLevel = 1;
G4PhysicsTableHelper::G4PhysicsTableHelper()
{
@@ -227,5 +227,15 @@ void G4PhysicsTableHelper::SetPhysicsVector(G4PhysicsTable* physTable,
}
void G4PhysicsTableHelper::SetVerboseLevel(G4int value)
{
verboseLevel = value;
}
G4int G4PhysicsTableHelper::GetVerboseLevel()
{
return verboseLevel;
}
+21 -17
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ProductionCuts.cc 73044 2013-08-15 09:44:11Z gcosmo $
// GEANT4 tag $Name: geant4-09-04-ref-00 $
//
//
@@ -37,10 +37,10 @@
#include "G4ProductionCutsTable.hh"
#include <iomanip>
const G4ParticleDefinition* G4ProductionCuts::gammaDef = 0;
const G4ParticleDefinition* G4ProductionCuts::electDef = 0;
const G4ParticleDefinition* G4ProductionCuts::positDef = 0;
const G4ParticleDefinition* G4ProductionCuts::protonDef = 0;
G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::gammaDef = 0;
G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::electDef = 0;
G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::positDef = 0;
G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::protonDef = 0;
G4ProductionCuts::G4ProductionCuts() :
isModified(true)
@@ -51,7 +51,11 @@ G4ProductionCuts::G4ProductionCuts() :
}
G4ProductionCuts::G4ProductionCuts(const G4ProductionCuts& right)
: isModified(true)
{
for (G4int i=0; i< NumberOfG4CutIndex; i++) {
fRangeCuts.push_back(0.0);
}
*this = right;
}
@@ -87,10 +91,10 @@ G4int G4ProductionCuts::operator!=(const G4ProductionCuts &right) const
G4int G4ProductionCuts::GetIndex(const G4String& name)
{
static G4String gamma("gamma");
static G4String electron("e-");
static G4String positron("e+");
static G4String proton("proton");
static const G4String gamma ("gamma");
static const G4String electron("e-");
static const G4String positron("e+");
static const G4String proton("proton");
G4int index;
if ( name == gamma ) { index = 0; }
@@ -107,16 +111,16 @@ G4int G4ProductionCuts::GetIndex(const G4ParticleDefinition* ptcl)
{
if(!ptcl) return -1;
// In the first call, pointers are set
if(gammaDef==0 && ptcl->GetParticleName()=="gamma") { gammaDef = ptcl; }
if(electDef==0 && ptcl->GetParticleName()=="e-") { electDef = ptcl; }
if(positDef==0 && ptcl->GetParticleName()=="e+") { positDef = ptcl; }
if(protonDef==0 && ptcl->GetParticleName()=="proton") { protonDef = ptcl; }
if(gammaDef==0 && ptcl->GetParticleName()=="gamma") { gammaDef = (G4ParticleDefinition*) ptcl; }
if(electDef==0 && ptcl->GetParticleName()=="e-") { electDef = (G4ParticleDefinition*) ptcl; }
if(positDef==0 && ptcl->GetParticleName()=="e+") { positDef = (G4ParticleDefinition*) ptcl; }
if(protonDef==0 && ptcl->GetParticleName()=="proton") { protonDef = (G4ParticleDefinition*) ptcl; }
G4int index;
if(ptcl==gammaDef) { index = 0; }
else if(ptcl==electDef) { index = 1; }
else if(ptcl==positDef) { index = 2; }
else if(ptcl==protonDef) { index = 3; }
if(ptcl==(const G4ParticleDefinition*) gammaDef) { index = 0; }
else if(ptcl==(const G4ParticleDefinition*) electDef) { index = 1; }
else if(ptcl==(const G4ParticleDefinition*) positDef) { index = 2; }
else if(ptcl==(const G4ParticleDefinition*) protonDef) { index = 3; }
else { index = -1; }
return index;

Some files were not shown because too many files have changed in this diff Show More