18 #include "Geant4/G4PVPlacement.hh" 19 #include "Geant4/G4PVReplica.hh" 20 #include "Geant4/G4LogicalVolume.hh" 21 #include "Geant4/G4VisAttributes.hh" 22 #include "Geant4/G4VSolid.hh" 23 #include "Geant4/G4Box.hh" 24 #include "Geant4/G4Tubs.hh" 25 #include "Geant4/G4ThreeVector.hh" 26 #include "Geant4/G4RotationMatrix.hh" 27 #include "Geant4/G4VSensitiveDetector.hh" 28 #include "Geant4/G4SDManager.hh" 29 #include "Geant4/G4Material.hh" 30 #include "Geant4/G4Point3D.hh" 31 #include "Geant4/globals.hh" 40 : G4VUserParallelWorld(name)
56 unsigned int MaxDepth = 8;
57 std::vector<const G4VPhysicalVolume*> path(MaxDepth);
59 G4Transform3D InitTransform( path[0]->GetObjectRotationValue(),
60 path[0]->GetObjectTranslation() );
76 G4Transform3D DepthToWorld)
79 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
81 std::string volName(path[depth]->GetName());
82 if( volName.find(
"volAuxDet") != std::string::npos &&
83 volName.find(
"Sensitive") != std::string::npos){
86 G4Point3D local(0., 0., 0.);
87 G4Point3D world = DepthToWorld * local;
88 double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
97 LOG_DEBUG(
"AuxDetReadoutGeometry") <<
"found" << path[depth]->GetName()
98 <<
", number " << adNum <<
":" << svNum;
101 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
102 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
108 unsigned int deeper = depth+1;
109 if(deeper >= path.size()){
110 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
114 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
115 for(
int d = 0;
d < nd; ++
d){
118 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
121 G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
122 path[deeper]->GetObjectTranslation() );
123 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
132 G4Transform3D DepthToWorld)
135 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
137 std::string volName(path[depth]->GetName());
138 if( volName.find(
"volAuxDet") != std::string::npos ){
141 G4Point3D local(0., 0., 0.);
142 G4Point3D world = DepthToWorld * local;
143 double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
148 std::string SDName =
"AuxDetSD_AuxDet" +
std::to_string(adNum) +
"_0";
151 LOG_DEBUG(
"AuxDetReadoutGeometry") <<
"found" << path[depth]->GetName()
152 <<
", number " << adNum <<
":0";
155 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
156 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
162 unsigned int deeper = depth+1;
163 if(deeper >= path.size()){
164 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
168 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
169 for(
int d = 0;
d < nd; ++
d){
172 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
175 G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
176 path[deeper]->GetObjectTranslation() );
177 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
Build Geant4 geometry from GDML.
static G4VPhysicalVolume * GetWorld()
AuxDetGeo const & PositionToAuxDet(geo::Point_t const &point, unsigned int &ad) const
Returns the auxiliary detector at specified location.
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
uint32_t fNumSensitiveVol
number of sensitive volumes
void FindAuxDetSensitiveAtPosition(geo::Point_t const &point, std::size_t &adg, std::size_t &sv) const
Fills the indices of the sensitive auxiliary detector at location.
AuxDetReadoutGeometry(const G4String name="AuxDetReadoutGeometry")
Constructor and destructor.
virtual ~AuxDetReadoutGeometry()
Define the "parallel" geometry that's seen by the AuxDet.
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
art::ServiceHandle< geo::Geometry > fGeo
Handle to the geometry.
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