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")
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;
130 becal_length / 2, 0, 2 *
M_PI);
133 Radius - 1, max_radius + 1,
134 abs(CenterZ_Shift), 0, 2 *
M_PI);
141 Radius - 1, Radius - 1,
142 Radius - 1, Radius + cone1_h,
143 cone1_dz, 0, 2 *
M_PI);
150 Radius - 1, Radius + cone2_h,
151 Radius - 1, Radius - 1,
152 cone2_dz, 0, 2 *
M_PI);
159 assert(cylinder_mat);
162 "BCAL_SOLID", 0, 0, 0);
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)
213 becal_rotm.
rotateY(iterator->second.rotx);
214 becal_rotm.
rotateY(iterator->second.roty);
215 becal_rotm.
rotateZ(iterator->second.rotz);
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);
229 G4String(
string(iterator->first) +
string(
"_Glass")),
237 G4double pTheta = iterator->second.pTheta;
240 G4double sci_sr = len * tan(pTheta);
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);
249 G4String(
string(iterator->first) +
string(
"_Si")),
259 G4double kapton_sr = len * tan(pTheta);
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);
268 G4String(
string(iterator->first) +
string(
"_Kapton")),
278 G4double SIO2_sr = len * tan(pTheta);
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);
287 G4String(
string(iterator->first) +
string(
"SIO2")),
294 if (iterator->second.idx_k % 2 == 0)
305 G4double Carbon_sr = len * tan(pTheta);
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);
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;
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;
478 assert(material_shell);
481 G4String(
string(iterator->first) +
string(
"_Tower")), 0, 0,
492 assert(material_glass);
494 G4String(
string(iterator->first) +
string(
"_Glass")), 0, 0,
502 static string matname =
"CrystalCarbonFiber";
507 carbonfiber =
new G4Material(matname, density_carbon_fiber, 1);
515 static string matname =
"sciglass";
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;
543 iterator->second.pTheta, 0,
544 size_y1, size_x1, size_x1,
546 size_y2, size_x2, size_x2,
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.,
578 iterator->second.pTheta, 0,
579 size_y1, size_x1, size_x1,
581 size_y2, size_x2, size_x2,
598 iterator->second.pTheta, 0,
599 size_y1, size_x1, size_x1,
601 size_y2, size_x2, size_x2,
615 G4String(
string(iterator->first) +
string(
"_solid_Si")), 0, 0,
629 iterator->second.pTheta, 0,
630 size_y1, size_x1, size_x1,
632 size_y2, size_x2, size_x2,
643 assert(material_kapton);
645 G4String(
string(iterator->first) +
string(
"_solid_Si")), 0, 0,
660 iterator->second.pTheta, 0,
661 size_y1, size_x1, size_x1,
663 size_y2, size_x2, size_x2,
674 assert(material_SIO2);
676 G4String(
string(iterator->first) +
string(
"_solid_material_SIO2")), 0, 0,
691 iterator->second.pTheta, 0,
692 size_y1, size_x1, size_x1,
694 size_y2, size_x2, size_x2,
706 assert(material_Carbon);
708 G4String(
string(iterator->first) +
string(
"_solid_material_C")), 0, 0,