16 #include "Geant4/G4VPhysicalVolume.hh" 62 double MinDistance = UINT_MAX;
63 int ClosestOpDet = -1;
65 for(
size_t o=0; o!=geom->
NOpDets(); o++) {
69 CLHEP::Hep3Vector DetPos(xyz[0],xyz[1],xyz[2]);
70 CLHEP::Hep3Vector ThisVolPos = vol->GetTranslation();
77 double Distance = (DetPos-ThisVolPos).
mag();
78 if(Distance < MinDistance)
80 MinDistance = Distance;
87 throw cet::exception(
"OpDetLookup Error") <<
"No nearby OpDet found!\n";
90 distance = MinDistance;
101 std::stringstream VolName(
"");
107 VolName << volume->GetName() <<
"_" << NearestOpDet;
108 volume->SetName(VolName.str().c_str());
static constexpr double cm
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
static const std::string volume[nvol]
std::map< std::string, int > fTheOpDetMap
void GetCenter(double *xyz, double localz=0.0) const
art framework interface to geometry description
void AddPhysicalVolume(G4VPhysicalVolume *)
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static OpDetLookup * Instance()
int FindClosestOpDet(G4VPhysicalVolume *vol, double &Distance)
unsigned int NOpDets() const
Number of OpDets in the whole detector.
OpDetLookup * TheOpDetLookup
Encapsulate the geometry of an optical detector.
int GetOpDet(G4VPhysicalVolume *)
cet::coded_exception< error, detail::translate > exception