Skip to content

Commit f8b903e

Browse files
authored
Merge pull request #163 from WireCell/wcp-charge-solving
Charge solving, imaging and configuration
2 parents e3de38e + 1c4b47b commit f8b903e

File tree

355 files changed

+28150
-11260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

355 files changed

+28150
-11260
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ calgrind.*
5353
*.hdf
5454
wct-deps.dot
5555

56+
*.npy
57+
*.tix
58+
*.xz

aux/README.org

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ Some categories of code appropriate for ~aux~:
1414
- general utility code that operate on interfaces (eg, ~FrameTools~)
1515

1616

17+
When describing a class or code outgrows what can easily be expressed
18+
in comments a file in [[./docs][docs/]] may be provided.
19+
1720

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#ifndef WIRECELLAUX_CLUSTERARRAYS
2+
#define WIRECELLAUX_CLUSTERARRAYS
3+
4+
#include "ClusterHelpers.h"
5+
#include "WireCellIface/ICluster.h"
6+
#include <boost/multi_array.hpp>
7+
#include <boost/range/counting_range.hpp>
8+
9+
namespace WireCell::Aux {
10+
11+
12+
/**
13+
A small helper to it just a bit easier to loop over a node type
14+
partition inside a node array using a node type array.
15+
16+
ClusterArray ca = ...;
17+
for (auto ind : index_range(ca.node_ranges()[4])) {
18+
auto d = data_array[ind];
19+
}
20+
21+
See also ca.ntype_range(char code).
22+
*/
23+
template<typename ArrayType>
24+
boost::iterator_range<boost::counting_iterator<size_t>>
25+
index_range(const ArrayType& arr) {
26+
return boost::counting_range(arr[0], arr[0] + arr[1]);
27+
}
28+
29+
/**
30+
ClusterArrays produces array representations from ICluster data.
31+
32+
See also AnodeArrays for array representations all anode wires.
33+
34+
See also the aux/docs/ClusterArrays.org document.
35+
*/
36+
class ClusterArrays {
37+
public:
38+
39+
ClusterArrays(const cluster_graph_t& graph);
40+
41+
// Clear all stored data. This will invalidate any arrays
42+
// previously accessed and held by const reference.
43+
void clear();
44+
45+
public:
46+
// Type codes of all nodes.
47+
const std::string& node_codes() const;
48+
private:
49+
mutable std::string m_node_codes;
50+
51+
public:
52+
// A vertext descriptor array (specially indexed by graph
53+
// vertex descriptors) holding node array indices. This array
54+
// is only required if node arrays are accessed in graph node
55+
// order.
56+
using vdesc_indices_t = boost::multi_array<size_t, 1>;
57+
const vdesc_indices_t& vdesc_indices() const;
58+
private:
59+
mutable vdesc_indices_t m_vdesc_indices;
60+
61+
public:
62+
// A node array giving graph vertex descriptors. This array
63+
// is only required if graph nodes are to be accessed in
64+
// node-array order.
65+
using vdescs_t = boost::multi_array<cluster_vertex_t, 1>;
66+
const vdescs_t& graph_vertices() const;
67+
private:
68+
mutable vdescs_t m_vdescs;
69+
70+
public:
71+
// Nedge rows, columns are indices (not vdescs!) for
72+
// (tail,head) nodes. Ordered by tail then head.
73+
using edges_t = boost::multi_array<size_t, 2>;
74+
const edges_t& edges() const;
75+
private:
76+
mutable edges_t m_edges;
77+
78+
79+
public:
80+
// Helper to get one range by type code. Eg, iterate over
81+
// slices:
82+
//
83+
// for (auto ind : ca.ntype_range('s') {
84+
// auto d = all_node_data_array[ind];
85+
// }
86+
boost::iterator_range<boost::counting_iterator<size_t>>
87+
ntype_range(char code) const;
88+
89+
/// Return (5,2) array of all node parition ranges.
90+
using node_ranges_t = boost::multi_array<size_t, 2>;
91+
const node_ranges_t& node_ranges() const;
92+
private:
93+
mutable node_ranges_t m_node_ranges;
94+
95+
public:
96+
// The full node array of node idents. Note, m-node idents
97+
// are taken as the ident of their first channel.
98+
using idents_t = boost::multi_array<int, 1>;
99+
const idents_t& idents() const;
100+
private:
101+
mutable idents_t m_idents;
102+
103+
public:
104+
// The full node array (if code = '0' or otherwise a node
105+
// code) or a node type array (if code in "cwbsm") of signals.
106+
// First column is central value, second is uncertainty. A
107+
// w-node has zero signal value and uncertainty.
108+
using value_t = ISlice::value_t;
109+
using signals_t = boost::multi_array<float, 2LU>;
110+
const signals_t& signals() const;
111+
private:
112+
mutable signals_t m_signals;
113+
114+
115+
public:
116+
// Slice node type array of shape (Nslices, 2) giving slice
117+
// duration with columns (start time, time span).
118+
using slice_durations_t = boost::multi_array<float, 2>;
119+
const slice_durations_t& slice_durations() const;
120+
private:
121+
mutable slice_durations_t m_slice_durations;
122+
123+
public:
124+
// Wire node type array giving wire endpoints. Shape is
125+
// (Nwire, 2, 3) where second dimension is first tail and
126+
// second head wire endpoint and last dimension is 3-vector in
127+
// global detector volume coordinates.
128+
using wire_endpoints_t = boost::multi_array<float, 3>;
129+
const wire_endpoints_t& wire_endpoints() const;
130+
private:
131+
mutable wire_endpoints_t m_wire_endpoints;
132+
133+
public:
134+
// Wire addresses is (Nwire, 4) with columns (WIP, segment, channelID, planeID).
135+
using wire_addresses_t = boost::multi_array<int, 2>;
136+
const wire_addresses_t& wire_addresses() const;
137+
private:
138+
mutable wire_addresses_t m_wire_addresses;
139+
140+
public:
141+
142+
// Blob node type array of shape (Nblobs, 3, 2). Each (3,2)
143+
// "row" gives the bounds of the blob in terms of the WIP
144+
// indices for a pair of wires in each of 3 wire planes.
145+
// Important note, this provides only partial bounds as blobs
146+
// are also bound in the horizontal and vertical direction by
147+
// the active area of the anode. These bounds are not
148+
// provided here. See AnodeArrays for ways access them.
149+
using blob_shapes_t = boost::multi_array<int, 3>;
150+
const blob_shapes_t& blob_shapes() const;
151+
private:
152+
mutable blob_shapes_t m_blob_shapes;
153+
154+
155+
private:
156+
// fill node_ranges, vdescs and vdesc_indices arrays
157+
void core_nodes() const;
158+
// filel wire node type arrays
159+
void core_wires() const;
160+
161+
const cluster_graph_t& m_graph;
162+
};
163+
164+
}
165+
166+
#endif

