4 #include <phparameter/PHParameters.h>
11 #include <Geant4/G4Box.hh>
12 #include <Geant4/G4Cons.hh>
13 #include <Geant4/G4CutTubs.hh>
14 #include <Geant4/G4DisplacedSolid.hh>
15 #include <Geant4/G4LogicalVolume.hh>
16 #include <Geant4/G4Material.hh>
17 #include <Geant4/G4MaterialPropertiesTable.hh>
18 #include <Geant4/G4MaterialPropertyVector.hh>
19 #include <Geant4/G4PVPlacement.hh>
20 #include <Geant4/G4RotationMatrix.hh>
21 #include <Geant4/G4SubtractionSolid.hh>
22 #include <Geant4/G4ThreeVector.hh>
23 #include <Geant4/G4Transform3D.hh>
24 #include <Geant4/G4Tubs.hh>
25 #include <Geant4/G4Types.hh>
26 #include <Geant4/G4VPhysicalVolume.hh>
27 #include <Geant4/G4NistManager.hh>
48 , m_Params(parameters)
49 , m_ActiveFlag(m_Params->get_int_param(
"active"))
50 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
51 , m_SupportActiveFlag(m_Params->get_int_param(
"supportactive"))
52 , m_TowerLogicNamePrefix(
"bcalTower")
53 , m_SuperDetector(
"NONE")
61 G4LogicalVolume* mylogvol = volume->GetLogicalVolume();
93 std::cout <<
"PHG4BarrelEcalDetector: Begin Construction" << std::endl;
98 std::cout <<
"ERROR in PHG4BarrelEcalDetector: No mapping file specified. Abort detector construction." << std::endl;
99 std::cout <<
"Please run set_string_param(\"mapping_file\", std::string filename ) first." << std::endl;
124 G4double pos_x1 = 0 *
cm;
125 G4double pos_y1 = 0 *
cm;
126 G4double pos_z1 = 0 *
cm;
128 G4Tubs* cylinder_solid1 =
new G4Tubs(
"BCAL_SOLID1",
130 becal_length / 2, 0, 2 *
M_PI);
132 G4Tubs* cylinder_solid2 =
new G4Tubs(
"BCAL_SOLID2",
133 Radius - 1, max_radius + 1,
134 abs(CenterZ_Shift), 0, 2 *
M_PI);
136 G4ThreeVector shift_cs2 = G4ThreeVector(0, 0, becal_length / 2);
138 G4VSolid* cylinder_solid3 =
new G4SubtractionSolid(
"BCAL_SOLID3", cylinder_solid1, cylinder_solid2, 0, shift_cs2);
140 G4Cons* cone1 =
new G4Cons(
"cone1",
141 Radius - 1, Radius - 1,
142 Radius - 1, Radius + cone1_h,
143 cone1_dz, 0, 2 *
M_PI);
145 G4ThreeVector shift_cone1 = G4ThreeVector(0, 0, becal_length / 2 -
abs(CenterZ_Shift) - cone1_dz);
147 G4VSolid* cylinder_solid4 =
new G4SubtractionSolid(
"BCAL_SOLID4", cylinder_solid3, cone1, 0, shift_cone1);
149 G4Cons* cone2 =
new G4Cons(
"cone2",
150 Radius - 1, Radius + cone2_h,
151 Radius - 1, Radius - 1,
152 cone2_dz, 0, 2 *
M_PI);
154 G4ThreeVector shift_cone2 = G4ThreeVector(0, 0, -becal_length / 2 + cone2_dz);
156 G4VSolid* cylinder_solid =
new G4SubtractionSolid(
"BCAL_SOLID", cylinder_solid4, cone2, 0, shift_cone2);
159 assert(cylinder_mat);
161 G4LogicalVolume* cylinder_logic =
new G4LogicalVolume(cylinder_solid, cylinder_mat,
162 "BCAL_SOLID", 0, 0, 0);
168 G4PVPlacement* phys_envelope =
169 new G4PVPlacement(0, G4ThreeVector(pos_x1, pos_y1, pos_z1), cylinder_logic, name_envelope,
185 std::cout <<
"PHG4BarrelEcalDetector: Place tower " << iterator->first
186 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k << std::endl;
189 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
193 if (iterator->second.idx_k % 2 == 0)
203 if (iterator->second.idx_k % 2 == 0)
212 G4RotationMatrix becal_rotm;
213 becal_rotm.rotateY(iterator->second.rotx);
214 becal_rotm.rotateY(iterator->second.roty);
215 becal_rotm.rotateZ(iterator->second.rotz);
217 new G4PVPlacement(G4Transform3D(becal_rotm, G4ThreeVector(iterator->second.centerx, iterator->second.centery, iterator->second.centerz)),
219 G4String(
string(iterator->first) +
string(
"_TT")),
223 G4double posx_glass = iterator->second.centerx +
th / 2 *
abs(
cos(iterator->second.roty - M_PI_2)) *
cos(iterator->second.rotz);
224 G4double posy_glass = iterator->second.centery +
th / 2 *
abs(
cos(iterator->second.roty - M_PI_2)) * sin(iterator->second.rotz);
225 G4double posz_glass = iterator->second.centerz +
th * sin(iterator->second.roty - M_PI_2);
227 new G4PVPlacement(G4Transform3D(becal_rotm, G4ThreeVector(posx_glass, posy_glass, posz_glass)),
229 G4String(
string(iterator->first) +
string(
"_Glass")),
234 G4LogicalVolume* block_silicon =
ConstructSi(iterator);
237 G4double pTheta = iterator->second.pTheta;
238 G4double
theta = iterator->second.roty - M_PI_2;
240 G4double sci_sr = len * tan(pTheta);
241 G4double sci_sz = len;
242 G4double sci_mag = sqrt(sci_sr * sci_sr + sci_sz * sci_sz);
244 G4double posz_si = iterator->second.centerz - sci_mag * sin(theta + pTheta);
245 G4double posy_si = iterator->second.centery + sci_mag *
cos(theta + pTheta) * sin(iterator->second.rotz);
246 G4double posx_si = iterator->second.centerx + sci_mag *
cos(theta + pTheta) *
cos(iterator->second.rotz);
247 new G4PVPlacement(G4Transform3D(becal_rotm, G4ThreeVector(posx_si, posy_si, posz_si)),
249 G4String(
string(iterator->first) +
string(
"_Si")),
259 G4double kapton_sr = len * tan(pTheta);
260 G4double kapton_sz = len;
261 G4double kapton_mag = sqrt(kapton_sr * kapton_sr + kapton_sz * kapton_sz);
263 G4double posz_kapton = iterator->second.centerz - kapton_mag * sin(theta + pTheta);
264 G4double posy_kapton = iterator->second.centery + kapton_mag *
cos(theta + pTheta) * sin(iterator->second.rotz);
265 G4double posx_kapton = iterator->second.centerx + kapton_mag *
cos(theta + pTheta) *
cos(iterator->second.rotz);
266 new G4PVPlacement(G4Transform3D(becal_rotm, G4ThreeVector(posx_kapton, posy_kapton, posz_kapton)),
268 G4String(
string(iterator->first) +
string(
"_Kapton")),
278 G4double SIO2_sr = len * tan(pTheta);
279 G4double SIO2_sz = len;
280 G4double SIO2_mag = sqrt(SIO2_sr * SIO2_sr + SIO2_sz * SIO2_sz);
282 G4double posz_SIO2 = iterator->second.centerz - SIO2_mag * sin(theta + pTheta);
283 G4double posy_SIO2 = iterator->second.centery + SIO2_mag *
cos(theta + pTheta) * sin(iterator->second.rotz);
284 G4double posx_SIO2 = iterator->second.centerx + SIO2_mag *
cos(theta + pTheta) *
cos(iterator->second.rotz);
285 new G4PVPlacement(G4Transform3D(becal_rotm, G4ThreeVector(posx_SIO2, posy_SIO2, posz_SIO2)),
287 G4String(
string(iterator->first) +
string(
"SIO2")),
294 if (iterator->second.idx_k % 2 == 0)
305 G4double Carbon_sr = len * tan(pTheta);
306 G4double Carbon_sz = len;
307 G4double Carbon_mag = sqrt(Carbon_sr * Carbon_sr + Carbon_sz * Carbon_sz);
309 G4double posz_Carbon = iterator->second.centerz - Carbon_mag * sin(theta + pTheta);
310 G4double posy_Carbon = iterator->second.centery + Carbon_mag *
cos(theta + pTheta) * sin(iterator->second.rotz);
311 G4double posx_Carbon = iterator->second.centerx + Carbon_mag *
cos(theta + pTheta) *
cos(iterator->second.rotz);
312 new G4PVPlacement(G4Transform3D(becal_rotm, G4ThreeVector(posx_Carbon, posy_Carbon, posz_Carbon)),
314 G4String(
string(iterator->first) +
string(
"Carbon")),
324 std::ifstream istream_mapping;
326 if (!istream_mapping.is_open())
328 std::cout <<
"ERROR in PHG4BarrelEcalDetector: Failed to open mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
333 std::string line_mapping;
334 while (
getline(istream_mapping, line_mapping))
336 std::istringstream iss(line_mapping);
338 if (line_mapping.find(
"BECALtower ") != string::npos)
340 unsigned idphi_j, ideta_k;
342 G4double rot_z, rot_y, rot_x;
343 G4double
size_z, size_y1, size_x1, size_y2, size_x2, p_Theta;
346 if (!(iss >> dummys >> ideta_k >> idphi_j >> size_x1 >> size_x2 >> size_y1 >> size_y2 >> size_z >> p_Theta >> cx >> cy >> cz >> rot_x >> rot_y >> rot_z))
348 std::cout <<
"ERROR in PHG4BarrelEcalDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mapping_file") << std::endl;
354 std::ostringstream towername;
365 tower_new.
pTheta = p_Theta;
369 tower_new.
rotx = rot_x;
370 tower_new.
roty = rot_y;
371 tower_new.
rotz = rot_z;
372 tower_new.
idx_j = idphi_j;
373 tower_new.
idx_k = ideta_k;
383 if (!(iss >> parname >> parval))
385 cout <<
"ERROR in PHG4CrystalCalorimeterDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mappingtower") << endl;
393 std::map<string, G4double>::iterator parit;
475 G4ThreeVector shift = G4ThreeVector(-
th * sin(iterator->second.roty - M_PI_2), 0,
th / 2 *
abs(
cos(iterator->second.roty - M_PI_2)));
476 G4VSolid* block_solid =
new G4SubtractionSolid(G4String(
string(iterator->first) +
string(
"_Envelope")), block_tower, block_glass, 0, shift);
478 assert(material_shell);
480 G4LogicalVolume* block_logic =
new G4LogicalVolume(block_solid, material_shell,
481 G4String(
string(iterator->first) +
string(
"_Tower")), 0, 0,
492 assert(material_glass);
493 G4LogicalVolume* block_logic =
new G4LogicalVolume(block_solid, material_glass,
494 G4String(
string(iterator->first) +
string(
"_Glass")), 0, 0,
502 static string matname =
"CrystalCarbonFiber";
506 G4double density_carbon_fiber = 1.44 *
g /
cm3;
507 carbonfiber =
new G4Material(matname, density_carbon_fiber, 1);
515 static string matname =
"sciglass";
522 sciglass =
new G4Material(matname, density = 4.22 *
g /
cm3, ncomponents = 4, kStateSolid);
535 G4double size_x1 = iterator->second.sizex1 / 2 -
th;
536 G4double size_x2 = iterator->second.sizex2 / 2 -
th;
537 G4double size_y1 = iterator->second.sizey1 / 2 -
th;
538 G4double size_y2 = iterator->second.sizey2 / 2 -
th;
539 G4double
size_z = iterator->second.sizez / 2 -
th;
541 G4Trap* block_glass =
new G4Trap(
"solid_glass",
543 iterator->second.pTheta, 0,
544 size_y1, size_x1, size_x1,
546 size_y2, size_x2, size_x2,
555 G4Trap* block_tower =
new G4Trap(
"solid_tower",
556 iterator->second.sizez / 2,
557 iterator->second.pTheta, 0,
558 iterator->second.sizey1 / 2, iterator->second.sizex1 / 2, iterator->second.sizex1 / 2.,
560 iterator->second.sizey2 / 2, iterator->second.sizex2 / 2, iterator->second.sizex2 / 2.,
570 G4double size_x1 = iterator->second.sizex1 / 2 - th +
overlap;
571 G4double size_x2 = iterator->second.sizex2 / 2 - th +
overlap;
572 G4double size_y1 = iterator->second.sizey1 / 2 - th +
overlap;
573 G4double size_y2 = iterator->second.sizey2 / 2 - th +
overlap;
574 G4double
size_z = iterator->second.sizez / 2 - th / 2 +
overlap;
576 G4Trap* block_glass =
new G4Trap(
"solid_glass",
578 iterator->second.pTheta, 0,
579 size_y1, size_x1, size_x1,
581 size_y2, size_x2, size_x2,
590 G4double size_x1 = iterator->second.sizex2 / 2 -
overlap;
591 G4double size_x2 = iterator->second.sizex2 / 2 -
overlap;
592 G4double size_y1 = iterator->second.sizey2 / 2 -
overlap;
593 G4double size_y2 = iterator->second.sizey2 / 2 -
overlap;
596 G4Trap* block_si =
new G4Trap(
"Si",
598 iterator->second.pTheta, 0,
599 size_y1, size_x1, size_x1,
601 size_y2, size_x2, size_x2,
611 G4Trap* block_solid =
GetSiTrap(iterator);
614 G4LogicalVolume* block_logic =
new G4LogicalVolume(block_solid, material_si,
615 G4String(
string(iterator->first) +
string(
"_solid_Si")), 0, 0,
622 G4double size_x1 = iterator->second.sizex2 / 2 -
overlap;
623 G4double size_x2 = iterator->second.sizex2 / 2 -
overlap;
624 G4double size_y1 = iterator->second.sizey2 / 2 -
overlap;
625 G4double size_y2 = iterator->second.sizey2 / 2 -
overlap;
627 G4Trap* block_si =
new G4Trap(
"Kapton",
629 iterator->second.pTheta, 0,
630 size_y1, size_x1, size_x1,
632 size_y2, size_x2, size_x2,
643 assert(material_kapton);
644 G4LogicalVolume* block_logic =
new G4LogicalVolume(block_solid, material_kapton,
645 G4String(
string(iterator->first) +
string(
"_solid_Si")), 0, 0,
652 G4double size_x1 = iterator->second.sizex2 / 2 -
overlap;
653 G4double size_x2 = iterator->second.sizex2 / 2 -
overlap;
654 G4double size_y1 = iterator->second.sizey2 / 2 -
overlap;
655 G4double size_y2 = iterator->second.sizey2 / 2 -
overlap;
658 G4Trap* block_SIO2 =
new G4Trap(
"SIO2",
660 iterator->second.pTheta, 0,
661 size_y1, size_x1, size_x1,
663 size_y2, size_x2, size_x2,
674 assert(material_SIO2);
675 G4LogicalVolume* block_logic =
new G4LogicalVolume(block_solid, material_SIO2,
676 G4String(
string(iterator->first) +
string(
"_solid_material_SIO2")), 0, 0,
683 G4double size_x1 = iterator->second.sizex2 / 2 -
overlap;
684 G4double size_x2 = iterator->second.sizex2 / 2 -
overlap;
685 G4double size_y1 = iterator->second.sizey2 / 2 -
overlap;
686 G4double size_y2 = iterator->second.sizey2 / 2 -
overlap;
689 G4Trap* block_SIO2 =
new G4Trap(
"C",
691 iterator->second.pTheta, 0,
692 size_y1, size_x1, size_x1,
694 size_y2, size_x2, size_x2,
706 assert(material_Carbon);
707 G4LogicalVolume* block_logic =
new G4LogicalVolume(block_solid, material_Carbon,
708 G4String(
string(iterator->first) +
string(
"_solid_material_C")), 0, 0,