14 #include "art_root_io/TFileService.h" 38 std::vector<size_t> algo_list = pset.
get<std::vector<size_t>>(
"MatchAlgoList");
50 for (
auto const v : algo_list) {
54 mf::LogError(
"ClusterMatchAlg") << Form(
"Invalid algorithm enum: %zu", v);
67 std::ostringstream msg;
69 <<
" ClusterMatchAlg Configuration: " << std::endl
70 <<
"---------------------------------------------" << std::endl;
71 msg <<
" Debug Mode ... " << (
_debug_mode ?
"enabled!" :
"disabled!") << std::endl;
80 <<
" Charge-Ratio Diff. Cut : " <<
_qratio_cut << std::endl
81 <<
" Minimum # of SpacePoint : " <<
_num_sps_cut << std::endl
83 msg <<
"---------------------------------------------" << std::endl;
156 _match_tree = fileService->make<TTree>(
"match_tree",
"");
186 _cluster_tree = fileService->make<TTree>(
"cluster_tree",
"");
203 std::vector<const simb::MCTruth*> mciArray;
214 for (
size_t i = 0; i < mciArray.size(); ++i) {
217 mf::LogWarning(
"ClusterMatchAlg") <<
" Ignoring > 2nd MCTruth in MC generator...";
222 for (
size_t j = 0; j < (size_t)(mci_ptr->NParticles()); ++j) {
225 mf::LogWarning(
"ClusterMatchAlg") <<
" Ignoring > 2nd MCParticle in MC generator...";
289 mf::LogError(
"ClusterMatchAlg") << Form(
"Found an invalid plane ID: %d", in_cluster.
View());
298 out_hit_v.
reserve(in_hit_v.size());
300 double time_offset = 0;
309 for (
auto const hit : in_hit_v) {
311 unsigned int wire =
hit->WireID().Wire;
312 double tstart =
hit->PeakTimePlusRMS(-1.) - time_offset;
313 double tpeak =
hit->PeakTime() - time_offset;
314 double tend =
hit->PeakTimePlusRMS(+1.) - time_offset;
332 ci.
nhits = in_hit_v.size();
357 double y, z_min, z_max;
358 y = z_min = z_max = -1;
366 return z_max > z_min;
375 double overlay_tratio =
407 std::vector<recob::SpacePoint>& sps_v)
417 "Requested to cluster-index (U,V,W) = (%zu,%zu,%zu) where max-length is (%zu,%zu,%zu)",
431 if (use_wplane) trange_min = std::min(trange_min,
_wcluster_v.at(windex).peak_time_min);
435 if (use_wplane) trange_max = std::max(trange_max,
_wcluster_v.at(windex).peak_time_max);
444 if (use_wplane) max_size +=
_whits_v.at(windex).size();
448 if (
hit->PeakTime() < trange_min)
continue;
449 if (
hit->PeakTime() > trange_max)
continue;
453 size_t u_nhits = hit_group.
size();
457 if (
hit->PeakTime() < trange_min)
continue;
458 if (
hit->PeakTime() > trange_max)
continue;
462 size_t v_nhits = hit_group.
size() - u_nhits;
468 if (
hit->PeakTime() < trange_min)
continue;
469 if (
hit->PeakTime() > trange_max)
continue;
474 size_t w_nhits = hit_group.
size() - u_nhits - v_nhits;
475 if (!(w_nhits) && use_wplane && !
_debug_mode)
return false;
478 if (u_nhits && v_nhits && (!use_wplane || (w_nhits && use_wplane))) {
483 size_t nsps = sps_v.size();
486 if (use_wplane)
_w_nhits_v.push_back(w_nhits);
487 _nsps.push_back(nsps);
495 std::vector<std::vector<unsigned int>> result;
505 std::ostringstream msg;
506 msg << Form(
"Received (U,V,W) = (%zu,%zu,%zu) clusters...",
518 <<
"No input cluster info found! Aborting the function call...";
527 bool overlay_2d =
false;
528 for (
size_t uci_index = 0; uci_index <
_ucluster_v.size(); ++uci_index) {
530 for (
size_t vci_index = 0; vci_index <
_vcluster_v.size(); ++vci_index) {
569 std::vector<recob::SpacePoint> sps_v;
593 if (i == 0) msg <<
"Listing matched clusters (U,V)..." << std::endl;
613 std::ostringstream msg;
614 msg << Form(
"Received (U,V,W) = (%zu,%zu,%zu) clusters...",
626 <<
"No input cluster info found! Aborting the function call...";
635 bool overlay_2d =
true;
636 bool overlay_3d =
true;
638 for (
size_t uci_index = 0; uci_index <
_ucluster_v.size(); ++uci_index) {
640 for (
size_t vci_index = 0; vci_index <
_vcluster_v.size(); ++vci_index) {
667 for (
size_t wci_index = 0; wci_index <
_wcluster_v.size(); ++wci_index) {
669 overlay_3d = overlay_2d;
675 bool rough_time_match =
688 overlay_3d = overlay_3d && rough_time_match;
689 if (rough_time_match)
696 std::vector<recob::SpacePoint> sps_v;
699 if (
Match_SpacePoint(clock_data, det_prop, uci_index, vci_index, wci_index, sps_v))
722 if (i == 0) msg <<
"Listing matched clusters (U,V,W)..." << std::endl;
724 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.
Utilities related to art service access.
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
void AppendClusterInfo(detinfo::DetectorPropertiesData const &det_prop, 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.
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 GetXTicksOffset(int p, int t, int c) const
double end_time_max
Maximum "end time" among all hits in this cluster.
unsigned short _tot_pass_t
bool Match_SpacePoint(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const size_t uindex, const size_t vindex, const size_t windex, std::vector< recob::SpacePoint > &sps_v)
Declaration of signal hit object.
std::vector< double > _wu_tratio_v
std::vector< double > _qratio_v
The data type to uniquely identify a Plane.
void ClearEventInfo()
Method to clear event-wise information.
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.
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
double _time_offset_vplane
std::vector< double > _charge_v
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< uint16_t > _nhits_v
void PrepareTTree()
Internal method to create output TTree for quality checking of the algorithm.
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.
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
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.
std::vector< art::PtrVector< recob::Hit > > _uhits_v
Local Hit pointer vector container ... U-plane.
double maxDT() const noexcept
std::vector< uint16_t > _u_nhits_v
The data type to uniquely identify a TPC.
Declaration of cluster object.
void AppendClusterTreeVariables(const cluster_match_info &ci)
Internal method to fill cluster-info tree.
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.
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void ClearTTreeInfo()
Method to clear TTree variables.
geo::View_t View() const
Returns the view for this cluster.
bool Match_SumCharge(const cluster_match_info &uc, const cluster_match_info &vc)
std::vector< uint16_t > _view_v
unsigned short _tot_pass_qsum
Contains all timing reference information for the detector.
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
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
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.
bool IntersectionPoint(WireID const &wid1, WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
geo::View_t view
Wire plane ID.
void MatchTwoPlanes(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop)
Two plane version of cluster matching method.
Event generator information.
void ReportConfig() const
Method to report the current configuration.
Algorithm for generating space points from hits.
Namespace collecting geometry-related classes utilities.
void PrepareDetParams(detinfo::DetectorPropertiesData const &clockData)
Internal method, called only once, to fill detector-wise information.
std::vector< unsigned int > _matched_wclusters_v
W plane matched clusters' index.
std::vector< unsigned int > _matched_vclusters_v
V plane matched clusters' index.
void MatchThreePlanes(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop)
void FillHitInfo(cluster_match_info &ci, art::PtrVector< recob::Hit > &out_hit_v, const std::vector< art::Ptr< recob::Hit >> &in_hit_v)
Rough-Z comparison method ... see Match_RoughZ() description.
art framework interface to geometry description
std::vector< double > _tpeak_min_v
std::vector< cluster_match_info > _ucluster_v
Local cluster data container... U-plane.
double start_time_min
Minimum "start time" among all hits in this cluster.