LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
cluster::ClusterMergeHelper Class Reference

#include "ClusterMergeHelper.h"

Public Member Functions

::cmtool::CMergeManagerGetManager ()
 
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 recob::Hit art::Ptr) More...
 
void SetClusters (util::GeometryUtilities const &gser, const art::Event &evt, const std::string &cluster_module_label)
 Utility method to set cluster input information to CMerteManager from art::Event and cluster data product label. More...
 
void Process (util::GeometryUtilities const &gser)
 Function to execute CMergeManager::Process() More...
 
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> More...
 
const std::vector< cluster::ClusterParamsAlg > & GetMergedCPAN () const
 Utility method to retrieve merged clusters in terms of a vector of CPAN. More...
 
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. More...
 

Protected Member Functions

void SetClusters (util::GeometryUtilities const &gser, const std::vector< std::vector< util::PxHit >> &clusters)
 Internal method to transfer input cluster information in the right format to CMergeManager. More...
 

Protected Attributes

::cmtool::CMergeManager fMgr
 CMergeManager instance. More...
 
::util::GeometryUtilities fGeoU
 GeometryUtilities. More...
 
std::vector< std::vector< art::Ptr< recob::Hit > > > fInputClusters
 Input clusters in terms of a vector of art::Ptr<recob::Hit> collection. More...
 
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
 Output clusters in terms of a vector of art::Ptr<recob::Hit> collection. More...
 

Detailed Description

Definition at line 38 of file ClusterMergeHelper.h.

Member Function Documentation

void cluster::ClusterMergeHelper::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.

Definition at line 148 of file ClusterMergeHelper.cxx.

References util::CreateAssn(), cluster::cluster_params::end_point, cluster::LazyClusterParamsAlg::EndAngle(), cluster::LazyClusterParamsAlg::EndCharge(), cluster::LazyClusterParamsAlg::EndOpeningAngle(), fGeoU, fOutputClusters, Get, GetMergedClusterHits(), GetMergedCPAN(), hits(), cluster::LazyClusterParamsAlg::Integral(), cluster::LazyClusterParamsAlg::IntegralStdDev(), cluster::LazyClusterParamsAlg::MultipleHitDensity(), cluster::LazyClusterParamsAlg::NHits(), recob::Cluster::Sentry, cluster::cluster_params::start_point, cluster::LazyClusterParamsAlg::StartAngle(), cluster::LazyClusterParamsAlg::StartCharge(), cluster::LazyClusterParamsAlg::StartOpeningAngle(), cluster::LazyClusterParamsAlg::SummedADC(), cluster::LazyClusterParamsAlg::SummedADCStdDev(), util::PxPoint::t, util::GeometryUtilities::TimeToCm(), cluster::details::Measure_t< T >::value(), util::PxPoint::w, cluster::LazyClusterParamsAlg::Width(), and util::GeometryUtilities::WireToCm().

