11 #include <phparameter/PHParameters.h>
15 #include <Geant4/G4LogicalVolume.hh>
16 #include <Geant4/G4Material.hh>
17 #include <Geant4/G4PVPlacement.hh>
18 #include <Geant4/G4String.hh>
19 #include <Geant4/G4SystemOfUnits.hh>
20 #include <Geant4/G4ThreeVector.hh>
21 #include <Geant4/G4Tubs.hh>
22 #include <Geant4/G4UserLimits.hh>
23 #include <Geant4/G4VPhysicalVolume.hh>
38 , m_Params(parameters)
39 , m_ActiveFlag(m_Params->get_int_param(
"active"))
40 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
41 , m_InnerCageRadius(m_Params->get_double_param(
"gas_inner_radius") *
cm - m_Params->get_double_param(
"cage_layer_9_thickness") *
cm - m_Params->get_double_param(
"cage_layer_8_thickness") *
cm - m_Params->get_double_param(
"cage_layer_7_thickness") *
cm - m_Params->get_double_param(
"cage_layer_6_thickness") *
cm - m_Params->get_double_param(
"cage_layer_5_thickness") *
cm - m_Params->get_double_param(
"cage_layer_4_thickness") *
cm - m_Params->get_double_param(
"cage_layer_3_thickness") *
cm - m_Params->get_double_param(
"cage_layer_2_thickness") *
cm - m_Params->get_double_param(
"cage_layer_1_thickness") *
cm)
42 , m_OuterCageRadius(m_Params->get_double_param(
"gas_outer_radius") *
cm + m_Params->get_double_param(
"cage_layer_9_thickness") *
cm + m_Params->get_double_param(
"cage_layer_8_thickness") *
cm + m_Params->get_double_param(
"cage_layer_7_thickness") *
cm + m_Params->get_double_param(
"cage_layer_6_thickness") *
cm + m_Params->get_double_param(
"cage_layer_5_thickness") *
cm + m_Params->get_double_param(
"cage_layer_4_thickness") *
cm + m_Params->get_double_param(
"cage_layer_3_thickness") *
cm + m_Params->get_double_param(
"cage_layer_2_thickness") *
cm + m_Params->get_double_param(
"cage_layer_1_thickness") *
cm)
82 if (std::isfinite(steplimits))
90 G4LogicalVolume *tpc_envelope_logic =
new G4LogicalVolume(tpc_envelope,
101 tpc_envelope_logic,
"tpc_envelope",
107 static std::map<int, std::string> tpcgasvolname =
119 material.push_back(
"G4_Ni");
120 thickness.push_back(.240 *
cm);
121 material.push_back(
"G4_Au");
122 thickness.push_back(.008 *
cm);
123 G4Material *temp =
nullptr;
135 G4LogicalVolume *tpc_window_logic =
new G4LogicalVolume(tpc_window,
148 G4VPhysicalVolume *tpc_window_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
149 tpc_window_logic,
"tpc_window",
158 double tpc_window_surface2_core_thickness = tpc_window_thickness - 2 * tpc_window_surface1_thickness;
159 double tpc_window_core_thickness = tpc_window_surface2_core_thickness - 2 * (tpc_window_surface2_thickness);
161 G4VSolid *tpc_window_surface2_core =
163 tpc_window_surface2_core_thickness / 2., 0., 2 *
M_PI);
164 G4LogicalVolume *tpc_window_surface2_core_logic =
new G4LogicalVolume(tpc_window_surface2_core,
166 "tpc_window_surface2_core");
174 G4VPhysicalVolume *tpc_window_surface2_core_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
175 tpc_window_surface2_core_logic,
"tpc_window_surface2_core",
181 G4VSolid *tpc_window_core =
183 tpc_window_core_thickness / 2., 0., 2 *
M_PI);
184 G4LogicalVolume *tpc_window_core_logic =
new G4LogicalVolume(tpc_window_core,
189 G4VPhysicalVolume *tpc_window_core_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
190 tpc_window_core_logic,
"tpc_window_core",
198 G4LogicalVolume *tpc_gas_logic =
new G4LogicalVolume(tpc_gas,
204 G4VPhysicalVolume *tpc_gas_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, (tpc_half_length + tpc_window_thickness) / 2.),
206 tpc_envelope,
false, PHG4TpcDefs::North,
OverlapCheck());
207 std::cout <<
"north copy no: " << tpc_gas_phys->GetCopyNo() << std::endl;
210 tpc_gas_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, -(tpc_half_length + tpc_window_thickness) / 2.),
212 tpc_envelope,
false, PHG4TpcDefs::South,
OverlapCheck());
214 std::cout <<
"south copy no: " << tpc_gas_phys->GetCopyNo() << std::endl;
217 #if G4VERSION_NUMBER >= 1033
218 const G4RegionStore *theRegionStore = G4RegionStore::GetInstance();
219 G4Region *tpcregion = theRegionStore->GetRegion(
"REGION_TPCGAS");
220 tpc_gas_logic->SetRegion(tpcregion);
221 tpcregion->AddRootLogicalVolume(tpc_gas_logic);
242 double hangerAngle=41.39*
M_PI/180.;
243 double hangerRadius=32.05*
inch;
244 double hangerX=std::sin(hangerAngle)*hangerRadius;
245 double hangerY=
std::cos(hangerAngle)*hangerRadius;
246 double hangerDiameter=2.*
inch;
248 G4LogicalVolume *hangerBeamLogic =
new G4LogicalVolume(hangerBeam,
253 G4VPhysicalVolume *tpc_hanger_beam_phys[2]={
nullptr,
nullptr};
254 tpc_hanger_beam_phys[0] =
new G4PVPlacement(0, G4ThreeVector(hangerX,hangerY, 0),
255 hangerBeamLogic,
"tpc_hanger_beam_left",
257 tpc_hanger_beam_phys[1] =
new G4PVPlacement(0, G4ThreeVector(-hangerX,hangerY, 0),
258 hangerBeamLogic,
"tpc_hanger_beam_right",
269 double rodAngleStart=
M_PI/12.;
270 double rodAngularSpacing=2*
M_PI/12.;
271 double rodRadius=31.5*
inch;
272 double rodWallThickness=1./8.*
inch;
273 double rodDiameter=3./4.*
inch;
274 G4VSolid *tieRod =
new G4Tubs(
"tpc_tie_rod",rodDiameter/2.-rodWallThickness, rodDiameter/2.,(
m_Params->
get_double_param(
"tpc_length") *
cm )/ 2., 0., 2*
M_PI);
275 G4LogicalVolume *tieRodLogic =
new G4LogicalVolume(tieRod,
279 G4VPhysicalVolume *tpc_tie_rod_phys[12]={
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
280 nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};
282 std::ostringstream
name;
283 for (
int i=0;i<12;i++){
284 double ang=rodAngleStart+rodAngularSpacing*i;
286 name <<
"tpc_tie_rod_" << i;
287 tpc_tie_rod_phys[i] =
new G4PVPlacement(0, G4ThreeVector(rodRadius*
cos(ang),rodRadius*sin(ang), 0),
288 tieRodLogic, name.str(),
313 static const int nlayers = 9;
339 std::ostringstream
name;
340 for (
int i = 0; i < nlayers; i++)
344 name <<
"tpc_cage_layer_" << layerno;
345 G4VSolid *tpc_cage_layer =
new G4Tubs(name.str(), tpc_cage_radius, tpc_cage_radius + thickness[i],
m_Params->
get_double_param(
"tpc_length") *
cm / 2., 0., 2 *
M_PI);
346 G4LogicalVolume *tpc_cage_layer_logic =
new G4LogicalVolume(tpc_cage_layer,
350 G4VPhysicalVolume *tpc_cage_layer_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
351 tpc_cage_layer_logic, name.str(),
354 tpc_cage_radius += thickness[i];
359 for (
int i = 0; i < nlayers; i++)
361 tpc_cage_radius -= thickness[i];
363 int layerno = 10 + 1 + i;
364 name <<
"tpc_cage_layer_" << layerno;
365 G4VSolid *tpc_cage_layer =
new G4Tubs(name.str(), tpc_cage_radius, tpc_cage_radius + thickness[i],
m_Params->
get_double_param(
"tpc_length") *
cm / 2., 0., 2 *
M_PI);
366 G4LogicalVolume *tpc_cage_layer_logic =
new G4LogicalVolume(tpc_cage_layer,
370 G4VPhysicalVolume *tpc_cage_layer_phys =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0),
371 tpc_cage_layer_logic, name.str(),
381 std::string compositeName,
382 std::vector<std::string> materialName,
389 std::cout << __PRETTY_FUNCTION__ <<
" NOTICE: Checking if material " << compositeName <<
" exists. This will return a warning if it doesn't, but that is okay." << std::endl;
392 if (tempmat !=
nullptr)
394 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: composite material " << compositeName <<
" already exists" << std::endl;
399 assert(materialName.size() == thickness.size());
402 double totalArealDensity = 0, totalThickness = 0;
403 for (std::vector<double>::size_type i = 0; i < thickness.size(); i++)
406 if (tempmat ==
nullptr)
408 std::cout << __PRETTY_FUNCTION__ <<
" Fatal Error: component material " << materialName[i] <<
" does not exist." << std::endl;
412 totalArealDensity += tempmat->GetDensity() * thickness[i];
413 totalThickness += thickness[i];
417 double compositeDensity = totalArealDensity / totalThickness;
418 G4Material *composite =
new G4Material(compositeName, compositeDensity, thickness.size());
421 for (std::vector<double>::size_type i = 0; i < thickness.size(); i++)
424 composite->AddMaterial(tempmat, thickness[i] * tempmat->GetDensity() / totalArealDensity);