From ba7582125fbb9c5a66323dc06ce2b4b4d80229ad Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Sat, 16 May 2020 17:33:39 +0200 Subject: [PATCH 1/9] Introduce rock in NextTonScale geometry --- source/geometries/NextTonScale.cc | 59 ++++++++++++++++++++++++++++--- source/geometries/NextTonScale.h | 2 ++ source/materials/MaterialsList.cc | 15 ++++++++ source/materials/MaterialsList.h | 3 ++ 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/source/geometries/NextTonScale.cc b/source/geometries/NextTonScale.cc index 79b062c058..632da26624 100644 --- a/source/geometries/NextTonScale.cc +++ b/source/geometries/NextTonScale.cc @@ -33,6 +33,7 @@ NextTonScale::NextTonScale(): msg_(nullptr), gas_("naturalXe"), gas_pressure_(15.*bar), gas_temperature_(300.*kelvin), detector_diam_(0.), detector_length_(0.), + rock_thickn_(2.*m), rock_diam_(0.), tank_size_(0.), tank_thickn_(1.*cm), water_thickn_(3.*m), vessel_thickn_(1.5*mm), ics_thickn_(12.*cm), endcap_hollow_(20.*cm), fcage_thickn_(1.*cm), @@ -73,12 +74,13 @@ void NextTonScale::Construct() 2.*ics_thickn_ + 2.*endcap_hollow_ + 2.*vessel_thickn_; tank_size_ = std::max(detector_diam_, detector_length_) + 2.*water_thickn_ + 2.*tank_thickn_; + rock_diam_ = tank_size_ + 2. * cm + 2. * rock_thickn_; // LABORATORY //////////////////////////////////////////// // Volume of air that contains all other detector volumes. G4String lab_name = "LABORATORY"; - G4double lab_size = tank_size_ + 4.*m; // Clearance of 2 m around water tank + G4double lab_size = rock_diam_ + 4.*m; // Clearance of 2 m around water tank and rock G4Material* lab_material = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"); @@ -96,12 +98,53 @@ void NextTonScale::Construct() G4LogicalVolume* mother_logic_vol = lab_logic_vol; + mother_logic_vol = ConstructLabRock(mother_logic_vol); mother_logic_vol = ConstructWaterTank(mother_logic_vol); mother_logic_vol = ConstructVesselAndICS(mother_logic_vol); mother_logic_vol = ConstructFieldCageAndReadout(mother_logic_vol); } +G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vol) +{ + // Lab rock // + // Tube of rock (Standard or G4_CONCRETE) with additional cylinder above tank + G4String top_rock_name = "LAB_ROCK_TOP"; + G4String side_rock_name = "LAB_ROCK_SURROUND"; + G4Material* rock_material = + G4NistManager::Instance()->FindOrBuildMaterial("G4_CONCRETE"); + + G4Tubs* top_rock_solid = + new G4Tubs(top_rock_name, 0, rock_diam_ / 2., + rock_thickn_ / 2., 0., 360. * deg); + G4double side_rock_height = tank_size_ + 1. * cm; + G4double side_rock_inner_diam = tank_size_ + 2. * cm; + G4Tubs* side_rock_solid = + new G4Tubs(side_rock_name, side_rock_inner_diam / 2., rock_diam_ / 2., + side_rock_height / 2., 0., 360. * deg); + + G4LogicalVolume* top_rock_logic = + new G4LogicalVolume(top_rock_solid, rock_material, top_rock_name); + + G4LogicalVolume* side_rock_logic = + new G4LogicalVolume(side_rock_solid, rock_material, side_rock_name); + + G4RotationMatrix* rock_rotation = new G4RotationMatrix(); + rock_rotation->rotateX(90. * deg); + G4double top_rock_y = tank_size_ / 2. + 1.*cm + rock_thickn_ / 2; + G4ThreeVector top_rock_pos(0., top_rock_y, 0.); + new G4PVPlacement(rock_rotation, top_rock_pos, top_rock_logic, + top_rock_name, mother_logic_vol, false, 0, true); + + G4double side_rock_y = 0.5 * cm; + new G4PVPlacement(rock_rotation, G4ThreeVector(0., side_rock_y, 0.), + side_rock_logic, side_rock_name, mother_logic_vol, + false, 0, true); + + return mother_logic_vol; +} + + G4LogicalVolume* NextTonScale::ConstructWaterTank(G4LogicalVolume* mother_logic_vol) { // WATER TANK //////////////////////////////////////////// @@ -146,9 +189,10 @@ G4LogicalVolume* NextTonScale::ConstructWaterTank(G4LogicalVolume* mother_logic_ ////////////////////////////////////////////////////////// - muon_gen_ = new MuonsPointSampler(tank_size_/2. + 50. * cm, - tank_size_/2. + 1. * cm, - tank_size_/2. + 50. * cm); + G4double mu_gen_x = rock_diam_ / 2.; + G4double mu_gen_y = tank_size_/2. + rock_thickn_ + 2. * cm; + G4double mu_gen_z = rock_diam_ / 2.; + muon_gen_ = new MuonsPointSampler(mu_gen_x, mu_gen_y, mu_gen_z, true); // Primarily for neutron generation external_gen_ = new CylinderPointSampler(tank_size_/2. + 1 * cm, @@ -482,6 +526,13 @@ void NextTonScale::DefineConfigurationParameters() gas_temperature_cmd.SetParameterName("gas_temperature", false); gas_temperature_cmd.SetRange("gas_temperature>0."); + G4GenericMessenger::Command& rock_thickn_cmd = + msg_->DeclareProperty("rock_thickness", rock_thickn_, + "Thickness of surrounding rock to simulate."); + rock_thickn_cmd.SetUnitCategory("Length"); + rock_thickn_cmd.SetParameterName("rock_thickness", false); + rock_thickn_cmd.SetRange("rock_thickness>=0."); + G4GenericMessenger::Command& active_diam_cmd = msg_->DeclareProperty("active_diam", active_diam_, "Diameter of the active diameter of the detector."); diff --git a/source/geometries/NextTonScale.h b/source/geometries/NextTonScale.h index feb02de7dc..e56ede13db 100644 --- a/source/geometries/NextTonScale.h +++ b/source/geometries/NextTonScale.h @@ -34,6 +34,7 @@ namespace nexus { private: // + G4LogicalVolume* ConstructLabRock(G4LogicalVolume*); G4LogicalVolume* ConstructWaterTank(G4LogicalVolume*); G4LogicalVolume* ConstructVesselAndICS(G4LogicalVolume*); G4LogicalVolume* ConstructFieldCageAndReadout(G4LogicalVolume*); @@ -50,6 +51,7 @@ namespace nexus { G4String gas_; G4double gas_pressure_, gas_temperature_; G4double detector_diam_, detector_length_; + G4double rock_thickn_, rock_diam_; G4double tank_size_, tank_thickn_, water_thickn_; G4double vessel_thickn_, ics_thickn_, endcap_hollow_; G4double fcage_thickn_, active_diam_, active_length_; diff --git a/source/materials/MaterialsList.cc b/source/materials/MaterialsList.cc index 7a31d6205f..05a0056cda 100644 --- a/source/materials/MaterialsList.cc +++ b/source/materials/MaterialsList.cc @@ -265,6 +265,21 @@ G4Material* MaterialsList::GXeHe(G4double pressure, } +G4Material* MaterialsList::StandardRock(){ + + G4String name = "StandRock"; + + G4Material* mat = G4Material::GetMaterial(name, false); + + if (mat == 0){ + G4double Z = 11; + G4double A = 22; + G4double rho = 2.65 * g / cm3; + mat = new G4Material(name, Z, A, rho, kStateSolid); + } + return mat; +} + diff --git a/source/materials/MaterialsList.h b/source/materials/MaterialsList.h index 83557c1583..ab38eef3d7 100644 --- a/source/materials/MaterialsList.h +++ b/source/materials/MaterialsList.h @@ -134,6 +134,9 @@ namespace nexus { static G4Material* CopyMaterial(G4Material*, const G4String&); + // Standard rock + static G4Material* StandardRock(); + private: /// Constructor (hidden) MaterialsList(); From 384df70eccf1c7cb5285353adbc38220997b0643 Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Tue, 2 Jun 2020 16:17:30 +0200 Subject: [PATCH 2/9] Integrated member name changes --- source/utils/MuonsPointSampler.cc | 10 ++++++++-- source/utils/MuonsPointSampler.h | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/utils/MuonsPointSampler.cc b/source/utils/MuonsPointSampler.cc index a34cc8e53d..cfda8c680e 100644 --- a/source/utils/MuonsPointSampler.cc +++ b/source/utils/MuonsPointSampler.cc @@ -21,8 +21,8 @@ namespace nexus { using namespace CLHEP; MuonsPointSampler::MuonsPointSampler - (G4double x, G4double yPoint, G4double z): - x_(x),yPoint_(yPoint),z_(z) + (G4double x, G4double yPoint, G4double z, G4bool disc): + x_(x),yPoint_(yPoint),z_(z),disc_(disc) { } @@ -42,6 +42,12 @@ namespace nexus { // y is fixed G4double x = -x_ + G4UniformRand()*2*x_; G4double z = -z_ + G4UniformRand()*2*z_; + if (_disc){ + while (x*x / (x_*x_) + z*z / (z_*z_) > 1){ + x = -x_ + G4UniformRand()*2*x_; + z = -z_ + G4UniformRand()*2*z_; + } + } G4ThreeVector mypoint(x, yPoint_, z); diff --git a/source/utils/MuonsPointSampler.h b/source/utils/MuonsPointSampler.h index a2dc8fd129..f93bc68829 100644 --- a/source/utils/MuonsPointSampler.h +++ b/source/utils/MuonsPointSampler.h @@ -20,8 +20,7 @@ namespace nexus { public: /// Constructor - MuonsPointSampler(G4double x, G4double yPoint, G4double z); - + MuonsPointSampler(G4double x, G4double yPoint, G4double z, G4bool disc=false); /// Destructor ~MuonsPointSampler(); @@ -37,6 +36,7 @@ namespace nexus { G4ThreeVector GetXZPointInMuonsPlane(); G4double x_, yPoint_,z_; + G4bool disc_; }; From 2c9e3a81897aaccd2aa54dda020195a9bad81b44 Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Mon, 1 Jun 2020 12:49:30 +0200 Subject: [PATCH 3/9] No Save event action added for tests --- source/actions/NoSaveEventAction.cc | 37 +++++++++++++++++++++++++++++ source/actions/NoSaveEventAction.h | 32 +++++++++++++++++++++++++ source/base/ActionsFactory.cc | 2 ++ source/geometries/NextTonScale.cc | 31 ++++++++++++++++++------ 4 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 source/actions/NoSaveEventAction.cc create mode 100644 source/actions/NoSaveEventAction.h diff --git a/source/actions/NoSaveEventAction.cc b/source/actions/NoSaveEventAction.cc new file mode 100644 index 0000000000..e9a54f63c3 --- /dev/null +++ b/source/actions/NoSaveEventAction.cc @@ -0,0 +1,37 @@ +#include "NoSaveEventAction.h" + +#include "PersistencyManager.h" + +#include +#include +#include + + +namespace nexus { + + + NoSaveEventAction::NoSaveEventAction(): + G4UserEventAction() + { + + } + + + + NoSaveEventAction::~NoSaveEventAction() + { + } + + + + void NoSaveEventAction::BeginOfEventAction(const G4Event* /*event*/) + { + PersistencyManager* pm = dynamic_cast + (G4VPersistencyManager::GetPersistencyManager()); + pm->StoreCurrentEvent(false); + } + + void NoSaveEventAction::EndOfEventAction(const G4Event* event) + { + } +} diff --git a/source/actions/NoSaveEventAction.h b/source/actions/NoSaveEventAction.h new file mode 100644 index 0000000000..7a85ee7068 --- /dev/null +++ b/source/actions/NoSaveEventAction.h @@ -0,0 +1,32 @@ +#ifndef __NOSAVE_EVENT_ACTION__ +#define __NOSAVE_EVENT_ACTION__ + +#include +#include + +class G4Event; +class G4GenericMessenger; + +namespace nexus { + + /// This class is a general-purpose event action, where all events are stored, not only + /// those that deposit some energy in the active volume. It is used mainly for EL table production + + class NoSaveEventAction: public G4UserEventAction + { + public: + /// Constructor + NoSaveEventAction(); + /// Destructor + ~NoSaveEventAction(); + + /// Hook at the beginning of the event loop + void BeginOfEventAction(const G4Event*); + /// Hook at the end of the event loop + void EndOfEventAction(const G4Event*); + + }; + +} // namespace nexus + +#endif diff --git a/source/base/ActionsFactory.cc b/source/base/ActionsFactory.cc index 0e31107614..9b6a3ab854 100644 --- a/source/base/ActionsFactory.cc +++ b/source/base/ActionsFactory.cc @@ -58,6 +58,7 @@ G4UserRunAction* ActionsFactory::CreateRunAction() const #include "DefaultEventAction.h" #include "SaveAllEventAction.h" #include "MuonsEventAction.h" +#include "NoSaveEventAction.h" G4UserEventAction* ActionsFactory::CreateEventAction() const { @@ -69,6 +70,7 @@ G4UserEventAction* ActionsFactory::CreateEventAction() const else if (evtact_name_ == "MUONS") p = new MuonsEventAction(); + else if (_evtact_name == "NoSave") p = new NoSaveEventAction(); else { G4String err = "Unknown user event action: " + evtact_name_; G4Exception("[ActionsFactory]", "CreateEventAction()", JustWarning, err); diff --git a/source/geometries/NextTonScale.cc b/source/geometries/NextTonScale.cc index 632da26624..ef6a619c64 100644 --- a/source/geometries/NextTonScale.cc +++ b/source/geometries/NextTonScale.cc @@ -74,13 +74,13 @@ void NextTonScale::Construct() 2.*ics_thickn_ + 2.*endcap_hollow_ + 2.*vessel_thickn_; tank_size_ = std::max(detector_diam_, detector_length_) + 2.*water_thickn_ + 2.*tank_thickn_; - rock_diam_ = tank_size_ + 2. * cm + 2. * rock_thickn_; + rock_diam_ = tank_size_ + 2. * cm + std::min(2. * rock_thickn_, 2. *m); // LABORATORY //////////////////////////////////////////// // Volume of air that contains all other detector volumes. G4String lab_name = "LABORATORY"; - G4double lab_size = rock_diam_ + 4.*m; // Clearance of 2 m around water tank and rock + G4double lab_size = rock_diam_ + 6.*m; // Clearance of 2 m around water tank and rock G4Material* lab_material = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"); @@ -111,8 +111,9 @@ G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vo // Tube of rock (Standard or G4_CONCRETE) with additional cylinder above tank G4String top_rock_name = "LAB_ROCK_TOP"; G4String side_rock_name = "LAB_ROCK_SURROUND"; - G4Material* rock_material = - G4NistManager::Instance()->FindOrBuildMaterial("G4_CONCRETE"); + // G4Material* rock_material = + // G4NistManager::Instance()->FindOrBuildMaterial("G4_CONCRETE"); + G4Material* rock_material = MaterialsList::StandardRock(); G4Tubs* top_rock_solid = new G4Tubs(top_rock_name, 0, rock_diam_ / 2., @@ -121,7 +122,7 @@ G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vo G4double side_rock_inner_diam = tank_size_ + 2. * cm; G4Tubs* side_rock_solid = new G4Tubs(side_rock_name, side_rock_inner_diam / 2., rock_diam_ / 2., - side_rock_height / 2., 0., 360. * deg); + side_rock_height / 2., 0., 360. * deg); G4LogicalVolume* top_rock_logic = new G4LogicalVolume(top_rock_solid, rock_material, top_rock_name); @@ -138,8 +139,24 @@ G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vo G4double side_rock_y = 0.5 * cm; new G4PVPlacement(rock_rotation, G4ThreeVector(0., side_rock_y, 0.), - side_rock_logic, side_rock_name, mother_logic_vol, - false, 0, true); + side_rock_logic, side_rock_name, mother_logic_vol, + false, 0, true); + + G4Tubs *tempLab = new G4Tubs("LAB_INNER", 0, tank_size_ / 2., 1 * cm / 2., + 0, 360. * deg); + G4LogicalVolume* tempLab_logic = + new G4LogicalVolume(tempLab, G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"), "LAB_INNER"); + G4ThreeVector tempPos(0., tank_size_ / 2. + 0.5*cm, 0.); + new G4PVPlacement(rock_rotation, tempPos, tempLab_logic, + "LAB_INNER", mother_logic_vol, false, 0, true); + + G4Tubs *temp2Lab = new G4Tubs("LAB_INNER_SIDE", tank_size_ / 2., + side_rock_inner_diam / 2., tank_size_ / 2., + 0, 360. * deg); + G4LogicalVolume* temp2Lab_logic = + new G4LogicalVolume(temp2Lab, G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"), "LAB_INNER_SIDE"); + new G4PVPlacement(rock_rotation, G4ThreeVector(0.,0.,0.), temp2Lab_logic, + "LAB_INNER_SIDE", mother_logic_vol, false, 0, true); return mother_logic_vol; } From 101d0c68aefb070d01cce7ef4c8f171ae9bb449f Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Thu, 28 May 2020 10:00:32 +0200 Subject: [PATCH 4/9] Add region for rock to limit complexity of tracking --- source/geometries/NextTonScale.cc | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/source/geometries/NextTonScale.cc b/source/geometries/NextTonScale.cc index ef6a619c64..02bb5a006f 100644 --- a/source/geometries/NextTonScale.cc +++ b/source/geometries/NextTonScale.cc @@ -24,6 +24,8 @@ #include #include #include +#include +#include using namespace nexus; @@ -74,7 +76,7 @@ void NextTonScale::Construct() 2.*ics_thickn_ + 2.*endcap_hollow_ + 2.*vessel_thickn_; tank_size_ = std::max(detector_diam_, detector_length_) + 2.*water_thickn_ + 2.*tank_thickn_; - rock_diam_ = tank_size_ + 2. * cm + std::min(2. * rock_thickn_, 2. *m); + rock_diam_ = tank_size_ + 2. * cm + 2. *m; // LABORATORY //////////////////////////////////////////// // Volume of air that contains all other detector volumes. @@ -111,8 +113,6 @@ G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vo // Tube of rock (Standard or G4_CONCRETE) with additional cylinder above tank G4String top_rock_name = "LAB_ROCK_TOP"; G4String side_rock_name = "LAB_ROCK_SURROUND"; - // G4Material* rock_material = - // G4NistManager::Instance()->FindOrBuildMaterial("G4_CONCRETE"); G4Material* rock_material = MaterialsList::StandardRock(); G4Tubs* top_rock_solid = @@ -124,11 +124,17 @@ G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vo new G4Tubs(side_rock_name, side_rock_inner_diam / 2., rock_diam_ / 2., side_rock_height / 2., 0., 360. * deg); + G4Region *rock_region = new G4Region("LAB_ROCK"); + G4ProductionCuts *rock_prod_cut = new G4ProductionCuts(); + rock_prod_cut->SetProductionCut(50. * cm); G4LogicalVolume* top_rock_logic = new G4LogicalVolume(top_rock_solid, rock_material, top_rock_name); + rock_region->AddRootLogicalVolume(top_rock_logic); G4LogicalVolume* side_rock_logic = new G4LogicalVolume(side_rock_solid, rock_material, side_rock_name); + rock_region->AddRootLogicalVolume(side_rock_logic); + rock_region->SetProductionCuts(rock_prod_cut); G4RotationMatrix* rock_rotation = new G4RotationMatrix(); rock_rotation->rotateX(90. * deg); @@ -141,23 +147,6 @@ G4LogicalVolume* NextTonScale::ConstructLabRock(G4LogicalVolume* mother_logic_vo new G4PVPlacement(rock_rotation, G4ThreeVector(0., side_rock_y, 0.), side_rock_logic, side_rock_name, mother_logic_vol, false, 0, true); - - G4Tubs *tempLab = new G4Tubs("LAB_INNER", 0, tank_size_ / 2., 1 * cm / 2., - 0, 360. * deg); - G4LogicalVolume* tempLab_logic = - new G4LogicalVolume(tempLab, G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"), "LAB_INNER"); - G4ThreeVector tempPos(0., tank_size_ / 2. + 0.5*cm, 0.); - new G4PVPlacement(rock_rotation, tempPos, tempLab_logic, - "LAB_INNER", mother_logic_vol, false, 0, true); - - G4Tubs *temp2Lab = new G4Tubs("LAB_INNER_SIDE", tank_size_ / 2., - side_rock_inner_diam / 2., tank_size_ / 2., - 0, 360. * deg); - G4LogicalVolume* temp2Lab_logic = - new G4LogicalVolume(temp2Lab, G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"), "LAB_INNER_SIDE"); - new G4PVPlacement(rock_rotation, G4ThreeVector(0.,0.,0.), temp2Lab_logic, - "LAB_INNER_SIDE", mother_logic_vol, false, 0, true); - return mother_logic_vol; } From d2b567fba811ec859053f62e03dc44e9259ae57b Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Tue, 2 Jun 2020 16:42:59 +0200 Subject: [PATCH 5/9] Fixes post rebase --- source/base/ActionsFactory.cc | 2 +- source/utils/MuonsPointSampler.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/base/ActionsFactory.cc b/source/base/ActionsFactory.cc index 9b6a3ab854..3a912d71a1 100644 --- a/source/base/ActionsFactory.cc +++ b/source/base/ActionsFactory.cc @@ -70,7 +70,7 @@ G4UserEventAction* ActionsFactory::CreateEventAction() const else if (evtact_name_ == "MUONS") p = new MuonsEventAction(); - else if (_evtact_name == "NoSave") p = new NoSaveEventAction(); + else if (evtact_name_ == "NoSave") p = new NoSaveEventAction(); else { G4String err = "Unknown user event action: " + evtact_name_; G4Exception("[ActionsFactory]", "CreateEventAction()", JustWarning, err); diff --git a/source/utils/MuonsPointSampler.cc b/source/utils/MuonsPointSampler.cc index cfda8c680e..975e440363 100644 --- a/source/utils/MuonsPointSampler.cc +++ b/source/utils/MuonsPointSampler.cc @@ -42,7 +42,7 @@ namespace nexus { // y is fixed G4double x = -x_ + G4UniformRand()*2*x_; G4double z = -z_ + G4UniformRand()*2*z_; - if (_disc){ + if (disc_){ while (x*x / (x_*x_) + z*z / (z_*z_) > 1){ x = -x_ + G4UniformRand()*2*x_; z = -z_ + G4UniformRand()*2*z_; From 0882ac344dd6806b96214d922a45769d6d1c813e Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Wed, 3 Jun 2020 10:45:32 +0200 Subject: [PATCH 6/9] Updated NoSaveEventAction for new nexus coding conventions --- source/actions/NoSaveEventAction.cc | 2 -- source/actions/NoSaveEventAction.h | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/actions/NoSaveEventAction.cc b/source/actions/NoSaveEventAction.cc index e9a54f63c3..47f75c494c 100644 --- a/source/actions/NoSaveEventAction.cc +++ b/source/actions/NoSaveEventAction.cc @@ -3,8 +3,6 @@ #include "PersistencyManager.h" #include -#include -#include namespace nexus { diff --git a/source/actions/NoSaveEventAction.h b/source/actions/NoSaveEventAction.h index 7a85ee7068..ca95cedca9 100644 --- a/source/actions/NoSaveEventAction.h +++ b/source/actions/NoSaveEventAction.h @@ -1,16 +1,23 @@ -#ifndef __NOSAVE_EVENT_ACTION__ -#define __NOSAVE_EVENT_ACTION__ +// ---------------------------------------------------------------------------- +// nexus | NoSaveEventAction.h +// +// This event action saves no event information to file +// +// The NEXT Collaboration +// ---------------------------------------------------------------------------- + +#ifndef NOSAVE_EVENT_ACTION_H +#define NOSAVE_EVENT_ACTION_H #include #include class G4Event; -class G4GenericMessenger; namespace nexus { - /// This class is a general-purpose event action, where all events are stored, not only - /// those that deposit some energy in the active volume. It is used mainly for EL table production + /// This class is an Event Action which forces nexus + /// Not to store any event information class NoSaveEventAction: public G4UserEventAction { From fed63cb3ec7b65bf2d582a2911b1897893a423b0 Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Wed, 3 Jun 2020 10:46:56 +0200 Subject: [PATCH 7/9] Change NoSaveEventAction option to all capital --- source/base/ActionsFactory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/base/ActionsFactory.cc b/source/base/ActionsFactory.cc index 3a912d71a1..a5d8637552 100644 --- a/source/base/ActionsFactory.cc +++ b/source/base/ActionsFactory.cc @@ -70,7 +70,7 @@ G4UserEventAction* ActionsFactory::CreateEventAction() const else if (evtact_name_ == "MUONS") p = new MuonsEventAction(); - else if (evtact_name_ == "NoSave") p = new NoSaveEventAction(); + else if (evtact_name_ == "NO_SAVE") p = new NoSaveEventAction(); else { G4String err = "Unknown user event action: " + evtact_name_; G4Exception("[ActionsFactory]", "CreateEventAction()", JustWarning, err); From aa7f81b46f1a3af12a996988265e7d1de7865b61 Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Wed, 3 Jun 2020 10:49:23 +0200 Subject: [PATCH 8/9] Change StandRock material name to StandardRock --- source/materials/MaterialsList.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/materials/MaterialsList.cc b/source/materials/MaterialsList.cc index 05a0056cda..e483900ab4 100644 --- a/source/materials/MaterialsList.cc +++ b/source/materials/MaterialsList.cc @@ -267,7 +267,7 @@ G4Material* MaterialsList::GXeHe(G4double pressure, G4Material* MaterialsList::StandardRock(){ - G4String name = "StandRock"; + G4String name = "StandardRock"; G4Material* mat = G4Material::GetMaterial(name, false); From beea687de190fd714ee75b4156b9467899f33a0e Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Fri, 5 Jun 2020 13:22:26 +0200 Subject: [PATCH 9/9] Add LowMemoryTrackingAction Allows for runs where only primaries, neutrons and ions are saved to disc. Reduces memory usage for Muon runs. --- source/actions/LowMemoryTrackingAction.cc | 98 +++++++++++++++++++++++ source/actions/LowMemoryTrackingAction.h | 40 +++++++++ source/base/ActionsFactory.cc | 3 + 3 files changed, 141 insertions(+) create mode 100644 source/actions/LowMemoryTrackingAction.cc create mode 100644 source/actions/LowMemoryTrackingAction.h diff --git a/source/actions/LowMemoryTrackingAction.cc b/source/actions/LowMemoryTrackingAction.cc new file mode 100644 index 0000000000..4ab5bcd6a2 --- /dev/null +++ b/source/actions/LowMemoryTrackingAction.cc @@ -0,0 +1,98 @@ +// ---------------------------------------------------------------------------- +// nexus | LowMemoryTrackingAction.cc +// +// This class is a tracking action of the NEXT simulation. +// It stores in memory the trajectories of particles -- with the exception of +// optical photons, ionization electrons, and electrons starting in +// Rock or water -- with the relevant tracking information that will be +// saved to the output file. First version useful for TonneScale with no +// Cerenkov studies (June 2020). +// +// The NEXT Collaboration +// ---------------------------------------------------------------------------- + + +#include "LowMemoryTrackingAction.h" + +#include "Trajectory.h" +#include "TrajectoryMap.h" +#include "IonizationElectron.h" + +#include +#include +#include +#include +#include +#include + + + +using namespace nexus; + + + +LowMemoryTrackingAction::LowMemoryTrackingAction(): G4UserTrackingAction() +{ +} + + + +LowMemoryTrackingAction::~LowMemoryTrackingAction() +{ +} + + + +void LowMemoryTrackingAction::PreUserTrackingAction(const G4Track* track) +{ + // Do nothing if the track is an optical photon or an ionization electron + if (track->GetDefinition() == G4OpticalPhoton::Definition() || + track->GetDefinition() == IonizationElectron::Definition()) { + fpTrackingManager->SetStoreTrajectory(false); + return; + } + + if (track->GetParentID() == 0 || + track->GetParticleDefinition() == G4Neutron::Definition() || + track->GetParticleDefinition()->IsGeneralIon() ){ + + // Create a new trajectory associated to the track. + // N.B. If the processesing of a track is interrupted to be resumed + // later on (to process, for instance, its secondaries) more than + // one trajectory associated to the track will be created, but + // the event manager will merge them at some point. + G4VTrajectory* trj = new Trajectory(track); + + // Set the trajectory in the tracking manager + fpTrackingManager->SetStoreTrajectory(true); + fpTrackingManager->SetTrajectory(trj); + return; + } + + fpTrackingManager->SetStoreTrajectory(false); + } + + + +void LowMemoryTrackingAction::PostUserTrackingAction(const G4Track* track) +{ + // Do nothing if the track is an optical photon or an ionization electron + if (track->GetDefinition() == G4OpticalPhoton::Definition() || + track->GetDefinition() == IonizationElectron::Definition()) return; + + Trajectory* trj = (Trajectory*) TrajectoryMap::Get(track->GetTrackID()); + + // Do nothing if the track has no associated trajectory in the map + if (!trj) return; + + // Record final time and position of the track + trj->SetFinalPosition(track->GetPosition()); + trj->SetFinalTime(track->GetGlobalTime()); + trj->SetTrackLength(track->GetTrackLength()); + trj->SetFinalVolume(track->GetVolume()->GetName()); + trj->SetFinalMomentum(track->GetMomentum()); + + // Record last process of the track + G4String proc_name = track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); + trj->SetFinalProcess(proc_name); +} diff --git a/source/actions/LowMemoryTrackingAction.h b/source/actions/LowMemoryTrackingAction.h new file mode 100644 index 0000000000..895ae3146c --- /dev/null +++ b/source/actions/LowMemoryTrackingAction.h @@ -0,0 +1,40 @@ +// ---------------------------------------------------------------------------- +// nexus | LowMemoryTrackingAction.h +// +// This class is a tracking action of the NEXT simulation. +// It stores in memory the trajectories of particles -- with the exception of +// optical photons, ionization electrons, and electrons starting in +// Rock or water -- with the relevant tracking information that will be +// saved to the output file. First version useful for TonneScale with no +// Cerenkov studies (June 2020). +// +// The NEXT Collaboration +// ---------------------------------------------------------------------------- + +#ifndef LOW_MEMORY_TRACKING_ACTION_H +#define LOW_MEMORY_TRACKING_ACTION_H + +#include + +class G4Track; + + +namespace nexus { + + // Low memory usage user tracking action + + class LowMemoryTrackingAction: public G4UserTrackingAction + { + public: + /// Constructor + LowMemoryTrackingAction(); + /// Destructor + virtual ~LowMemoryTrackingAction(); + + virtual void PreUserTrackingAction(const G4Track*); + virtual void PostUserTrackingAction(const G4Track*); + }; + +} + +#endif diff --git a/source/base/ActionsFactory.cc b/source/base/ActionsFactory.cc index a5d8637552..e9acc7f0fd 100644 --- a/source/base/ActionsFactory.cc +++ b/source/base/ActionsFactory.cc @@ -84,6 +84,7 @@ G4UserEventAction* ActionsFactory::CreateEventAction() const #include "DefaultTrackingAction.h" #include "ValidationTrackingAction.h" #include "OpticalTrackingAction.h" +#include "LowMemoryTrackingAction.h" G4UserTrackingAction* ActionsFactory::CreateTrackingAction() const { @@ -95,6 +96,8 @@ G4UserTrackingAction* ActionsFactory::CreateTrackingAction() const else if (trkact_name_ == "OPTICAL") p = new OpticalTrackingAction(); + else if (trkact_name_ == "LOW_MEMORY") p = new LowMemoryTrackingAction(); + else { G4String err = "Unknown user tracking action: " + trkact_name_; G4Exception("[ActionsFactory]", "CreateTrackingAction()",