40 std::normal_distribution<double> spread(0.0,
gaussian);
41 for (
int idepo=0;idepo<
ndepos;++idepo) {
43 for (
int iele=0; iele<
neles; ++iele) {
44 const Point delta(x, spread(generator), spread(generator));
45 const Point pt = cp + delta;
48 warn(
"Rejecting far away point: {} + {}" , cp, delta);
51 points.push_back(cp+delta);
64 std::vector<measure_t> measures(nlayers);
66 const auto& centers = coords.
centers();
69 for (
size_t ipt=0; ipt<points.size(); ++ipt ) {
70 const auto&
p = points[ipt];
71 for (
int ilayer = 0; ilayer<nlayers; ++ilayer) {
72 const auto& pit = pitches[ilayer];
73 const auto& cen = centers[ilayer];
74 const auto rel =
p-cen;
75 const int pit_ind = pit.dot(rel)/pitch_mags[ilayer];
77 warn(
"Negative pitch indices not allowed, got {} from ilayer {} ipt {} for point {}",
78 pit_ind, ilayer, ipt,
p);
82 if (pit_ind >= 1 or pit_ind < 0) {
83 debug(
"mm: pit_ind={} with ipt={}", pit_ind, ipt);
85 debug(
"\tpit={} cen={} rel={}", pit, cen, rel);
91 if ((
int)m.size() <= pit_ind) {
92 debug(
"resize for ipt {} ilayer {} from {} to {}", ipt, ilayer, m.size(), pit_ind+1);
93 m.resize(pit_ind+1, 0.0);
97 debug(
"adding to pit_ind {} ilayer {} ipt {}", pit_ind, ilayer, ipt);
99 debug(
"valud: {}", m[pit_ind]);
109 int nlayers = coords.
nlayers();
111 for (
int ilayer = 0; ilayer<nlayers; ++ilayer) {
112 auto&
m = measures[ilayer];
113 info(
"Make activity for layer: {}: {}", ilayer,
m.size());
126 typedef typename std::unordered_set<std::size_t>
indices_t;
135 , sel1(new indices_t)
136 , sel2(new indices_t)
144 const auto& astrips = a->strips();
145 const int nlayers = astrips.size();
148 for (
const auto&
c : b->corners()) {
152 const auto& astrip = astrips[layer];
153 if (layer ==
c.first.layer) {
154 info(
"L{} A: {} {}", layer, astrip,
c);
155 if (astrip.on(
c.first.grid)) {
156 info(
"\ton with found={} nlayers={}", found, nlayers);
160 info(
"\toff with found={} nlayers={}", found, nlayers);
163 if (layer ==
c.second.layer) {
164 info(
"L{} A: {} {}", layer, astrip,
c);
165 if (astrip.on(
c.second.grid)) {
166 info(
"\ton with found={} nlayers={}", found, nlayers);
170 info(
"\toff with found={} nlayers={}",found, nlayers);
176 info(
"L{} A: {} pind={} ploc={} {}", layer, astrip, pind, ploc,
c);
178 if (astrip.in(pind)) {
179 info(
"\tin with found={} nlayers={}", found, nlayers);
183 info(
"\tout with found={} nlayers={}", found, nlayers);
187 if (found == nlayers) {
197 const std::size_t d1 = a-one.begin();
198 const std::size_t d2 = b-two.begin();
200 info(
"overlap: a{} and b{}", d1, d2);
201 info(
"\tblob a #{}: {}", d1, a->as_string());
202 info(
"\tblob b #{}: {}", d2, b->as_string());
204 if (!this->in(a,b)) {
205 warn(
"NO CONTAINED CORNERS");
215 for (
const auto ind : *sel1) {
216 const auto& br = one[ind];
217 dumper(br, 10.0, 1.0, 1, ind);
221 for (
const auto ind : *sel2) {
222 const auto& br = two[ind];
223 dumper(br, 20.0, 1.0, 2, ind);
234 for (
const auto& blob : blobs) {
235 const auto& strips = blob.strips();
253 std::vector<Point> pts1 =
make_points(generator, 10.0);
254 std::vector<Point> pts2 =
make_points(generator, 20.0);
275 for (
const auto& pt : pts1) { dumper(pt); }
276 for (
const auto& pt : pts2) { dumper(pt); }
277 Chirp chirp(blobs1, blobs2, coords, dumper);
void dump(JsonEvent &dumper)
std::vector< Activity::value_t > measure_t
void dump(const std::string &filename)
void info(const char *fmt, const Args &...args)
D3Vector< double > Point
A 3D Cartesian point in double precision.
double pitch_location(const coordinate_t &one, const coordinate_t &two, layer_index_t other) const
static std::vector< Point > make_points(std::default_random_engine &generator, double x)
std::unordered_set< std::size_t > indices_t
const double pitch_magnitude
const vector_array1d_t & pitch_dirs() const
std::function< void(blobref_t &a, blobref_t &b)> associator_t
def activity(output, slices, slice_line, cluster_tap_file)
int pitch_index(double pitch, layer_index_t layer) const
static std::vector< measure_t > make_measures(Coordinates &coords, const std::vector< Point > &points)
blobs_t::const_iterator blobref_t
const vector_array1d_t & centers() const
const std::vector< double > & pitch_mags() const
Chirp(const blobs_t &one, const blobs_t &two, Coordinates &coords, JsonEvent &dumper)
static int max(int a, int b)
void warn(const char *fmt, const Args &...args)
BoundingBox bounds(int x, int y, int w, int h)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
static activities_t make_activities(Coordinates &coords, std::vector< measure_t > &measures)
std::vector< Blob > blobs_t
static void test_blobs(const blobs_t &blobs)
int main(int argc, char *argv[])
bool in(const blobref_t &a, const blobref_t &b)
void debug(const char *fmt, const Args &...args)
blobs_t make_blobs(const Coordinates &coords, const activities_t &activities)
bool associate(const std::string &classname, WireCell::INamedFactory *factory)
Associate a factory with the type it makes.
std::vector< Activity > activities_t
ray_pair_vector_t make_raypairs(double width=100, double height=100, double pitch_mag=3, double angle=60.0 *M_PI/180.0)
bool surrounding(const blobref_t &a, const blobref_t &b)
void operator()(const blobref_t &a, const blobref_t &b)