From 56fe968ce01d58c7d9e637b04af9ddec3ba7ab7f Mon Sep 17 00:00:00 2001 From: Paola Ferrario Date: Wed, 4 Oct 2023 15:17:23 +0200 Subject: [PATCH] Add vertex generator --- source/geometries/Honeycomb.cc | 77 +++++++++++++++++------ source/geometries/Honeycomb.h | 8 +++ source/geometries/HoneycombBeam.h | 1 + source/geometries/Next100.cc | 3 +- source/geometries/Next100InnerElements.cc | 6 +- 5 files changed, 73 insertions(+), 22 deletions(-) diff --git a/source/geometries/Honeycomb.cc b/source/geometries/Honeycomb.cc index 466678f0a..93e27f50c 100644 --- a/source/geometries/Honeycomb.cc +++ b/source/geometries/Honeycomb.cc @@ -10,6 +10,7 @@ #include "HoneycombBeam.h" #include "MaterialsList.h" #include "Visibilities.h" +#include "CylinderPointSampler2020.h" #include #include @@ -17,16 +18,22 @@ #include #include #include - +#include namespace nexus { using namespace CLHEP; - Honeycomb::Honeycomb(): GeometryBase(), angle_(pi / 6.), beam_dist_(102.25 * mm), + Honeycomb::Honeycomb(): GeometryBase(), + angle_(pi / 6.), + beam_dist_(102.25 * mm), beam_thickn_(6 * mm) { compl_angle_ = pi/2. - angle_; + + /// Initializing the geometry navigator (used in vertex generation) + geom_navigator_ = + G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); } Honeycomb::~Honeycomb() @@ -37,13 +44,14 @@ namespace nexus { { G4double shorter_height = 117 * mm; G4double longer_height = 130 * mm; + G4double longer_length = 1210.6*mm; HoneycombBeam* short_beam = new HoneycombBeam(beam_thickn_, 1085.9*mm, 184*mm, shorter_height); HoneycombBeam* medium_beam = new HoneycombBeam(beam_thickn_, 1170.2*mm, 273.5*mm, longer_height); HoneycombBeam* long_beam = - new HoneycombBeam(beam_thickn_, 1210.6*mm, 407.4*mm, longer_height); + new HoneycombBeam(beam_thickn_, longer_length, 407.4*mm, longer_height); G4double short_displ = (longer_height-shorter_height)/2.; @@ -57,7 +65,8 @@ namespace nexus { G4RotationMatrix rot; rot.rotateX(3*pi/2.); - G4ThreeVector ini_pos = G4ThreeVector(-(beam_dist_+beam_thickn_)/2., 0., 0.); + G4ThreeVector ini_pos = + G4ThreeVector(-(beam_dist_+beam_thickn_)/2., 0., 0.); struct_solid->AddNode(long_beam->GetSolidVol(), G4Transform3D(rot, ini_pos)); @@ -68,19 +77,24 @@ namespace nexus { rot_right.rotateX(3*pi/2.); rot_right.rotateY(-(pi/2.+angle_)); - G4double r_pos = 1/2*beam_dist_+ 2*(beam_dist_+beam_thickn_) + 1/2*beam_thickn_; + G4double r_pos = + 1/2*beam_dist_+ 2*(beam_dist_+beam_thickn_) + 1/2*beam_thickn_; r_pos = r_pos + (beam_dist_ + beam_thickn_)/2.*cos(compl_angle_) + 2.75*cm; G4double x = r_pos * sin(angle_); G4double z = r_pos * cos(angle_); struct_solid->AddNode(short_beam->GetSolidVol(), - G4Transform3D(rot_left, G4ThreeVector(x, short_displ, z))); + G4Transform3D(rot_left, + G4ThreeVector(x, short_displ, z))); struct_solid->AddNode(short_beam->GetSolidVol(), - G4Transform3D(rot_right, G4ThreeVector(-x, short_displ, z))); + G4Transform3D(rot_right, + G4ThreeVector(-x, short_displ, z))); struct_solid->AddNode(short_beam->GetSolidVol(), - G4Transform3D(rot_left, G4ThreeVector(-x, short_displ, -z))); + G4Transform3D(rot_left, + G4ThreeVector(-x, short_displ, -z))); struct_solid->AddNode(short_beam->GetSolidVol(), - G4Transform3D(rot_right, G4ThreeVector(x, short_displ, -z))); + G4Transform3D(rot_right, + G4ThreeVector(x, short_displ, -z))); x = (r_pos-(beam_dist_+beam_thickn_)) * sin(angle_); @@ -116,7 +130,8 @@ namespace nexus { G4Transform3D(rot, G4ThreeVector(x, 0., 0.))); x = ini_pos.x() - 2*(beam_dist_+beam_thickn_); struct_solid->AddNode(short_beam->GetSolidVol(), - G4Transform3D(rot, G4ThreeVector(x, short_displ, 0.))); + G4Transform3D(rot, + G4ThreeVector(x, short_displ, 0.))); x = ini_pos.x() + (beam_dist_+beam_thickn_); struct_solid->AddNode(long_beam->GetSolidVol(), G4Transform3D(rot, G4ThreeVector(x, 0., 0.))); @@ -125,32 +140,54 @@ namespace nexus { G4Transform3D(rot, G4ThreeVector(x, 0., 0.))); x = ini_pos.x() + 3*(beam_dist_+beam_thickn_); struct_solid->AddNode(short_beam->GetSolidVol(), - G4Transform3D(rot, G4ThreeVector(x, short_displ, 0.))); + G4Transform3D(rot, + G4ThreeVector(x, short_displ, 0.))); struct_solid->Voxelize(); - G4LogicalVolume* struct_logic = new G4LogicalVolume(struct_solid, materials::Steel(), - "UnionBeams"); - - //this->SetLogicalVolume(struct_logic); - + G4LogicalVolume* struct_logic = + new G4LogicalVolume(struct_solid, materials::Steel(), "HONEYCOMB"); G4RotationMatrix rot_placement; rot_placement.rotateZ(-pi/2); rot_placement.rotateY(-pi/2); - G4double hc_posz_ = end_of_EP_copper_plate_z_ + longer_height/2.; - new G4PVPlacement(G4Transform3D(rot_placement, G4ThreeVector(0., 0., hc_posz_)), - struct_logic, "HONEYCOMB", mother_logic_, false, 0, true); + G4double hc_posz = end_of_EP_copper_plate_z_ + longer_height/2.; + new G4PVPlacement(G4Transform3D(rot_placement, + G4ThreeVector(0., 0., hc_posz)), + struct_logic, "HONEYCOMB", mother_logic_, + false, 0, false); G4VisAttributes red_col = nexus::Red(); red_col.SetForceSolid(true); struct_logic->SetVisAttributes(red_col); + // Vertex generator + gen_ = + new CylinderPointSampler2020(0., longer_length/2., longer_height/2., + 0., 360.*deg, 0, + G4ThreeVector(0., 0., hc_posz)); + } G4ThreeVector Honeycomb::GenerateVertex(const G4String& region) const { - return G4ThreeVector(0, 0, 0); + G4ThreeVector vertex(0, 0, 0); + + if (region == "HONEYCOMB") { + G4VPhysicalVolume* VertexVolume; + do { + vertex = gen_->GenerateVertex("VOLUME"); + G4ThreeVector glob_vtx(vertex); + glob_vtx = glob_vtx + G4ThreeVector(0, 0, -GetELzCoord()); + VertexVolume = geom_navigator_->LocateGlobalPointAndSetup(glob_vtx, 0, false); + } while (VertexVolume->GetName() != region); + } + else { + G4Exception("[Honeycomb]", "GenerateVertex()", FatalException, + "Unknown vertex generation region!"); + } + + return vertex; } } diff --git a/source/geometries/Honeycomb.h b/source/geometries/Honeycomb.h index 52bf20fd7..c57a9a64b 100644 --- a/source/geometries/Honeycomb.h +++ b/source/geometries/Honeycomb.h @@ -11,7 +11,11 @@ #include "GeometryBase.h" +#include + namespace nexus { + class CylinderPointSampler2020; + class Honeycomb: public GeometryBase { public: @@ -43,6 +47,10 @@ namespace nexus { // Relationships among beams G4double angle_, beam_dist_, beam_thickn_; G4double compl_angle_; + + CylinderPointSampler2020* gen_; + + G4Navigator* geom_navigator_; }; inline void Honeycomb::SetMotherLogicalVolume(G4LogicalVolume* mother_logic) { diff --git a/source/geometries/HoneycombBeam.h b/source/geometries/HoneycombBeam.h index 041596f9c..220140a48 100644 --- a/source/geometries/HoneycombBeam.h +++ b/source/geometries/HoneycombBeam.h @@ -14,6 +14,7 @@ class G4Trd; namespace nexus { + class HoneycombBeam: public GeometryBase { public: diff --git a/source/geometries/Next100.cc b/source/geometries/Next100.cc index c7baeea3a..787cd6381 100644 --- a/source/geometries/Next100.cc +++ b/source/geometries/Next100.cc @@ -250,7 +250,8 @@ namespace nexus { (region == "FIELD_RING") || (region == "GATE_RING") || (region == "ANODE_RING") || - (region == "RING_HOLDER")) { + (region == "RING_HOLDER") || + (region == "HONEYCOMB")) { vertex = inner_elements_->GenerateVertex(region); } diff --git a/source/geometries/Next100InnerElements.cc b/source/geometries/Next100InnerElements.cc index 73752ffd1..6b5b71e0b 100644 --- a/source/geometries/Next100InnerElements.cc +++ b/source/geometries/Next100InnerElements.cc @@ -79,7 +79,7 @@ namespace nexus { // Honeycomb support structure for EP honeycomb_->SetMotherLogicalVolume(mother_logic_); - //honeycomb_->SetELzCoord(gate_zpos); + honeycomb_->SetELzCoord(gate_zpos); honeycomb_->SetEndOfCopperPlateZ(energy_plane_->GetCopperPlateEndZ()); honeycomb_->Construct(); @@ -129,6 +129,10 @@ namespace nexus { (region == "PMT_BASE")) { vertex = energy_plane_->GenerateVertex(region); } + // Honeycomb region + else if (region == "HONEYCOMB") { + vertex = honeycomb_->GenerateVertex(region); + } // Tracking Plane regions else if ((region == "TP_COPPER_PLATE") || (region == "SIPM_BOARD") ||