4 #include <phparameter/PHParameters.h>
12 #include <Geant4/G4Box.hh>
13 #include <Geant4/G4Cons.hh>
14 #include <Geant4/G4Element.hh>
15 #include <Geant4/G4LogicalVolume.hh>
16 #include <Geant4/G4Material.hh>
17 #include <Geant4/G4PVPlacement.hh>
18 #include <Geant4/G4RotationMatrix.hh>
19 #include <Geant4/G4String.hh>
20 #include <Geant4/G4SubtractionSolid.hh>
21 #include <Geant4/G4SystemOfUnits.hh>
22 #include <Geant4/G4ThreeVector.hh>
23 #include <Geant4/G4Transform3D.hh>
24 #include <Geant4/G4Types.hh>
42 , m_SuperDetector(
"NONE")
43 , m_Params(parameters)
45 , _towerlogicnameprefix(
"CrystalCalorimeterTower")
46 , m_IsActive(m_Params->get_int_param(
"active"))
47 , m_AbsorberActive(m_Params->get_int_param(
"absorberactive"))
76 cout <<
"PHG4CrystalCalorimeterDetector: Begin Construction" << endl;
81 cout <<
"ERROR in PHG4CrystalCalorimeterDetector: No tower mapping file specified. Abort detector construction." << endl;
82 cout <<
"Please run set_string_param(\"mappingtower\", std::string filename ) first." << endl;
93 G4VSolid* eemc_envelope_solid =
new G4Cons(
"eemc_envelope_solid",
99 G4LogicalVolume* eemc_envelope_log =
new G4LogicalVolume(eemc_envelope_solid, WorldMaterial, G4String(
"eemc_envelope"), 0, 0, 0);
103 G4RotationMatrix eemc_rotm;
114 eemc_envelope_log, name_envelope, logicWorld, 0,
false,
OverlapCheck());
131 cout <<
"PHG4CrystalCalorimeterDetector: Build logical volume for single tower..." << endl;
134 G4double carbon_thickness = 0.009 *
cm;
135 G4double airgap_crystal_carbon = 0.012 *
cm;
146 G4VSolid* single_tower_solid =
new G4Box(G4String(
"single_tower_solid"),
151 G4LogicalVolume* single_tower_logic =
new G4LogicalVolume(single_tower_solid,
153 "single_tower_logic",
157 G4VSolid* solid_crystal =
new G4Box(G4String(
"single_crystal_solid"),
163 G4VSolid* Carbon_hunk_solid =
new G4Box(G4String(
"Carbon_hunk_solid"),
166 ((tower_dz / 2.0) - 1 *
mm));
168 G4double lead_dx = tower_dx - 2.0 * carbon_thickness;
169 G4double lead_dy = tower_dy - 2.0 * carbon_thickness;
171 G4VSolid* lead_solid =
new G4Box(G4String(
"lead_solid"),
176 G4SubtractionSolid* Carbon_shell_solid =
new G4SubtractionSolid(G4String(
"Carbon_Shell_solid"),
180 G4ThreeVector(0.00 *
mm, 0.00 *
mm, 0.00 *
mm));
185 G4LogicalVolume* logic_crystal =
new G4LogicalVolume(solid_crystal,
187 "single_crystal_logic",
203 G4LogicalVolume* logic_shell =
new G4LogicalVolume(Carbon_shell_solid,
205 "single_absorber_logic",
215 G4VPhysicalVolume* physvol =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
224 physvol =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
232 cout <<
"PHG4CrystalCalorimeterDetector: Building logical volume for single tower done." << endl;
235 return single_tower_logic;
241 typedef std::map<std::string, towerposition>::iterator it_type;
247 cout <<
"PHG4CrystalCalorimeterDetector: Place tower " << iterator->first
248 <<
" idx_j = " << iterator->second.idx_j <<
", idx_k = " << iterator->second.idx_k
249 <<
" at x = " << iterator->second.x <<
" , y = " << iterator->second.y <<
" , z = " << iterator->second.z << endl;
251 int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
252 new G4PVPlacement(0, G4ThreeVector(iterator->second.x, iterator->second.y, iterator->second.z),
266 if (!istream_mapping.is_open())
268 cout <<
"ERROR in PHG4CrystalCalorimeterDetector: Failed to open mapping file " <<
m_Params->
get_string_param(
"mappingtower") << endl;
274 while (
getline(istream_mapping, line_mapping))
277 if (line_mapping.find(
"#") != string::npos)
281 cout <<
"PHG4CrystalCalorimeterDetector: SKIPPING line in mapping file: " << line_mapping << endl;
286 istringstream iss(line_mapping);
289 if (line_mapping.find(
"Tower ") != string::npos)
291 unsigned idx_j, idx_k, idx_l;
292 G4double pos_x, pos_y, pos_z;
293 G4double size_x, size_y,
size_z;
294 G4double rot_x, rot_y, rot_z;
299 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))
301 cout <<
"ERROR in PHG4CrystalCalorimeterDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mappingtower") << endl;
307 ostringstream towername;
321 tower_new.
idx_j = idx_j;
322 tower_new.
idx_k = idx_k;
323 _map_tower.insert(make_pair(towername.str(), tower_new));
332 if (!(iss >> parname >> parval))
334 cout <<
"ERROR in PHG4CrystalCalorimeterDetector: Failed to read line in mapping file " <<
m_Params->
get_string_param(
"mappingtower") << endl;
343 std::map<string, G4double>::iterator parit;
432 static string matname =
"CrystalCarbonFiber";
436 G4double density_carbon_fiber = 1.44 *
g /
cm3;
437 carbonfiber =
new G4Material(matname, density_carbon_fiber, 1);
438 carbonfiber->AddElement(G4Element::GetElement(
"C"), 1);