From f5e540b1a239c5167db3e81e6d470451fe6d6aa5 Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 28 Oct 2022 15:08:08 +0200 Subject: [PATCH] Add function to set optical properties. Change string options to bool. Remove duplicates of PVT material --- source/geometries/GenericWLSFiber.cc | 57 +++++++++++++------------- source/geometries/GenericWLSFiber.h | 32 ++++++++++----- source/geometries/NextFlexFieldCage.cc | 4 +- source/materials/MaterialsList.cc | 46 --------------------- source/materials/MaterialsList.h | 6 --- 5 files changed, 51 insertions(+), 94 deletions(-) diff --git a/source/geometries/GenericWLSFiber.cc b/source/geometries/GenericWLSFiber.cc index edd0d9c225..f5219424a4 100644 --- a/source/geometries/GenericWLSFiber.cc +++ b/source/geometries/GenericWLSFiber.cc @@ -1,7 +1,7 @@ // ----------------------------------------------------------------------------- // nexus | GenericWLSFiber.cc // -// Geometry of a configurable wave-length shifting optical fiber. +// Geometry of a configurable wavelength shifting optical fiber. // // The NEXT Collaboration // ----------------------------------------------------------------------------- @@ -27,32 +27,27 @@ using namespace nexus; GenericWLSFiber::GenericWLSFiber(G4String name, - G4String shape, + G4bool isround, G4double thickness, G4double length, - G4int num_claddings, + G4bool doubleclad, G4bool with_coating, + G4Material* coating_mat, G4Material* core_mat, G4bool visibility): GeometryBase (), name_ (name), - shape_ (shape), // "round" or "square" + isround_ (isround), // "round" or "square" thickness_ (thickness), // Diameter (for round), Side (for square) length_ (length), - num_claddings_ (num_claddings), + doubleclad_ (doubleclad), with_coating_ (with_coating), + coating_mat_ (coating_mat), + coating_optProp_(nullptr), core_mat_ (core_mat), + core_optProp_ (nullptr), visibility_ (visibility) { - // Assert num_claddings in [1, 2] - if ((num_claddings_ < 1) || (num_claddings_ > 2)) - G4Exception("[GenericWLSFiber]", "GenericWLSFiber()", FatalException, - "Number of claddings not valid."); - - // Assert shape in ['round', 'square'] - if ((shape_ != "round") && (shape_ != "square")) - G4Exception("[GenericWLSFiber]", "GenericWLSFiber()", FatalException, - "Wrong shape. Valid shapes: round or square."); } @@ -71,14 +66,14 @@ void GenericWLSFiber::ComputeDimensions() G4double coating_thickness = 1. * um; // Single cladding fibers - if (num_claddings_ == 1) { + if (!doubleclad_) { iclad_rad_ = thickness_ / 2.; core_rad_ = iclad_rad_ - clad_thickness; if (with_coating_) iclad_rad_ -= coating_thickness; } // Double cladding fibers - else if (num_claddings_ == 2) { + else { oclad_rad_ = thickness_ / 2.; iclad_rad_ = oclad_rad_ - clad_thickness; core_rad_ = iclad_rad_ - clad_thickness; @@ -97,15 +92,19 @@ void GenericWLSFiber::DefineMaterials() iclad_mat_->SetMaterialPropertiesTable(opticalprops::PMMA()); // If 2 claddings, defining the outer cladding material - if (num_claddings_ == 2) { + if (doubleclad_) { oclad_mat_ = materials::FPethylene(); oclad_mat_->SetMaterialPropertiesTable(opticalprops::FPethylene()); } - // If coated, always with TPB - if (with_coating_) { - coating_mat_ = materials::TPB(); - coating_mat_->SetMaterialPropertiesTable(opticalprops::TPB()); + // If optical properties of coating are set explicitly, use them + if (with_coating_ && coating_optProp_) { + coating_mat_->SetMaterialPropertiesTable(coating_optProp_); + } + + // If optical properties of core are set explicitly, use them + if (core_optProp_) { + core_mat_->SetMaterialPropertiesTable(core_optProp_); } } @@ -116,8 +115,8 @@ void GenericWLSFiber::Construct() DefineMaterials(); - if (shape_ == "round") BuildRoundFiber(); - else if (shape_ == "square") BuildSquareFiber(); + if (isround_) BuildRoundFiber(); + else BuildSquareFiber(); } @@ -149,7 +148,7 @@ void GenericWLSFiber::BuildRoundFiber() // Outer Cladding (only if it exists ...) G4LogicalVolume* oclad_logic; - if (num_claddings_ == 2) { + if (doubleclad_) { G4String oclad_name = name_ + "_OCLAD"; G4cout << "**** Building OCLAD " << oclad_name << G4endl; G4Tubs* oclad_solid = @@ -191,7 +190,7 @@ void GenericWLSFiber::BuildRoundFiber() // VISIBILITIES if (visibility_) { - if (num_claddings_ == 2) + if (doubleclad_) oclad_logic->SetVisAttributes(nexus::LightBlue()); iclad_logic ->SetVisAttributes(nexus::LightGrey()); core_logic ->SetVisAttributes(G4Colour::Green()); @@ -200,7 +199,7 @@ void GenericWLSFiber::BuildRoundFiber() } else { - if (num_claddings_ == 2) + if (doubleclad_) oclad_logic->SetVisAttributes(G4VisAttributes::GetInvisible()); iclad_logic ->SetVisAttributes(G4VisAttributes::GetInvisible()); core_logic ->SetVisAttributes(G4VisAttributes::GetInvisible()); @@ -241,7 +240,7 @@ void GenericWLSFiber::BuildSquareFiber() // Outer Cladding (only if it exists ...) G4LogicalVolume* oclad_logic; - if (num_claddings_ == 2) { + if (doubleclad_) { G4String oclad_name = name_ + "_OCLAD"; G4Box* oclad_solid = new G4Box(oclad_name, oclad_rad_, oclad_rad_, length_/2.); @@ -280,7 +279,7 @@ void GenericWLSFiber::BuildSquareFiber() // VISIBILITIES if (visibility_) { - if (num_claddings_ == 2) + if (doubleclad_) oclad_logic->SetVisAttributes(nexus::LightBlue()); iclad_logic ->SetVisAttributes(nexus::LightGrey()); core_logic ->SetVisAttributes(G4Colour::Green()); @@ -289,7 +288,7 @@ void GenericWLSFiber::BuildSquareFiber() } else { - if (num_claddings_ == 2) + if (doubleclad_) oclad_logic->SetVisAttributes(G4VisAttributes::GetInvisible()); iclad_logic ->SetVisAttributes(G4VisAttributes::GetInvisible()); core_logic ->SetVisAttributes(G4VisAttributes::GetInvisible()); diff --git a/source/geometries/GenericWLSFiber.h b/source/geometries/GenericWLSFiber.h index 65fcfc741d..c12313d6a9 100644 --- a/source/geometries/GenericWLSFiber.h +++ b/source/geometries/GenericWLSFiber.h @@ -1,7 +1,7 @@ // ----------------------------------------------------------------------------- // nexus | GenericWLSFiber.h // -// Geometry of a configurable wave-length shifting optical fiber. +// Geometry of a configurable wavelength shifting optical fiber. // // The NEXT Collaboration // ----------------------------------------------------------------------------- @@ -22,13 +22,14 @@ namespace nexus { { public: - // Constructor for a generic wave-length shifting optical fiber + // Constructor for a generic wavelength shifting optical fiber GenericWLSFiber(G4String name, - G4String shape, // "round" or "square" + G4bool isround, // "round" or "square" G4double thickness, // diameter or side G4double length, - G4int num_claddings, + G4bool doubleclad, G4bool with_coating, + G4Material* coating_material, G4Material* core_material, G4bool visibility); @@ -40,10 +41,13 @@ namespace nexus { // Getters const G4String& GetName() const; - const G4String& GetShape() const; + const G4bool& GetShape() const; G4double GetThickness() const; G4double GetLength() const; - G4int GetNumCladdings() const; + G4bool GetNumCladdings() const; + + void SetCoatingOpticalProperties(G4MaterialPropertiesTable* ctmp); + void SetCoreOpticalProperties(G4MaterialPropertiesTable* crmp); // Setters void SetVisibility(G4bool visibility); @@ -56,31 +60,37 @@ namespace nexus { void BuildSquareFiber(); G4String name_; - G4String shape_; + G4bool isround_; G4double thickness_; G4double length_; G4double core_rad_; G4double iclad_rad_; G4double oclad_rad_; - G4int num_claddings_; + G4bool doubleclad_; G4bool with_coating_; G4Material* core_mat_; G4Material* iclad_mat_; G4Material* oclad_mat_; - G4Material* coating_mat_; + G4Material* coating_mat_; + G4MaterialPropertiesTable* coating_optProp_; + G4MaterialPropertiesTable* core_optProp_; G4bool visibility_; }; inline const G4String& GenericWLSFiber::GetName() const { return name_; } - inline const G4String& GenericWLSFiber::GetShape() const { return shape_; } + inline const G4bool& GenericWLSFiber::GetShape() const { return isround_; } inline G4double GenericWLSFiber::GetThickness() const { return thickness_; } inline G4double GenericWLSFiber::GetLength() const { return length_; } - inline G4int GenericWLSFiber::GetNumCladdings() const { return num_claddings_; } + inline G4bool GenericWLSFiber::GetNumCladdings() const { return doubleclad_; } inline void GenericWLSFiber::SetVisibility(G4bool visibility) { visibility_ = visibility; } + inline void GenericWLSFiber::SetCoatingOpticalProperties(G4MaterialPropertiesTable* ctmp) + { coating_optProp_ = ctmp; } + inline void GenericWLSFiber::SetCoreOpticalProperties(G4MaterialPropertiesTable* crmp) + { core_optProp_ = crmp; } } // namespace nexus diff --git a/source/geometries/NextFlexFieldCage.cc b/source/geometries/NextFlexFieldCage.cc index fb0d734287..17f249dba7 100644 --- a/source/geometries/NextFlexFieldCage.cc +++ b/source/geometries/NextFlexFieldCage.cc @@ -330,11 +330,11 @@ void NextFlexFieldCage::DefineMaterials() // Fiber core material if (fiber_mat_name_ == "EJ280") { - fiber_mat_ = materials::EJ280(); + fiber_mat_ = materials::PVT(); fiber_mat_->SetMaterialPropertiesTable(opticalprops::EJ280()); } else if (fiber_mat_name_ == "EJ286") { - fiber_mat_ = materials::EJ280(); // Same base material than EJ280 + fiber_mat_ = materials::PVT(); // Same base material than EJ280 fiber_mat_->SetMaterialPropertiesTable(opticalprops::EJ286()); } else if (fiber_mat_name_ == "Y11") { diff --git a/source/materials/MaterialsList.cc b/source/materials/MaterialsList.cc index 096138bf41..a544741d2a 100644 --- a/source/materials/MaterialsList.cc +++ b/source/materials/MaterialsList.cc @@ -795,52 +795,6 @@ namespace materials { } - // WLS EJ-280 - G4Material* EJ280() - { - G4String name = "EJ280"; // - - G4Material* mat = G4Material::GetMaterial(name, false); - - if (mat == 0) { - G4NistManager* nist = G4NistManager::Instance(); - - // The base is Polyvinyltoluene - // Linear formula: [CH2CH(C6H4CH3)]n - G4Element* H = nist->FindOrBuildElement("H"); - G4Element* C = nist->FindOrBuildElement("C"); - - mat = new G4Material(name, 1.023*g/cm3, 2, kStateSolid); - mat->AddElement(H, 10); - mat->AddElement(C, 9); - } - - return mat; - } - - // WLS EJ-286 - G4Material* EJ286() - { - G4String name = "EJ286"; // - - G4Material* mat = G4Material::GetMaterial(name, false); - - if (mat == 0) { - G4NistManager* nist = G4NistManager::Instance(); - - // The base is Polyvinyltoluene - // Linear formula: [CH2CH(C6H4CH3)]n - G4Element* H = nist->FindOrBuildElement("H"); - G4Element* C = nist->FindOrBuildElement("C"); - - mat = new G4Material(name, 1.023*g/cm3, 2, kStateSolid); - mat->AddElement(H, 10); - mat->AddElement(C, 9); - } - - return mat; - } - // Kuraray Y-11 G4Material* Y11() { diff --git a/source/materials/MaterialsList.h b/source/materials/MaterialsList.h index 81f4fe02f4..97bb81348c 100644 --- a/source/materials/MaterialsList.h +++ b/source/materials/MaterialsList.h @@ -115,12 +115,6 @@ namespace materials { // FR4 G4Material* FR4(); - // WLS EJ-280 - G4Material* EJ280(); - - // WLS EJ-286 - G4Material* EJ286(); - // Kuraray Fiber Y11 G4Material* Y11();