Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement modular biasing options #92

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
085a7cb
fail when process is not understood
lobis Dec 15, 2022
0201f6b
minor cleanup
lobis Dec 15, 2022
20efca0
add prototype for biasing example
lobis Dec 15, 2022
44f9015
Merge branch 'master' into lobis-gamma-biasing
lobis Feb 22, 2023
aef3b20
biasing templated based on example 4 (Geant4) compiles
lobis Feb 22, 2023
4d88650
working splitting in physics list
lobis Feb 22, 2023
df8707b
split only when pointing towards (0,0,0)
lobis Feb 22, 2023
0452254
attempt to integrate with TRestGeant4Metadata
lobis Feb 22, 2023
520aed1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 22, 2023
a5482df
attempt to fix pipeline failure
lobis Feb 22, 2023
2c66056
support for old biasing
lobis Feb 23, 2023
5165af1
update constructor order
lobis Feb 27, 2023
e61475a
update volume names
lobis Feb 27, 2023
5558ccc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2023
b6ac1aa
reduce number of backwards tracks
lobis Feb 27, 2023
961f86e
Merge remote-tracking branch 'origin/lobis-gamma-biasing' into lobis-…
lobis Feb 27, 2023
fb596cb
fix bad volume name
lobis Feb 27, 2023
fd1e9f8
fix bad volume name
lobis Feb 27, 2023
84a8605
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2023
7a63d7c
grouped biasing in a single header/src file
lobis Feb 27, 2023
00e56a1
fix merge conflicts
lobis Feb 27, 2023
1a9cc40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2023
ae79122
add generic "cosmic" distribution (power -2.7)
lobis Feb 27, 2023
ab45454
Merge remote-tracking branch 'origin/lobis-gamma-biasing' into lobis-…
lobis Feb 27, 2023
f687f58
add option to save kill volume energy
lobis Feb 27, 2023
3b897b1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2023
7245b17
working biasing example
lobis Feb 28, 2023
78bc24b
Merge remote-tracking branch 'origin/lobis-gamma-biasing' into lobis-…
lobis Feb 28, 2023
9acbf0f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions examples/13.IAXO/GammaBiasing.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<!--
Author: Luis Obis ([email protected])
-->

<restG4>
<TRestRun title="GammaBiasing">
<parameter name="experimentName" value="IAXO"/>
</TRestRun>

<TRestGeant4Metadata>
<parameter name="gdmlFile" value="geometry/setup.gdml"/>
<parameter name="seed" value="137"/>
<parameter name="nRequestedEntries" value="1"/>
<parameter name="saveAllEvents" value="false"/>

<generator type="cosmic">
<source particle="gamma">
<energy type="formula" name="cosmic" range="(1, 100)GeV"/>
<angular type="formula" name="Cos2" direction="(0,-1,0)" nPoints="1000"/>
</source>
</generator>

<detector>
<parameter name="maxStepSize" value="1mm"/>
<removeUnwantedTracks enabled="true" keepZeroEnergyTracks="true"/>

<volume name="gasVolume" sensitive="true" maxStepSize="0.05mm"/>
<volume name="^scintillatorVolume" sensitive="false" keepTracks="false" maxStepSize="0.5mm"/>
<volume name="^captureLayerVolume" sensitive="false" keepTracks="false" maxStepSize="0.05mm"/>
<volume name="shieldingVolume" sensitive="false" maxStepSize="5mm"/>
</detector>

<biasing type="split">
<volume name="shieldingVolume"/>
<parameter name="splittingFactor" value="2"/>
<parameter name="center" value="(0,0,0)mm"/>
</biasing>

</TRestGeant4Metadata>

<TRestGeant4PhysicsLists>
<parameter name="cutForGamma" value="1" units="mm"/>
<parameter name="cutForElectron" value="1" units="mm"/>
<parameter name="cutForPositron" value="1" units="mm"/>
<parameter name="cutForMuon" value="1" units="mm"/>
<parameter name="cutForNeutron" value="1" units="mm"/>

