7 #include "nug4/G4Base/DetectorConstruction.h"
10 #include "messagefacility/MessageLogger/MessageLogger.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();
66 std::string volName(path[depth]->GetName());
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;
73 double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
77 fGeo->FindAuxDetSensitiveAtPosition(worldPos, adNum, svNum);
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();
123 std::string volName(path[depth]->GetName());
124 if( volName.find(
"volAuxDet") != std::string::npos ){
127 G4Point3D
local(0., 0., 0.);
128 G4Point3D world = DepthToWorld *
local;
129 double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
132 fGeo->PositionToAuxDet(worldPos, adNum);
134 std::string SDName =
"AuxDetSD_AuxDet" +
std::to_string(adNum) +
"_0";
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;
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
uint32_t fNumSensitiveVol
number of sensitive volumes
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
AuxDetReadoutGeometry(const G4String name="AuxDetReadoutGeometry")
Constructor and destructor.
virtual ~AuxDetReadoutGeometry()
art::ServiceHandle< geo::Geometry const > fGeo
Handle to the geometry.
Define the "parallel" geometry that's seen by the AuxDet.
std::string to_string(WindowPattern const &pattern)
A Geant4 sensitive detector that accumulates information.
void FindAndMakeAuxDetSensitive(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)