152  {
153 
154  if (!fOutputClusters.size())
155 
156  throw cet::exception(__FUNCTION__)
157  << "\033[93m"
158  << "You must call Process() before calling " << __FUNCTION__ << " to retrieve result."
159  << "\033[00m" << std::endl;
160 
161  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
162 
163  // Store output
164  for (size_t out_index = 0; out_index < GetMergedCPAN().size(); ++out_index) {
165 
166  // To save typing let's just retrieve const cluster_params instance
167  const cluster_params& res = GetMergedCPAN()[out_index].GetParams();
168 
169  // this "algo" is actually parroting its cluster_params
170  LazyClusterParamsAlg algo(res);
171 
172  std::vector<art::Ptr<recob::Hit>> const& hits = GetMergedClusterHits().at(out_index);
173 
174  // the full plane needed but not a part of cluster_params...
175  // get the one from the first hit
176  geo::PlaneID plane; // invalid by default
177  if (!hits.empty()) plane = hits.front()->WireID().planeID();
178 
179  // View_t needed but not a part of cluster_params, so retrieve it here
180  geo::View_t view_id = wireReadoutGeom.Plane(plane).View();
181 
182  // Push back a new cluster data product with parameters copied from cluster_params
183  out_clusters.emplace_back(res.start_point.w / fGeoU.WireToCm(), // start_wire
184  0., // sigma_start_wire
185  res.start_point.t / fGeoU.TimeToCm(), // start_tick
186  0., // sigma_start_tick
187  algo.StartCharge(gser).value(),
188  algo.StartAngle().value(),
189  algo.StartOpeningAngle().value(),
190  res.end_point.w / fGeoU.WireToCm(), // end_wire
191  0., // sigma_end_wire
192  res.end_point.t / fGeoU.TimeToCm(), // end_tick
193  0., // sigma_end_tick
194  algo.EndCharge(gser).value(),
195  algo.EndAngle().value(),
196  algo.EndOpeningAngle().value(),
197  algo.Integral().value(),
198  algo.IntegralStdDev().value(),
199  algo.SummedADC().value(),
200  algo.SummedADCStdDev().value(),
201  algo.NHits(),
202  algo.MultipleHitDensity(),
203  algo.Width(gser),
204  out_clusters.size(), // ID
205  view_id,
206  plane,
208 
209  util::CreateAssn(ev, out_clusters, GetMergedClusterHits().at(out_index), assns);
210  }
211  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
The data type to uniquely identify a Plane.
Definition: geo_types.h:364
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:174
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> ...
void hits()
Definition: readHits.C:15
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.
::util::GeometryUtilities fGeoU
GeometryUtilities.
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.
const std::vector< cluster::ClusterParamsAlg > & GetMergedCPAN() const
Utility method to retrieve merged clusters in terms of a vector of CPAN.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
::cmtool::CMergeManager& cluster::ClusterMergeHelper::GetManager ( )
inline

Definition at line 40 of file ClusterMergeHelper.h.

References tca::evt, and lar::dump::vector().

40 { return fMgr; }
::cmtool::CMergeManager fMgr
CMergeManager instance.
const std::vector< std::vector< art::Ptr< recob::Hit > > > & cluster::ClusterMergeHelper::GetMergedClusterHits ( ) const

Utility method to retrieve merged clusters in terms of a vector of art::Ptr<recob::Hit>

Definition at line 122 of file ClusterMergeHelper.cxx.

References fOutputClusters.

Referenced by AppendResult().

125  {
126  if (!fOutputClusters.size())
127  throw cet::exception(__FUNCTION__)
128  << "\033[93m"
129  << "You must call Process() before calling " << __FUNCTION__ << " to retrieve result."
130  << "\033[00m" << std::endl;
131 
132  return fOutputClusters;
133  }
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< cluster::ClusterParamsAlg > & cluster::ClusterMergeHelper::GetMergedCPAN ( ) const

Utility method to retrieve merged clusters in terms of a vector of CPAN.

Definition at line 136 of file ClusterMergeHelper.cxx.

References fMgr, fOutputClusters, and cmtool::CMergeManager::GetClusters().

Referenced by AppendResult().

138  {
139  if (!fOutputClusters.size())
140  throw cet::exception(__FUNCTION__)
141  << "\033[93m"
142  << "You must call Process() before calling " << __FUNCTION__ << " to retrieve result."
143  << "\033[00m" << std::endl;
144 
145  return fMgr.GetClusters();
146  }
const std::vector< cluster::ClusterParamsAlg > & GetClusters() const
A method to obtain output clusters.
Definition: CMergeManager.h:49
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.
::cmtool::CMergeManager fMgr
CMergeManager instance.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cluster::ClusterMergeHelper::Process ( util::GeometryUtilities const &  gser)

Function to execute CMergeManager::Process()

Definition at line 89 of file ClusterMergeHelper.cxx.

References fInputClusters, fMgr, fOutputClusters, cmtool::CMergeManager::GetBookKeeper(), cmtool::CMergeManager::GetClusters(), cmtool::CMergeBookKeeper::GetResult(), and cmtool::CMManagerBase::Process().

91  {
92  if (fMgr.GetClusters().size())
93  throw cet::exception(__PRETTY_FUNCTION__)
94  << "\033[93m"
95  << "Merged cluster set not empty... Called Process() twice?"
96  << "\033[00m" << std::endl;
97 
98  fMgr.Process(gser);
99 
100  // Now create output clusters
101  auto res = fMgr.GetBookKeeper();
102 
103  std::vector<std::vector<unsigned short>> out_clusters = res.GetResult();
104  fOutputClusters.clear();
105 
106  fOutputClusters.reserve(out_clusters.size());
107 
108  for (auto const& cluster_index_v : out_clusters) {
109 
110  std::vector<art::Ptr<recob::Hit>> out_cluster;
111 
112  for (auto const& cluster_index : cluster_index_v) {
113  out_cluster.reserve(out_cluster.size() + fInputClusters.at(cluster_index).size());
114  for (auto const& hit_ptr : fInputClusters.at(cluster_index))
115  out_cluster.push_back(hit_ptr);
116  }
117  fOutputClusters.push_back(out_cluster);
118  }
119  }
std::vector< std::vector< art::Ptr< recob::Hit > > > fInputClusters
Input clusters in terms of a vector of art::Ptr<recob::Hit> collection.
std::vector< std::vector< unsigned short > > GetResult() const
const std::vector< cluster::ClusterParamsAlg > & GetClusters() const
A method to obtain output clusters.
Definition: CMergeManager.h:49
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.
void Process(util::GeometryUtilities const &gser)
A method to execute the main action, to be called per event.
const CMergeBookKeeper & GetBookKeeper() const
A method to obtain book keeper.
Definition: CMergeManager.h:52
::cmtool::CMergeManager fMgr
CMergeManager instance.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cluster::ClusterMergeHelper::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 recob::Hit art::Ptr)

Definition at line 24 of file ClusterMergeHelper.cxx.

References fGeoU, fInputClusters, fOutputClusters, util::GeometryUtilities::TimeToCm(), and util::GeometryUtilities::WireToCm().

Referenced by SetClusters().

28  {
29  fInputClusters.clear();
30  fOutputClusters.clear();
31 
32  std::vector<std::vector<util::PxHit>> px_clusters(clusters.size(), std::vector<util::PxHit>());
33 
34  fInputClusters.resize(clusters.size(), std::vector<art::Ptr<recob::Hit>>());
35 
36  for (size_t cluster_index = 0; cluster_index < clusters.size(); ++cluster_index) {
37 
38  px_clusters.at(cluster_index).resize(clusters.at(cluster_index).size(), util::PxHit());
39 
40  fInputClusters.at(cluster_index).resize(clusters.at(cluster_index).size());
41 
42  for (size_t hit_index = 0; hit_index < clusters.at(cluster_index).size(); ++hit_index) {
43 
44  px_clusters.at(cluster_index).at(hit_index).plane =
45  clusters.at(cluster_index).at(hit_index)->WireID().Plane;
46  px_clusters.at(cluster_index).at(hit_index).w =
47  clusters.at(cluster_index).at(hit_index)->WireID().Wire * fGeoU.WireToCm();
48  px_clusters.at(cluster_index).at(hit_index).t =
49  clusters.at(cluster_index).at(hit_index)->PeakTime() * fGeoU.TimeToCm();
50  px_clusters.at(cluster_index).at(hit_index).charge =
51  clusters.at(cluster_index).at(hit_index)->Integral();
52 
53  fInputClusters.at(cluster_index).at(hit_index) = clusters.at(cluster_index).at(hit_index);
54  }
55  }
56 
57  SetClusters(gser, px_clusters);
58  }
std::vector< std::vector< art::Ptr< recob::Hit > > > fInputClusters
Input clusters in terms of a vector of art::Ptr<recob::Hit> collection.
std::vector< std::vector< art::Ptr< recob::Hit > > > fOutputClusters
Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.
::util::GeometryUtilities fGeoU
GeometryUtilities.
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...
void cluster::ClusterMergeHelper::SetClusters ( util::GeometryUtilities const &  gser,
const art::Event evt,
const std::string &  cluster_module_label 
)

Utility method to set cluster input information to CMerteManager from art::Event and cluster data product label.

Definition at line 61 of file ClusterMergeHelper.cxx.

References art::ProductRetriever::getByLabel(), art::Handle< T >::isValid(), and SetClusters().

65  {
66 
68  evt.getByLabel(cluster_module_label, clusters_h);
69 
70  if (!(clusters_h.isValid()))
71 
72  throw cet::exception(__FUNCTION__)
73  << "\033[93m"
74  << " Failed to retrieve recob::Cluster with label: " << cluster_module_label.c_str()
75  << "\033[00m" << std::endl;
76 
77  std::vector<std::vector<art::Ptr<recob::Hit>>> cluster_hits_v;
78  cluster_hits_v.reserve(clusters_h->size());
79 
80  art::FindManyP<recob::Hit> hit_m(clusters_h, evt, cluster_module_label);
81 
82  for (size_t i = 0; i < clusters_h->size(); ++i)
83  cluster_hits_v.push_back(hit_m.at(i));
84 
85  SetClusters(gser, cluster_hits_v);
86  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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...
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cluster::ClusterMergeHelper::SetClusters ( util::GeometryUtilities const &  gser,
const std::vector< std::vector< util::PxHit >> &  clusters 
)
inlineprotected

Internal method to transfer input cluster information in the right format to CMergeManager.

Definition at line 68 of file ClusterMergeHelper.h.

70  {
71  fMgr.Reset();
72  fMgr.SetClusters(gser, clusters);
73  }
virtual void Reset()
Method to reset itself.
void SetClusters(util::GeometryUtilities const &gser, const std::vector< std::vector< util::PxHit >> &clusters)
A simple method to add a cluster.
::cmtool::CMergeManager fMgr
CMergeManager instance.

Member Data Documentation

::util::GeometryUtilities cluster::ClusterMergeHelper::fGeoU
protected

GeometryUtilities.

Definition at line 80 of file ClusterMergeHelper.h.

Referenced by AppendResult(), and SetClusters().

std::vector<std::vector<art::Ptr<recob::Hit> > > cluster::ClusterMergeHelper::fInputClusters
protected

Input clusters in terms of a vector of art::Ptr<recob::Hit> collection.

Definition at line 83 of file ClusterMergeHelper.h.

Referenced by Process(), and SetClusters().

::cmtool::CMergeManager cluster::ClusterMergeHelper::fMgr
protected

CMergeManager instance.

Definition at line 77 of file ClusterMergeHelper.h.

Referenced by GetMergedCPAN(), and Process().

std::vector<std::vector<art::Ptr<recob::Hit> > > cluster::ClusterMergeHelper::fOutputClusters
protected

Output clusters in terms of a vector of art::Ptr<recob::Hit> collection.

Definition at line 86 of file ClusterMergeHelper.h.

Referenced by AppendResult(), GetMergedClusterHits(), GetMergedCPAN(), Process(), and SetClusters().


The documentation for this class was generated from the following files: