7 #include <phparameter/PHParameters.h>
26 #include <calobase/RawTowerDefs.h>
27 #include <calobase/RawTowerGeom.h>
28 #include <calobase/RawTowerGeomContainer.h>
29 #include <calobase/RawTowerGeomContainer_Cylinderv1.h>
30 #include <calobase/RawTowerGeomv1.h>
34 #include <Geant4/G4AssemblyVolume.hh>
35 #include <Geant4/G4LogicalVolume.hh>
36 #include <Geant4/G4Material.hh>
37 #include <Geant4/G4PVPlacement.hh>
38 #include <Geant4/G4RotationMatrix.hh>
39 #include <Geant4/G4String.hh>
40 #include <Geant4/G4SystemOfUnits.hh>
41 #include <Geant4/G4ThreeVector.hh>
42 #include <Geant4/G4Transform3D.hh>
43 #include <Geant4/G4Tubs.hh>
44 #include <Geant4/G4VPhysicalVolume.hh>
45 #include <Geant4/G4VSolid.hh>
47 #pragma GCC diagnostic push
48 #pragma GCC diagnostic ignored "-Wshadow"
49 #pragma GCC diagnostic ignored "-Wpedantic"
50 #include <Geant4/G4GDMLParser.hh>
51 #include <Geant4/G4GDMLReadStructure.hh>
52 #pragma GCC diagnostic pop
54 #include <boost/lexical_cast.hpp>
55 #include <boost/tokenizer.hpp>
61 #include <type_traits>
71 , m_Params(parameters)
72 , m_InnerRadius(m_Params->get_double_param(
"inner_radius") *
cm)
73 , m_OuterRadius(m_Params->get_double_param(
"outer_radius") *
cm)
74 , m_SizeZ(m_Params->get_double_param(
"size_z") *
cm)
75 , m_NumScintiPlates(m_Params->get_int_param(PHG4HcalDefs::
scipertwr) * m_Params->get_int_param(
"n_towers"))
76 , m_Active(m_Params->get_int_param(
"active"))
77 , m_AbsorberActive(m_Params->get_int_param(
"absorberactive"))
78 , m_GDMPath(m_Params->get_string_param(
"GDMPath"))
118 G4LogicalVolume *hcal_envelope_log =
new G4LogicalVolume(hcal_envelope_cylinder, worldmat,
"Hcal_envelope",
nullptr,
nullptr,
nullptr);
120 G4RotationMatrix hcal_rotm;
133 const G4MaterialTable *mtable = G4Material::GetMaterialTable();
134 int nMaterials = G4Material::GetNumberOfMaterials();
135 for (G4int
i = 0;
i < nMaterials; ++
i)
137 const G4Material *mat = (*mtable)[
i];
138 if (mat->GetName() ==
"Uniplast_scintillator")
140 if ((mat->GetIonisation()->GetBirksConstant()) == 0)
153 std::unique_ptr<G4GDMLReadStructure>
reader(
new G4GDMLReadStructure());
154 G4GDMLParser gdmlParser(reader.get());
158 G4AssemblyVolume *abs_asym = reader->GetAssembly(
"InnerSector");
160 std::vector<G4VPhysicalVolume *>::iterator
it = abs_asym->GetVolumesIterator();
161 static const unsigned int tilepersec = 24 * 4 * 2;
162 for (
unsigned int isector = 0; isector < abs_asym->TotalImprintedVolumes(); isector++)
166 hcalenvelope->AddDaughter((*it));
168 m_VolumeSteel += (*it)->GetLogicalVolume()->GetSolid()->GetCubicVolume();
170 unsigned int ioff = isector * tilepersec;
171 for (
unsigned int j = 0;
j < ioff;
j++)
175 for (
unsigned int j = ioff;
j < ioff + tilepersec;
j++)
179 hcalenvelope->AddDaughter((*its));
197 <<
" cm" << std::endl;
205 std::cout <<
"Inner Hcal Detector:" << std::endl;
206 if (what ==
"ALL" || what ==
"VOLUME")
209 std::cout <<
"Volume Steel: " <<
m_VolumeSteel /
cm3 <<
" cm^3" << std::endl;
223 std::cout <<
"could not locate volume " << volume->GetName()
224 <<
" in Inner Hcal scintillator map" << std::endl;
238 std::cout <<
"could not locate volume " << volume->GetName()
239 <<
" in Inner Hcal Absorber map" << std::endl;
248 boost::char_separator<char> sep(
"_");
249 boost::tokenizer<boost::char_separator<char>> tok(volume->GetName(), sep);
250 boost::tokenizer<boost::char_separator<char>>::const_iterator tokeniter;
251 int layer_id = -1, tower_id = -1;
252 for (tokeniter = tok.begin(); tokeniter != tok.end(); ++tokeniter)
254 if (*tokeniter ==
"impr")
257 if (tokeniter != tok.end())
259 layer_id = boost::lexical_cast<
int>(*tokeniter) / 2;
263 std::cout <<
"invalid scintillator row " << layer_id
270 std::cout <<
PHWHERE <<
" Error parsing " << volume->GetName()
271 <<
" for mother volume number " << std::endl;
277 for (tokeniter = tok.begin(); tokeniter != tok.end(); ++tokeniter)
279 if (*tokeniter ==
"pv")
282 if (tokeniter != tok.end())
284 tower_id = boost::lexical_cast<
int>(*tokeniter);
300 int itmp = tower_id / 2;
421 rowid = layer_id + 68;
423 else if (layer_id > 60 && layer_id < 188)
425 rowid = layer_id + 68;
427 else if (layer_id >= 188)
429 rowid = layer_id - 188;
433 if (rowid > 255) rowid -= 256;
435 if (rowid > 255 || rowid < 0)
437 std::cout <<
PHWHERE <<
" row id out of range: " << rowid << std::endl;
450 std::cout <<
PHWHERE <<
"Run Node missing, exiting." << std::endl;
475 double geom_ref_radius = innerrad + thickness / 2.;
477 if (!std::isfinite(phistart))
479 std::cout <<
PHWHERE <<
" phistart is not finite: " << phistart
480 <<
", exiting now (this will crash anyway)" << std::endl;
486 std::pair<double, double> range = std::make_pair(phiend, phistart);
496 double etahibound = etalowbound +
498 std::pair<double, double> range = std::make_pair(etalowbound, etahibound);
500 etalowbound = etahibound;
517 std::cout <<
"IHCalDetector::InitRun - Tower geometry " << key <<
" already exists" << std::endl;
520 if (fabs(tg->get_center_x() -
x) > 1
e-4)
522 std::cout <<
"IHCalDetector::InitRun - Fatal Error - duplicated Tower geometry " << key <<
" with existing x = " << tg->
get_center_x() <<
" and expected x = " << x
527 if (fabs(tg->get_center_y() -
y) > 1
e-4)
529 std::cout <<
"IHCalDetector::InitRun - Fatal Error - duplicated Tower geometry " << key <<
" with existing y = " << tg->get_center_y() <<
" and expected y = " << y
533 if (fabs(tg->get_center_z() -
z) > 1
e-4)
535 std::cout <<
"IHCalDetector::InitRun - Fatal Error - duplicated Tower geometry " << key <<
" with existing z= " << tg->get_center_z() <<
" and expected z = " <<
z
544 std::cout <<
"IHCalDetector::InitRun - building tower geometry " << key <<
"" << std::endl;