<parameter name="minEnergyRangeProductionCuts" value="1" units="keV"/>
<parameter name="maxEnergyRangeProductionCuts" value="1" units="GeV"/>

<physicsList name="G4EmLivermorePhysics">
<option name="pixe" value="false"/>
</physicsList>

<physicsList name="G4HadronElasticPhysicsHP"/>
<physicsList name="G4IonBinaryCascadePhysics"/>
<physicsList name="G4HadronPhysicsQGSP_BIC_HP"/>
<physicsList name="G4EmExtraPhysics"/>

<physicsList name="G4DecayPhysics"/>
<physicsList name="G4RadioactiveDecayPhysics"/>
<physicsList name="G4RadioactiveDecay">
<option name="ICM" value="true"/>
<option name="ARM" value="true"/>
</physicsList>

<physicsList name="G4NeutronTrackingCut"/>

</TRestGeant4PhysicsLists>
</restG4>
2 changes: 1 addition & 1 deletion examples/13.IAXO/Neutrons.rml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Author: Luis Obis ([email protected])
<volume name="gasVolume" sensitive="true" maxStepSize="0.05mm"/>
<volume name="^scintillatorVolume" sensitive="false" keepTracks="true" maxStepSize="0.5mm"/>
<volume name="^captureLayerVolume" sensitive="false" keepTracks="true" maxStepSize="0.05mm"/>
<volume name="ShieldingVolume" sensitive="false" maxStepSize="5mm"/>
<volume name="shieldingVolume" sensitive="false" maxStepSize="5mm"/>
</detector>
</TRestGeant4Metadata>

Expand Down
12 changes: 6 additions & 6 deletions examples/13.IAXO/geometry/setup.gdml
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
<materialref ref="G4_Galactic"/>
<solidref ref="detectorPipeInside"/>
</volume>
<assembly name="DetectorPipe">
<assembly name="detectorPipe">
<physvol name="detectorPipe">
<volumeref ref="detectorPipeVolume"/>
</physvol>
Expand All @@ -474,13 +474,13 @@
<position name="detectorPipeFilling.position" z="82.675" unit="mm"/>
</physvol>
</assembly>
<volume name="ShieldingVolume">
<volume name="shieldingVolume">
<materialref ref="G4_Pb"/>
<solidref ref="leadBoxWithShaftSolid"/>
</volume>
<assembly name="Shielding">
<assembly name="shielding">
<physvol name="shielding20cm">
<volumeref ref="ShieldingVolume"/>
<volumeref ref="shieldingVolume"/>
<position name="shielding20cm.position" z="29.5" unit="mm"/>
</physvol>
</assembly>
Expand Down Expand Up @@ -895,11 +895,11 @@
<volumeref ref="Chamber"/>
</physvol>
<physvol name="DetectorPipe">
<volumeref ref="DetectorPipe"/>
<volumeref ref="detectorPipe"/>
<position name="DetectorPipe.position" z="27.0" unit="mm"/>
</physvol>
<physvol name="Shielding">
<volumeref ref="Shielding"/>
<volumeref ref="shielding"/>
</physvol>
<physvol name="VetoSystem">
<volumeref ref="assembly-3"/>
Expand Down
69 changes: 69 additions & 0 deletions examples/15.GammaBiasing/ShieldingBiasing.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<!--
Author: Luis Obis ([email protected])
-->

<restG4>
<TRestRun title="ShieldingBiasing">
<parameter name="experimentName" value="IAXO"/>
</TRestRun>

<TRestGeant4Metadata>
<parameter name="gdmlFile" value="geometry/setup.gdml"/>
<parameter name="seed" value="137"/>
<parameter name="saveAllEvents" value="false"/>

<biasing type="split">
<volume name="shieldingVolume"/>
<parameter name="splittingFactor" value="2"/>
<parameter name="center" value="(0,0,0)mm"/>
</biasing>

<generator type="point" position="(0,0,-100)" units="mm">
<source particle="gamma">
<energy type="mono" energy="10.0" units="MeV"/>
<angular type="flux" direction="(0,0,1)"/>
</source>
</generator>

