25 , m_drift_speed(1.6*units::
mm/units::
us)
30 Img::JsonClusterTap::~JsonClusterTap()
36 m_filename =
get(
cfg,
"filename", m_filename);
37 m_drift_speed =
get(
cfg,
"drift_speed", m_drift_speed);
44 cfg[
"filename"] = m_filename;
46 cfg[
"drift_speed"] = m_drift_speed;
54 return Json::nullValue;
61 for (
int ind=0; ind<3; ++ind) {
72 ret[
"ident"] = ich->ident();
73 ret[
"index"] = ich->index();
74 ret[
"wpid"] = ich->planeid().ident();
83 ret[
"ident"] = iwire->ident();
84 ret[
"index"] = iwire->index();
85 ret[
"wpid"] = iwire->planeid().ident();
86 ret[
"chid"] = iwire->channel();
87 ret[
"seg"] = iwire->segment();
88 auto r = iwire->ray();
107 const double xplane = iwire->center().x();
110 const double xsign = iface->ident() == 0 ? 1.0 : -1.0;
115 double x0 = xplane + xsign * islice->start()*
drift_speed;
117 const auto& coords = iface->raygrid();
121 ret[
"ident"] = iblob->ident();
122 ret[
"value"] = iblob->value();
123 ret[
"error"] = iblob->uncertainty();
124 ret[
"faceid"] = iblob->face()->ident();
125 ret[
"sliceid"] = iblob->slice()->ident();
127 const auto& blob = iblob->shape();
128 for (
const auto&
c : blob.corners()) {
133 ret[
"corners"] = jcorners;
164 ret[
"ident"] = islice->ident();
165 ret[
"frameid"] = islice->frame()->ident();
166 ret[
"start"] = islice->start();
167 ret[
"span"] = islice->span();
169 for (
const auto& it : islice->activity()) {
172 ret[
"activity"] = jact;
178 IChannel::shared_vector ichv = std::get<IChannel::shared_vector>(n.ptr);
181 for (
auto ich : *ichv) {
182 j.append(ich->ident());
183 ret[
"wpid"] = ich->planeid().ident();
197 std::vector< std::function< Json::Value(const cluster_node_t& ptr) > > jsoners{
206 return jsoners[
n.ptr.index()](
n);
222 const auto& gr = in->graph();
225 for (
auto vtx : boost::make_iterator_range(boost::vertices(gr))) {
226 const auto& vobj = gr[vtx];
227 if (!vobj.ptr.index()) {
232 jvtx[
"ident"] = (
int)vtx;
234 jvtx[
"data"] = asjson(vobj);
236 jvertices.append(jvtx);
240 for (
auto eit : boost::make_iterator_range(boost::edges(gr))) {
242 jedge[0] = (
int) boost::source(eit, gr);
244 jedges.append(jedge);
248 top[
"vertices"] = jvertices;
249 top[
"edges"] = jedges;
252 if (m_filename.find(
"%") != std::string::npos) {
254 log->debug(
"JsonClusterTap: {} -> {}", m_filename, fname);
256 std::ofstream fstr(fname);
258 log->error(
"JsonClusterTap failed to open for writing: {}", fname);
261 log->info(
"JsonClusterTap writing: {}", fname);
static Json::Value size_stringer(const cluster_node_t &n)
static Json::Value wire_jsoner(const cluster_node_t &n)
WIRECELL_FACTORY(JsonClusterTap, WireCell::Img::JsonClusterTap, WireCell::IClusterFilter, WireCell::IConfigurable) using namespace WireCell
Json::Value operator()(const cluster_node_t &n)
Cluster finding and building.
std::shared_ptr< const ICluster > input_pointer
static Json::Value jpoint(const Point &p)
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Json::Value measurement_jsoner(const cluster_node_t &n)
Json::Value slice_jsoner(const cluster_node_t &n)
std::shared_ptr< const ICluster > output_pointer
logptr_t logger(std::string name)
void log(source_loc source, level::level_enum lvl, const char *fmt, const Args &...args)
Json::Value Configuration
static Json::Value channel_jsoner(const cluster_node_t &n)
const GenericPointer< typename T::ValueType > & pointer