All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EndPointModule_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // EndPointModule class
4 //
5 // joshua.spitz@yale.edu
6 //
7 // This algorithm is designed to find (weak) vertices from hits after deconvolution and hit finding.
8 // A weak vertex is a vertex that has been found using a dedicated vertex finding algorithm only. A
9 // strong vertex is a vertex that has been found using a dedicated vertex finding algorithm and matched
10 // to a crossing of two or more HoughLineFinder lines. The VertexMatch module finds strong vertices.
11 ////////////////////////////////////////////////////////////////////////
12 /// The algorithm is based on:
13 ///C. Harris and M. Stephens (1988). "A combined corner and edge detector". Proceedings of the 4th Alvey
14 ///Vision Conference. pp. 147-151.
15 ///B. Morgan (2010). "Interest Point Detection for Reconstruction in High Granularity Tracking Detectors".
16 ///arXiv:1006.3012v1 [physics.ins-det]
17 //Thanks to B. Morgan of U. of Warwick for comments and suggestions
18 
19 #include <string>
20 #include <vector>
21 
22 // Framework includes
23 #include "art/Framework/Core/EDProducer.h"
24 #include "art/Framework/Core/ModuleMacros.h"
25 #include "art/Framework/Principal/Event.h"
26 #include "art/Framework/Principal/Handle.h"
27 #include "canvas/Persistency/Common/Assns.h"
28 #include "canvas/Persistency/Common/Ptr.h"
29 #include "canvas/Persistency/Common/PtrVector.h"
30 #include "messagefacility/MessageLogger/MessageLogger.h"
31 #include "fhiclcpp/ParameterSet.h"
32 
33 // LArSoft includes
39 
40 /// 2D end point reconstruction
41 namespace cluster {
42 
43  ///module to find 2D end points
44  class EndPointModule : public art::EDProducer {
45 
46  public:
47 
48  explicit EndPointModule(fhicl::ParameterSet const& pset);
49 
50  private:
51 
52  void produce(art::Event& evt);
53 
54  std::string fDBScanModuleLabel;
55 
56  EndPointAlg fEPAlg; ///< object that contains the end point finding algorithm
57 
58  };
59 
60 }
61 
62 
63 namespace cluster {
64 
65 
66  //-----------------------------------------------------------------------------
67  EndPointModule::EndPointModule(fhicl::ParameterSet const& pset)
68  : EDProducer{pset}
69  , fEPAlg(pset.get< fhicl::ParameterSet >("EndPointAlg"))
70  {
71  fDBScanModuleLabel = pset.get<std::string>("DBScanModuleLabel");
72 
73  produces< std::vector<recob::EndPoint2D> >();
74  produces< art::Assns<recob::EndPoint2D, recob::Hit> >();
75  }
76 
77  //-----------------------------------------------------------------------------
78 
79  void EndPointModule::produce(art::Event& evt)
80  {
81 
82  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
83  evt.getByLabel(fDBScanModuleLabel,clusterListHandle);
84  //Point to a collection of vertices to output.
85 
86  //.......................................
87  art::PtrVector<recob::Cluster> clusIn;
88  for(unsigned int ii = 0; ii < clusterListHandle->size(); ++ii)
89  {
90  art::Ptr<recob::Cluster> cluster(clusterListHandle, ii);
91  clusIn.push_back(cluster);
92  }
93 
94  // make a std::vector<recob::Cluster> for the output of the
95  // Hough Transform
96  std::vector<recob::EndPoint2D> vtxOut;
97  std::vector< art::PtrVector<recob::Hit> > vtxHitsOut;
98  size_t numvtx = fEPAlg.EndPoint(clusIn, vtxOut, vtxHitsOut, evt, fDBScanModuleLabel);
99 
100  MF_LOG_DEBUG("Vertex") << "found " << numvtx << "vertices with VertexService";
101 
102  //Point to a collection of vertices to output.
103  std::unique_ptr<std::vector<recob::EndPoint2D> > vtxcol(new std::vector<recob::EndPoint2D>(vtxOut));
104  std::unique_ptr< art::Assns<recob::EndPoint2D, recob::Hit> > assn(new art::Assns<recob::EndPoint2D, recob::Hit>);
105 
106  for(size_t v = 0; v < vtxcol->size(); ++v)
107  util::CreateAssn(*this, evt, *(vtxcol.get()), vtxHitsOut[v], *(assn.get()), v);
108 
109  evt.put(std::move(vtxcol));
110  evt.put(std::move(assn));
111  }
112 
113 
114 } // end namespace
115 
116 
117 
118 
119 
120 
121 
122 namespace cluster{
123 
124  DEFINE_ART_MODULE(EndPointModule)
125 
126 }
algorithm to find 2D endpoints
process_name cluster
Definition: cheaterreco.fcl:51
Declaration of signal hit object.
void produce(art::Event &evt)
size_t EndPoint(const art::PtrVector< recob::Cluster > &clusIn, std::vector< recob::EndPoint2D > &vtxcol, std::vector< art::PtrVector< recob::Hit > > &vtxHitsOut, art::Event const &evt, std::string const &label) const
Declaration of cluster object.
Algorithm to find 2D end points.
Definition: EndPointAlg.h:27
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
EndPointAlg fEPAlg
object that contains the end point finding algorithm
TCEvent evt
Definition: DataStructs.cxx:8
module to find 2D end points
EndPointModule(fhicl::ParameterSet const &pset)