4 #include <phparameter/PHParameters.h>
12 #include <Geant4/G4Box.hh>
13 #include <Geant4/G4Cons.hh>
14 #include <Geant4/G4LogicalVolume.hh>
15 #include <Geant4/G4Material.hh>
16 #include <Geant4/G4PVPlacement.hh>
17 #include <Geant4/G4RotationMatrix.hh>
18 #include <Geant4/G4SubtractionSolid.hh>
19 #include <Geant4/G4SystemOfUnits.hh>
20 #include <Geant4/G4ThreeVector.hh>
21 #include <Geant4/G4Transform3D.hh>
22 #include <Geant4/G4Types.hh>
23 #include <Geant4/G4VPhysicalVolume.hh>
41 , m_Params(parameters)
42 , m_ActiveFlag(m_Params->get_int_param(
"active"))
43 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
44 , m_SupportActiveFlag(m_Params->get_int_param(
"supportactive"))
45 , m_TowerLogicNamePrefix(
"hHcalTower")
46 , m_SuperDetector(
"NONE")
84 std::cout <<
"PHG4ForwardHcalDetector: Begin Construction" << std::endl;
89 std::cout <<
"ERROR in PHG4ForwardHcalDetector: No mapping file specified. Abort detector construction." << std::endl;
90 std::cout <<
"Please run set_string_param(\"mapping_file\", std::string filename ) first." << std::endl;
106 G4VSolid* hcal_envelope_solid =
new G4Cons(
"FHCAL_envelope_solid_cutout",
129 hcal_envelope_log, name_envelope, logicWorld, 0,
false,
OverlapCheck());
146 std::cout <<
"PHG4ForwardHcalDetector: Build logical volume for single tower..." << std::endl;
157 G4VSolid* single_tower_solid =
new G4Box(
"single_tower_solid",
164 "single_tower_logic",
171 G4int nlayers = TowerDz / (thickness_absorber + thickness_scintillator);
173 G4VSolid* solid_absorber =
new G4Box(
"single_plate_absorber_solid",
174 (TowerDx - WlsDw) / 2.0,
175 (TowerDy - SupportDw) / 2.0,
176 thickness_absorber / 2.0);
178 G4VSolid* solid_scintillator =
new G4Box(
"single_plate_scintillator",
179 (TowerDx - WlsDw) / 2.0,
180 (TowerDy - SupportDw) / 2.0,
181 thickness_scintillator / 2.0);
185 (TowerDy - SupportDw) / 2.0,
188 G4VSolid* solid_support_plate =
new G4Box(
"single_plate_support",
203 material_absorber =
new G4Material(
"FeTungstenMix", density = 10.1592 *
g /
cm3, natoms = 2);
209 "single_plate_absorber_logic",
215 material_scintillator,
216 "hHcal_scintillator_plate_logic",
222 "hHcal_wls_plate_logic",
228 "hHcal_support_plate_logic",
241 G4double zpos_i = (-1 * TowerDz / 2.0) + thickness_absorber / 2.0;
251 for (
int i = 1; i <= nlayers; i++)
259 zpos_i += (thickness_absorber / 2. + thickness_scintillator / 2.);
267 zpos_i += (thickness_absorber / 2. + thickness_scintillator / 2.);
284 std::cout <<
"PHG4ForwardHcalDetector: Building logical volume for single tower done." << std::endl;
287 return single_tower_logic;
297 std::cout <<
"PHG4ForwardHcalDetector: Place tower " << iterator->first
298 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k
299 <<
" at x = " << iterator->second.x <<
" , y = " << iterator->second.y <<
" , z = " << iterator->second.z << std::endl;
302 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
316 std::ifstream istream_mapping;
318 if (!istream_mapping.is_open())
320 std::cout <<
"ERROR in PHG4ForwardHcalDetector: Failed to open mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
325 std::string line_mapping;
326 while (getline(istream_mapping, line_mapping))
329 if (line_mapping.find(
"#") != std::string::npos)
333 std::cout <<
"PHG4ForwardHcalDetector: SKIPPING line in mapping file: " << line_mapping << std::endl;
338 std::istringstream iss(line_mapping);
341 if (line_mapping.find(
"Tower ") != std::string::npos)
343 unsigned idx_j, idx_k, idx_l;
351 if (!(iss >> dummys >> dummy >> idx_j >> idx_k >> idx_l >> pos_x >> pos_y >> pos_z >> size_x >> size_y >> size_z >> rot_x >> rot_y >> rot_z))
353 std::cout <<
"ERROR in PHG4ForwardHcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
359 std::ostringstream towername;
373 tower_new.
idx_j = idx_j;
374 tower_new.
idx_k = idx_k;
384 if (!(iss >> parname >> parval))
386 std::cout <<
"ERROR in PHG4ForwardHcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
395 std::map<std::string, G4double>::iterator parit;