22 const std::vector<unsigned int>& g4_trackid_v,
23 const std::vector<sim::SimChannel>& simch_v,
28 return BuildMap(clockData, cluster_v);
32 const std::vector<std::vector<unsigned int>>& g4_trackid_v,
33 const std::vector<sim::SimChannel>& simch_v,
39 return BuildMap(clockData, cluster_v);
46 size_t num_cluster = cluster_v.size();
62 _summed_mcq.resize(num_mcobj + 1, std::vector<double>(wireReadoutGeom.Nplanes(), 0));
66 for (
auto const& hit_v : cluster_v) {
68 size_t plane = wireReadoutGeom.Nplanes();
71 std::vector<WireRange_t> wr_v;
72 wr_v.reserve(hit_v.size());
74 for (
auto const& h : hit_v) {
78 wr.
start = h->StartTick();
79 wr.
end = h->EndTick();
81 if (plane == wireReadoutGeom.Nplanes()) plane = h->WireID().Plane;
88 for (
size_t i = 0; i < mcq_v.size(); ++i)
99 _bmatch_id.resize(num_mcobj, std::vector<int>(wireReadoutGeom.Nplanes(), -1));
101 std::vector<std::vector<double>> bmatch_mcq(num_mcobj,
102 std::vector<double>(wireReadoutGeom.Nplanes(), 0));
104 for (
size_t mc_index = 0; mc_index < num_mcobj; ++mc_index) {
106 for (
size_t cluster_index = 0; cluster_index < num_cluster; ++cluster_index) {
112 if (bmatch_mcq[mc_index][plane] < q) {
114 bmatch_mcq[mc_index][plane] = q;
130 "Input cluster index (%zu) out of range (%zu)!", cluster_index,
_cluster_mcq_v.size()));
134 Form(
"Input MC object index (%zu) out of range (%zu)!", mc_index,
_bmatch_id.size()));
138 auto best_cluster_index =
_bmatch_id.at(mc_index).at(plane);
140 if (best_cluster_index < 0)
return -1;
147 const std::vector<unsigned int> cluster_indices)
const 154 Form(
"Input cluster indices length (%zu) > # of registered clusters (%zu)!",
155 cluster_indices.size(),
158 if (!cluster_indices.size())
throw MCBTException(
"Input cluster indices empty!");
161 std::vector<double> match_eff(
_bmatch_id.size(), 1);
163 for (
auto const& cluster_index : cluster_indices) {
165 for (
size_t mc_index = 0; mc_index <
_bmatch_id.size(); ++mc_index) {
169 if (correctness >= 0) match_eff.at(mc_index) *= correctness;
173 std::pair<size_t, double> result(0, -1);
176 for (
size_t mc_index = 0; mc_index < match_eff.size(); ++mc_index) {
178 if (match_eff.at(mc_index) < result.second)
continue;
180 result.second = match_eff.at(mc_index);
182 result.first = mc_index;
188 const size_t mc_index)
const 194 "Input cluster index (%zu) out of range (%zu)!", cluster_index,
_cluster_mcq_v.size()));
198 Form(
"Input MC object index (%zu) out of range (%zu)!", mc_index,
_bmatch_id.size()));
203 std::pair<double, double> result;
209 double cluster_mcq_total = 0;
211 cluster_mcq_total += q;
213 result.second =
_cluster_mcq_v[cluster_index][mc_index] / cluster_mcq_total;
224 Form(
"Input MC object index (%zu) out of range (%zu)!", mc_index,
_bmatch_id.size()));
230 const size_t plane_id)
const 235 if (c_index_v.size() <= plane_id)
237 "Plane ID %zu exceeds # of planes recorded in data (%zu)...", plane_id, c_index_v.size()));
239 std::pair<double, double> result(0, 0);
241 if (c_index_v[plane_id] < 0)
return result;
243 return ClusterEP(c_index_v[plane_id], mc_index);
Class def header for a class MCMatchAlg.
std::pair< double, double > BestClusterEP(const size_t mcshower_index, const size_t plane_id) const
void Reset(const std::vector< unsigned int > &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v)
Declaration of signal hit object.
Class def header for a class MCBTAlg.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
bool BuildMap(detinfo::DetectorClocksData const &clockData, const std::vector< unsigned int > &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v, const std::vector< std::vector< art::Ptr< recob::Hit >>> &cluster_v)
Constructs needed information for Reco=>MC matching.
std::vector< std::vector< double > > _summed_mcq
std::vector< unsigned char > _cluster_plane_id
std::vector< std::vector< double > > _cluster_mcq_v
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double ClusterCorrectness(const size_t cluster_index, const size_t mcshower_index) const
MCBTAlg fBTAlgo
MCBTAlg instance.
std::pair< double, double > ClusterEP(const size_t cluster_index, const size_t mcshower_index) const
For a specified cluster, compute cluster efficiency and purity in terms of specified MC object...
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition of data types for geometry description.
const std::vector< int > & BestClusters(const size_t mcshower_index) const
std::vector< size_t > _view_to_plane
Contains all timing reference information for the detector.
MCMatchAlg()
Default constructor.
std::pair< size_t, double > ShowerCorrectness(const std::vector< unsigned int > cluster_indices) const
std::vector< std::vector< int > > _bmatch_id
Class def header for exception classes in MCComp package.