BlobSetSync.cxx
Go to the documentation of this file.
3 
5 
8 using namespace WireCell;
9 
11  : m_multiplicity(0)
12  , l(Log::logger("glue"))
13 {
14 }
15 
16 Img::BlobSetSync::~BlobSetSync()
17 {
18 }
19 
20 
21 WireCell::Configuration Img::BlobSetSync::default_configuration() const
22 {
24  cfg["multiplicity"] = (int)m_multiplicity;
25  return cfg;
26 }
27 
29 {
30  int m = get<int>(cfg, "multiplicity", (int)m_multiplicity);
31  if (m<=0) {
32  THROW(ValueError() << errmsg{"BlobSync multiplicity must be positive"});
33  }
34  m_multiplicity = m;
35 }
36 
37 std::vector<std::string> Img::BlobSetSync::input_types()
38 {
39  const std::string tname = std::string(typeid(input_type).name());
40  std::vector<std::string> ret(m_multiplicity, tname);
41  return ret;
42 
43 }
44 
45 bool Img::BlobSetSync::operator()(const input_vector& invec, output_pointer& out)
46 {
47  SimpleBlobSet* sbs = new SimpleBlobSet(0,nullptr);
48  out = IBlobSet::pointer(sbs);
49 
50  int neos = 0;
51  for (const auto& ibs : invec) {
52  if (!ibs) {
53  ++neos;
54  break;
55  }
56  ISlice::pointer newslice = ibs->slice();
57  if (!sbs->slice() or sbs->slice()->start() > newslice->start()) {
58  sbs->m_slice = newslice;
59  sbs->m_ident = newslice->ident();
60  }
61  for (const auto& iblob : ibs->blobs()) {
62  sbs->m_blobs.push_back(iblob);
63  }
64  }
65  if (neos) {
66  out = nullptr;
67  SPDLOG_LOGGER_TRACE(l,"BlobSetSink: EOS");
68  return true;
69  }
70  SPDLOG_LOGGER_TRACE(l,"BlobSetSink: sync'ed {} blobs", sbs->m_blobs.size());
71  return true;
72 }
73 
74 
static QCString name
Definition: declinfo.cpp:673
IBlob::vector m_blobs
Definition: SimpleBlob.h:61
static const double m
Definition: Units.h:79
std::shared_ptr< const ISlice > pointer
Definition: IData.h:19
std::vector< input_pointer > input_vector
Definition: IFaninNode.h:46
WIRECELL_FACTORY(BlobSetSync, WireCell::Img::BlobSetSync, WireCell::IBlobSetFanin, WireCell::IConfigurable) using namespace WireCell
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
cfg
Definition: dbjson.py:29
static QStrList * l
Definition: config.cpp:1044
def configure(cfg)
Definition: cuda.py:34
#define THROW(e)
Definition: Exceptions.h:25
logptr_t logger(std::string name)
Definition: Logging.cxx:71
Thrown when a wrong value has been encountered.
Definition: Exceptions.h:37
Definition: Main.h:22
#define SPDLOG_LOGGER_TRACE(logger,...)
Definition: spdlog.h:319
virtual ISlice::pointer slice() const
Definition: SimpleBlob.h:55
Json::Value Configuration
Definition: Configuration.h:50
std::shared_ptr< const IBlobSet > output_pointer
Definition: IFaninNode.h:45
ISlice::pointer m_slice
Definition: SimpleBlob.h:60
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124