48 std::string TheName = TheVolume->GetName();
60 double MinDistance = UINT_MAX;
61 int ClosestOpDet = -1;
63 for(
size_t o=0; o!=geom->
NOpDets(); o++) {
67 CLHEP::Hep3Vector DetPos(xyz[0],xyz[1],xyz[2]);
68 CLHEP::Hep3Vector ThisVolPos = vol->GetTranslation();
70 ThisVolPos/=CLHEP::cm;
75 double Distance = (DetPos-ThisVolPos).
mag();
76 if(Distance < MinDistance)
78 MinDistance = Distance;
85 throw cet::exception(
"OpDetLookup Error") <<
"No nearby OpDet found!\n";
88 distance = MinDistance;
99 std::stringstream VolName(
"");
105 VolName << volume->GetName() <<
"_" << NearestOpDet;
106 volume->SetName(VolName.str().c_str());
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Number of OpDets in the whole detector.
Encapsulate the construction of a single cyostat.
std::map< std::string, int > fTheOpDetMap
void GetCenter(double *xyz, double localz=0.0) const
void AddPhysicalVolume(G4VPhysicalVolume *)
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 *)
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception