5 #include <phparameter/PHParameters.h>
13 #include <Geant4/G4AssemblyVolume.hh>
14 #include <Geant4/G4Box.hh>
15 #include <Geant4/G4ExtrudedSolid.hh>
16 #include <Geant4/G4LogicalVolume.hh>
17 #include <Geant4/G4Material.hh>
18 #include <Geant4/G4RotationMatrix.hh>
19 #include <Geant4/G4String.hh>
20 #include <Geant4/G4SystemOfUnits.hh>
21 #include <Geant4/G4ThreeVector.hh>
22 #include <Geant4/G4Transform3D.hh>
23 #include <Geant4/G4Tubs.hh>
24 #include <Geant4/G4TwoVector.hh>
25 #include <Geant4/G4Types.hh>
26 #include <Geant4/G4VPhysicalVolume.hh>
28 #include <CLHEP/Vector/RotationZ.h>
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wshadow"
32 #include <boost/format.hpp>
33 #pragma GCC diagnostic pop
50 , m_Params(parameters)
65 std::cout << __PRETTY_FUNCTION__ <<
" delete m_EndCapAssembly" << std::endl;
75 G4LogicalVolume *logvol = volume->GetLogicalVolume();
95 G4RotateY3D rotm_otherside(180 *
deg);
100 G4RotationMatrix rotm_center;
104 G4Transform3D transform_center(rotm_center, g4vec_center);
108 G4Transform3D transform_side1 = transform_center * g4vec_front_z;
111 G4Transform3D transform_side2 = transform_center * rotm_otherside * g4vec_front_z;
119 G4AssemblyVolume *assemblyvol =
new G4AssemblyVolume();
135 material.push_back(
"G4_Cu");
136 thickness.push_back(0.0005 * 2. *
cm);
137 material.push_back(
"G4_KAPTON");
138 thickness.push_back(0.005 *
cm);
139 material.push_back(
"sPHENIX_TPC_Gas");
140 thickness.push_back(0.2 *
cm);
146 double totalThickness = 0;
147 for (std::vector<double>::size_type
i = 0;
i < thickness.size();
i++)
149 totalThickness += thickness[
i];
155 totalThickness *= n_GEM_layers;
156 AddLayer(assemblyvol, starting_z, G4String(
"GEMAllParts"),
"GEMeffective", totalThickness, 64);
160 const int n_PCB_layers(16);
162 AddLayer(assemblyvol, starting_z, G4String(
"PCBCu"),
"G4_Cu", 0.0035 *
cm * n_PCB_layers, 80);
164 AddLayer(assemblyvol, starting_z,
"PCBBase",
"FR4", 0.00254 *
cm * 7 * n_PCB_layers, 100);
174 std::vector<std::string> materialName,
182 if (tempmat !=
nullptr)
184 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: composite material " << compositeName <<
" already exists" << std::endl;
189 assert(materialName.size() == thickness.size());
192 double totalArealDensity = 0, totalThickness = 0;
193 for (std::vector<double>::size_type
i = 0;
i < thickness.size();
i++)
196 if (tempmat ==
nullptr)
198 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: component material " << materialName[
i] <<
" does not exist." << std::endl;
202 totalArealDensity += tempmat->GetDensity() * thickness[
i];
203 totalThickness += thickness[
i];
207 double compositeDensity = totalArealDensity / totalThickness;
208 G4Material *composite =
new G4Material(compositeName, compositeDensity, thickness.size());
211 for (std::vector<double>::size_type
i = 0;
i < thickness.size();
i++)
214 composite->AddMaterial(tempmat, thickness[i] * tempmat->GetDensity() / totalArealDensity);
222 G4AssemblyVolume *assemblyvol,
227 double _percentage_filled
230 z_start += _depth / 2.;
231 G4ThreeVector g4vec(0, 0, z_start);
232 z_start += _depth / 2.;
236 G4VSolid *solid_layer =
new G4Tubs(
240 _depth * _percentage_filled / 100. / 2.,
244 if (material ==
nullptr)
246 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: missing material " << _material << std::endl;
250 G4LogicalVolume *logical_layer =
new G4LogicalVolume(solid_layer, material, name_base);
253 assemblyvol->AddPlacedVolume(logical_layer, g4vec,
nullptr);
267 assert(n_radial_modules >= 1);
271 if (material ==
nullptr)
273 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: missing material " <<
m_Params->
get_string_param(
"wagon_wheel_material") << std::endl;
283 std::cout << __PRETTY_FUNCTION__ <<
" - wagon_wheel_front_frame z_start = " << z_start << std::endl;
289 z_start += wagon_wheel_front_frame_thickness / 2.;
290 G4ThreeVector g4vec_wagon_wheel_front_frame(0, 0, z_start);
291 z_start += wagon_wheel_front_frame_thickness / 2.;
296 for (
int ring_id = 0; ring_id <= n_radial_modules; ++ring_id)
298 G4double Rin = wagon_wheel_front_frame_R_inner;
299 G4double Rout = wagon_wheel_front_frame_R_outer;
307 if (ring_id < n_radial_modules)
316 G4VSolid *solid_wagon_wheel_front_frame =
new G4Tubs(
320 wagon_wheel_front_frame_thickness / 2.,
323 G4LogicalVolume *log_solid_wagon_wheel_front_frame =
new G4LogicalVolume(solid_wagon_wheel_front_frame, material, name_base);
326 assmeblyvol->AddPlacedVolume(log_solid_wagon_wheel_front_frame,
327 g4vec_wagon_wheel_front_frame,
337 for (
int ring_id = 1; ring_id <= n_radial_modules; ++ring_id)
348 const G4double reduced_height = sqrt(Rout * Rout - wagon_wheel_front_frame_spoke_width / 2 * wagon_wheel_front_frame_spoke_width / 2);
350 std::vector<G4TwoVector> vertexes;
351 vertexes.push_back(G4TwoVector(-wagon_wheel_front_frame_spoke_width / 2, Rin));
352 vertexes.push_back(G4TwoVector(+wagon_wheel_front_frame_spoke_width / 2, Rin));
353 vertexes.push_back(G4TwoVector(+wagon_wheel_front_frame_spoke_width / 2, reduced_height));
354 vertexes.push_back(G4TwoVector(-wagon_wheel_front_frame_spoke_width / 2, reduced_height));
356 G4TwoVector
zero(0, 0);
360 G4VSolid *solid_wagon_wheel_front_frame_spoke =
new G4ExtrudedSolid(name_base_spoke,
362 wagon_wheel_front_frame_thickness / 2.,
365 G4LogicalVolume *log_solid_wagon_wheel_front_frame_spoke =
new G4LogicalVolume(solid_wagon_wheel_front_frame_spoke, material, name_base_spoke);
369 for (
int sector_id = 0; sector_id < n_sectors; ++sector_id)
371 G4Transform3D trans_spoke(CLHEP::HepRotationZ(wagon_wheel_sector_phi_offset + sector_dphi * sector_id), g4vec_wagon_wheel_front_frame);
373 assmeblyvol->AddPlacedVolume(log_solid_wagon_wheel_front_frame_spoke,
387 std::cout << __PRETTY_FUNCTION__ <<
" - wagon_wheel_rim_outer z_start = " << z_start << std::endl;
395 G4ThreeVector g4vec_wagon_wheel_rim_outer(0, 0, z_start + wagon_wheel_rim_outer_thickness / 2.);
399 G4VSolid *solid_wagon_wheel =
new G4Tubs(
401 wagon_wheel_rim_outer_Rin,
402 wagon_wheel_rim_outer_Rout,
403 wagon_wheel_rim_outer_thickness / 2.,
406 G4LogicalVolume *log_solid_wagon_wheel =
new G4LogicalVolume(solid_wagon_wheel, material, name_base);
409 assmeblyvol->AddPlacedVolume(log_solid_wagon_wheel,
410 g4vec_wagon_wheel_rim_outer,
429 std::vector<G4TwoVector> vertexes;
430 vertexes.push_back(G4TwoVector(0, wagon_wheel_spoke_R_inner));
431 vertexes.push_back(G4TwoVector(0, wagon_wheel_spoke_R_outer));
432 vertexes.push_back(G4TwoVector(wagon_wheel_spoke_height_outer, wagon_wheel_spoke_R_outer));
433 vertexes.push_back(G4TwoVector(wagon_wheel_spoke_height_inner, wagon_wheel_spoke_R_inner));
434 G4TwoVector
zero(0, 0);
436 G4VSolid *solid_wagon_wheel_spoke =
new G4ExtrudedSolid(name_base,
438 wagon_wheel_spoke_width / 2.,
441 G4LogicalVolume *log_solid_wagon_wheel_spoke =
new G4LogicalVolume(solid_wagon_wheel_spoke, material, name_base);
444 G4ThreeVector g4vec_wagon_wheel_spoke(0, 0, z_start + wagon_wheel_spoke_width / 2.);
447 for (
int sector_id = 0; sector_id < n_sectors; ++sector_id)
449 G4RotateY3D rotm_spoke(-90 *
deg);
450 G4Transform3D trans_spoke(CLHEP::HepRotationZ(wagon_wheel_sector_phi_offset + sector_dphi * sector_id),
451 g4vec_wagon_wheel_spoke);
452 G4Transform3D trans_spoke_final = trans_spoke * rotm_spoke;
454 assmeblyvol->AddPlacedVolume(log_solid_wagon_wheel_spoke,
473 assert(n_radial_modules >= 1);
481 if (electronics_cooling_block_thickness > 0)
485 std::cout << __PRETTY_FUNCTION__ <<
" - electronics_cooling_block_material z_start = " << z_start << std::endl;
490 if (material ==
nullptr)
492 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: missing material " <<
m_Params->
get_string_param(
"electronics_cooling_block_material_name") << std::endl;
497 G4ThreeVector g4vec_electronics_cooling_block(0, 0, z_start + electronics_cooling_block_thickness / 2.);
502 for (
int ring_id = 0; ring_id <= n_radial_modules; ++ring_id)
504 G4double Rin = electronics_cooling_block_R_inner;
505 G4double Rout = electronics_cooling_block_R_outer;
513 if (ring_id < n_radial_modules)
522 const G4double spoke_phi = atan2(wagon_wheel_spoke_width, Rin);
526 G4VSolid *solid =
new G4Tubs(
530 electronics_cooling_block_thickness / 2.,
531 spoke_phi, sector_dphi - 2 * spoke_phi);
535 std::cout << __PRETTY_FUNCTION__ <<
" - electronics_cooling_block " << name_base
536 <<
" Rin = " << Rin <<
" Rout = " << Rout
537 <<
" phi = " << spoke_phi <<
" to " << (sector_dphi - spoke_phi) << std::endl;
541 G4LogicalVolume *log_vol =
new G4LogicalVolume(solid, material, name_base);
544 for (
int sector_id = 0; sector_id < n_sectors; ++sector_id)
547 CLHEP::HepRotationZ(wagon_wheel_sector_phi_offset + sector_dphi * sector_id),
548 g4vec_electronics_cooling_block);
550 assmeblyvol->AddPlacedVolume(log_vol, trans);
565 const G4double electronics_assemly_thickness = electronics_FEE_Cu_thickness + electronics_FEE_PCB_thickness + electronics_FEE_Al_thickness;
569 for (
int ring_id = 1; ring_id <= n_radial_modules; ++ring_id)
574 electronics_assemly_thickness;
578 electronics_assemly_thickness;
583 std::cout << __PRETTY_FUNCTION__ <<
" warning : ignore FEE construction for module " << ring_id <<
" as "
589 G4AssemblyVolume *assmeblyvol_electronics =
new G4AssemblyVolume();
590 G4double starting_electronics(0);
595 std::cout << __PRETTY_FUNCTION__ <<
" - electronics G4_PCB z_start = " << z_start
596 <<
" starting_electronics = " << starting_electronics << std::endl;
598 starting_electronics -= electronics_FEE_PCB_thickness / 2.;
599 G4ThreeVector g4vec_electronics;
600 g4vec_electronics.set(starting_electronics, (Rout + Rin) * .5, z_start + electronics_FEE_depth / 2.);
601 starting_electronics -= electronics_FEE_PCB_thickness / 2.;
602 G4VSolid *solid_electronics =
nullptr;
603 solid_electronics =
new G4Box(name_base +
"_PCB",
604 electronics_FEE_PCB_thickness / 2.,
606 electronics_FEE_depth / 2.);
608 G4LogicalVolume *log_electronics =
nullptr;
609 log_electronics =
new G4LogicalVolume(solid_electronics,
GetDetectorMaterial(
"FR4"), name_base +
"_PCB");
612 assmeblyvol_electronics->AddPlacedVolume(log_electronics,
613 g4vec_electronics,
nullptr);
617 std::cout << __PRETTY_FUNCTION__ <<
" - electronics G4_Cu z_start = " << z_start
618 <<
" starting_electronics = " << starting_electronics << std::endl;
620 starting_electronics -= electronics_FEE_Cu_thickness / 2.;
621 g4vec_electronics.set(starting_electronics, (Rout + Rin) * .5, z_start + electronics_FEE_depth / 2.);
622 starting_electronics -= electronics_FEE_Cu_thickness / 2.;
624 solid_electronics =
new G4Box(name_base +
"_Cu",
625 electronics_FEE_Cu_thickness / 2.,
627 electronics_FEE_depth / 2.);
629 log_electronics =
new G4LogicalVolume(solid_electronics,
GetDetectorMaterial(
"G4_Cu"), name_base +
"_Cu");
632 assmeblyvol_electronics->AddPlacedVolume(log_electronics,
633 g4vec_electronics,
nullptr);
637 std::cout << __PRETTY_FUNCTION__ <<
" - electronics Al z_start = " << z_start
638 <<
" starting_electronics = " << starting_electronics << std::endl;
640 starting_electronics -= electronics_FEE_Al_thickness / 2.;
641 g4vec_electronics.set(starting_electronics, (Rout + Rin) * .5, z_start + electronics_FEE_depth / 2.);
642 starting_electronics -= electronics_FEE_Al_thickness / 2.;
644 solid_electronics =
new G4Box(name_base +
"_Al",
645 electronics_FEE_Al_thickness / 2.,
647 electronics_FEE_depth / 2.);
649 log_electronics =
new G4LogicalVolume(solid_electronics,
654 assmeblyvol_electronics->AddPlacedVolume(log_electronics,
655 g4vec_electronics,
nullptr);
658 for (
int sector_id = 0; sector_id < n_sectors; ++sector_id)
660 const G4double sector_phi_shift = wagon_wheel_sector_phi_offset + sector_dphi * sector_id;
661 const G4double spoke_phi = atan2(wagon_wheel_spoke_width, Rin);
662 const G4double board_dphi = (sector_dphi - 2 * spoke_phi) / (nFEE + 1);
663 const G4double board_phi_start = sector_phi_shift + spoke_phi + board_dphi;
665 for (
int board_id = 0; board_id < nFEE; ++board_id)
667 G4Transform3D trans_electronic = G4RotateZ3D(board_phi_start + board_dphi * board_id);
669 assmeblyvol->AddPlacedAssembly(assmeblyvol_electronics, trans_electronic);
680 std::cout <<
"PHG4TpcEndCap Detector:" << std::endl;
681 if (what ==
"ALL" || what ==
"VOLUME")
683 std::cout <<
"Version 0.1" << std::endl;
684 std::cout <<
"Parameters:" << std::endl;