9 #include "art/Framework/Principal/Event.h"
10 #include "art/Framework/Principal/Handle.h"
11 #include "art/Framework/Services/Registry/ServiceHandle.h"
12 #include "canvas/Persistency/Common/FindManyP.h"
31 std::vector<std::vector<util::PxHit>> px_clusters(clusters.size(), std::vector<util::PxHit>());
33 fInputClusters.resize(clusters.size(), std::vector<art::Ptr<recob::Hit>>());
35 for (
size_t cluster_index = 0; cluster_index < clusters.size(); ++cluster_index) {
37 px_clusters.at(cluster_index).resize(clusters.at(cluster_index).size(),
util::PxHit());
39 fInputClusters.at(cluster_index).resize(clusters.at(cluster_index).size());
41 for (
size_t hit_index = 0; hit_index < clusters.at(cluster_index).size(); ++hit_index) {
43 px_clusters.at(cluster_index).at(hit_index).plane =
44 clusters.at(cluster_index).at(hit_index)->WireID().Plane;
45 px_clusters.at(cluster_index).at(hit_index).w =
46 clusters.at(cluster_index).at(hit_index)->WireID().Wire *
fGeoU.
WireToCm();
47 px_clusters.at(cluster_index).at(hit_index).t =
48 clusters.at(cluster_index).at(hit_index)->PeakTime() *
fGeoU.
TimeToCm();
49 px_clusters.at(cluster_index).at(hit_index).charge =
50 clusters.at(cluster_index).at(hit_index)->Integral();
52 fInputClusters.at(cluster_index).at(hit_index) = clusters.at(cluster_index).at(hit_index);
62 const art::Event&
evt,
63 const std::string& cluster_module_label)
67 art::Handle<std::vector<recob::Cluster>> clusters_h;
68 evt.getByLabel(cluster_module_label, clusters_h);
70 if (!(clusters_h.isValid()))
72 throw cet::exception(__FUNCTION__)
74 <<
" Failed to retrieve recob::Cluster with label: " << cluster_module_label.c_str()
75 <<
"\033[00m" << std::endl;
77 std::vector<std::vector<art::Ptr<recob::Hit>>> cluster_hits_v;
78 cluster_hits_v.reserve(clusters_h->size());
80 art::FindManyP<recob::Hit> hit_m(clusters_h, evt, cluster_module_label);
82 for (
size_t i = 0; i < clusters_h->size(); ++i)
83 cluster_hits_v.push_back(hit_m.at(i));
94 throw cet::exception(__PRETTY_FUNCTION__)
96 <<
"Merged cluster set not empty... Called Process() twice?"
97 <<
"\033[00m" << std::endl;
104 std::vector<std::vector<unsigned short>> out_clusters = res.
GetResult();
109 for (
auto const& cluster_index_v : out_clusters) {
111 std::vector<art::Ptr<recob::Hit>> out_cluster;
113 for (
auto const& cluster_index : cluster_index_v) {
114 out_cluster.reserve(out_cluster.size() +
fInputClusters.at(cluster_index).size());
116 out_cluster.push_back(hit_ptr);
123 const std::vector<std::vector<art::Ptr<recob::Hit>>>&
128 throw cet::exception(__FUNCTION__)
130 <<
"You must call Process() before calling " << __FUNCTION__ <<
" to retrieve result."
131 <<
"\033[00m" << std::endl;
137 const std::vector<cluster::ClusterParamsAlg>&
142 throw cet::exception(__FUNCTION__)
144 <<
"You must call Process() before calling " << __FUNCTION__ <<
" to retrieve result."
145 <<
"\033[00m" << std::endl;
153 std::vector<recob::Cluster>& out_clusters,
154 art::Assns<recob::Cluster, recob::Hit>& assns)
const
159 throw cet::exception(__FUNCTION__)
161 <<
"You must call Process() before calling " << __FUNCTION__ <<
" to retrieve result."
162 <<
"\033[00m" << std::endl;
164 art::ServiceHandle<geo::Geometry const> geo;
167 for (
size_t out_index = 0; out_index <
GetMergedCPAN().size(); ++out_index) {
180 if (!hits.empty()) plane = hits.front()->WireID().planeID();
Algorithm class inheriting pre-computed results.
Algorithm class inheriting cluster parameters.
std::vector< std::vector< art::Ptr< recob::Hit > > > fInputClusters
Input clusters in terms of a vector of art::Ptr<recob::Hit> collection.
Measure_t EndAngle() override
size_t NHits() override
Returns the number of hits in the cluster.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
The data type to uniquely identify a Plane.
Double_t TimeToCm() const
Double_t WireToCm() const
Measure_t SummedADC() override
Computes the total charge of the cluster from Hit::SummedADC()
static const SentryArgument_t Sentry
An instance of the sentry object.
const std::vector< std::vector< art::Ptr< recob::Hit > > > & GetMergedClusterHits() const
Utility method to retrieve merged clusters in terms of a vector of art::Ptr<recob::Hit> ...
Measure_t EndOpeningAngle() override
Measure_t Integral() override
Computes the total charge of the cluster from Hit::Integral()
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void AppendResult(util::GeometryUtilities const &gser, art::Event &ev, std::vector< recob::Cluster > &out_clusters, art::Assns< recob::Cluster, recob::Hit > &assns) const
Utility method to append result set to user's data product storage.
Measure_t SummedADCStdDev() override
Computes the standard deviation on the charge of the cluster hits.
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.
float MultipleHitDensity() override
Fraction of wires in the cluster with more than one hit.
void Process(util::GeometryUtilities const &gser)
Function to execute CMergeManager::Process()
util::PxPoint start_point
start point
::util::GeometryUtilities fGeoU
GeometryUtilities.
Measure_t IntegralStdDev() override
Computes the standard deviation on the charge of the cluster hits.
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.
util::PxPoint end_point
end point
Measure_t StartOpeningAngle() override
Computes the opening angle at the start or end of the cluster.
Measure_t StartAngle() override
Computes the angle of the cluster.
const std::vector< cluster::ClusterParamsAlg > & GetMergedCPAN() const
Utility method to retrieve merged clusters in terms of a vector of CPAN.
Measure_t StartCharge(util::GeometryUtilities const &gser) override
Computes the charge on the first and last wire of the track.
void SetClusters(util::GeometryUtilities const &gser, const std::vector< std::vector< art::Ptr< recob::Hit >>> &clusters)
Utility method to set cluster input information to CMergeManager from LArSoft data product (vector of...
Measure_t EndCharge(util::GeometryUtilities const &gser) override
::cmtool::CMergeManager fMgr
CMergeManager instance.
float Width(util::GeometryUtilities const &) override
Computes the width of the cluster.
art framework interface to geometry description