18 #include "Geant4/G4LogicalVolume.hh" 19 #include "Geant4/G4Point3D.hh" 20 #include "Geant4/G4SDManager.hh" 39 unsigned int MaxDepth = 8;
40 std::vector<const G4VPhysicalVolume*> path(MaxDepth);
42 G4Transform3D InitTransform(path[0]->GetObjectRotationValue(), path[0]->GetObjectTranslation());
53 std::vector<const G4VPhysicalVolume*>& path,
55 G4Transform3D DepthToWorld)
57 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
59 std::string volName(path[depth]->GetName());
60 if (volName.find(
"volAuxDet") != std::string::npos &&
61 volName.find(
"Sensitive") != std::string::npos) {
64 G4Point3D local(0., 0., 0.);
65 G4Point3D world = DepthToWorld * local;
67 world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm};
77 <<
"found" << path[depth]->GetName() <<
", number " << adNum <<
":" << svNum;
80 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
81 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
88 unsigned int deeper = depth + 1;
89 if (deeper >= path.size()) {
90 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
94 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
95 for (
int d = 0;
d < nd; ++
d) {
98 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
101 G4Transform3D DeeperToMother(path[deeper]->GetObjectRotationValue(),
102 path[deeper]->GetObjectTranslation());
103 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
111 G4Transform3D DepthToWorld)
113 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
115 std::string volName(path[depth]->GetName());
116 if (volName.find(
"volAuxDet") != std::string::npos) {
119 G4Point3D local(0., 0., 0.);
120 G4Point3D world = DepthToWorld * local;
122 world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm};
126 std::string SDName =
"AuxDetSD_AuxDet" +
std::to_string(adNum) +
"_0";
130 <<
"found" << path[depth]->GetName() <<
", number " << adNum <<
":0";
133 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
134 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
141 unsigned int deeper = depth + 1;
142 if (deeper >= path.size()) {
143 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
147 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
148 for (
int d = 0;
d < nd; ++
d) {
151 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
154 G4Transform3D DeeperToMother(path[deeper]->GetObjectRotationValue(),
155 path[deeper]->GetObjectTranslation());
156 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
Build Geant4 geometry from GDML.
std::size_t FindAuxDetAtPosition(Point_t const &point, double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
void Construct() override
static G4VPhysicalVolume * GetWorld()
geo::AuxDetGeometryCore const * fAuxDetGeom
Handle to the geometry.
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
AuxDetReadoutGeometry(geo::AuxDetGeometryCore const *auxDetGeom, G4String name="AuxDetReadoutGeometry")
Description of physical geometry of one set of auxiliary detectors.
uint32_t fNumSensitiveVol
number of sensitive volumes
Access the description of auxiliary detector geometry.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
void FindAuxDetSensitiveAtPosition(Point_t const &point, std::size_t &adg, std::size_t &sv, double tolerance=0) const
Fills the indices of the sensitive auxiliary detector at location.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Define the "parallel" geometry that's seen by the AuxDet.
A Geant4 sensitive detector that accumulates information.
void FindAndMakeAuxDetSensitive(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
cet::coded_exception< error, detail::translate > exception