Public Member Functions | Private Attributes | List of all members
WireCell::Img::GridTiling Class Reference

#include <GridTiling.h>

Inheritance diagram for WireCell::Img::GridTiling:
WireCell::ITiling WireCell::IConfigurable WireCell::IFunctionNode< ISlice, IBlobSet > WireCell::IComponent< IConfigurable > WireCell::IFunctionNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 GridTiling ()
 
virtual ~GridTiling ()
 
virtual void configure (const WireCell::Configuration &cfg)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
virtual bool operator() (const input_pointer &slice, output_pointer &blobset)
 The calling signature: More...
 
- Public Member Functions inherited from WireCell::ITiling
virtual ~ITiling ()
 
virtual std::string signature ()
 Set the signature for all subclasses. More...
 
- Public Member Functions inherited from WireCell::IFunctionNode< ISlice, IBlobSet >
virtual ~IFunctionNode ()
 
virtual bool operator() (const boost::any &anyin, boost::any &anyout)
 The calling signature: More...
 
virtual std::vector< std::stringinput_types ()
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::IFunctionNodeBase
virtual ~IFunctionNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual int concurrency ()
 By default assume all subclasses are stateless. More...
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
virtual void reset ()
 
- Public Member Functions inherited from WireCell::IComponent< INode >
virtual ~IComponent ()
 
- Public Member Functions inherited from WireCell::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from WireCell::IConfigurable
virtual ~IConfigurable ()
 
- Public Member Functions inherited from WireCell::IComponent< IConfigurable >
virtual ~IComponent ()
 

Private Attributes

size_t m_blobs_seen
 
IAnodePlane::pointer m_anode
 
IAnodeFace::pointer m_face
 
double m_threshold
 
Log::logptr_t l
 

Additional Inherited Members

- Public Types inherited from WireCell::ITiling
typedef std::shared_ptr< ITilingpointer
 
- Public Types inherited from WireCell::IFunctionNode< ISlice, IBlobSet >
typedef ISlice input_type
 
typedef IBlobSet output_type
 
typedef std::shared_ptr< const ISliceinput_pointer
 
typedef std::shared_ptr< const IBlobSetoutput_pointer
 
typedef IFunctionNode< ISlice, IBlobSetsignature_type
 
- Public Types inherited from WireCell::IFunctionNodeBase
typedef std::shared_ptr< IFunctionNodeBasepointer
 
- Public Types inherited from WireCell::INode
enum  NodeCategory {
  unknown, sourceNode, sinkNode, functionNode,
  queuedoutNode, joinNode, splitNode, faninNode,
  fanoutNode, multioutNode, hydraNode
}
 
- Public Types inherited from WireCell::IComponent< INode >
typedef std::shared_ptr< INodepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 
- Public Types inherited from WireCell::Interface
typedef std::shared_ptr< Interfacepointer
 
- Public Types inherited from WireCell::IComponent< IConfigurable >
typedef std::shared_ptr< IConfigurablepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 

Detailed Description

Definition at line 26 of file GridTiling.h.

Constructor & Destructor Documentation

Img::GridTiling::GridTiling ( )

Definition at line 14 of file GridTiling.cxx.

15  : m_blobs_seen(0)
16  , m_threshold(0.0)
17  , l(Log::logger("img"))
18 {
19 }
logptr_t logger(std::string name)
Definition: Logging.cxx:71
Img::GridTiling::~GridTiling ( )
virtual

Definition at line 21 of file GridTiling.cxx.

22 {
23 
24 }

Member Function Documentation

void Img::GridTiling::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 26 of file GridTiling.cxx.

27 {
28  m_anode = Factory::find_tn<IAnodePlane>(cfg["anode"].asString());
29  m_face = m_anode->face(cfg["face"].asInt());
30  m_threshold = get(cfg, "threshold", m_threshold);
31 }
IAnodePlane::pointer m_anode
Definition: GridTiling.h:39
cfg
Definition: dbjson.py:29
IAnodeFace::pointer m_face
Definition: GridTiling.h:40
WireCell::Configuration Img::GridTiling::default_configuration ( ) const
virtual

Optional, override to return a hard-coded default configuration.

Reimplemented from WireCell::IConfigurable.

Definition at line 33 of file GridTiling.cxx.

