7 #include "nug4/G4Base/DetectorConstruction.h" 17 #include "Geant4/G4LogicalVolume.hh" 18 #include "Geant4/G4SDManager.hh" 19 #include "Geant4/G4Point3D.hh" 25 : G4VUserParallelWorld(name)
41 unsigned int MaxDepth = 8;
42 std::vector<const G4VPhysicalVolume*> path(MaxDepth);
43 path[0] = g4b::DetectorConstruction::GetWorld();
44 G4Transform3D InitTransform( path[0]->GetObjectRotationValue(),
45 path[0]->GetObjectTranslation() );
61 G4Transform3D DepthToWorld)
64 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
67 if( volName.find(
"volAuxDet") != std::string::npos &&
68 volName.find(
"Sensitive") != std::string::npos){
71 G4Point3D local(0., 0., 0.);
72 G4Point3D world = DepthToWorld * local;
82 MF_LOG_DEBUG(
"AuxDetReadoutGeometry") <<
"found" << path[depth]->GetName()
83 <<
", number " << adNum <<
":" << svNum;
86 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
87 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
94 unsigned int deeper = depth+1;
95 if(deeper >= path.size()){
96 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
100 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
101 for(
int d = 0;
d < nd; ++
d){
104 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
107 G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
108 path[deeper]->GetObjectTranslation() );
109 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
118 G4Transform3D DepthToWorld)
121 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
124 if( volName.find(
"volAuxDet") != std::string::npos ){
127 G4Point3D local(0., 0., 0.);
128 G4Point3D world = DepthToWorld * local;
137 MF_LOG_DEBUG(
"AuxDetReadoutGeometry") <<
"found" << path[depth]->GetName()
138 <<
", number " << adNum <<
":0";
141 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
142 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
149 unsigned int deeper = depth+1;
150 if(deeper >= path.size()){
151 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
155 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
156 for(
int d = 0;
d < nd; ++
d){
159 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
162 G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
163 path[deeper]->GetObjectTranslation() );
164 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
static constexpr double cm
void FindAuxDetSensitiveAtPosition(geo::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.
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
uint32_t fNumSensitiveVol
number of sensitive volumes
AuxDetReadoutGeometry(const G4String name="AuxDetReadoutGeometry")
Constructor and destructor.
virtual ~AuxDetReadoutGeometry()
AuxDetGeo const & PositionToAuxDet(geo::Point_t const &point, unsigned int &ad, double tolerance=0) const
Returns the auxiliary detector at specified location.
art::ServiceHandle< geo::Geometry const > fGeo
Handle to the geometry.
Define the "parallel" geometry that's seen by the AuxDet.
std::string to_string(ModuleType const mt)
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