8 #include <phparameter/PHParameters.h>
15 #include <phfield/PHFieldConfig.h>
16 #include <phfield/PHFieldUtility.h>
30 #include <calobase/RawTowerDefs.h>
31 #include <calobase/RawTowerGeom.h>
32 #include <calobase/RawTowerGeomContainer.h>
33 #include <calobase/RawTowerGeomContainer_Cylinderv1.h>
34 #include <calobase/RawTowerGeomv1.h>
38 #include <Geant4/G4AssemblyVolume.hh>
39 #include <Geant4/G4LogicalVolume.hh>
40 #include <Geant4/G4Material.hh>
41 #include <Geant4/G4PVPlacement.hh>
42 #include <Geant4/G4RotationMatrix.hh>
43 #include <Geant4/G4String.hh>
44 #include <Geant4/G4SystemOfUnits.hh>
45 #include <Geant4/G4ThreeVector.hh>
46 #include <Geant4/G4Transform3D.hh>
47 #include <Geant4/G4Tubs.hh>
48 #include <Geant4/G4VPhysicalVolume.hh>
49 #include <Geant4/G4VSolid.hh>
51 #pragma GCC diagnostic push
52 #pragma GCC diagnostic ignored "-Wshadow"
53 #pragma GCC diagnostic ignored "-Wpedantic"
54 #include <Geant4/G4GDMLParser.hh>
55 #include <Geant4/G4GDMLReadStructure.hh>
56 #pragma GCC diagnostic pop
58 #include <boost/lexical_cast.hpp>
59 #include <boost/tokenizer.hpp>
75 , m_InnerRadius(m_Params->get_double_param(
"inner_radius") *
cm)
76 , m_OuterRadius(m_Params->get_double_param(
"outer_radius") *
cm)
77 , m_SizeZ(m_Params->get_double_param(
"size_z") *
cm)
78 , m_NumScintiPlates(m_Params->get_int_param(PHG4HcalDefs::
scipertwr) * m_Params->get_int_param(
"n_towers"))
79 , m_ActiveFlag(m_Params->get_int_param(
"active"))
80 , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
81 , m_GDMPath(m_Params->get_string_param(
"GDMPath"))
132 G4LogicalVolume *hcal_envelope_log =
new G4LogicalVolume(hcal_envelope_cylinder, Air, G4String(
"OHCal_envelope"),
nullptr,
nullptr,
nullptr);
133 G4RotationMatrix hcal_rotm;
152 const G4MaterialTable *mtable = G4Material::GetMaterialTable();
153 int nMaterials = G4Material::GetNumberOfMaterials();
154 for (G4int
i = 0;
i < nMaterials; ++
i)
156 const G4Material *mat = (*mtable)[
i];
157 if (mat->GetName() ==
"Uniplast_scintillator")
159 if ((mat->GetIonisation()->GetBirksConstant()) == 0)
172 std::unique_ptr<G4GDMLReadStructure>
reader(
new G4GDMLReadStructure());
173 G4GDMLParser gdmlParser(reader.get());
177 G4AssemblyVolume *abs_asym = reader->GetAssembly(
"sector");
181 std::vector<G4VPhysicalVolume *>::iterator it1 = abs_asym->GetVolumesIterator();
182 for (
unsigned int isector = 0; isector < abs_asym->TotalImprintedVolumes(); isector++)
186 hcalenvelope->AddDaughter((*it1));
187 m_VolumeSteel += (*it1)->GetLogicalVolume()->GetSolid()->GetCubicVolume();
189 unsigned int ncnt = 24 * 5 * 2;
190 unsigned int ioff = isector * ncnt;
192 for (
unsigned int j = 0;
j < ioff;
j++)
196 for (
unsigned int j = ioff;
j < ioff + ncnt;
j++)
200 hcalenvelope->AddDaughter((*it3));
209 G4AssemblyVolume *chimAbs_asym = reader->GetAssembly(
"sectorChimney");
212 std::vector<G4VPhysicalVolume *>::iterator it2 = chimAbs_asym->GetVolumesIterator();
214 std::map<unsigned int, unsigned int> sectormap;
215 sectormap.insert(std::make_pair(0, 30));
216 sectormap.insert(std::make_pair(1, 31));
217 sectormap.insert(std::make_pair(2, 29));
218 for (
unsigned int isector = 0; isector < chimAbs_asym->TotalImprintedVolumes(); isector++)
223 hcalenvelope->AddDaughter((*it2));
224 m_VolumeSteel += (*it2)->GetLogicalVolume()->GetSolid()->GetCubicVolume();
226 unsigned int ncnt = 24 * 5 * 2;
227 unsigned int ioff = isector * ncnt;
229 for (
unsigned int j = 0;
j < ioff;
j++)
233 for (
unsigned int j = ioff;
j < ioff + ncnt;
j++)
237 hcalenvelope->AddDaughter((*it4));
253 std::cout << __PRETTY_FUNCTION__ <<
" : setup Field_Manager_Iron for LV "
254 << logical_vol->GetName() <<
" w/ # of daughter " << logical_vol->GetNoDaughters() << std::endl;
264 std::cout <<
"Outer Hcal Detector:" << std::endl;
265 if (what ==
"ALL" || what ==
"VOLUME")
272 std::cout <<
"******\tm_GDMPath : " <<
m_GDMPath << std::endl;
284 std::cout <<
"could not locate volume " << volume->GetName()
285 <<
" in Outer Hcal scintillator map" << std::endl;
294 boost::char_separator<char> sep(
"_");
295 boost::tokenizer<boost::char_separator<char>> tok(volume->GetName(), sep);
296 boost::tokenizer<boost::char_separator<char>>::const_iterator tokeniter;
299 for (tokeniter = tok.begin(); tokeniter != tok.end(); ++tokeniter)
301 if (*tokeniter ==
"impr")
304 if (tokeniter != tok.end())
306 layer_id = boost::lexical_cast<
int>(*tokeniter) / 2;
310 std::cout <<
"invalid scintillator row " << layer_id
317 std::cout <<
PHWHERE <<
" Error parsing " << volume->GetName()
318 <<
" for mother volume number " << std::endl;
324 for (tokeniter = tok.begin(); tokeniter != tok.end(); ++tokeniter)
326 if (*tokeniter ==
"pv")
329 if (tokeniter != tok.end())
331 tower_id = boost::lexical_cast<
int>(*tokeniter);
347 int itmp = tower_id / 2;
467 rowid = layer_id + 95;
469 else if ( layer_id < 225)
471 rowid = layer_id + 95;
475 rowid = layer_id - 225;
479 rowid = 45 + layer_id;
481 else if (isector >= 30)
483 rowid = 75 + layer_id;
487 if(rowid > 319) rowid -= 320;
488 if (rowid < 0 || rowid > 319)
490 std::cout <<
"bad rowid " << rowid <<
" for sector " << isector <<
", layer_id " << layer_id << std::endl;
504 std::cout <<
PHWHERE <<
"Run Node missing, exiting." << std::endl;
529 double geom_ref_radius = innerrad + thickness / 2.;
531 if (!std::isfinite(phistart))
533 std::cout <<
PHWHERE <<
" phistart is not finite: " << phistart
534 <<
", exiting now (this will crash anyway)" << std::endl;
540 std::pair<double, double> range = std::make_pair(phiend, phistart);
550 double etahibound = etalowbound +
552 std::pair<double, double> range = std::make_pair(etalowbound, etahibound);
554 etalowbound = etahibound;
571 std::cout <<
"IHCalDetector::InitRun - Tower geometry " << key <<
" already exists" << std::endl;
574 if (fabs(tg->get_center_x() -
x) > 1
e-4)
576 std::cout <<
"IHCalDetector::InitRun - Fatal Error - duplicated Tower geometry " << key <<
" with existing x = " << tg->
get_center_x() <<
" and expected x = " << x
581 if (fabs(tg->get_center_y() -
y) > 1
e-4)
583 std::cout <<
"IHCalDetector::InitRun - Fatal Error - duplicated Tower geometry " << key <<
" with existing y = " << tg->get_center_y() <<
" and expected y = " << y
587 if (fabs(tg->get_center_z() -
z) > 1
e-4)
589 std::cout <<
"IHCalDetector::InitRun - Fatal Error - duplicated Tower geometry " << key <<
" with existing z= " << tg->get_center_z() <<
" and expected z = " <<
z
598 std::cout <<
"IHCalDetector::InitRun - building tower geometry " << key <<
"" << std::endl;