LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
cluster::ClusterMergeHelper Class Reference

#include "ClusterMergeHelper.h"

Public Member Functions

 ClusterMergeHelper ()
 Default constructor with fhicl parameters. More...
 
virtual ~ClusterMergeHelper ()
 Default destructor. More...
 
::cmtool::CMergeManagerGetManager ()
 A method to retrieve Manager. More...
 
void SetClusters (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 (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 ()
 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 (art::EDProducer &ed, 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 (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 46 of file ClusterMergeHelper.h.

Constructor & Destructor Documentation

cluster::ClusterMergeHelper::ClusterMergeHelper ( )
inline

Default constructor with fhicl parameters.

Definition at line 51 of file ClusterMergeHelper.h.

51 {};
virtual cluster::ClusterMergeHelper::~ClusterMergeHelper ( )
inlinevirtual

Default destructor.

Definition at line 54 of file ClusterMergeHelper.h.

54 {}

Member Function Documentation

void cluster::ClusterMergeHelper::AppendResult ( art::EDProducer ed,
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 154 of file ClusterMergeHelper.cxx.

References util::CreateAssn(), cluster::cluster_params::end_point, cluster::LazyClusterParamsAlg::EndAngle(), cluster::LazyClusterParamsAlg::EndCharge(), cluster::LazyClusterParamsAlg::EndOpeningAngle(), fGeoU, fOutputClusters, GetMergedClusterHits(), GetMergedCPAN(), hits(), cluster::LazyClusterParamsAlg::Integral(), cluster::LazyClusterParamsAlg::IntegralStdDev(), cluster::LazyClusterParamsAlg::MultipleHitDensity(), cluster::LazyClusterParamsAlg::NHits(), geo::GeometryCore::Plane(), 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(), geo::PlaneGeo::View(), util::PxPoint::w, cluster::LazyClusterParamsAlg::Width(), and util::GeometryUtilities::WireToCm().

Referenced by GetManager().

158  {
159 
160  if(!fOutputClusters.size())
161 
162  throw cet::exception(__FUNCTION__)
163  << "\033[93m"
164  << "You must call Process() before calling " << __FUNCTION__ << " to retrieve result."
165  << "\033[00m"
166  << std::endl;
167 
168 
170 
171  // Store output
172  for(size_t out_index=0; out_index < GetMergedCPAN().size(); ++out_index) {
173 
174  // To save typing let's just retrieve const cluster_params instance
175  const cluster_params &res = GetMergedCPAN().at(out_index).GetParams();
176 
177  // this "algo" is actually parroting its cluster_params
178  LazyClusterParamsAlg algo(res);
179 
180  std::vector<art::Ptr<recob::Hit>> const& hits
181  = GetMergedClusterHits().at(out_index);
182 
183  // the full plane needed but not a part of cluster_params...
184  // get the one from the first hit
185  geo::PlaneID plane; // invalid by default
186  if (!hits.empty()) plane = hits.front()->WireID().planeID();
187 
188  // View_t needed but not a part of cluster_params, so retrieve it here
189  geo::View_t view_id = geo->Plane(plane).View();
190 
191  // Push back a new cluster data product with parameters copied from cluster_params
192  out_clusters.emplace_back(
193  res.start_point.w / fGeoU.WireToCm(), // start_wire
194  0., // sigma_start_wire
195  res.start_point.t / fGeoU.TimeToCm(), // start_tick
196  0., // sigma_start_tick
197  algo.StartCharge().value(), // start_charge
198  algo.StartAngle().value(), // start_angle
199  algo.StartOpeningAngle().value(), // start_opening
200  res.end_point.w / fGeoU.WireToCm(), // end_wire
201  0., // sigma_end_wire
202  res.end_point.t / fGeoU.TimeToCm(), // end_tick
203  0., // sigma_end_tick
204  algo.EndCharge().value(), // end_charge
205  algo.EndAngle().value(), // end_angle
206  algo.EndOpeningAngle().value(), // end_opening
207  algo.Integral().value(), // integral
208  algo.IntegralStdDev().value(), // integral_stddev
209  algo.SummedADC().value(), // summedADC
210  algo.SummedADCStdDev().value(), // summedADC_stddev
211  algo.NHits(), // n_hits
212  algo.MultipleHitDensity(), // multiple_hit_density
213  algo.Width(), // width
214  out_clusters.size(), // ID
215  view_id, // view
216  plane, // plane
217  recob::Cluster::Sentry // sentry
218  );
219 
220  util::CreateAssn(ed,
221  ev,
222  out_clusters,
223  GetMergedClusterHits().at(out_index),
224  assns
225  );
226  }
227 
228  }
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
Double_t TimeToCm() const
Double_t WireToCm() const
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
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> ...
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:171
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.
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.
::util::GeometryUtilities fGeoU
GeometryUtilities.
const std::vector< cluster::ClusterParamsAlg > & GetMergedCPAN() const
Utility method to retrieve merged clusters in terms of a vector of CPAN.
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
::cmtool::CMergeManager& cluster::ClusterMergeHelper::GetManager ( )
inline

A method to retrieve Manager.

Definition at line 57 of file ClusterMergeHelper.h.

References AppendResult(), fMgr, GetMergedClusterHits(), GetMergedCPAN(), Process(), SetClusters(), and lar::dump::vector().

57 { 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 125 of file ClusterMergeHelper.cxx.

References fOutputClusters.

Referenced by AppendResult(), and GetManager().

127  {
128  if(!fOutputClusters.size())
129 
130  throw cet::exception(__FUNCTION__)
131  << "\033[93m"
132  << "You must call Process() before calling " << __FUNCTION__ << " to retrieve result."
133  << "\033[00m"
134  << std::endl;
135 
136  return fOutputClusters;
137  }
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 140 of file ClusterMergeHelper.cxx.

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

Referenced by AppendResult(), and GetManager().

142  {
143  if(!fOutputClusters.size())
144 
145  throw cet::exception(__FUNCTION__)
146  << "\033[93m"
147  << "You must call Process() before calling " << __FUNCTION__ << " to retrieve result."
148  << "\033[00m"
149  << std::endl;
150 
151  return fMgr.GetClusters();
152  }
const std::vector< cluster::ClusterParamsAlg > & GetClusters() const
A method to obtain output clusters.
Definition: CMergeManager.h:50
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 ( )

Function to execute CMergeManager::Process()

Definition at line 82 of file ClusterMergeHelper.cxx.

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

Referenced by GetManager().

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

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

Referenced by GetManager(), and SetClusters().

19  {
20  fInputClusters.clear();
21  fOutputClusters.clear();
22 
23  std::vector<std::vector<util::PxHit> > px_clusters(clusters.size(),std::vector<util::PxHit>());
24 
25  fInputClusters.resize(clusters.size(),std::vector<art::Ptr<recob::Hit> >());
26 
27  for(size_t cluster_index=0; cluster_index < clusters.size(); ++cluster_index) {
28 
29  px_clusters.at(cluster_index).resize(clusters.at(cluster_index).size(),util::PxHit());
30 
31  fInputClusters.at(cluster_index).resize(clusters.at(cluster_index).size());
32 
33  for(size_t hit_index=0; hit_index < clusters.at(cluster_index).size(); ++hit_index) {
34 
35  px_clusters.at(cluster_index).at(hit_index).plane = clusters.at(cluster_index).at(hit_index)->WireID().Plane;
36  px_clusters.at(cluster_index).at(hit_index).w = clusters.at(cluster_index).at(hit_index)->WireID().Wire * fGeoU.WireToCm();
37  px_clusters.at(cluster_index).at(hit_index).t = clusters.at(cluster_index).at(hit_index)->PeakTime() * fGeoU.TimeToCm();
38  px_clusters.at(cluster_index).at(hit_index).charge = clusters.at(cluster_index).at(hit_index)->Integral();
39 
40  fInputClusters.at(cluster_index).at(hit_index) = clusters.at(cluster_index).at(hit_index);
41 
42  }
43 
44  }
45 
46  SetClusters(px_clusters);
47 
48  }
std::vector< std::vector< art::Ptr< recob::Hit > > > fInputClusters
Input clusters in terms of a vector of art::Ptr<recob::Hit> collection.
Double_t TimeToCm() const
Double_t WireToCm() const
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(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 ( 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 51 of file ClusterMergeHelper.cxx.

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

53  {
54 
56  evt.getByLabel(cluster_module_label, clusters_h);
57 
58  if(!(clusters_h.isValid()))
59 
60  throw cet::exception(__FUNCTION__)
61  << "\033[93m"
62  << " Failed to retrieve recob::Cluster with label: "
63  << cluster_module_label.c_str()
64  << "\033[00m"
65  << std::endl;
66 
67  std::vector<std::vector<art::Ptr<recob::Hit> > > cluster_hits_v;
68 
69  cluster_hits_v.reserve(clusters_h->size());
70 
71  art::FindManyP<recob::Hit> hit_m(clusters_h, evt, cluster_module_label);
72 
73  for(size_t i=0; i<clusters_h->size(); ++i)
74 
75  cluster_hits_v.push_back(hit_m.at(i));
76 
77  SetClusters(cluster_hits_v);
78 
79  }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void SetClusters(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 ( 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 83 of file ClusterMergeHelper.h.

References fMgr, cmtool::CMergeManager::Reset(), and cmtool::CMManagerBase::SetClusters().

84  {
85  fMgr.Reset();
86  fMgr.SetClusters(clusters);
87  }
void SetClusters(const std::vector< std::vector< util::PxHit > > &clusters)
A simple method to add a cluster.
virtual void Reset()
Method to reset itself.
::cmtool::CMergeManager fMgr
CMergeManager instance.

Member Data Documentation

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

GeometryUtilities.

Definition at line 95 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 98 of file ClusterMergeHelper.h.

Referenced by Process(), and SetClusters().

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

CMergeManager instance.

Definition at line 92 of file ClusterMergeHelper.h.

Referenced by GetManager(), GetMergedCPAN(), Process(), and SetClusters().

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 101 of file ClusterMergeHelper.h.

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


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