|
| 1 | +#include "art/Utilities/ToolMacros.h" |
| 2 | +#include "fhiclcpp/ParameterSet.h" |
| 3 | + |
| 4 | +#include "larcore/Geometry/Geometry.h" |
| 5 | +#include "larcore/CoreUtils/ServiceUtil.h" |
| 6 | +#include "larcorealg/Geometry/GeometryCore.h" |
| 7 | + |
| 8 | +#include "ITCSSelectionTool.h" |
| 9 | + |
| 10 | +namespace sbn { |
| 11 | + |
| 12 | + class TrackCaloSkimmerSelectThroughgoingTrack: public ITCSSelectionTool { |
| 13 | + public: |
| 14 | + |
| 15 | + TrackCaloSkimmerSelectThroughgoingTrack(const fhicl::ParameterSet &p); |
| 16 | + ~TrackCaloSkimmerSelectThroughgoingTrack() {} |
| 17 | + |
| 18 | + bool Select(const TrackInfo &t) override; |
| 19 | + |
| 20 | + private: |
| 21 | + double fFVInsetMinX; |
| 22 | + double fFVInsetMaxX; |
| 23 | + double fFVInsetMinY; |
| 24 | + double fFVInsetMaxY; |
| 25 | + double fFVInsetMinZ; |
| 26 | + double fFVInsetMaxZ; |
| 27 | + bool fCheckFiducialX; |
| 28 | + |
| 29 | + std::vector<geo::BoxBoundedGeo> fTPCVolumes; |
| 30 | + geo::BoxBoundedGeo fActiveVolume, fFiducialVolume; |
| 31 | + }; |
| 32 | + |
| 33 | + TrackCaloSkimmerSelectThroughgoingTrack::TrackCaloSkimmerSelectThroughgoingTrack(const fhicl::ParameterSet &p): |
| 34 | + ITCSSelectionTool(p), |
| 35 | + fFVInsetMinX(p.get<double>("FVInsetMinX")), |
| 36 | + fFVInsetMaxX(p.get<double>("FVInsetMaxX")), |
| 37 | + fFVInsetMinY(p.get<double>("FVInsetMinY")), |
| 38 | + fFVInsetMaxY(p.get<double>("FVInsetMaxY")), |
| 39 | + fFVInsetMinZ(p.get<double>("FVInsetMinZ")), |
| 40 | + fFVInsetMaxZ(p.get<double>("FVInsetMaxZ")), |
| 41 | + fCheckFiducialX(p.get<bool>("CheckFiducialX")) |
| 42 | + { |
| 43 | + const geo::GeometryCore *geometry = lar::providerFrom<geo::Geometry>(); |
| 44 | + |
| 45 | + for(auto const &cryoid: geometry->Iterate<geo::CryostatID>()) |
| 46 | + { |
| 47 | + for(auto const& TPC : geometry->Iterate<geo::TPCGeo>(cryoid)) |
| 48 | + fTPCVolumes.push_back(TPC.ActiveBoundingBox()); |
| 49 | + } |
| 50 | + |
| 51 | + double XMin = std::min_element(fTPCVolumes.begin(), fTPCVolumes.end(), [](auto &lhs, auto &rhs) { return lhs.MinX() < rhs.MinX(); })->MinX(); |
| 52 | + double YMin = std::min_element(fTPCVolumes.begin(), fTPCVolumes.end(), [](auto &lhs, auto &rhs) { return lhs.MinY() < rhs.MinY(); })->MinY(); |
| 53 | + double ZMin = std::min_element(fTPCVolumes.begin(), fTPCVolumes.end(), [](auto &lhs, auto &rhs) { return lhs.MinZ() < rhs.MinZ(); })->MinZ(); |
| 54 | + |
| 55 | + double XMax = std::max_element(fTPCVolumes.begin(), fTPCVolumes.end(), [](auto &lhs, auto &rhs) { return lhs.MaxX() < rhs.MaxX(); })->MaxX(); |
| 56 | + double YMax = std::max_element(fTPCVolumes.begin(), fTPCVolumes.end(), [](auto &lhs, auto &rhs) { return lhs.MaxY() < rhs.MaxY(); })->MaxY(); |
| 57 | + double ZMax = std::max_element(fTPCVolumes.begin(), fTPCVolumes.end(), [](auto &lhs, auto &rhs) { return lhs.MaxZ() < rhs.MaxZ(); })->MaxZ(); |
| 58 | + |
| 59 | + fActiveVolume = geo::BoxBoundedGeo(XMin, XMax, YMin, YMax, ZMin, ZMax); |
| 60 | + |
| 61 | + fFiducialVolume = geo::BoxBoundedGeo(fActiveVolume.MinX() + fFVInsetMinX, fActiveVolume.MaxX() - fFVInsetMaxX, |
| 62 | + fActiveVolume.MinY() + fFVInsetMinY, fActiveVolume.MaxY() - fFVInsetMaxY, |
| 63 | + fActiveVolume.MinZ() + fFVInsetMinZ, fActiveVolume.MaxZ() - fFVInsetMaxZ); |
| 64 | + } |
| 65 | + |
| 66 | + bool TrackCaloSkimmerSelectThroughgoingTrack::Select(const TrackInfo &t) |
| 67 | + { |
| 68 | + geo::Point_t start {t.start.x, t.start.y, t.start.z}; |
| 69 | + bool start_is_non_fid = fCheckFiducialX ? !fFiducialVolume.ContainsPosition(start) : !fFiducialVolume.ContainsYZ(start.Y(), start.Z()); |
| 70 | + |
| 71 | + geo::Point_t end {t.end.x, t.end.y, t.end.z}; |
| 72 | + bool end_is_non_fid = fCheckFiducialX ? !fFiducialVolume.ContainsPosition(end) : !fFiducialVolume.ContainsYZ(end.Y(), end.Z()); |
| 73 | + |
| 74 | + return start_is_non_fid && end_is_non_fid; |
| 75 | + } |
| 76 | + |
| 77 | + DEFINE_ART_CLASS_TOOL(TrackCaloSkimmerSelectThroughgoingTrack) |
| 78 | + |
| 79 | +} |
0 commit comments