All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlaneStubMerge_tool.cc
Go to the documentation of this file.
1 /**
2  *
3  */
4 
5 // Framework Includes
6 #include "art/Utilities/ToolMacros.h"
7 #include "cetlib/cpu_timer.h"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
10 
11 // local includes
14 
15 // LArSoft includes
17 
18 // std includes
19 #include <memory>
20 
21 namespace sbn{
22 /**
23  * @brief Art tool for merging stubs on the same plane.
24  *
25  * Always merges into the larger stub.
26  */
28 public:
29  /**
30  * @brief Constructor
31  */
32  PlaneStubMerge(fhicl::ParameterSet const &pset);
33 
34  std::vector<sbn::StubInfo> Merge(const std::vector<sbn::StubInfo> &stubs,
35  const geo::GeometryCore *geo,
36  const spacecharge::SpaceCharge *sce,
37  const detinfo::DetectorClocksData &dclock,
38  const detinfo::DetectorPropertiesData &dprop) override;
39 
40 private:
41  double fStubDotCut;
42 };
43 
44 PlaneStubMerge::PlaneStubMerge(fhicl::ParameterSet const &pset):
45  fStubDotCut(pset.get<double>("StubDotCut"))
46 {
47 }
48 
49 std::vector<sbn::StubInfo> PlaneStubMerge::Merge(const std::vector<sbn::StubInfo> &stubs,
50  const geo::GeometryCore *geo,
51  const spacecharge::SpaceCharge *sce,
52  const detinfo::DetectorClocksData &dclock,
53  const detinfo::DetectorPropertiesData &dprop) {
54 
55  std::vector<bool> toerase(stubs.size(), false);
56  for (unsigned i_stub = 0; i_stub < stubs.size(); i_stub++) {
57  for (unsigned j_stub = 0; j_stub < stubs.size(); j_stub++) {
58  if (i_stub == j_stub) continue;
59  if (toerase[j_stub]) continue; // Already being erased
60  if (sbn::StubContains(stubs[i_stub], stubs[j_stub])) {
61  if (sbn::StubDirectionDot(stubs[i_stub], stubs[j_stub], geo, dprop) > fStubDotCut) {
62  toerase[j_stub] = true;
63  }
64  }
65  }
66  }
67 
68  std::vector<sbn::StubInfo> ret;
69  // Keep only good stubs
70  for (unsigned i = 0; i < stubs.size(); i++) {
71  if (!toerase[i]) ret.push_back(stubs[i]);
72  }
73 
74  return ret;
75 }
76 
77 DEFINE_ART_CLASS_TOOL(PlaneStubMerge)
78 
79 } // namespace sbn
Abstract interface intended for art tools which take a list of stubs and return a new list with some ...
Definition: IStubMerge.h:30
float StubDirectionDot(const sbn::StubInfo &A, const sbn::StubInfo &B, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
Computes the dot product of two stubs.
PlaneStubMerge(fhicl::ParameterSet const &pset)
Constructor.
Art tool for merging stubs on the same plane.
std::vector< sbn::StubInfo > Merge(const std::vector< sbn::StubInfo > &stubs, const geo::GeometryCore *geo, const spacecharge::SpaceCharge *sce, const detinfo::DetectorClocksData &dclock, const detinfo::DetectorPropertiesData &dprop) override
Access the description of detector geometry.
bool StubContains(const sbn::StubInfo &A, const sbn::StubInfo &B)
Returns whether stub A contains stub B.
Description of geometry of one entire detector.
Contains all timing reference information for the detector.