10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Services/Registry/ServiceHandle.h"
15 #include "canvas/Utilities/InputTag.h"
16 #include "fhiclcpp/ParameterSet.h"
56 , fCCHFAlg(pset.get<fhicl::ParameterSet>(
"CCHitFinderAlg"))
57 , fCCAlg(pset.get<fhicl::ParameterSet>(
"ClusterCrawlerAlg"))
58 , fCalDataModuleLabel(pset.get<std::string>(
"CalDataModuleLabel"))
60 mf::LogWarning(
"ClusterCrawler")
61 <<
"\nClusterCrawler module has been deprecated and will be removed."
62 "\nIt is now replaced by HitFinder and LineCluster modules.";
69 produces<std::vector<recob::Cluster>>();
70 produces<std::vector<recob::Vertex>>();
71 produces<art::Assns<recob::Cluster, recob::Hit>>();
72 produces<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
81 art::ValidHandle<std::vector<recob::Wire>> wireVecHandle =
90 auto const clock_data =
91 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
93 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
98 auto FinalHits = std::make_unique<std::vector<recob::Hit>>(
fCCAlg.
YieldHits());
100 art::ServiceHandle<geo::Geometry const> geo;
106 std::vector<recob::Cluster> sccol;
107 std::vector<recob::Vertex> sv3col;
109 auto hc_assn = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
110 auto cv_assn = std::make_unique<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
117 for (
unsigned int icl = 0; icl < tcl.size(); ++icl) {
119 if (clstr.
ID < 0)
continue;
121 unsigned short plane = planeID.
Plane;
122 for (
unsigned short ii = 0; ii < clstr.
tclhits.size(); ++ii) {
123 unsigned int iht = clstr.
tclhits[ii];
124 recob::Hit const& theHit = FinalHits->at(iht);
127 <<
" in cluster " << clstr.
ID <<
" WT " << clstr.
BeginWir <<
":"
131 if (inClus[iht] != clstr.
ID) {
132 std::cout <<
"CC: InClus mis-match " << inClus[iht] <<
" ID " << clstr.
ID
133 <<
" in cluster " << icl <<
"\n";
140 std::vector<ClusterCrawlerAlg::Vtx3Store>
const& Vertices =
fCCAlg.
GetVertices();
142 double xyz[3] = {0, 0, 0};
143 unsigned int vtxID = 0,
end;
146 if (vtx3.Ptr2D[0] < 0)
continue;
147 if (vtx3.Ptr2D[1] < 0)
continue;
148 if (vtx3.Ptr2D[2] < 0)
continue;
153 sv3col.emplace_back(xyz, vtxID);
156 std::unique_ptr<std::vector<recob::Vertex>> v3col(
157 new std::vector<recob::Vertex>(std::move(sv3col)));
160 float sumChg, sumADC;
161 unsigned int clsID = 0, nclhits;
162 for (
unsigned int icl = 0; icl < tcl.size(); ++icl) {
164 if (clstr.
ID < 0)
continue;
169 unsigned short plane = planeID.
Plane;
170 nclhits = clstr.
tclhits.size();
171 std::vector<unsigned int> clsHitIndices;
173 for (
unsigned int itt = 0; itt < nclhits; ++itt) {
174 unsigned int iht = clstr.
tclhits[itt];
180 unsigned int iht = clstr.
tclhits[0];
183 sccol.emplace_back((
float)clstr.
BeginWir,
211 *
this, evt, *hc_assn, sccol.size() - 1, clstr.
tclhits.begin(), clstr.
tclhits.end())) {
212 throw art::Exception(art::errors::ProductRegistrationFailure)
213 <<
"Failed to associate hit " << iht <<
" with cluster " << icl;
219 unsigned short vtxIndex = 0;
222 if (vtx3.Ptr2D[0] < 0)
continue;
223 if (vtx3.Ptr2D[1] < 0)
continue;
224 if (vtx3.Ptr2D[2] < 0)
continue;
225 if (vtx3.Ptr2D[plane] == clstr.
BeginVtx) {
227 throw art::Exception(art::errors::ProductRegistrationFailure)
228 <<
"Failed to associate cluster " << icl <<
" with vertex";
238 unsigned short vtxIndex = 0;
241 if (vtx3.Ptr2D[0] < 0)
continue;
242 if (vtx3.Ptr2D[1] < 0)
continue;
243 if (vtx3.Ptr2D[2] < 0)
continue;
244 if (vtx3.Ptr2D[plane] == clstr.
EndVtx) {
246 throw art::Exception(art::errors::ProductRegistrationFailure)
247 <<
"Failed to associate cluster " << icl <<
" with endpoint";
257 std::unique_ptr<std::vector<recob::Cluster>> ccol(
258 new std::vector<recob::Cluster>(std::move(sccol)));
260 shcol.
use_hits(std::move(FinalHits));
267 evt.put(std::move(ccol));
268 evt.put(std::move(hc_assn));
269 evt.put(std::move(v3col));
270 evt.put(std::move(cv_assn));
277 DEFINE_ART_MODULE(ClusterCrawler)
void RunCCHitFinder(std::vector< recob::Wire > const &Wires)
bool CreateAssnD(art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data)
Creates a single one-to-one association with associated data.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
Declaration of signal hit object.
hit::CCHitFinderAlg fCCHFAlg
The data type to uniquely identify a Plane.
std::vector< ClusterStore > const & GetClusters() const
Returns a constant reference to the clusters found.
Definition of basic raw digits.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
struct of temporary clusters
void use_hits(std::unique_ptr< std::vector< recob::Hit >> &&srchits)
Uses the specified collection as data product.
struct of temporary 3D vertices
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Hit finder algorithm designed to work with Cluster Crawler.
static const SentryArgument_t Sentry
An instance of the sentry object.
static geo::PlaneID DecodeCTP(CTP_t CTP)
ClusterCrawler(fhicl::ParameterSet const &pset)
Helper functions to create a hit.
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
A class handling a collection of hits and its associations.
void produce(art::Event &evt) override
auto end(FixedBins< T, C > const &) noexcept
PlaneID_t Plane
Index of the plane within its TPC.
Declaration of cluster object.
Definition of data types for geometry description.
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.
std::string fCalDataModuleLabel
label of module producing input wires
std::vector< Vtx3Store > const & GetVertices() const
Returns a constant reference to the 3D vertices found.
std::vector< unsigned int > tclhits
void RunCrawler(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, std::vector< recob::Hit > const &srchits)
void put_into(art::Event &)
Moves the data into the event.
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Declaration of basic channel signal object.
std::vector< short > const & GetinClus() const
2D representation of charge deposited in the TDC/wire plane
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
art framework interface to geometry description
BEGIN_PROLOG could also be cout