7 #ifndef CLUSTERMATCHALG_CC 8 #define CLUSTERMATCHALG_CC 25 std::vector<size_t> algo_list = pset.
get<std::vector<size_t> > (
"MatchAlgoList");
37 for(
auto const v : algo_list) {
41 mf::LogError(
"ClusterMatchAlg")<<Form(
"Invalid algorithm enum: %zu",v);
55 std::ostringstream msg;
58 <<
" ClusterMatchAlg Configuration: " << std::endl
59 <<
"---------------------------------------------" << std::endl;
60 msg <<
" Debug Mode ... " << (
_debug_mode ?
"enabled!" :
"disabled!") << std::endl;
68 <<
" Charge-Ratio Diff. Cut : " <<
_qratio_cut << std::endl
69 <<
" Minimum # of SpacePoint : " <<
_num_sps_cut << std::endl
72 <<
"---------------------------------------------" << std::endl;
206 std::vector<const simb::MCTruth*> mciArray;
218 for(
size_t i=0; i < mciArray.size(); ++i){
221 mf::LogWarning(
"ClusterMatchAlg")<<
" Ignoring > 2nd MCTruth in MC generator...";
226 for(
size_t j=0; j < (size_t)(mci_ptr->NParticles()); ++j){
229 mf::LogWarning(
"ClusterMatchAlg")<<
" Ignoring > 2nd MCParticle in MC generator...";
294 mf::LogError(
"ClusterMatchAlg")<<Form(
"Found an invalid plane ID: %d",in_cluster.
View());
327 mf::LogError(
"ClusterMatchAlg")<<Form(
"Found an invalid plane ID: %d",in_cluster->
View());
339 out_hit_v.
reserve(in_hit_v.size());
341 double time_offset = 0;
347 for(
auto const hit : in_hit_v){
349 unsigned int wire =
hit->WireID().Wire;
350 double tstart =
hit->PeakTimePlusRMS(-1.) - time_offset;
351 double tpeak =
hit->PeakTime() - time_offset;
352 double tend =
hit->PeakTimePlusRMS(+1.) - time_offset;
370 ci.
nhits = in_hit_v.size();
396 double y, z_min, z_max;
397 y = z_min = z_max = -1;
400 return (z_max > z_min);
440 std::vector<recob::SpacePoint> &sps_v)
451 << Form(
"Requested to cluster-index (U,V,W) = (%zu,%zu,%zu) where max-length is (%zu,%zu,%zu)",
471 if(use_wplane) max_size +=
_whits_v.at(windex).size();
475 if(
hit->PeakTime() < trange_min)
continue;
476 if(
hit->PeakTime() > trange_max)
continue;
480 size_t u_nhits = hit_group.
size();
484 if(
hit->PeakTime() < trange_min)
continue;
485 if(
hit->PeakTime() > trange_max)
continue;
489 size_t v_nhits = hit_group.
size() - u_nhits;
495 if(
hit->PeakTime() < trange_min)
continue;
496 if(
hit->PeakTime() > trange_max)
continue;
501 size_t w_nhits = hit_group.
size() - u_nhits - v_nhits;
502 if( !(w_nhits) && use_wplane && !
_debug_mode)
return false;
505 if(u_nhits && v_nhits &&
506 (!use_wplane || (w_nhits && use_wplane))) {
511 size_t nsps = sps_v.size();
516 _nsps.push_back(nsps);
526 std::vector<std::vector<unsigned int> > result;
537 std::ostringstream msg;
538 msg << Form(
"Received (U,V,W) = (%zu,%zu,%zu) clusters...",
549 mf::LogError(__PRETTY_FUNCTION__)<<
"No input cluster info found! Aborting the function call...";
558 bool overlay_2d =
false;
559 for(
size_t uci_index=0; uci_index<
_ucluster_v.size(); ++uci_index) {
561 for(
size_t vci_index=0; vci_index<
_vcluster_v.size(); ++vci_index) {
572 else overlay_2d =
false;
582 else overlay_2d =
false;
591 else overlay_2d =
false;
595 std::vector<recob::SpacePoint> sps_v;
601 else overlay_2d =
false;
619 if(i==0) msg <<
"Listing matched clusters (U,V)..." << std::endl;
640 std::ostringstream msg;
641 msg << Form(
"Received (U,V,W) = (%zu,%zu,%zu) clusters...",
652 mf::LogError(__PRETTY_FUNCTION__)<<
"No input cluster info found! Aborting the function call...";
661 bool overlay_2d=
true;
662 bool overlay_3d=
true;
664 for(
size_t uci_index=0; uci_index<
_ucluster_v.size(); ++uci_index) {
666 for(
size_t vci_index=0; vci_index<
_vcluster_v.size(); ++vci_index) {
677 else overlay_2d =
false;
686 else overlay_2d =
false;
689 for(
size_t wci_index=0; wci_index<
_wcluster_v.size(); ++wci_index) {
691 overlay_3d = overlay_2d;
705 overlay_3d = overlay_3d && rough_time_match;
711 std::vector<recob::SpacePoint> sps_v;
717 else overlay_3d =
false;
737 if(i==0) msg <<
"Listing matched clusters (U,V,W)..." << std::endl;
739 msg << Form(
"Pair %-2zu: (%-3d, %-3d, %-3d)",
std::vector< uint16_t > _w_nhits_v
Use summed charge comparison ... see Match_SumCharge() description.
void ClearMatchInputInfo()
Method to clear input cluster information.
void reserve(size_type n)
std::vector< std::vector< unsigned int > > GetMatchedClusters() const
Method to retrieve matched cluster combinations. The format is [wire_plane][cluster_index].
trkf::SpacePointAlg * _sps_algo
SpacePointFinder algorithm pointer.
double peak_time_max
Maximum "peak time" among all hits in this cluster.
std::vector< art::PtrVector< recob::Hit > > _vhits_v
Local Hit pointer vector container ... V-plane.
void FillMCInfo(const art::Event &evt)
Internal method to fill MCTruth information when available.
double _time_offset_wplane
bool Match_RoughTime(const cluster_match_info &ci1, const cluster_match_info &ci2)
Checks min/max hit timing among two clusters and make sure there is an overlap.
double end_time_min
Minimum "end time" among all hits in this cluster.
std::vector< double > _vw_tratio_v
unsigned short wire_min
Minimum wire number in this cluster.
std::vector< art::PtrVector< recob::Hit > > _whits_v
Local Hit pointer vector container ... W-plane.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
double _time_offset_uplane
double end_time_max
Maximum "end time" among all hits in this cluster.
unsigned short _tot_pass_t
std::vector< double > _wu_tratio_v
std::vector< double > _qratio_v
void ClearEventInfo()
Method to clear event-wise information.
void FillHitInfo(cluster_match_info &ci, art::PtrVector< recob::Hit > &out_hit_v, const std::vector< art::Ptr< recob::Hit > > &in_hit_v)
double _qratio_cut
Maximum difference among clusters' charge sum used in Match_SumCharge method.
void ClearMatchOutputInfo()
Method to clear output matched cluster information.
bool _store_sps
Boolean to enable storage of SpacePoint vector.
bool Match_RoughZ(const cluster_match_info &ci1, const cluster_match_info &ci2, const geo::View_t v1, const geo::View_t v2) const
Set of hits with a 2D structure.
Use SpacePoint finder algorithm ... see Match_SpacePoint() description.
void MatchTwoPlanes()
Two plane version of cluster matching method.
void AppendClusterInfo(const recob::Cluster &in_cluster, const std::vector< art::Ptr< recob::Hit > > &in_hit_v)
Method to fill cluster information to be used for matching.
std::vector< cluster_match_info > _wcluster_v
Local cluster data container... W-plane.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
unsigned short _tot_pass_sps
std::vector< double > _tpeak_max_v
double _overlay_tratio_cut
Minimum overlayed time fraction among two clusters used in Match_RoughTime method.
double _time_offset_vplane
std::vector< double > _charge_v
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
std::vector< uint16_t > _nhits_v
void PrepareTTree()
Internal method to create output TTree for quality checking of the algorithm.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< double > _tend_max_v
std::vector< double > _tend_min_v
std::vector< uint16_t > _nsps
void push_back(Ptr< U > const &p)
double peak_time_min
Minimum "peak time" among all hits in this cluster.
T get(std::string const &key) const
double sum_charge
Summed charge among all hits in this cluster.
Rough-Time comparison method ... see Match_RoughTime() description.
std::string _ModName_MCTruth
MCTruth producer's module name.
bool Match_SpacePoint(const size_t uindex, const size_t vindex, const size_t windex, std::vector< recob::SpacePoint > &sps_v)
std::vector< art::PtrVector< recob::Hit > > _uhits_v
Local Hit pointer vector container ... U-plane.
std::vector< uint16_t > _u_nhits_v
void AppendClusterTreeVariables(const cluster_match_info &ci)
Internal method to fill cluster-info tree.
bool IntersectionPoint(geo::WireID const &wid1, geo::WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
std::vector< double > _tstart_max_v
std::vector< cluster_match_info > _vcluster_v
Local cluster data container... V-plane.
std::vector< double > _tstart_min_v
std::vector< double > _uv_tratio_v
bool _debug_mode
Boolean to enable debug mode (call all enabled matching methods)
ClusterMatchAlg(fhicl::ParameterSet const &pset)
Default constructor with fhicl parameters.
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void ClearTTreeInfo()
Method to clear TTree variables.
void makeSpacePoints(const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
geo::View_t View() const
Returns the view for this cluster.
bool Match_SumCharge(const cluster_match_info &uc, const cluster_match_info &vc)
T * make(ARGS...args) const
size_t _num_sps_cut
Number of SpacePoint used to cut in Match_SpacePoint method.
std::vector< uint16_t > _view_v
unsigned short _tot_pass_qsum
ID_t ID() const
Identifier of this cluster.
unsigned short wire_max
Maximum wire number in this cluster.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool _det_params_prepared
std::vector< uint16_t > _v_nhits_v
std::vector< std::vector< recob::SpacePoint > > _matched_sps_v
Local SpacePoint vector container.
std::vector< unsigned int > _matched_uclusters_v
U plane matched clusters' index.
unsigned int nhits
Number of hits.
unsigned short _tot_pass_z
double start_time_max
Maximum "start time" among all hits in this cluster.
Planes which measure W (third view for Bo, MicroBooNE, etc).
bool _match_methods[kMATCH_METHOD_MAX]
Boolean list for enabled algorithms.
geo::View_t view
Wire plane ID.
Event generator information.
void PrepareDetParams()
Internal method, called only once, to fill detector-wise information.
void ReportConfig() const
Method to report the current configuration.
Namespace collecting geometry-related classes utilities.
std::vector< unsigned int > _matched_wclusters_v
W plane matched clusters' index.
std::vector< unsigned int > _matched_vclusters_v
V plane matched clusters' index.
Rough-Z comparison method ... see Match_RoughZ() description.
std::vector< double > _tpeak_min_v
std::vector< cluster_match_info > _ucluster_v
Local cluster data container... U-plane.
virtual double GetXTicksOffset(int p, int t, int c) const =0
double start_time_min
Minimum "start time" among all hits in this cluster.