All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoUtil.cc
Go to the documentation of this file.
1 #include "GeoUtil.h"
2 
3 std::vector<geo::BoxBoundedGeo> SBNRecoUtils::ActiveVolumes(const geo::GeometryCore *geometry) {
4  std::vector<std::vector<geo::BoxBoundedGeo>> tpc_volumes = TPCVolumes(geometry);;
5  std::vector<geo::BoxBoundedGeo> active_volumes;
6 
7  // make each cryostat volume a box enclosing all tpc volumes
8  for (const std::vector<geo::BoxBoundedGeo> &tpcs: tpc_volumes) {
9  double XMin = std::min_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MinX() < rhs.MinX(); })->MinX();
10  double YMin = std::min_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MinY() < rhs.MinY(); })->MinY();
11  double ZMin = std::min_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MinZ() < rhs.MinZ(); })->MinZ();
12 
13  double XMax = std::max_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MaxX() < rhs.MaxX(); })->MaxX();
14  double YMax = std::max_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MaxY() < rhs.MaxY(); })->MaxY();
15  double ZMax = std::max_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MaxZ() < rhs.MaxZ(); })->MaxZ();
16 
17  active_volumes.emplace_back(XMin, XMax, YMin, YMax, ZMin, ZMax);
18  }
19  return active_volumes;
20 }
21 
23  std::vector<geo::BoxBoundedGeo> active_volumes = ActiveVolumes(geometry);
24  double max_length = -1;
25  for (const geo::BoxBoundedGeo &vol: active_volumes) {
26  double X = vol.MaxX() - vol.MinX();
27  double Y = vol.MaxY() - vol.MinY();
28  double Z = vol.MaxZ() - vol.MinZ();
29  double this_length = sqrt(X*X + Y*Y + Z*Z);
30  if (this_length > max_length) max_length = this_length;
31  }
32  return max_length;
33 }
34 
36  std::vector<geo::BoxBoundedGeo> active_volumes = ActiveVolumes(geometry);
37 
38  double XMin = std::min_element(active_volumes.begin(), active_volumes.end(), [](auto &lhs, auto &rhs) { return lhs.MinX() < rhs.MinX(); })->MinX();
39  double YMin = std::min_element(active_volumes.begin(), active_volumes.end(), [](auto &lhs, auto &rhs) { return lhs.MinY() < rhs.MinY(); })->MinY();
40  double ZMin = std::min_element(active_volumes.begin(), active_volumes.end(), [](auto &lhs, auto &rhs) { return lhs.MinZ() < rhs.MinZ(); })->MinZ();
41 
42  double XMax = std::max_element(active_volumes.begin(), active_volumes.end(), [](auto &lhs, auto &rhs) { return lhs.MaxX() < rhs.MaxX(); })->MaxX();
43  double YMax = std::max_element(active_volumes.begin(), active_volumes.end(), [](auto &lhs, auto &rhs) { return lhs.MaxY() < rhs.MaxY(); })->MaxY();
44  double ZMax = std::max_element(active_volumes.begin(), active_volumes.end(), [](auto &lhs, auto &rhs) { return lhs.MaxZ() < rhs.MaxZ(); })->MaxZ();
45 
46  return geo::BoxBoundedGeo(XMin, XMax, YMin, YMax, ZMin, ZMax);
47 }
48 
49 std::vector<std::vector<geo::BoxBoundedGeo>> SBNRecoUtils::TPCVolumes(const geo::GeometryCore *geometry) {
50  std::vector<std::vector<geo::BoxBoundedGeo>> tpc_volumes;
51  for (auto const &cryo: geometry->IterateCryostats()) {
52  geo::GeometryCore::TPC_iterator iTPC = geometry->begin_TPC(cryo.ID()),
53  tend = geometry->end_TPC(cryo.ID());
54  std::vector<geo::BoxBoundedGeo> this_tpc_volumes;
55  while (iTPC != tend) {
56  geo::TPCGeo const& TPC = *iTPC;
57  this_tpc_volumes.push_back(TPC.ActiveBoundingBox());
58  iTPC++;
59  }
60  tpc_volumes.push_back(std::move(this_tpc_volumes));
61  }
62  return tpc_volumes;
63 }
64 
std::vector< geo::BoxBoundedGeo > ActiveVolumes(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:3
const geo::GeometryCore * geometry
Geometry information for a single TPC.
Definition: TPCGeo.h:38
geo::BoxBoundedGeo DetectorVolume(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:35
geo::BoxBoundedGeo const & ActiveBoundingBox() const
Returns the box of the active volume of this TPC.
Definition: TPCGeo.h:320
double MaxLength(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:22
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
BEGIN_PROLOG TPC
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC in the detector.
Description of geometry of one entire detector.
std::vector< std::vector< geo::BoxBoundedGeo > > TPCVolumes(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:49
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
Forward iterator browsing all geometry elements in the detector.
Definition: GeometryCore.h:727
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.