<detector>
<parameter name="maxStepSize" value="1mm"/>
<removeUnwantedTracks enabled="true" keepZeroEnergyTracks="true"/>

<volume name="target" sensitive="true" kill="true" maxStepSize="0.05mm"/>

</detector>

</TRestGeant4Metadata>

<TRestGeant4PhysicsLists>
<parameter name="cutForGamma" value="1" units="mm"/>
<parameter name="cutForElectron" value="1" units="mm"/>
<parameter name="cutForPositron" value="1" units="mm"/>
<parameter name="cutForMuon" value="1" units="mm"/>
<parameter name="cutForNeutron" value="1" units="mm"/>

<parameter name="minEnergyRangeProductionCuts" value="1" units="keV"/>
<parameter name="maxEnergyRangeProductionCuts" value="1" units="GeV"/>

<physicsList name="G4EmLivermorePhysics">
<option name="pixe" value="false"/>
</physicsList>

<physicsList name="G4HadronElasticPhysicsHP"/>
<physicsList name="G4IonBinaryCascadePhysics"/>
<physicsList name="G4HadronPhysicsQGSP_BIC_HP"/>
<physicsList name="G4EmExtraPhysics"/>

<physicsList name="G4DecayPhysics"/>
<physicsList name="G4RadioactiveDecayPhysics"/>
<physicsList name="G4RadioactiveDecay">
<option name="ICM" value="true"/>
<option name="ARM" value="true"/>
</physicsList>

<physicsList name="G4NeutronTrackingCut"/>

</TRestGeant4PhysicsLists>
</restG4>
77 changes: 77 additions & 0 deletions examples/15.GammaBiasing/geometry/setup.gdml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!-- ##VERSION REST Example 01.NLDBD Version 1.0## -->

<!DOCTYPE gdml [
<!ENTITY materials SYSTEM "https://rest-for-physics.github.io/materials/rest.xml">
]>

<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">

<!-- Just an example of main geometry file : myGeometryTemplate.gdml
This file just defines de parameters of the geometry.
The geometry it is defined in geometry/myGeometryDefinition.gdml
The materials are defined in geometry/materials.xml
Author : J. Galan Date : 09-Jul-2015
-->

<!-- All values should be in mm -->

<define>
<constant name="world_size" value="2000"/>

<variable name="shieldingThickness" value="200"/>
<variable name="shieldingSide" value="1000"/>

<!-- This should not be required because it's not relevant -->
<variable name="targetGasDensity" value="1.78"/> <!-- mg/cm3 -->
<variable name="quencherDensity" value="2.51*0.01"/> <!-- mg/cm3 -->
<variable name="quencherFraction" value="0.01"/>
<variable name="gasTemperature" value="300"/>
<variable name="gasPressure" value="1"/>

</define>

&materials;

<solids>
<box name="WorldSolid" x="world_size" y="world_size" z="world_size" lunit="mm"/>
<box name="shieldingSolid" x="shieldingSide" y="shieldingSide" z="shieldingThickness" lunit="mm"/>
<box name="targetSolid" x="shieldingSide / 2" y="shieldingSide / 2" z="shieldingThickness / 2" lunit="mm"/>

</solids>

<structure>

<volume name="targetVolume">
<materialref ref="Lead"/>
<solidref ref="targetSolid"/>
</volume>

<volume name="shieldingVolume">
<materialref ref="Lead"/>
<solidref ref="shieldingSolid"/>
</volume>

<volume name="World">
<materialref ref="Vacuum"/>
<solidref ref="WorldSolid"/>

<physvol name="target">
<volumeref ref="targetVolume"/>
<position name="targetPosition" unit="mm" x="0" y="0" z="2 * shieldingThickness"/>
</physvol>

<physvol name="shielding">
<volumeref ref="shieldingVolume"/>
<position name="shieldingPosition" unit="mm" x="0" y="0" z="1 * shieldingThickness"/>
</physvol>
</volume>

</structure>

