Skip to content

Commit

Permalink
Add function to set optical properties. Change string options to bool…
Browse files Browse the repository at this point in the history
…. Remove duplicates of PVT material
  • Loading branch information
Fabian committed Oct 28, 2022
1 parent 10226f4 commit f5e540b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 94 deletions.
57 changes: 28 additions & 29 deletions source/geometries/GenericWLSFiber.cc
Original file line number Diff line number Diff line change
@@ -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
// -----------------------------------------------------------------------------
Expand All @@ -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.");
}


Expand All @@ -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;
Expand All @@ -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_);
}
}

Expand All @@ -116,8 +115,8 @@ void GenericWLSFiber::Construct()

DefineMaterials();

if (shape_ == "round") BuildRoundFiber();
else if (shape_ == "square") BuildSquareFiber();
if (isround_) BuildRoundFiber();
else BuildSquareFiber();
}


Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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.);
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
32 changes: 21 additions & 11 deletions source/geometries/GenericWLSFiber.h
Original file line number Diff line number Diff line change
@@ -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
// -----------------------------------------------------------------------------
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions source/geometries/NextFlexFieldCage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
46 changes: 0 additions & 46 deletions source/materials/MaterialsList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
6 changes: 0 additions & 6 deletions source/materials/MaterialsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ namespace materials {
// FR4
G4Material* FR4();

// WLS EJ-280
G4Material* EJ280();

// WLS EJ-286
G4Material* EJ286();

// Kuraray Fiber Y11
G4Material* Y11();

Expand Down

0 comments on commit f5e540b

Please sign in to comment.