1 #ifndef RECOTOOL_MCMATCHALG_CXX 2 #define RECOTOOL_MCMATCHALG_CXX 13 const std::vector<sim::SimChannel> &simch_v,
22 const std::vector<sim::SimChannel> &simch_v,
34 size_t num_cluster = cluster_v.size();
54 for(
auto const& hit_v : cluster_v) {
59 std::vector<WireRange_t> wr_v;
60 wr_v.reserve(hit_v.size());
62 for(
auto const& h : hit_v) {
66 wr.
start = h->StartTick();
67 wr.
end = h->EndTick();
69 if(plane==geo->
Nplanes()) plane = h->WireID().Plane;
78 for(
size_t i=0; i<mcq_v.size(); ++i)
92 std::vector<std::vector<double> > bmatch_mcq (num_mcobj,std::vector<double>(geo->
Nplanes(),0));
94 for(
size_t mc_index=0; mc_index < num_mcobj; ++mc_index) {
96 for(
size_t cluster_index=0; cluster_index < num_cluster; ++cluster_index) {
104 if( bmatch_mcq[mc_index][plane] < q ) {
106 bmatch_mcq[mc_index][plane] = q;
117 const size_t mc_index)
const 124 throw MCBTException(Form(
"Input cluster index (%zu) out of range (%zu)!",
130 throw MCBTException(Form(
"Input MC object index (%zu) out of range (%zu)!",
137 auto best_cluster_index =
_bmatch_id.at(mc_index).at(plane);
139 if(best_cluster_index < 0)
return -1;
152 throw MCBTException(Form(
"Input cluster indices length (%zu) > # of registered clusters (%zu)!",
153 cluster_indices.size(),
157 if(!cluster_indices.size())
throw MCBTException(
"Input cluster indices empty!");
160 std::vector<double> match_eff(
_bmatch_id.size(),1);
162 for(
auto const& cluster_index : cluster_indices) {
164 for(
size_t mc_index=0; mc_index <
_bmatch_id.size(); ++mc_index) {
169 match_eff.at(mc_index) *= correctness;
174 std::pair<size_t,double> result(0,-1);
177 for(
size_t mc_index=0; mc_index < match_eff.size(); ++mc_index) {
179 if(match_eff.at(mc_index) < result.second)
continue;
181 result.second = match_eff.at(mc_index);
183 result.first = mc_index;
190 const size_t mc_index)
const 196 throw MCBTException(Form(
"Input cluster index (%zu) out of range (%zu)!",
202 throw MCBTException(Form(
"Input MC object index (%zu) out of range (%zu)!",
210 std::pair<double,double> result;
216 double cluster_mcq_total = 0;
217 for(
auto const& q :
_cluster_mcq_v[cluster_index]) cluster_mcq_total += q;
219 result.second =
_cluster_mcq_v[cluster_index][mc_index] / cluster_mcq_total;
230 throw MCBTException(Form(
"Input MC object index (%zu) out of range (%zu)!",
240 const size_t plane_id)
const 245 if(c_index_v.size() <= plane_id)
246 throw MCBTException(Form(
"Plane ID %zu exceeds # of planes recorded in data (%zu)...",
251 std::pair<double,double> result(0,0);
253 if(c_index_v[plane_id]<0)
return result;
255 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)
std::vector< std::vector< double > > _summed_mcq
std::vector< unsigned char > _cluster_plane_id
std::vector< std::vector< double > > _cluster_mcq_v
bool BuildMap(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.
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...
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
const std::vector< int > & BestClusters(const size_t mcshower_index) const
std::vector< size_t > _view_to_plane
std::vector< double > MCQ(const WireRange_t &hit) const
MCMatchAlg()
Default constructor.
std::pair< size_t, double > ShowerCorrectness(const std::vector< unsigned int > cluster_indices) const
std::vector< std::vector< int > > _bmatch_id
Namespace collecting geometry-related classes utilities.