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/G4SystemOfUnits.hh>
19 #include <Geant4/G4ThreeVector.hh>
20 #include <Geant4/G4Transform3D.hh>
21 #include <Geant4/G4Types.hh>
22 #include <Geant4/G4VPhysicalVolume.hh>
42 , m_Params(parameters)
43 , m_ActiveFlag(m_Params->get_int_param(
"active"))
44 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
45 , m_TowerLogicNamePrefix(
"hHcalTower")
46 , m_SuperDetector(
"NONE")
52 G4LogicalVolume* mylogvol = volume->GetLogicalVolume();
76 std::cout <<
"PHG4BackwardHcalDetector: Begin Construction" << std::endl;
81 cout <<
"ERROR in PHG4BackwardHcalDetector: No mapping file specified. Abort detector construction." << endl;
82 cout <<
"Please run set_string_param(\"mapping_file\", std::string filename ) first." << endl;
93 G4VSolid* hcal_envelope_solid =
new G4Cons(
"hHcal_envelope_solid",
101 G4LogicalVolume* hcal_envelope_log =
new G4LogicalVolume(hcal_envelope_solid, WorldMaterial,
"hHcal_envelope", 0, 0, 0);
106 G4RotationMatrix hcal_rotm;
117 hcal_envelope_log, name_envelope, logicWorld, 0,
false,
OverlapCheck());
134 std::cout <<
"PHG4BackwardHcalDetector: Build logical volume for single tower..." << std::endl;
145 G4VSolid* single_tower_solid =
new G4Box(
"single_tower_solid",
150 G4LogicalVolume* single_tower_logic =
new G4LogicalVolume(single_tower_solid,
152 "single_tower_logic",
159 G4int nlayers = TowerDz / (thickness_absorber + thickness_scintillator);
161 G4VSolid* solid_absorber =
new G4Box(
"single_plate_absorber_solid",
162 (TowerDx - WlsDw) / 2.0,
163 (TowerDy - SupportDw) / 2.0,
164 thickness_absorber / 2.0);
166 G4VSolid* solid_scintillator =
new G4Box(
"single_plate_scintillator",
167 (TowerDx - WlsDw) / 2.0,
168 (TowerDy - SupportDw) / 2.0,
169 thickness_scintillator / 2.0);
171 G4VSolid* solid_WLS_plate =
new G4Box(
"single_plate_wls",
173 (TowerDy - SupportDw) / 2.0,
176 G4VSolid* solid_support_plate =
new G4Box(
"single_plate_support",
187 G4LogicalVolume* logic_absorber =
new G4LogicalVolume(solid_absorber,
189 "single_plate_absorber_logic",
194 G4LogicalVolume* logic_scint =
new G4LogicalVolume(solid_scintillator,
195 material_scintillator,
196 "hHcal_scintillator_plate_logic",
200 G4LogicalVolume* logic_wls =
new G4LogicalVolume(solid_WLS_plate,
202 "hHcal_wls_plate_logic",
206 G4LogicalVolume* logic_support =
new G4LogicalVolume(solid_support_plate,
208 "hHcal_support_plate_logic",
218 G4double xpos_i = -WlsDw / 2.0;
219 G4double ypos_i = -SupportDw / 2.0;
220 G4double zpos_i = (-1 * TowerDz / 2.0) + thickness_absorber / 2.0;
230 for (
int i = 1; i <= nlayers; i++)
232 new G4PVPlacement(0, G4ThreeVector(xpos_i, ypos_i, zpos_i),
238 zpos_i += (thickness_absorber / 2. + thickness_scintillator / 2.);
240 new G4PVPlacement(0, G4ThreeVector(xpos_i, ypos_i, zpos_i),
246 zpos_i += (thickness_absorber / 2. + thickness_scintillator / 2.);
248 new G4PVPlacement(0, G4ThreeVector(0, (TowerDy / 2) - SupportDw / 2, 0),
254 new G4PVPlacement(0, G4ThreeVector((TowerDx / 2) - WlsDw / 2, -SupportDw / 2, 0),
263 std::cout <<
"PHG4BackwardHcalDetector: Building logical volume for single tower done." << std::endl;
266 return single_tower_logic;
276 std::cout <<
"PHG4BackwardHcalDetector: Place tower " << iterator->first
277 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k
278 <<
" at x = " << iterator->second.x <<
" , y = " << iterator->second.y <<
" , z = " << iterator->second.z << std::endl;
281 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
282 new G4PVPlacement(0, G4ThreeVector(iterator->second.x, iterator->second.y, iterator->second.z),
295 ifstream istream_mapping;
297 if (!istream_mapping.is_open())
299 std::cout <<
"ERROR in PHG4BackwardHcalDetector: Failed to open mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
305 while (
getline(istream_mapping, line_mapping))
308 if (line_mapping.find(
"#") != string::npos)
312 std::cout <<
"PHG4BackwardHcalDetector: SKIPPING line in mapping file: " << line_mapping << std::endl;
317 istringstream iss(line_mapping);
320 if (line_mapping.find(
"Tower ") != string::npos)
322 unsigned idx_j, idx_k, idx_l;
323 G4double pos_x, pos_y, pos_z;
324 G4double size_x, size_y,
size_z;
325 G4double rot_x, rot_y, rot_z;
330 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))
332 cout <<
"ERROR in PHG4BackwardHcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
338 ostringstream towername;
352 tower_new.
idx_j = idx_j;
353 tower_new.
idx_k = idx_k;
363 if (!(iss >> parname >> parval))
365 cout <<
"ERROR in PHG4BackwardHcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
374 std::map<string, G4double>::iterator parit;