DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
ConstructHexPart.cc
Go to the documentation of this file.
1#include "DetectorConstruction_includes.hh" // common includes
2#include "VolumeBuilders.hh"
3using namespace CLHEP;
4namespace VB = DLG4::VolumeBuilders; // Geometry builder helpers.
5
6void DetectorConstruction::ConstructHexPart() {
7 static bool firstcall = true;
8 if (!firstcall) {
9 // only run once
10 return;
11 }
12 firstcall = false;
13
14 //make a dedicated sample_material for vertex generation:
15 // Density in materials is 1.14, but internet :) says 1.18 to 1.19 for cast acrylic. Should weigh it really:
16 G4Material *sample_mat = DetectorConstruction::CopyMaterial(_copper, "sample_mat");
17 G4cout << "now ConstructArrayHexPart()\n" << G4endl;
18
19 G4double sample_thickness_mm = 50;
20 if (ExtraOpts.find("hex_insert_mm") != ExtraOpts.end()) {
21 //if option is set
22 std::stringstream ss(ExtraOpts["hex_insert_mm"]);
23 ss >> sample_thickness_mm; //read it
24 } else {
25 //else set default but complain
26 // Echo command instructions:
27 sample_thickness_mm = 50.;
28 G4cout << "Use:" << G4endl;
29 G4cout << " /detGeometry/opt \"hex_insert_mm\" " << G4endl;
30 G4cout << " to set thickness of hex shield insert" << G4endl;
31 G4cout << "Assuming default value of:" << 50 << false << G4endl;
32 }
33
34 // Copper hex: //////////////////////
35 VB::RZPlane p; // just for clarity and temps, since we use the component setting method here:
36 auto hex_filler = VB::CreatePolyhedraBuilder(
37 "hex_filler",
38 6,
39 30.) // start at 30 deg
40 ->SetVisibility(true)
41 ->SetMaterial(sample_mat)
42 ->SetColor(0.8, 0.45, 0.45, 1)
43 ->ForceSolid(true)
44 ->SetDefaultUnit(CLHEP::mm)
45 //@formatter:off
46 ->AddPlane(p.IR = 0, p.OR = 110.0 / 2.0, p.z = 0)
47 ->AddPlane(p.IR, p.OR, p.z += sample_thickness_mm);
48
49 //*******************WARNING This may not be exactly the same as top of surround, derived in different ways.
50 //*******************samples that sit on both should be reviewed for overlap ex: Cu2019 sample
51 auto filler_id = VB::CreatePolyconeBuilder("filler_cu_id") // will be unioned to hex_filler.
52 ->AddPlane(p.IR = 0, p.OR = 85 / 2.0, p.z = -0.1)
53 ->AddPlane(p.IR, p.OR, p.z += sample_thickness_mm+0.1);
54 //@formatter:on
55
56 hex_filler->AddSubtraction(filler_id)
57 ->SetBooleanName("hex_insert");
58
59
60 hex_filler
61 ->SetMother(world_phys)
62 ->PlaceAndFork();
63}
RZBuilder CreatePolyconeBuilder(const G4String &name, G4double phi_start, G4double phi_tot)
Create a builder for associated IR,OR,Z defined object.
RZBuilder CreatePolyhedraBuilder(const G4String &name, int sides, G4double phi_start, G4double phi_tot)
Create a builder for associated IR,OR,Z defined object.
Struct for adding planes to GeantMultiPlane –DSLeonard 2024 Overloads make this not strictly needed.