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

Fix segmentation fault due to G4 bug by setting G4MaterialPropertiesTable #168

Merged
merged 5 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
13 changes: 12 additions & 1 deletion source/geometries/Next1EL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,25 @@ void Next1EL::DefineMaterials()
{
// AIR
air_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
air_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
// GASEOUS XENON
gxe_ = materials::GXe(pressure_, 303);
gxe_->SetMaterialPropertiesTable(opticalprops::GXe(pressure_, 303, sc_yield_, e_lifetime_));
// PTFE (TEFLON)
teflon_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
// STAINLESS STEEL
steel_ = materials::Steel();
steel_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
// ALUMINUM
aluminum_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
aluminum_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
//LEAD
lead_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb");
lead_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
//PLASTIC
plastic_ = materials::PS();
plastic_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
//TPB
tpb_ = materials::TPB();
tpb_->SetMaterialPropertiesTable(opticalprops::TPB());
Expand Down Expand Up @@ -352,6 +358,7 @@ void Next1EL::BuildExtScintillator()
new G4Tubs("SOURCE", 0., source_diam/2., source_thick/2., 0., twopi);
G4Material* sodium22_mat =
G4NistManager::Instance()->FindOrBuildMaterial("G4_Na");
sodium22_mat->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
G4LogicalVolume* source_logic =
new G4LogicalVolume(source_solid, sodium22_mat, "SOURCE");

Expand Down Expand Up @@ -400,6 +407,7 @@ void Next1EL::BuildExtScintillator()
G4Tubs* sc_solid = new G4Tubs("NaI", 0., radius, length/2., 0., twopi);
G4Material* mat =
G4NistManager::Instance()->FindOrBuildMaterial("G4_SODIUM_IODIDE");
mat->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
G4LogicalVolume* sc_logic = new G4LogicalVolume(sc_solid, mat, "NaI");
sc_logic->SetUserLimits(new G4UserLimits(1.*mm));

Expand Down Expand Up @@ -955,8 +963,11 @@ void Next1EL::BuildFieldCage()
new G4UnionSolid("SUPPORT_BAR", bar_base, addon, 0,
G4ThreeVector(bar_thickn_, 0., (bar_length - bar_addon_length_)/2.));

G4Material* peek_mat_ = materials::PEEK();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In nexus conventions, we use the trailing underscore for members of the classes. In this case, since you are defining a local variable, you should just use peek_mat. Please, review the rest of the code following this convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now added a commit with the changes.

peek_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* bar_logic =
new G4LogicalVolume(bar_solid, materials::PEEK(), "SUPPORT_BAR");
new G4LogicalVolume(bar_solid, peek_mat_, "SUPPORT_BAR");


G4double pos_rad = ring_diam_/2. + ring_thickn_ + bar_thickn_/2.;
Expand Down
1 change: 1 addition & 0 deletions source/geometries/Next1ELDBO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace nexus {

G4Material* teflon =
G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* board_logic =
new G4LogicalVolume(board_solid, teflon, "DBO");
Expand Down
7 changes: 6 additions & 1 deletion source/geometries/NextDemo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ void NextDemo::ConstructLab()
G4Box* lab_solid_vol =
new G4Box(lab_name, lab_size_/2., lab_size_/2., lab_size_/2.);

G4Material* air_mat_ =
G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");

air_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* lab_logic_vol =
new G4LogicalVolume(lab_solid_vol,
G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"),
air_mat_,
lab_name);

// Make the volume invisible in the visualization
Expand Down
12 changes: 10 additions & 2 deletions source/geometries/NextDemoEnergyPlane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ namespace nexus {
pmt_positions_[i]);
}

G4Material* aluminum_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
aluminum_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* carrier_plate_logic =
new G4LogicalVolume(carrier_plate_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_Al"),
aluminum_,
"EP_PLATE");
G4double carrier_plate_posz =
GetELzCoord() + gate_support_surface_dist_ + carrier_plate_thickness_/2.;
Expand All @@ -139,6 +142,7 @@ namespace nexus {
sapphire->SetMaterialPropertiesTable(opticalprops::Sapphire());

G4Material* copper = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4Material* vacuum =
G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
Expand Down Expand Up @@ -247,9 +251,13 @@ namespace nexus {
G4Tubs* pmt_base_solid =
new G4Tubs("PMT_BASE", 0., pmt_base_diam_/2., pmt_base_thickness_,
0.,twopi);

G4Material* kapton_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
kapton_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* pmt_base_logic =
new G4LogicalVolume(pmt_base_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON"),
kapton_,
"PMT_BASE");
G4double pmt_base_pos = pmt_hole_length_/2. - pmt_base_thickness_;
new G4PVPlacement(0, G4ThreeVector(0.,0., pmt_base_pos),
Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextDemoFieldCage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ namespace nexus {
temperature_ = gas_->GetTemperature();

aluminum_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
aluminum_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

/// Teflon for the light tube
teflon_ =
G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

/// Quartz
quartz_ = materials::FusedSilica();
Expand Down
10 changes: 8 additions & 2 deletions source/geometries/NextDemoSiPMBoard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ void NextDemoSiPMBoard::Construct()
G4Box* kapton_solid = new G4Box(kapton_name, board_size_x/2.,
board_size_y/2., kapton_thickn_/2.);

G4Material* kapton_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
kapton_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* kapton_logic =
new G4LogicalVolume(kapton_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON"),
kapton_mat_,
kapton_name);

new G4PVPlacement(nullptr, G4ThreeVector(0., 0., kapton_posz), kapton_logic,
Expand All @@ -196,8 +199,11 @@ void NextDemoSiPMBoard::Construct()
G4Box* mask_solid = new G4Box(mask_name, board_size_x/2.,
board_size_y/2., mask_thickn_/2.);

G4Material* teflon_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* mask_logic =
new G4LogicalVolume(mask_solid, G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON"),
new G4LogicalVolume(mask_solid, teflon_,
mask_name);

// Adding the optical surface
Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextElDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ namespace nexus {
G4Material* teflon =
G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");

teflon->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* board_logic =
new G4LogicalVolume(board_solid, teflon, "DICE_BOARD");

Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextFlex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ void NextFlex::DefineMaterials()
{
// Copper
copper_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// Air
air_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
air_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// Defining the gas xenon
if (gas_name_ == "naturalXe")
Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextFlexEnergyPlane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ void NextFlexEnergyPlane::DefineMaterials()

// Copper
copper_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// Teflon
teflon_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// Sapphire
sapphire_mat_ = materials::Sapphire();
Expand Down
1 change: 1 addition & 0 deletions source/geometries/NextFlexFieldCage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ void NextFlexFieldCage::DefineMaterials()

// Teflon
teflon_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// UV shifting material
if (wls_mat_name_ == "NONE") {
Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextFlexTrackingPlane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ void NextFlexTrackingPlane::DefineMaterials()

// Copper
copper_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// Teflon
teflon_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

// UV shifting material
if (wls_mat_name_ == "NONE") {
Expand Down
6 changes: 5 additions & 1 deletion source/geometries/NextNew.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ namespace nexus {
hallA_length, hallA_length);
G4Material *vacuum =
G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
vacuum->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

lab_logic_ = new G4LogicalVolume(lab_solid, vacuum, "LAB");
this->SetSpan(2 * hallA_length);
} else {
G4Box* lab_solid =
new G4Box("LAB", lab_size_/2., lab_size_/2., lab_size_/2.);

lab_logic_ = new G4LogicalVolume(lab_solid, G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"), "LAB");
G4Material* air_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
air_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
lab_logic_ = new G4LogicalVolume(lab_solid, air_mat_, "LAB");
}
lab_logic_->SetVisAttributes(G4VisAttributes::GetInvisible());

Expand Down
4 changes: 3 additions & 1 deletion source/geometries/NextNewEnergyPlane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ namespace nexus {
new G4SubtractionSolid("CARRIER_PLATE", carrier_plate_solid, axial_port_hole_solid,
0, G4ThreeVector(0., 0., - carrier_plate_front_buffer_thickness_ - axial_port_thickn_));

G4Material* copper_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* carrier_plate_logic =
new G4LogicalVolume(carrier_plate_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu"),
copper_mat_,
"CARRIER_PLATE");


Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextNewFieldCage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ namespace nexus {

// Copper for field rings
copper_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
// Teflon for the light tube
teflon_ =
G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());
// TPB coating
tpb_ = materials::TPB();
tpb_->SetMaterialPropertiesTable(opticalprops::TPB());
Expand Down
5 changes: 3 additions & 2 deletions source/geometries/NextNewIcs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ namespace nexus {
ics_solid = new G4SubtractionSolid("ICS", ics_solid, up_big_nozzle_hole_solid, rotx,
G4ThreeVector( 0., up_nozzle_y_pos_, center_nozzle_z_pos_ +up_nozzle_z_pos_));

G4Material* copper_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* ics_logic =
new G4LogicalVolume(ics_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu"), "ICS");
new G4LogicalVolume(ics_solid, copper_mat_, "ICS");

new G4PVPlacement(0, G4ThreeVector(0.,0.,-body_zpos_), ics_logic, "ICS", mother_logic_, false, 0, false);

Expand Down
2 changes: 2 additions & 0 deletions source/geometries/NextNewKDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace nexus {

G4Material* kapton =
G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
kapton->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* board_logic =
new G4LogicalVolume(board_solid, kapton, "DICE_BOARD");
Expand All @@ -125,6 +126,7 @@ namespace nexus {

G4Material* teflon =
G4NistManager::Instance()->FindOrBuildMaterial("G4_TEFLON");
teflon->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* mask_logic =
new G4LogicalVolume(mask_solid, teflon, "DICE_MASK");
Expand Down
11 changes: 8 additions & 3 deletions source/geometries/NextNewMiniCastle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ namespace nexus {
new G4UnionSolid("MINI_CASTLE", castle_solid, z_wall_solid_sipms, 0,
G4ThreeVector(0., -y_/2.+thickness_/2., z_/2.-thickness_/2.));

G4Material* lead_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb");
lead_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* castle_logic =
new G4LogicalVolume (castle_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb"),"CASTLE");
new G4LogicalVolume (castle_solid, lead_, "CASTLE");

G4double y_pos = pedestal_surf_y_ + y_ -thickness_/2.;
new G4PVPlacement(0, G4ThreeVector(0., y_pos, 0.), castle_logic,
Expand Down Expand Up @@ -158,8 +160,11 @@ namespace nexus {
new G4UnionSolid("MINI_CASTLE_STEEL", steel_solid, z_steel_solid_sipms, 0,
G4ThreeVector(0., -steel_y/2.+steel_thickn_/2., steel_z/2.-steel_thickn_/2.));

G4Material* steel_ = materials::Steel();
steel_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* steel_logic =
new G4LogicalVolume (steel_solid, materials::Steel(), "MINI_CASTLE_STEEL");
new G4LogicalVolume (steel_solid, steel_, "MINI_CASTLE_STEEL");

y_pos = pedestal_surf_y_ + y_ -thickness_ - steel_thickn_/2.;
new G4PVPlacement(0, G4ThreeVector(0., y_pos, 0.), steel_logic,
Expand Down
6 changes: 5 additions & 1 deletion source/geometries/NextNewPedestal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "MaterialsList.h"
#include "Visibilities.h"

#include <G4Material.hh>
#include <G4GenericMessenger.hh>
#include <G4LogicalVolume.hh>
#include <G4PVPlacement.hh>
Expand Down Expand Up @@ -53,8 +54,11 @@ namespace nexus {
G4Box* table_solid =
new G4Box("TABLE", table_x_/2., table_y_/2., table_z_/2.);

G4Material* steel_316_Ti_ = materials::Steel316Ti();
steel_316_Ti_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* table_logic = new G4LogicalVolume(table_solid,
materials::Steel316Ti(),
steel_316_Ti_,
"TABLE");
new G4PVPlacement(0, G4ThreeVector(0.,y_pos_,0.), table_logic, "TABLE", mother_logic_, false, 0,false);

Expand Down
11 changes: 9 additions & 2 deletions source/geometries/NextNewPmtEnclosure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ namespace nexus{
G4UnionSolid* enclosure_solid =
new G4UnionSolid("ENCLOSURE_SOLID", enclosure_body, enclosure_endcap, nullptr, transl);

G4Material* copper = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* enclosure_logic =
new G4LogicalVolume(enclosure_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu"),
copper,
"ENCLOSURE");
GeometryBase::SetLogicalVolume(enclosure_logic);

Expand Down Expand Up @@ -198,9 +201,13 @@ namespace nexus{
// Adding the PMT base
G4Tubs* pmt_base_solid =
new G4Tubs("PMT_BASE", 0., pmt_base_diam_/2., pmt_base_thickness_, 0.,twopi);

G4Material* kapton = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
kapton->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* pmt_base_logic =
new G4LogicalVolume(pmt_base_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON"),
kapton,
"PMT_BASE");
new G4PVPlacement(nullptr, G4ThreeVector(0.,0., -pmt_base_z_),
pmt_base_logic, "PMT_BASE", enclosure_gas_logic, false, 0, false);
Expand Down
11 changes: 9 additions & 2 deletions source/geometries/NextNewTrackingPlane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ namespace nexus {
support_plate_cable_hole_solid, 0, pos);
}

G4Material* copper_mat_ = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu");
copper_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* support_plate_logic = new G4LogicalVolume(support_plate_solid,
G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu"),
copper_mat_,
"SUPPORT_PLATE");

///// Support Plate placement
Expand Down Expand Up @@ -142,7 +145,11 @@ namespace nexus {

//PIGGY TAIL PLUG/////////////////////////////////////////////////////
G4Box* plug_solid = new G4Box("DB_CONNECTOR", plug_x_/2., plug_y_/2., plug_z_/2.);
G4LogicalVolume* plug_logic = new G4LogicalVolume(plug_solid, materials::PEEK(), "DB_PLUG");

G4Material* peek_mat_ = materials::PEEK();
peek_mat_->SetMaterialPropertiesTable(new G4MaterialPropertiesTable());

G4LogicalVolume* plug_logic = new G4LogicalVolume(plug_solid, peek_mat_, "DB_PLUG");
//G4PVPlacement * plug_physi;
G4ThreeVector positn;
for (int i=0; i<num_DBs_; i++) {
Expand Down
Loading