34 {
36  cfg["anode"] = ""; // user must set
37  cfg["face"] = 0; // the face number to focus on
38  // activity must be bigger than this much to consider.
39  cfg["threshold"] = m_threshold;
40  return cfg;
41 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Img::GridTiling::operator() ( const input_pointer in,
output_pointer out 
)
virtual

The calling signature:

Implements WireCell::IFunctionNode< ISlice, IBlobSet >.

Definition at line 45 of file GridTiling.cxx.

46 {
47  out = nullptr;
48  if (!slice) {
49  m_blobs_seen = 0;
50  SPDLOG_LOGGER_TRACE(l, "GridTiling: EOS");
51  return true; // eos
52  }
53 
54  const int sbs_ident = slice->ident();
55  SimpleBlobSet* sbs = new SimpleBlobSet(sbs_ident, slice);
56  out = IBlobSet::pointer(sbs);
57 
58  const int nbounds_layers = 2;
59  const int nlayers = m_face->nplanes() + nbounds_layers;
60  std::vector< std::vector<Activity::value_t> > measures(nlayers);
61  measures[0].push_back(1); // assume first two layers in RayGrid::Coordinates
62  measures[1].push_back(1); // are for horiz/vert bounds
63 
64  const auto anodeid = m_anode->ident();
65  const auto faceid = m_face->ident();
66  auto chvs = slice->activity();
67  if (chvs.empty()) {
68  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} no activity",
69  anodeid, faceid, slice->ident());
70  return true;
71  }
72 
73  const int nactivities = slice->activity().size();
74  int total_activity=0;
75  if (nactivities < m_face->nplanes()) {
76  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} too few activities given",
77  anodeid, faceid, slice->ident());
78  return true;
79  }
80 
81  for (const auto& chv : slice->activity()) {
82  for (const auto& wire : chv.first->wires()) {
83  auto wpid = wire->planeid();
84  if (wpid.face() != faceid) {
85  //l->trace("anode:{} face:{} slice:{} chan:{} wip:{} q:{} skip {}", anodeid, faceid, slice->ident(), chv.first->ident(), wire->index(), chv.second, wpid);
86  continue;
87  }
88  //l->trace("anode:{} face:{} slice:{} chan:{} wip:{} q:{} keep {}", anodeid, faceid, slice->ident(), chv.first->ident(), wire->index(), chv.second, wpid);
89  const int pit_ind = wire->index();
90  const int layer = nbounds_layers + wire->planeid().index();
91  auto& m = measures[layer];
92  if (pit_ind < 0) {
93  continue;
94  }
95  if ((int)m.size() <= pit_ind) {
96  m.resize(pit_ind+1, 0.0);
97  }
98  m[pit_ind] += 1.0;
99  ++total_activity;
100  }
101  }
102 
103  if (!total_activity) {
104  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} no activity",
105  anodeid, faceid, slice->ident());
106  return true;
107  }
108  size_t nactive_layers = 0;
109  for (size_t ind = 0; ind<measures.size(); ++ind) {
110  const auto& blah = measures[ind];
111  if (blah.empty()) {
112  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} empty active layer ind={} out of {}",
113  anodeid, faceid, slice->ident(), ind, measures.size());
114  continue;
115  }
116  ++nactive_layers;
117  }
118  if (nactive_layers != measures.size()) {
119  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} missing active layers {} != {}, {} activities",
120  anodeid, faceid, slice->ident(), nactive_layers, measures.size(), nactivities);
121  return true;
122  }
123 
124  activities_t activities;
125  for (int layer = 0; layer<nlayers; ++layer) {
126  auto& m = measures[layer];
127  Activity activity(layer, {m.begin(), m.end()}, 0, m_threshold);
128  SPDLOG_LOGGER_TRACE(l, "L{} A:{}", layer, activity.as_string());
129  activities.push_back(activity);
130  }
131 
132  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} making blobs",
133  anodeid, faceid, slice->ident());
134  auto blobs = make_blobs(m_face->raygrid(), activities);
135 
136  const float blob_value = 0.0; // tiling doesn't consider particular charge
137  for (const auto& blob : blobs) {
138  SimpleBlob* sb = new SimpleBlob(m_blobs_seen++, blob_value, 0.0, blob, slice, m_face);
139  sbs->m_blobs.push_back(IBlob::pointer(sb));
140  }
141  SPDLOG_LOGGER_TRACE(l,"GridTiling: anode:{} face:{} slice:{} found {} blobs",
142  anodeid, faceid, slice->ident(), sbs->m_blobs.size());
143 
144  return true;
145 }
static const double m
Definition: Units.h:79
std::shared_ptr< const IBlobSet > pointer
Definition: IData.h:19
IAnodePlane::pointer m_anode
Definition: GridTiling.h:39
def blobs(cm, hist)
Definition: plots.py:79
def activity(output, slices, slice_line, cluster_tap_file)
Definition: main.py:144
IAnodeFace::pointer m_face
Definition: GridTiling.h:40
#define SPDLOG_LOGGER_TRACE(logger,...)
Definition: spdlog.h:319
blobs_t make_blobs(const Coordinates &coords, const activities_t &activities)
Definition: RayTiling.cxx:371
std::vector< Activity > activities_t
Definition: RayTiling.h:105

Member Data Documentation

Log::logptr_t WireCell::Img::GridTiling::l
private

Definition at line 42 of file GridTiling.h.

IAnodePlane::pointer WireCell::Img::GridTiling::m_anode
private

Definition at line 39 of file GridTiling.h.

size_t WireCell::Img::GridTiling::m_blobs_seen
private

Definition at line 38 of file GridTiling.h.

IAnodeFace::pointer WireCell::Img::GridTiling::m_face
private

Definition at line 40 of file GridTiling.h.

double WireCell::Img::GridTiling::m_threshold
private

Definition at line 41 of file GridTiling.h.


The documentation for this class was generated from the following files: