Skip to content

Commit

Permalink
Merge pull request #255 from HaiwangYu/clustering
Browse files Browse the repository at this point in the history
Shared noise model
  • Loading branch information
brettviren committed Nov 9, 2023
2 parents 34cf9ed + 7d313aa commit 4546353
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cfg/pgrapher/experiment/dune-vd/sim.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,31 @@ function(params, tools) {
},
uses: [anode, tools.dft] + if std.type(csdb) == "null" then [] else [csdb],
},
local noise_models = [make_noise_model(anode) for anode in tools.anodes],

local mega_anode = {
type: 'MegaAnodePlane',
name: 'meganodes',
data: {
anodes_tn: [wc.tn(anode) for anode in tools.anodes],
},
},

local add_noise = function(model) g.pnode({
local add_noise = function(model, name="") g.pnode({
type: "AddNoise",
name: "addnoise%s"%[model.name],
name: "addnoise%s"%[name],
data: {
rng: wc.tn(tools.random),
dft: wc.tn(tools.dft),
model: wc.tn(model),
nsamples: params.daq.nticks,
nsamples: params.daq.nticks,
replacement_percentage: 0.02, // random optimization
}}, nin=1, nout=1, uses=[tools.random, tools.dft, model]),

local noises = [add_noise(model) for model in noise_models],
// TODO: make this an option?
local use_shared_model = true,
local noises = if use_shared_model == true
then [add_noise(make_noise_model(mega_anode), anode.name) for anode in tools.anodes]
else [add_noise(make_noise_model(anode), anode.name) for anode in tools.anodes],

local digitizers = [
sim.digitizer(anode, name="digitizer%d"%anode.data.ident, tag="orig%d"%anode.data.ident)
Expand Down
2 changes: 2 additions & 0 deletions gen/inc/WireCellGen/EmpiricalNoiseModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <unordered_map>
#include <mutex>

namespace WireCell {
namespace Gen {
Expand Down Expand Up @@ -90,6 +91,7 @@ namespace WireCell {
int get_nsamples() { return m_nsamples; };

private:
mutable std::mutex m_mutex_cache;
IAnodePlane::pointer m_anode;
IChannelStatus::pointer m_chanstat;
IDFT::pointer m_dft;
Expand Down
1 change: 1 addition & 0 deletions gen/src/EmpiricalNoiseModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ Gen::EmpiricalNoiseModel::channel_spectrum(int chid) const
}
}

std::lock_guard<std::mutex> lock(m_mutex_cache);
// get truncated wire length for cache
int ilen = 0;
auto chlen = m_chid_to_intlen.find(chid);
Expand Down

0 comments on commit 4546353

Please sign in to comment.