3 #include <phparameter/PHParameters.h>
11 #include <Geant4/G4Box.hh>
12 #include <Geant4/G4LogicalVolume.hh>
13 #include <Geant4/G4Material.hh>
14 #include <Geant4/G4PVPlacement.hh>
15 #include <Geant4/G4PhysicalConstants.hh>
16 #include <Geant4/G4RotationMatrix.hh>
17 #include <Geant4/G4String.hh>
18 #include <Geant4/G4SystemOfUnits.hh>
19 #include <Geant4/G4ThreeVector.hh>
20 #include <Geant4/G4Transform3D.hh>
21 #include <Geant4/G4Tubs.hh>
22 #include <Geant4/G4Types.hh>
23 #include <Geant4/G4VPhysicalVolume.hh>
42 , m_Params(parameters)
43 , m_scintLogical(nullptr)
44 , m_absorberLogical(nullptr)
45 , m_tower_size_x(m_Params->get_double_param(
"tower_x")*cm)
46 , m_tower_size_y(m_Params->get_double_param(
"tower_y")*cm)
47 , m_tower_size_z(m_Params->get_double_param(
"tower_z")*cm)
48 , m_ntowers_x(m_Params->get_int_param(
"n_towers_x"))
49 , m_ntowers_y(m_Params->get_int_param(
"n_towers_y"))
50 , m_npbsc_layers(m_Params->get_int_param(
"n_layers"))
51 , m_ActiveFlag(m_Params->get_int_param(
"active"))
52 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
53 , m_SuperDetector(
"NONE")
60 G4LogicalVolume* mylogvol = volume->GetLogicalVolume();
63 if(m_scintLogical == mylogvol)
return 1;
65 if(m_AbsorberActiveFlag > 0)
67 if(m_absorberLogical == mylogvol)
return -1;
77 std::cout <<
"PHG4EMCalDetector: Begin Construction for " <<
name << std::endl;
81 double xLength_enve = m_tower_size_x*m_ntowers_x*cm;
82 double yLength_enve = m_tower_size_y*m_ntowers_y*cm;
83 double zLength_enve = m_tower_size_z*cm;
84 G4VSolid* emcal_enve_solid =
new G4Box(
name+
"_enve_solid", xLength_enve/2., yLength_enve/2., zLength_enve/2.);
86 G4Material* mat_Air = G4Material::GetMaterial(
"G4_AIR");
87 G4LogicalVolume* emcal_enve_logic =
new G4LogicalVolume(emcal_enve_solid, mat_Air,
name+
"_enve_logic");
89 G4RotationMatrix rot_enve;
94 G4ThreeVector loc_enve;
99 new G4PVPlacement(G4Transform3D(rot_enve, loc_enve), emcal_enve_logic,
name+
"_enve_phys", logicWorld,
false, 0,
overlapcheck);
102 G4LogicalVolume* singleTower_logic = ConstructSingleTower();
105 PlaceTower(emcal_enve_logic, singleTower_logic);
108 G4LogicalVolume* PHG4EMCalDetector::ConstructSingleTower()
112 std::cout <<
"PHG4EMCalDetector: Build logical volume for a single tower ..." << std::endl;
116 G4Material* mat_Air = G4Material::GetMaterial(
"G4_AIR");
117 G4VSolid* singleTower_solid =
new G4Box(
name+
"_singleTower_solid", m_tower_size_x/2., m_tower_size_y/2., m_tower_size_z/2.);
118 G4LogicalVolume* singleTower_logic =
new G4LogicalVolume(singleTower_solid, mat_Air,
name+
"_singleTower_logic");
122 double thickness_layer = m_tower_size_z/(float)m_npbsc_layers;
123 double thickness_absorber = 1.5*mm;
124 double thickness_scint = 4.0*mm;
125 double thickness_airgap = thickness_layer - thickness_absorber - thickness_scint;
127 G4VSolid* absorber_solid =
new G4Box(
name+
"_absorberplate_solid", m_tower_size_x/2., m_tower_size_y/2., thickness_absorber/2.);
128 G4VSolid* scint_solid =
new G4Box(
name+
"_scintplate_solid", m_tower_size_x/2., m_tower_size_y/2., thickness_scint/2.);
130 G4Material* mat_absorber = G4Material::GetMaterial(
"G4_Pb");
131 G4Material* mat_scint = G4Material::GetMaterial(
"G4_POLYSTYRENE");
132 m_absorberLogical =
new G4LogicalVolume(absorber_solid, mat_absorber,
name+
"_absorberplate_logic");
133 m_scintLogical =
new G4LogicalVolume(scint_solid, mat_scint,
name+
"_scintplace_logic");
136 double zpos_i = -m_tower_size_z/2. + thickness_absorber/2.;
137 for(
int i = 0; i < m_npbsc_layers; ++i)
140 new G4PVPlacement(0, G4ThreeVector(0., 0., zpos_i), m_absorberLogical, TString::Format(
"%s_absplate_%d",
name.c_str(), i).Data(), singleTower_logic,
false, i,
overlapcheck);
144 zpos_i += (thickness_absorber/2. + thickness_airgap/2. + thickness_scint/2.);
145 new G4PVPlacement(0, G4ThreeVector(0., 0., zpos_i), m_scintLogical, TString::Format(
"%s_sciplate_%d",
name.c_str(), i).Data(), singleTower_logic,
false, i,
overlapcheck);
149 zpos_i += (thickness_scint/2. + thickness_airgap/2. + thickness_absorber/2.);
152 return singleTower_logic;
155 void PHG4EMCalDetector::PlaceTower(G4LogicalVolume* envelope_Logic, G4LogicalVolume* singleTower_logic)
158 for(
int i = 0; i < m_ntowers_x; ++i)
160 double x_pos = -0.5*m_ntowers_x*m_tower_size_x + (i + 0.5)*m_tower_size_x;
161 for(
int j = 0; j < m_ntowers_y; ++j)
163 double y_pos = -0.5*m_ntowers_y*m_tower_size_y + (j + 0.5)*m_tower_size_y;
166 std::cout <<
" -- Placing tower (" << i <<
", " << j <<
") at x = " << x_pos/cm <<
" cm, y = " << y_pos/cm <<
" cm" << std::endl;
169 new G4PVPlacement(0, G4ThreeVector(x_pos, y_pos, 0.), singleTower_logic, TString::Format(
"%s_tower_%d_%d",
name.c_str(), i, j).Data(), envelope_Logic,
false, copyNo++,
overlapcheck);
@ VERBOSITY_SOME
Output some useful messages during manual command line running.
base class for phenix detector creation
virtual int Verbosity() const
int IsInForwardEcal(G4VPhysicalVolume *) const
virtual void Construct(G4LogicalVolume *world)
construct
PHG4EMCalDetector(PHCompositeNode *Node, PHParameters *parameters, const std::string &dnam="EMCal", const int lyr=0)
constructor
double get_double_param(const std::string &name) const