16 : m_drift_speed(1.6*units::
mm/units::
us)
17 , m_filename("
blobs-%02
d.json")
22 Img::JsonBlobSetSink::~JsonBlobSetSink()
29 m_face =
get(
cfg,
"face", m_face);
30 m_drift_speed =
get(
cfg,
"drift_speed", m_drift_speed);
31 m_filename =
get(
cfg,
"filename", m_filename);
40 cfg[
"filename"] = m_filename;
43 cfg[
"drift_speed"] = m_drift_speed;
50 l->debug(
"JsonBlobSetSink: eos");
54 const auto&
blobs = bs->blobs();
56 l->info(
"JsonBlobSetSink: no blobs");
60 auto slice =
blobs[0]->slice();
61 auto frame = slice->frame();
62 const double start = slice->start();
63 const double time = frame->time();
64 const double x = (start-time)*m_drift_speed;
66 l->debug(
"JsonBlobSetSink: frame:{}, slice:{} set:{} time:{} ms, start={} ms x:{} nblobs:{}",
67 frame->ident(), slice->ident(), bs->ident(),
74 for (
const auto& iblob:
blobs) {
75 if (m_face >= 0 and m_face != iblob->face()->ident()) {
78 const auto& coords = iblob->face()->raygrid();
79 const auto& blob = iblob->shape();
81 for (
const auto&
corner : blob.corners()) {
83 auto pt = coords.ray_crossing(
corner.first,
corner.second);
85 jcorner.append(pt.y());
86 jcorner.append(pt.z());
87 jcorners.append(jcorner);
90 jblob[
"points"] = jcorners;
91 jblob[
"values"][
"charge"] = iblob->value();
92 jblob[
"values"][
"uncert"] = iblob->uncertainty();
93 jblob[
"values"][
"ident"] = iblob->ident();
94 jblob[
"values"][
"inset"] = jblobs.size();
102 top[
"blobs"] = jblobs;
105 if (m_filename.find(
"%") != std::string::npos) {
108 std::ofstream fstr(fname);
110 l->error(
"Failed to open for writing: %s", fname);
std::shared_ptr< const IBlobSet > pointer
WIRECELL_FACTORY(JsonBlobSetSink, WireCell::Img::JsonBlobSetSink, WireCell::IBlobSetSink, WireCell::IConfigurable) using namespace WireCell
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
logptr_t logger(std::string name)
Json::Value Configuration