forked from DeepLearnPhysics/Supera
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SegLabelGhost.cxx
58 lines (44 loc) · 1.65 KB
/
SegLabelGhost.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef __SEGLABELGHOST_CXX__
#define __SEGLABELGHOST_CXX__
#include "SegLabelGhost.h"
#include "larcv/core/DataFormat/EventVoxel3D.h"
#include "larcv/core/DataFormat/EventParticle.h"
namespace larcv {
static SegLabelGhostProcessFactory __global_SegLabelGhostProcessFactory__;
SegLabelGhost::SegLabelGhost(const std::string name)
: ProcessBase(name)
{}
void SegLabelGhost::configure(const PSet& cfg)
{
_reco_prod = cfg.get<std::string>("RecoProducer");
_mc_prod = cfg.get<std::string>("McProducer");
_out_prod = cfg.get<std::string>("OutputProducer");
_min_num_voxel = cfg.get<size_t>("MinVoxelCount", 0);
}
void SegLabelGhost::initialize()
{}
bool SegLabelGhost::process(IOManager& mgr)
{
auto const& evt_reco = mgr.get_data<larcv::EventSparseTensor3D>(_reco_prod);
auto const& evt_mc = mgr.get_data<larcv::EventSparseTensor3D>(_mc_prod);
auto evt_out = reinterpret_cast<larcv::EventSparseTensor3D*>(
mgr.get_data("sparse3d", _out_prod));
evt_out->meta(evt_reco.meta());
for (auto const& reco : evt_reco.as_vector()) {
auto const& mc = evt_mc.find(reco.id());
float class_def = mc.id() == larcv::kINVALID_VOXELID ? 1 : 0;
((VoxelSet*)evt_out)->emplace(reco.id(), class_def, false);
}
if(_min_num_voxel<1) return true;
if(evt_out->as_vector().size() < _min_num_voxel) {
LARCV_NORMAL() << "Skipping event " << evt_out->event_key()
<< " due to voxel count (" << evt_out->as_vector().size()
<< " < " << _min_num_voxel << ")" << std::endl;
return false;
}
return true;
}
void SegLabelGhost::finalize()
{}
}
#endif