25 #include <phparameter/PHParameters.h>
31 #include <Geant4/G4Color.hh>
32 #include <Geant4/G4Box.hh>
33 #include <Geant4/G4LogicalVolume.hh>
34 #include <Geant4/G4Material.hh>
35 #include <Geant4/G4PVPlacement.hh>
36 #include <Geant4/G4SubtractionSolid.hh>
37 #include <Geant4/G4SystemOfUnits.hh>
38 #include <Geant4/G4Tubs.hh>
39 #include <Geant4/G4Box.hh>
40 #include <Geant4/G4RotationMatrix.hh>
41 #include <Geant4/G4SystemOfUnits.hh>
42 #include <Geant4/G4ThreeVector.hh>
43 #include <Geant4/G4Transform3D.hh>
44 #include <Geant4/G4Types.hh>
45 #include <Geant4/G4VPhysicalVolume.hh>
47 #include <Geant4/G4UnionSolid.hh>
48 #include <Geant4/G4VisAttributes.hh>
68 const std::string &dnam,
const int lyr)
70 , m_Params(parameters)
72 , _mapping_tower_file(
"")
73 , m_TowerLogicNamePrefix(
"BwdECALTower")
104 std::cout <<
"EICG4BwdDetector: Begin Construction" << std::endl;
150 std::cout <<
"ERROR in EICG4BwdDetector: No mapping file specified. Abort detector construction." << std::endl;
169 bwd_ecal_log->SetVisAttributes(vis);
176 bwd_ecal_log, name_envelope, logicWorld, 0,
false,
OverlapCheck());
181 cout <<
"Bwd ECal Envelope Location: x, y, z:"<<endl;
205 std::cout <<
"EICG4BwdDetector: Build logical volume for single tower..." << std::endl;
217 G4VSolid* single_tower_solid =
new G4Box(
"single_tower_solid",
224 "single_tower_logic",
231 return single_tower_logic;
241 std::cout <<
"EICG4BwdDetector: Place tower " << iterator->first
242 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k
243 <<
" at x = " << iterator->second.x /
cm <<
" , y = " << iterator->second.y /
cm <<
" , z = " << iterator->second.z /
cm << std::endl;
246 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
261 std::ifstream istream_mapping;
264 if (!istream_mapping.is_open())
266 std::cout <<
"ERROR in EICG4BwdDetector: Failed to open mapping file " <<
_mapping_tower_file << std::endl;
271 std::string line_mapping;
272 while (getline(istream_mapping, line_mapping))
275 if (line_mapping.find(
"#") != std::string::npos)
279 std::cout <<
"EICG4BwdDetector: SKIPPING line in mapping file: " << line_mapping << std::endl;
284 std::istringstream iss(line_mapping);
285 unsigned idx_j, idx_k, idx_l;
287 double Gpos_x, Gpos_y, Gpos_z, Gpos_z1;
296 if (line_mapping.find(
"Bwd ") != std::string::npos)
298 if (!(iss >> dummys>> Gpos_x >> Gpos_y >> Gpos_z >> Gpos_z1 ))
300 std::cout <<
"ERROR in EICG4BwdDetector: Failed to read global position from mapping file " <<
_mapping_tower_file << std::endl;
305 std::cout <<
"Bwd position changed since mapping file produced or wrong mapping is used "<<
_mapping_tower_file << std::endl;
307 std::cout<< Gpos_x <<
" " <<Gpos_y<<
" "<<Gpos_z <<std::endl;
316 else if (line_mapping.find(
"Tower ") != std::string::npos){
318 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))
321 std::cout <<
"ERROR in EICG4BwdDetector: Failed to read line in mapping file " <<
_mapping_tower_file << std::endl;
327 std::ostringstream towername;
341 tower_new.
idx_j = idx_j;
342 tower_new.
idx_k = idx_k;
345 else std::cout <<
"ERROR in EICG4BwdDetector: Unknown line in Mapping File " <<
_mapping_tower_file << std::endl;
354 std::cout <<
"EICG4Bwd Detector:" << std::endl;
355 if (what ==
"ALL" || what ==
"VOLUME")
357 std::cout <<
"Version 0.1" << std::endl;
358 std::cout <<
"Parameters:" << std::endl;