11 #include "art/Framework/Core/EDProducer.h"
12 #include "art/Framework/Core/ModuleMacros.h"
13 #include "art/Framework/Principal/Event.h"
14 #include "canvas/Utilities/InputTag.h"
15 #include "fhiclcpp/ParameterSet.h"
40 explicit LineCluster(fhicl::ParameterSet
const& pset);
64 #include "art/Framework/Principal/Handle.h"
65 #include "canvas/Persistency/Common/Assns.h"
66 #include "canvas/Utilities/Exception.h"
81 : EDProducer{pset}, fCCAlg{pset.get<fhicl::ParameterSet>(
"ClusterCrawlerAlg")}
83 fHitFinderLabel = pset.get<art::InputTag>(
"HitFinderModuleLabel");
84 fDoWireAssns = pset.get<
bool>(
"DoWireAssns",
true);
85 fDoRawDigitAssns = pset.get<
bool>(
"DoRawDigitAssns",
false);
91 producesCollector(),
"", fDoWireAssns, fDoRawDigitAssns);
93 produces<std::vector<recob::Cluster>>();
94 produces<std::vector<recob::Vertex>>();
95 produces<std::vector<recob::EndPoint2D>>();
96 produces<art::Assns<recob::Cluster, recob::Hit>>();
97 produces<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
98 produces<art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>>();
108 auto hitVecHandle = evt.getValidHandle<std::vector<recob::Hit>>(
fHitFinderLabel);
111 auto const clock_data =
112 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
113 auto const det_prop =
114 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
117 auto FinalHits = std::make_unique<std::vector<recob::Hit>>(std::move(
fCCAlg.
YieldHits()));
123 std::vector<recob::Cluster> sccol;
124 std::vector<recob::Vertex> sv3col;
125 std::vector<recob::EndPoint2D> sv2col;
127 std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>> hc_assn(
128 new art::Assns<recob::Cluster, recob::Hit>);
129 std::unique_ptr<art::Assns<recob::Cluster, recob::Vertex, unsigned short>> cv_assn(
130 new art::Assns<recob::Cluster, recob::Vertex, unsigned short>);
131 std::unique_ptr<art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>> cep_assn(
132 new art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>);
134 std::vector<ClusterCrawlerAlg::ClusterStore>
const& Clusters =
fCCAlg.
GetClusters();
162 std::vector<unsigned int> indxToIndx(EndPts.size());
163 art::ServiceHandle<geo::Geometry const> geom;
164 unsigned short vtxID = 0,
end, wire, ivx;
165 for (ivx = 0; ivx < EndPts.size(); ++ivx) {
166 if (EndPts[ivx].NClusters == 0)
continue;
167 indxToIndx[ivx] = vtxID;
170 wire = (0.5 + EndPts[ivx].Wire);
174 sv2col.emplace_back((
double)EndPts[ivx].Time,
182 std::unique_ptr<std::vector<recob::EndPoint2D>> v2col(
183 new std::vector<recob::EndPoint2D>(std::move(sv2col)));
186 std::vector<ClusterCrawlerAlg::Vtx3Store>
const& Vertices =
fCCAlg.
GetVertices();
187 double xyz[3] = {0, 0, 0};
191 if (vtx3.Ptr2D[0] < 0)
continue;
192 if (vtx3.Ptr2D[1] < 0)
continue;
193 if (vtx3.Ptr2D[2] < 0)
continue;
198 sv3col.emplace_back(xyz, vtxID);
201 std::unique_ptr<std::vector<recob::Vertex>> v3col(
202 new std::vector<recob::Vertex>(std::move(sv3col)));
205 float sumChg, sumADC;
206 unsigned int clsID = 0, nclhits;
207 for (
unsigned int icl = 0; icl < Clusters.size(); ++icl) {
209 if (clstr.
ID < 0)
continue;
214 unsigned short plane = planeID.
Plane;
215 nclhits = clstr.
tclhits.size();
216 std::vector<unsigned int> clsHitIndices;
218 for (
unsigned int itt = 0; itt < nclhits; ++itt) {
219 unsigned int iht = clstr.
tclhits[itt];
225 unsigned int iht = clstr.
tclhits[0];
228 sccol.emplace_back((
float)clstr.
BeginWir,
256 *
this, evt, *hc_assn, sccol.size() - 1, clstr.
tclhits.begin(), clstr.
tclhits.end())) {
257 throw art::Exception(art::errors::ProductRegistrationFailure)
258 <<
"Failed to associate hit " << iht <<
" with cluster " << icl;
265 throw art::Exception(art::errors::ProductRegistrationFailure)
266 <<
"Failed to associate cluster " << clsID <<
" with EndPoint2D " << clstr.
BeginVtx;
269 unsigned short vtxIndex = 0;
272 if (vtx3.Ptr2D[0] < 0)
continue;
273 if (vtx3.Ptr2D[1] < 0)
continue;
274 if (vtx3.Ptr2D[2] < 0)
continue;
275 if (vtx3.Ptr2D[plane] == clstr.
BeginVtx) {
277 throw art::Exception(art::errors::ProductRegistrationFailure)
278 <<
"Failed to associate cluster " << icl <<
" with vertex";
289 throw art::Exception(art::errors::ProductRegistrationFailure)
290 <<
"Failed to associate cluster " << clsID <<
" with EndPoint2D " << clstr.
BeginVtx;
293 unsigned short vtxIndex = 0;
296 if (vtx3.Ptr2D[0] < 0)
continue;
297 if (vtx3.Ptr2D[1] < 0)
continue;
298 if (vtx3.Ptr2D[2] < 0)
continue;
299 if (vtx3.Ptr2D[plane] == clstr.
EndVtx) {
301 throw art::Exception(art::errors::ProductRegistrationFailure)
302 <<
"Failed to associate cluster " << icl <<
" with endpoint";
312 std::unique_ptr<std::vector<recob::Cluster>> ccol(
313 new std::vector<recob::Cluster>(std::move(sccol)));
315 shcol.
use_hits(std::move(FinalHits));
322 evt.put(std::move(ccol));
323 evt.put(std::move(hc_assn));
324 evt.put(std::move(v2col));
325 evt.put(std::move(v3col));
326 evt.put(std::move(cv_assn));
327 evt.put(std::move(cep_assn));
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.
void produce(art::Event &evt) override
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Declaration of signal hit object.
The data type to uniquely identify a Plane.
std::vector< ClusterStore > const & GetClusters() const
Returns a constant reference to the clusters found.
CryostatID_t Cryostat
Index of cryostat.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
struct of temporary clusters
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.
static const SentryArgument_t Sentry
An instance of the sentry object.
static geo::PlaneID DecodeCTP(CTP_t CTP)
Helper functions to create a hit.
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
std::vector< VtxStore > const & GetEndPoints() const
Returns a constant reference to the 2D end points found.
void use_hits(std::unique_ptr< std::vector< recob::Hit >> &&srchits)
Uses the specified collection as data product.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void put_into(art::Event &)
Moves the data into the event.
auto end(FixedBins< T, C > const &) noexcept
art::InputTag fHitFinderLabel
label of module producing input hits
A class handling a collection of hits and its associations.
PlaneID_t Plane
Index of the plane within its TPC.
Declaration of cluster object.
Definition of data types for geometry description.
Produces clusters by ClusterCrawler algorithm.
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::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)
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
LineCluster(fhicl::ParameterSet const &pset)
2D representation of charge deposited in the TDC/wire plane
TPCID_t TPC
Index of the TPC within its cryostat.