27 #include <phparameter/PHParameters.h>
34 #include <Geant4/G4Box.hh>
35 #include <Geant4/G4Color.hh>
36 #include <Geant4/G4LogicalVolume.hh>
37 #include <Geant4/G4Material.hh>
38 #include <Geant4/G4PVPlacement.hh>
39 #include <Geant4/G4RotationMatrix.hh>
40 #include <Geant4/G4SubtractionSolid.hh>
41 #include <Geant4/G4SystemOfUnits.hh>
42 #include <Geant4/G4ThreeVector.hh>
43 #include <Geant4/G4Transform3D.hh>
44 #include <Geant4/G4Tubs.hh>
45 #include <Geant4/G4Types.hh>
46 #include <Geant4/G4UnionSolid.hh>
47 #include <Geant4/G4VPhysicalVolume.hh>
48 #include <Geant4/G4VisAttributes.hh>
66 const std::string &dnam,
const int lyr)
68 , m_Params(parameters)
70 , _mapping_tower_file(
"")
71 , m_TowerLogicNamePrefix(
"B0ECALTower")
102 std::cout <<
"EICG4B0ECALDetector: Begin Construction" << std::endl;
108 std::cout <<
" !!! No PACKMAN" << std::endl;
147 std::cout <<
"ERROR in EICG4B0EcalDetector: No mapping file specified. Abort detector construction." << std::endl;
161 b0_ecal_log->SetVisAttributes(vis);
166 b0_ecal_log, name_envelope, logicWorld, 0,
false,
OverlapCheck());
172 std::cout <<
"B0 ECal Envelope Location: x, y, z:" << std::endl;
194 std::cout <<
"EICG4B0ECALDetector: Build logical volume for single tower..." << std::endl;
207 G4VSolid *single_tower_solid =
new G4Box(
"single_tower_solid",
214 "single_tower_logic",
221 return single_tower_logic;
231 std::cout <<
"EICG4B0ECALDetector: Place tower " << iterator->first
232 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k
233 <<
" at x = " << iterator->second.x /
cm <<
" , y = " << iterator->second.y /
cm <<
" , z = " << iterator->second.z /
cm << std::endl;
236 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
251 std::ifstream istream_mapping;
254 if (!istream_mapping.is_open())
256 std::cout <<
"ERROR in EICG4B0ECALDetector: Failed to open mapping file " <<
_mapping_tower_file << std::endl;
261 std::string line_mapping;
262 while (getline(istream_mapping, line_mapping))
265 if (line_mapping.find(
"#") != std::string::npos)
269 std::cout <<
"EICG4B0ECALDetector: SKIPPING line in mapping file: " << line_mapping << std::endl;
274 std::istringstream iss(line_mapping);
275 unsigned idx_j, idx_k, idx_l;
277 double Gpos_x, Gpos_y, Gpos_z, Gpos_z1;
286 if (line_mapping.find(
"B0 ") != std::string::npos)
288 if (!(iss >> dummys >> Gpos_x >> Gpos_y >> Gpos_z >> Gpos_z1))
290 std::cout <<
"ERROR in EICG4B0Detector: Failed to read global position from mapping file " <<
_mapping_tower_file << std::endl;
295 std::cout << std::endl;
296 std::cout <<
"B0 position changed since mapping file produced or wrong mapping is used " <<
_mapping_tower_file << std::endl;
298 std::cout << Gpos_x <<
" " << Gpos_y <<
" " << Gpos_z << std::endl;
307 else if (line_mapping.find(
"Tower ") != std::string::npos)
310 if (!(iss >> dummys >> idx_j >> idx_k >> idx_l >> pos_x >> pos_y >> pos_z >> size_x >> size_y >> size_z >> rot_x >> rot_y >> rot_z >> dummy))
313 std::cout <<
"ERROR in EICG4B0ECALDetector: Failed to read line in mapping file " <<
_mapping_tower_file << std::endl;
319 std::ostringstream towername;
333 tower_new.
idx_j = idx_j;
334 tower_new.
idx_k = idx_k;
338 std::cout <<
"ERROR in EICG4B0ECALDetector: Unknown line in Mapping File " <<
_mapping_tower_file << std::endl;
347 std::cout <<
"EICG4B0ECAL Detector:" << std::endl;
348 if (what ==
"ALL" || what ==
"VOLUME")
350 std::cout <<
"Version 0.1" << std::endl;
351 std::cout <<
"Parameters:" << std::endl;