5 #include <phparameter/PHParameters.h>
16 #include <Geant4/G4Box.hh>
17 #include <Geant4/G4Cons.hh>
18 #include <Geant4/G4LogicalSkinSurface.hh>
19 #include <Geant4/G4LogicalVolume.hh>
20 #include <Geant4/G4Material.hh>
21 #include <Geant4/G4MaterialPropertiesTable.hh>
22 #include <Geant4/G4OpticalSurface.hh>
23 #include <Geant4/G4PVPlacement.hh>
24 #include <Geant4/G4PVReplica.hh>
25 #include <Geant4/G4PhysicalConstants.hh>
26 #include <Geant4/G4Polyhedra.hh>
27 #include <Geant4/G4RotationMatrix.hh>
28 #include <Geant4/G4String.hh>
29 #include <Geant4/G4SubtractionSolid.hh>
30 #include <Geant4/G4SystemOfUnits.hh>
31 #include <Geant4/G4ThreeVector.hh>
32 #include <Geant4/G4Transform3D.hh>
33 #include <Geant4/G4Tubs.hh>
34 #include <Geant4/G4Types.hh>
35 #include <Geant4/G4VPhysicalVolume.hh>
53 , m_Params(parameters)
55 , m_ActiveFlag(m_Params->get_int_param(
"active"))
56 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
57 , m_doLightProp(
false)
59 for (
int i = 0; i < 3; i++)
65 for (
int i = 3; i < 7; i++)
107 std::cout <<
"PHG4ForwardEcalDetector: Begin Construction" << std::endl;
122 (
m_dZ + tower_readout_dz),
124 G4VSolid* ecal_envelope_solid =
new G4Cons(
"FEMC_envelope_solid_cutout",
127 (
m_dZ + tower_readout_dz) / 2.0,
146 ecal_envelope_log, name_envelope, logicWorld, 0,
false,
OverlapCheck());
149 G4LogicalVolume* singletower[7] = {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};
150 typedef std::map<std::string, towerposition>::iterator it_type;
153 for (
int i = 0; i < 7; i++)
155 if (iterator->second.type == i && singletower[i] ==
nullptr)
164 std::cout << singletower << std::endl;
178 std::cout <<
"PHG4ForwardEcalDetector: Build logical volume for single tower, type = " << type << std::endl;
200 if (fiber_diam > 0) fiber_extra_length = 0.5 *
cm;
206 G4VSolid* single_tower_solid =
new G4Box(
"single_tower_solid2",
209 (
m_TowerDz[2] + tower_readout_dz) / 2.0);
210 G4VSolid* single_tower_solid_replica =
new G4Box(
"single_tower_solid_replica",
217 "single_tower_logic2",
224 std::cout <<
" m_TowerDz[2] = " <<
m_TowerDz[2] <<
" thickness_layer = " << thickness_layer <<
" thickness_cell = " << thickness_cell << std::endl;
227 if (thickness_layer <= thickness_cell)
229 std::cout << __PRETTY_FUNCTION__
230 <<
"Tower size z (m_TowerDz[2) from database is too thin. "
231 <<
"It does not fit the layer structure as described in https://doi.org/10.1016/S0168-9002(02)01954-X !" << std::endl
232 <<
"Abort" << std::endl;
233 std::cout <<
" m_TowerDz[2] = " <<
m_TowerDz[2] <<
" i.e. nlayers " << nlayers <<
" * thickness_layer " << thickness_layer <<
" <= thickness_cell " << thickness_cell << std::endl;
243 thickness_cell / 2.0);
252 G4VSolid* solid_absorber =
new G4Box(
"single_plate_absorber_solid2",
255 thickness_absorber / 2.0);
257 G4VSolid* solid_scintillator =
new G4Box(
"single_plate_scintillator2",
262 thickness_scintillator / 2.0);
264 if (clamp_plate_width > 0)
266 G4VSolid* solid_clamp1 =
new G4Box(
"single_plate_clamp_solid1",
269 clamp_plate_width / 2.0);
284 if (nFibers > 0 && nFibers == 5 && fiber_diam > 0)
307 if (clamp_plate_width > 0)
309 G4VSolid* solid_clamp2 =
new G4Box(
"single_plate_clamp_solid2",
312 clamp_plate_width / 2.0);
334 if (width_coating > 0)
336 G4double depthCoating = 0.93 * thickness_scintillator;
337 G4double zPlaneCoating[2] = {0, depthCoating};
343 zPlaneCoating, rInnerCoating, rOuterCoating);
359 solid_scintillator =
new G4SubtractionSolid(
G4String(
"solid_scintillator_cuCoating"), solid_scintillator, solid_coating, rotCoating,
G4ThreeVector(0, 0, thickness_scintillator / 2.0 - depthCoating));
363 "single_plate_absorber_logic2",
367 material_scintillator,
368 "hEcal_scintillator_plate_logic2",
396 "single_tower_replica_logic",
400 new G4PVReplica(name_tower, miniblock_logic, single_tower_replica_logic,
401 kZAxis, nlayers, thickness_layer, 0);
406 single_tower_replica_logic,
407 "replicated_layers_placed",
412 if (nFibers > 0 && nFibers == 5 && fiber_diam > 0)
414 std::string fiberName =
"single_fiber_scintillator_solid" +
std::to_string(type);
416 0.0, fiber_diam / 2.0, (
m_TowerDz[2] + fiber_extra_length) / 2, 0.0, 2 *
M_PI);
421 std::string fiberLogicName =
"hEcal_scintillator_fiber_logic" +
std::to_string(type);
432 single_scintillator_logic,
433 name_scintillator +
"_center",
438 single_scintillator_logic,
439 name_scintillator +
"_tl",
444 single_scintillator_logic,
445 name_scintillator +
"_bl",
450 single_scintillator_logic,
451 name_scintillator +
"_tr",
456 single_scintillator_logic,
457 name_scintillator +
"_br",
464 std::cout <<
"PHG4ForwardEcalDetector: Building logical volume for single tower done." << std::endl;
467 return single_tower_logic;
477 std::cout <<
"PHG4ForwardEcalDetector: Place tower " << iterator->first
478 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k
479 <<
" at x = " << iterator->second.x <<
" , y = " << iterator->second.y <<
" , z = " << iterator->second.z << std::endl;
482 assert(iterator->second.type >= 0 && iterator->second.type <= 6);
484 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
510 const G4int ntab = 4;
515 G4double rIndexPstyrene[] = {1.5, 1.5, 1.5, 1.5};
517 G4double scintilFast[] = {0.0, 0.0, 1.0, 1.0};
519 fMPTPStyrene->
AddProperty(
"RINDEX", wls_Energy, rIndexPstyrene, ntab);
520 fMPTPStyrene->
AddProperty(
"ABSLENGTH", wls_Energy, absorption1, ntab);
521 fMPTPStyrene->
AddProperty(
"SCINTILLATIONCOMPONENT1", wls_Energy, scintilFast, ntab);
531 return material_ScintFEMC;
550 density = 1.86 *
g /
cm3;
553 Coating_FEMC->
AddMaterial(material_TiO2, fractionmass = 0.20);
588 std::cout <<
"PHG4ForwardEcalDetector: Making WLSFiberFEMC material..." << std::endl;
600 const G4int ntab = 4;
604 G4double RefractiveIndexFiber[] = {1.6, 1.6, 1.6, 1.6};
606 G4double EmissionFib[] = {1.0, 1.0, 0.0, 0.0};
609 mptWLSfiber->
AddProperty(
"RINDEX", wls_Energy, RefractiveIndexFiber, ntab);
610 mptWLSfiber->
AddProperty(
"WLSABSLENGTH", wls_Energy, AbsFiber, ntab);
611 mptWLSfiber->
AddProperty(
"WLSCOMPONENT", wls_Energy, EmissionFib, ntab);
617 std::cout <<
"PHG4ForwardEcalDetector: Making WLSFiberFEMC material done." << std::endl;
620 return material_WLSFiberFEMC;
626 std::ifstream istream_mapping;
628 if (!istream_mapping.is_open())
630 std::cout <<
"ERROR in PHG4ForwardEcalDetector: Failed to open mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
635 std::string line_mapping;
636 while (getline(istream_mapping, line_mapping))
639 if (line_mapping.find(
"#") != std::string::npos)
643 std::cout <<
"PHG4ForwardEcalDetector: SKIPPING line in mapping file: " << line_mapping << std::endl;
648 std::istringstream iss(line_mapping);
651 if (line_mapping.find(
"Tower ") != std::string::npos)
653 unsigned idx_j, idx_k, idx_l;
661 if (!(iss >> dummys >> type >> idx_j >> idx_k >> idx_l >> pos_x >> pos_y >> pos_z >> size_x >> size_y >> size_z >> rot_x >> rot_y >> rot_z))
663 std::cout <<
"ERROR in PHG4ForwardEcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
669 std::ostringstream towername;
681 tower_new.
idx_j = idx_j;
682 tower_new.
idx_k = idx_k;
693 if (!(iss >> parname >> parval))
695 std::cout <<
"ERROR in PHG4ForwardEcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
703 std::map<std::string, double>::iterator parit;
704 std::ostringstream twr;
705 for (
int i = 0; i < 7; i++)
708 twr <<
"Gtower" << i <<
"_dx";
712 twr <<
"Gtower" << i <<
"_dy";
716 twr <<
"Gtower" << i <<
"_dz";
720 std::ostringstream
rad;
721 for (
int i = 0; i < 2; i++)
725 rad <<
"Gr" << index <<
"_inner";
732 rad <<
"Gr" << index <<
"_outer";
742 m_dZ = parit->second *
cm;
809 assert(type >= 0 && type <= 6);