aux/inc/WireCellAux/ClusterHelpers.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@
1111
#include <string>
1212

1313
namespace WireCell::Aux {
14+
1415
/// Return JSON representation of the cluster.
15-
Json::Value jsonify(const ICluster::pointer& cluster,
16-
double drift_speed);
16+
Json::Value jsonify(const ICluster& cluster);
17+
18+
/// Return GraphViz dot representation of the cluster. The nodes
19+
/// is a list (string) of cluster node type codes to include. If
20+
/// empty, all node types will be included.
21+
std::string dotify(const ICluster& cluster, const std::string& nodes="bsm");
1722

1823
/// Return name for the cluster in a canonical form suitable for
1924
/// use as a file name. It only includes info related directly to
2025
/// the cluster (the ident).
21-
std::string name(const ICluster::pointer& cluster);
26+
std::string name(const ICluster& cluster);
2227

2328
/// Return the slices in the cluster.
24-
ISlice::vector find_slices(const ICluster::pointer& cluster);
29+
ISlice::vector find_slices(const ICluster& cluster);
2530

2631
/// Return the frame of the first slice in the cluster. Note, in
2732
/// principle, clusters can span frames.
28-
IFrame::pointer find_frame(const ICluster::pointer& cluster);
33+
IFrame::pointer find_frame(const ICluster& cluster);
2934

3035
}
3136

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/** SimpleBlob
22
*/
3-
#ifndef WIRECELL_SIMPLEBLOB
4-
#define WIRECELL_SIMPLEBLOB
3+
#ifndef WIRECELLAUX_SIMPLEBLOB
4+
#define WIRECELLAUX_SIMPLEBLOB
55

