LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
EndPointModule_module.cc
Go to the documentation of this file.
1 //
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.
17 //Thanks to B. Morgan of U. of Warwick for comments and suggestions
18 
19 
20 
21 #include <iostream>
22 extern "C" {
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 }
26 
27 #include <sstream>
28 #include <fstream>
29 #include <math.h>
30 #include <algorithm>
31 #include "TMath.h"
32 #include "TMath.h"
33 #include <vector>
34 #include <string>
35 
36 // Framework includes
40 #include "fhiclcpp/ParameterSet.h"
48 
49 // LArSoft includes
55 
56 //#ifndef EndPointModule_H
57 //#define EndPointModule_H
58 
59 
60 
62 namespace cluster {
63 
66 
67  public:
68 
69  explicit EndPointModule(fhicl::ParameterSet const& pset);
70  virtual ~EndPointModule();
71 
72  void reconfigure(fhicl::ParameterSet const& p);
73  void produce(art::Event& evt);
74 
75  private:
76 
77  std::string fDBScanModuleLabel;
78 
80 
81  };
82 
83 }
84 
85 //#endif // EndPointModule_H
86 
87 
88 
89 namespace cluster {
90 
91 
92  //-----------------------------------------------------------------------------
94  : fEPAlg(pset.get< fhicl::ParameterSet >("EndPointAlg"))
95  {
96  this->reconfigure(pset);
97  produces< std::vector<recob::EndPoint2D> >();
98  produces< art::Assns<recob::EndPoint2D, recob::Hit> >();
99  }
100 
101  //-----------------------------------------------------------------------------
103  {
104  }
105 
106  //-----------------------------------------------------------------------------
108  {
109  fDBScanModuleLabel = p.get<std::string>("DBScanModuleLabel");
110  fEPAlg.reconfigure(p.get< fhicl::ParameterSet >("EndPointAlg"));
111  }
112 
113  //-----------------------------------------------------------------------------
114 
116  {
117 
118  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
119  evt.getByLabel(fDBScanModuleLabel,clusterListHandle);
120  //Point to a collection of vertices to output.
121 
122  //.......................................
124  for(unsigned int ii = 0; ii < clusterListHandle->size(); ++ii)
125  {
126  art::Ptr<recob::Cluster> cluster(clusterListHandle, ii);
127  clusIn.push_back(cluster);
128  }
129 
130  // make a std::vector<recob::Cluster> for the output of the
131  // Hough Transform
132  std::vector<recob::EndPoint2D> vtxOut;
133  std::vector< art::PtrVector<recob::Hit> > vtxHitsOut;
134  size_t numvtx = fEPAlg.EndPoint(clusIn, vtxOut, vtxHitsOut, evt, fDBScanModuleLabel);
135 
136  LOG_DEBUG("Vertex") << "found " << numvtx << "vertices with VertexService";
137 
138  //Point to a collection of vertices to output.
139  std::unique_ptr<std::vector<recob::EndPoint2D> > vtxcol(new std::vector<recob::EndPoint2D>(vtxOut));
140  std::unique_ptr< art::Assns<recob::EndPoint2D, recob::Hit> > assn(new art::Assns<recob::EndPoint2D, recob::Hit>);
141 
142  for(size_t v = 0; v < vtxcol->size(); ++v)
143  util::CreateAssn(*this, evt, *(vtxcol.get()), vtxHitsOut[v], *(assn.get()), v);
144 
145  evt.put(std::move(vtxcol));
146  evt.put(std::move(assn));
147  }
148 
149 
150 } // end namespace
151 
152 
153 
154 
155 
156 
157 
158 namespace cluster{
159 
161 
162 }
163 
algorithm to find 2D endpoints
void reconfigure(fhicl::ParameterSet const &pset)
Definition: EndPointAlg.cxx:62
Declaration of signal hit object.
void produce(art::Event &evt)
Cluster finding and building.
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)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
Declaration of cluster object.
Algorithm to find 2D end points.
Definition: EndPointAlg.h:28
void reconfigure(fhicl::ParameterSet const &p)
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
#define LOG_DEBUG(id)
EndPointAlg fEPAlg
object that contains the end point finding algorithm
module to find 2D end points
EndPointModule(fhicl::ParameterSet const &pset)