<setup name="Default" version="1.0">
<world ref="World"/>
</setup>

</gdml>
80 changes: 80 additions & 0 deletions include/Biasing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

#ifndef REST_BIASING_H
#define REST_BIASING_H

#include <TVector3.h>

#include <G4BiasingProcessInterface.hh>
#include <G4ParticleChange.hh>
#include <G4VBiasingOperation.hh>
#include <G4VBiasingOperator.hh>

class GammaBiasingOperation : public G4VBiasingOperation {
public:
GammaBiasingOperation(const G4String& name, G4int splittingFactor, const TVector3& biasingCenter);

virtual ~GammaBiasingOperation();

public:
virtual const G4VBiasingInteractionLaw* ProvideOccurenceBiasingInteractionLaw(
const G4BiasingProcessInterface*, G4ForceCondition&) {
return 0;
}

virtual G4VParticleChange* ApplyFinalStateBiasing(const G4BiasingProcessInterface*, const G4Track*,
const G4Step*, G4bool&);

virtual G4double DistanceToApplyOperation(const G4Track*, G4double, G4ForceCondition*) { return DBL_MAX; }

virtual G4VParticleChange* GenerateBiasingFinalState(const G4Track*, const G4Step*) { return 0; }

public:
void SetSplittingFactor(G4int splittingFactor) { fSplittingFactor = splittingFactor; }

G4int GetSplittingFactor() const { return fSplittingFactor; }

private:
G4int fSplittingFactor;
G4ParticleChange fParticleChange;
TVector3 fBiasingCenter;
};

class GammaBiasingOperator : public G4VBiasingOperator {
public:
GammaBiasingOperator(int splittingFactor, bool biasOnlyOnce, const TVector3& biasingCenter);

virtual ~GammaBiasingOperator() {}

public:
virtual void StartRun();

virtual void StartTracking(const G4Track* track);

TVector3 GetBiasingCenter() const { return fBiasingCenter; }

private:
virtual G4VBiasingOperation* ProposeNonPhysicsBiasingOperation(const G4Track*,
const G4BiasingProcessInterface*) {
return 0;
}

virtual G4VBiasingOperation* ProposeOccurenceBiasingOperation(const G4Track*,
const G4BiasingProcessInterface*) {
return 0;
}

virtual G4VBiasingOperation* ProposeFinalStateBiasingOperation(
const G4Track* track, const G4BiasingProcessInterface* callingProcess);

private:
using G4VBiasingOperator::OperationApplied;

private:
GammaBiasingOperation* fBremSplittingOperation;
G4int fSplittingFactor;
G4bool fBiasOnlyOnce;
G4int fNInteractions;
TVector3 fBiasingCenter;
};

#endif // REST_BIASING_H
8 changes: 8 additions & 0 deletions include/PhysicsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@

#include "SimulationManager.h"

class G4GenericBiasingPhysics;

class PhysicsList : public G4VModularPhysicsList {
public:
PhysicsList() = delete;

explicit PhysicsList(SimulationManager* simulationManager, TRestGeant4PhysicsLists* restPhysicsLists);

~PhysicsList() override;

protected:
// Construct particle and physics
virtual void InitializePhysicsLists();

void ConstructParticle() override;

void ConstructProcess() override;

void SetCuts() override;

private:
Expand All @@ -36,6 +42,8 @@ class PhysicsList : public G4VModularPhysicsList {
G4VPhysicsConstructor* fRadDecPhysicsList = nullptr;
std::vector<G4VPhysicsConstructor*> fHadronPhys;

G4GenericBiasingPhysics* fBiasingPhysicsList = nullptr;

TRestGeant4PhysicsLists* fRestPhysicsLists = nullptr;
};

Expand Down
1 change: 0 additions & 1 deletion include/TrackingAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class SimulationManager;
class TrackingAction : public G4UserTrackingAction {
public:
TrackingAction(SimulationManager*);
~TrackingAction();

virtual void PreUserTrackingAction(const G4Track*);
virtual void PostUserTrackingAction(const G4Track*);
Expand Down
Loading