66
#include "WireCellIface/IBlob.h"
77
#include "WireCellIface/IBlobSet.h"
88
#include "WireCellIface/ISlice.h"
99
#include "WireCellIface/IAnodeFace.h"
1010
#include "WireCellUtil/RayGrid.h"
1111

12-
namespace WireCell {
12+
namespace WireCell::Aux {
1313

1414
class SimpleBlob : public IBlob {
1515
public:
@@ -66,6 +66,7 @@ namespace WireCell {
6666
IBlob::vector m_blobs;
6767
};
6868

69-
} // namespace WireCell
69+
} // namespace WireCell::Aux
70+
71+
#endif
7072

71-
#endif /* WIRECELL_SIMPLEBLOB */
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// This implements an IChannel data interface.
22

3-
#ifndef WIRECELL_IFACE_SIMPLECHANNEL
4-
#define WIRECELL_IFACE_SIMPLECHANNEL
3+
#ifndef WIRECELLAUX_SIMPLECHANNEL
4+
#define WIRECELLAUX_SIMPLECHANNEL
55

66
#include "WireCellIface/IChannel.h"
77

8-
namespace WireCell {
8+
namespace WireCell::Aux {
99

1010
class SimpleChannel : public IChannel {
1111
public:
@@ -26,6 +26,6 @@ namespace WireCell {
2626
IWire::vector m_wires;
2727
};
2828

29-
} // namespace WireCell
29+
} // namespace WireCell::Aux
3030

3131
#endif
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "WireCellIface/ICluster.h"
22
#include <boost/graph/copy.hpp>
3-
namespace WireCell {
3+
namespace WireCell::Aux {
44

55
class SimpleCluster : public ICluster {
66
public:
@@ -20,4 +20,4 @@ namespace WireCell {
2020
int m_ident;
2121
cluster_graph_t m_graph;
2222
};
23-
} // namespace WireCell
23+
} // namespace WireCell::Aux
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "WireCellIface/IDepo.h"
22

3-
namespace WireCell {
3+
namespace WireCell::Aux {
44

55
// A deposition that simply holds all the data it presents. If
66
// you have something that makes depositions immediately and needs
@@ -40,4 +40,5 @@ namespace WireCell {
4040
double m_long, m_tran;
4141
};
4242

43-
} // namespace WireCell
43+
} // namespace WireCell::Aux
44+
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "WireCellIface/IDepoSet.h"
22

3-
namespace WireCell {
3+
namespace WireCell::Aux {
44

55
class SimpleDepoSet : public IDepoSet {
66
int m_ident;
@@ -17,4 +17,5 @@ namespace WireCell {
1717
virtual IDepo::shared_vector depos() const { return m_depos; }
1818
};
1919

20-
} // namespace WireCell
20+
} // namespace WireCell::Aux
21+
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#ifndef WIRECELL_SIMPLEFRAME
2-
#define WIRECELL_SIMPLEFRAME
1+
#ifndef WIRECELLAUX_SIMPLEFRAME
2+
#define WIRECELLAUX_SIMPLEFRAME
33

44
#include "WireCellIface/IFrame.h"
55
#include "WireCellUtil/Units.h"
66

77
#include <map>
88

9-
namespace WireCell {
9+
namespace WireCell::Aux {
1010

1111
/** A simple frame.
1212
*
@@ -61,6 +61,6 @@ namespace WireCell {
6161
const SimpleTraceInfo& get_trace_info(const IFrame::tag_t& tag) const;
6262
};
6363

64-
} // namespace WireCell
64+
} // namespace WireCell::Aux
6565

6666
#endif

0 commit comments

Comments
 (0)