17 #include "Geant4/G4LogicalVolume.hh" 18 #include "Geant4/G4Point3D.hh" 19 #include "Geant4/G4SDManager.hh" 25 : G4VUserParallelWorld(name), fNumSensitiveVol(0)
39 unsigned int MaxDepth = 8;
40 std::vector<const G4VPhysicalVolume*> path(MaxDepth);
42 G4Transform3D InitTransform(path[0]->GetObjectRotationValue(), path[0]->GetObjectTranslation());
55 std::vector<const G4VPhysicalVolume*>& path,
57 G4Transform3D DepthToWorld)
60 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
62 std::string volName(path[depth]->GetName());
63 if (volName.find(
"volAuxDet") != std::string::npos &&
64 volName.find(
"Sensitive") != std::string::npos) {
67 G4Point3D local(0., 0., 0.);
68 G4Point3D world = DepthToWorld * local;
70 world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm};
80 <<
"found" << path[depth]->GetName() <<
", number " << adNum <<
":" << svNum;
83 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
84 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
91 unsigned int deeper = depth + 1;
92 if (deeper >= path.size()) {
93 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
97 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
98 for (
int d = 0;
d < nd; ++
d) {
101 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
104 G4Transform3D DeeperToMother(path[deeper]->GetObjectRotationValue(),
105 path[deeper]->GetObjectTranslation());
106 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
114 G4Transform3D DepthToWorld)
117 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
119 std::string volName(path[depth]->GetName());
120 if (volName.find(
"volAuxDet") != std::string::npos) {
123 G4Point3D local(0., 0., 0.);
124 G4Point3D world = DepthToWorld * local;
126 world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm};
131 std::string SDName =
"AuxDetSD_AuxDet" +
std::to_string(adNum) +
"_0";
135 <<
"found" << path[depth]->GetName() <<
", number " << adNum <<
":0";
138 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
139 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
146 unsigned int deeper = depth + 1;
147 if (deeper >= path.size()) {
148 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
152 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
153 for (
int d = 0;
d < nd; ++
d) {
156 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
159 G4Transform3D DeeperToMother(path[deeper]->GetObjectRotationValue(),
160 path[deeper]->GetObjectTranslation());
161 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
Build Geant4 geometry from GDML.
static G4VPhysicalVolume * GetWorld()
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
uint32_t fNumSensitiveVol
number of sensitive volumes
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.
AuxDetReadoutGeometry(const G4String name="AuxDetReadoutGeometry")
Constructor and destructor.
virtual ~AuxDetReadoutGeometry()
AuxDetGeo const & PositionToAuxDet(Point_t const &point, unsigned int &ad, double tolerance=0) const
Returns the auxiliary detector at specified location.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
art::ServiceHandle< geo::Geometry const > fGeo
Handle to the geometry.
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