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);
109 unsigned int deeper = depth+1;
110 if(deeper >= path.size()){
111 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
115 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
116 for(
int d = 0;
d < nd; ++
d){
119 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
122 G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
123 path[deeper]->GetObjectTranslation() );
124 G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
133 G4Transform3D DepthToWorld)
136 G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
138 std::string volName(path[depth]->GetName());
139 if( volName.find(
"volAuxDet") != std::string::npos ){
142 G4Point3D local(0., 0., 0.);
143 G4Point3D world = DepthToWorld * local;
144 double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
149 std::string SDName =
"AuxDetSD_AuxDet" +
std::to_string(adNum) +
"_0";
152 LOG_DEBUG(
"AuxDetReadoutGeometry") <<
"found" << path[depth]->GetName()
153 <<
", number " << adNum <<
":0";
156 (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
157 LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
164 unsigned int deeper = depth+1;
165 if(deeper >= path.size()){
166 throw cet::exception(
"AuxDetReadoutGeometry") <<
"exceeded maximum TGeoNode depth\n";
170 G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
171 for(
int d = 0;
d < nd; ++
d){
174 path[deeper] = LogicalVolumeAtDepth->GetDaughter(
d);
177 G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
178 path[deeper]->GetObjectTranslation() );
179 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