6 #include <phparameter/PHParameters.h>
8 #include <Geant4/G4Box.hh>
9 #include <Geant4/G4Cons.hh>
10 #include <Geant4/G4LogicalVolume.hh>
11 #include <Geant4/G4Material.hh>
12 #include <Geant4/G4PVPlacement.hh>
13 #include <Geant4/G4RotationMatrix.hh>
14 #include <Geant4/G4String.hh>
15 #include <Geant4/G4SystemOfUnits.hh>
16 #include <Geant4/G4ThreeVector.hh>
17 #include <Geant4/G4Transform3D.hh>
18 #include <Geant4/G4Types.hh>
38 , _tower_dz(170.0 *
mm)
39 , _materialScintillator(
"G4_POLYSTYRENE")
40 , _materialAbsorber(
"G4_Pb")
49 cout <<
"PHG4EICForwardEcalDetector: Begin Construction" << endl;
58 G4VSolid* ecal_envelope_solid =
new G4Cons(
"hEcal_envelope_solid",
64 G4LogicalVolume* ecal_envelope_log =
new G4LogicalVolume(ecal_envelope_solid, Air, G4String(
"hEcal_envelope"), 0, 0, 0);
70 G4RotationMatrix ecal_rotm;
76 ostringstream name_envelope;
77 name_envelope.str(
"");
81 ecal_envelope_log, name_envelope.str().c_str(), logicWorld, 0,
false,
OverlapCheck());
98 cout <<
"PHG4EICForwardEcalDetector: Build logical volume for single tower..." << endl;
104 G4VSolid* single_tower_solid =
new G4Box(G4String(
"single_tower_solid"),
109 G4LogicalVolume* single_tower_logic =
new G4LogicalVolume(single_tower_solid,
111 "single_tower_logic",
116 G4double thickness_layer =
_tower_dz / (float) nlayers;
117 G4double thickness_absorber = thickness_layer / 3.0 * 2.0;
118 G4double thickness_scintillator = thickness_layer / 3.0 * 1.0;
125 G4VSolid* solid_absorber =
new G4Box(G4String(
"single_plate_absorber_solid"),
128 thickness_absorber / 2.0);
130 G4VSolid* solid_scintillator =
new G4Box(G4String(
"single_plate_scintillator"),
133 thickness_scintillator / 2.0);
139 G4LogicalVolume* logic_absorber =
new G4LogicalVolume(solid_absorber,
141 "single_plate_absorber_logic",
144 G4LogicalVolume* logic_scint =
new G4LogicalVolume(solid_scintillator,
145 material_scintillator,
146 "hEcal_scintillator_plate_logic",
156 G4double zpos_i = (-1 *
_tower_dz / 2.0) + thickness_absorber / 2.0;
158 ostringstream name_absorber;
159 name_absorber.str(
"");
162 ostringstream name_scintillator;
163 name_scintillator.str(
"");
166 for (
int i = 1; i <= nlayers; i++)
168 new G4PVPlacement(0, G4ThreeVector(xpos_i, ypos_i, zpos_i),
170 name_absorber.str().c_str(),
174 zpos_i += (thickness_absorber / 2. + thickness_scintillator / 2.);
176 new G4PVPlacement(0, G4ThreeVector(xpos_i, ypos_i, zpos_i),
178 name_scintillator.str().c_str(),
182 zpos_i += (thickness_absorber / 2. + thickness_scintillator / 2.);
189 cout <<
"PHG4EICForwardEcalDetector: Building logical volume for single tower done." << endl;
192 return single_tower_logic;
198 typedef std::map<std::string, towerposition>::iterator it_type;
204 cout <<
"PHG4EICForwardEcalDetector: Place tower " << iterator->first
205 <<
" at x = " << iterator->second.x <<
" , y = " << iterator->second.y <<
" , z = " << iterator->second.z << endl;
208 new G4PVPlacement(0, G4ThreeVector(iterator->second.x, iterator->second.y, iterator->second.z),
210 iterator->first.c_str(),
221 ifstream istream_mapping;
222 istream_mapping.open(
GetParams()->get_string_param(
"mapping_file"));
223 if (!istream_mapping.is_open())
225 cout <<
"ERROR in PHG4EICForwardEcalDetector: Failed to open mapping file " <<
GetParams()->
get_string_param(
"mapping_file") << endl;
231 while (
getline(istream_mapping, line_mapping))
234 if (line_mapping.find(
"#") != string::npos)
238 cout <<
"PHG4EICForwardEcalDetector: SKIPPING line in mapping file: " << line_mapping << endl;
243 istringstream iss(line_mapping);
246 if (line_mapping.find(
"Tower ") != string::npos)
248 unsigned idx_j, idx_k, idx_l;
249 G4double pos_x, pos_y, pos_z;
250 G4double size_x, size_y,
size_z;
251 G4double rot_x, rot_y, rot_z;
256 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))
258 cerr <<
"ERROR in PHG4EICForwardEcalDetector: Failed to read line in mapping file " <<
GetParams()->
get_string_param(
"mapping_file") << endl;
264 ostringstream towername;
278 _map_tower.insert(make_pair(towername.str(), tower_new));
287 if (!(iss >> parname >> parval))
289 cerr <<
"ERROR in PHG4EICForwardEcalDetector: Failed to read line in mapping file " <<
GetParams()->
get_string_param(
"mapping_file") << endl;
297 std::map<string, double>::const_iterator parit;
312 for (
int i = 0; i < 2; i++)
316 rad <<
"Gr" << index <<
"_inner";
323 rad <<
"Gr" << index <<
"_outer";