Skip to content

Commit 6fb6cef

Browse files
committed
add noise filtering only jsonnet configuration
1 parent cfc2cae commit 6fb6cef

2 files changed

Lines changed: 214 additions & 0 deletions

File tree

sbndcode/WireCell/cfg/pgrapher/experiment/sbnd/funcs.jsonnet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ local g = import 'pgraph.jsonnet';
5050
trace: {
5151
//gauss: 'gauss%d' % n,
5252
//wiener: 'wiener%d' % n,
53+
['raw%d' % n]: ['raw%d' % n],
5354
['gauss%d' % n]: ['gauss%d' % n],
5455
['wiener%d' % n]: ['wiener%d' % n],
5556
['threshold%d' % n]: ['threshold%d' % n],
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
// This is a main entry point to configure a WC/LS job that applies
2+
// noise filtering and signal processing to existing RawDigits. The
3+
// FHiCL is expected to provide the following parameters as attributes
4+
// in the "params" structure.
5+
//
6+
// epoch: the hardware noise fix expoch: "before", "after", "dynamic" or "perfect"
7+
// reality: whether we are running on "data" or "sim"ulation.
8+
// raw_input_label: the art::Event inputTag for the input RawDigit
9+
//
10+
// see the .fcl of the same name for an example
11+
//
12+
// Manual testing, eg:
13+
//
14+
// jsonnet -V reality=data -V epoch=dynamic -V raw_input_label=daq \\
15+
// -V signal_output_form=sparse \\
16+
// -J cfg cfg/pgrapher/experiment/uboone/wcls-nf-sp.jsonnet
17+
//
18+
// jsonnet -V reality=sim -V epoch=perfect -V raw_input_label=daq \\
19+
// -V signal_output_form=sparse \\
20+
// -J cfg cfg/pgrapher/experiment/uboone/wcls-nf-sp.jsonnet
21+
22+
23+
//local epoch = std.extVar('epoch'); // eg "dynamic", "after", "before", "perfect"
24+
local sigoutform = std.extVar('signal_output_form'); // eg "sparse" or "dense"
25+
local raw_input_label = std.extVar('raw_input_label'); // eg "daq"
26+
local use_paramresp = std.extVar('use_paramresp'); // eg "true" or "false"
27+
28+
local g = import 'pgraph.jsonnet';
29+
local f = import 'pgrapher/experiment/sbnd/funcs.jsonnet';
30+
local wc = import 'wirecell.jsonnet';
31+
local tools_maker = import 'pgrapher/common/tools.jsonnet';
32+
33+
local data_params = import 'params.jsonnet';
34+
35+
local params = data_params {
36+
daq: super.daq { // <- super.daq overrides default values
37+
// Set the waveform sample length, eg, 6000, 15000, "auto"
38+
nticks: std.extVar('nticks'),
39+
},
40+
# provides filename for parametrized per channel electronics response correction
41+
# default is: use_parmresp = false
42+
files: super.files {
43+
chresp: if (use_paramresp == 'true') then "sbnd-params-chresp-ideal-v1.json.bz2" else null,
44+
},
45+
};
46+
47+
48+
local tools = tools_maker(params);
49+
50+
51+
local mega_anode = {
52+
type: 'MegaAnodePlane',
53+
name: 'meganodes',
54+
data: {
55+
anodes_tn: [wc.tn(anode) for anode in tools.anodes],
56+
},
57+
};
58+
59+
local wcls_maker = import 'pgrapher/ui/wcls/nodes.jsonnet';
60+
local wcls = wcls_maker(params, tools);
61+
62+
// Collect the WC/LS input converters for use below. Make sure the
63+
// "name" argument matches what is used in the FHiCL that loads this
64+
// file. In particular if there is no ":" in the inputer then name
65+
// must be the emtpy string.
66+
local wcls_input = {
67+
adc_digits: g.pnode({
68+
type: 'wclsRawFrameSource',
69+
name: '',
70+
data: {
71+
art_tag: raw_input_label,
72+
frame_tags: ['orig'], // this is a WCT designator
73+
// nticks: params.daq.nticks,
74+
},
75+
}, nin=0, nout=1),
76+
77+
};
78+
79+
80+
// Collect all the wc/ls output converters for use below. Note the
81+
// "name" MUST match what is used in theh "outputers" parameter in the
82+
// FHiCL that loads this file.
83+
84+
local wcls_output = {
85+
// The noise filtered "ADC" values. These are truncated for
86+
// art::Event but left as floats for the WCT SP. Note, the tag
87+
// "raw" is somewhat historical as the output is not equivalent to
88+
// "raw data".
89+
nf_digits: g.pnode({
90+
type: 'wclsFrameSaver',
91+
name: 'nfsaver',
92+
data: {
93+
// anode: wc.tn(tools.anode),
94+
anode: wc.tn(mega_anode),
95+
digitize: true, // true means save as RawDigit, else recob::Wire
96+
frame_tags: ['raw'],
97+
nticks: params.daq.nticks,
98+
chanmaskmaps: ['bad'],
99+
},
100+
}, nin=1, nout=1, uses=[mega_anode]),
101+
102+
103+
// The output of signal processing. Note, there are two signal
104+
// sets each created with its own filter. The "gauss" one is best
105+
// for charge reconstruction, the "wiener" is best for S/N
106+
// separation. Both are used in downstream WC code.
107+
sp_signals: g.pnode({
108+
type: 'wclsFrameSaver',
109+
name: 'spsaver',
110+
data: {
111+
anode: wc.tn(mega_anode),
112+
digitize: false, // true means save as RawDigit, else recob::Wire
113+
frame_tags: ['gauss', 'wiener'],
114+
115+
// this may be needed to convert the decon charge [units:e-] to be consistent with the LArSoft default ?unit? e.g. decon charge * 0.005 --> "charge value" to GaussHitFinder
116+
frame_scale: [0.02, 0.02],
117+
nticks: params.daq.nticks,
118+
119+
120+
// uncomment the below configs to save summaries and cmm
121+
summary_tags: ['wiener'],
122+
summary_operator: {wiener: 'set'},
123+
summary_scale: [0.02], # summary scale should be the same as frame_scale
124+
chanmaskmaps: ['bad'],
125+
},
126+
}, nin=1, nout=1, uses=[mega_anode]),
127+
};
128+
129+
local base = import 'pgrapher/experiment/sbnd/chndb-base.jsonnet';
130+
131+
local chndb = [{
132+
type: 'OmniChannelNoiseDB',
133+
name: 'ocndbperfect%d' % n,
134+
data: base(params, tools.anodes[n], tools.field, n){dft:wc.tn(tools.dft)},
135+
uses: [tools.anodes[n], tools.field, tools.dft],
136+
} for n in std.range(0, std.length(tools.anodes) - 1)];
137+
138+
local chsel_pipes = [
139+
g.pnode({
140+
type: 'ChannelSelector',
141+
name: 'chsel%d' % n,
142+
data: {
143+
channels: std.range(5638 * n, 5638 * (n + 1) - 1),
144+
//tags: ['orig%d' % n], // traces tag
145+
},
146+
}, nin=1, nout=1)
147+
for n in std.range(0, std.length(tools.anodes) - 1)
148+
];
149+
150+
local nf_maker = import 'pgrapher/experiment/sbnd/nf-data.jsonnet'; //added Ewerton 2024-08
151+
local nf_pipes = [nf_maker(params, tools.anodes[n], chndb[n], n, name='nf%d' % n) for n in std.range(0, std.length(tools.anodes) - 1)];
152+
153+
local sp_maker = import 'pgrapher/experiment/sbnd/sp.jsonnet';
154+
local sp = sp_maker(params, tools, { sparse: sigoutform == 'sparse' });
155+
local sp_pipes = [sp.make_sigproc(a) for a in tools.anodes];
156+
157+
local magoutput = 'sbnd-data-check.root';
158+
local magnify = import 'pgrapher/experiment/sbnd/magnify-sinks.jsonnet';
159+
local sinks = magnify(tools, magoutput);
160+
161+
local nfsp_pipes = [
162+
g.pipeline([
163+
chsel_pipes[n],
164+
// sinks.orig_pipe[n],
165+
166+
nf_pipes[n],
167+
// sinks.raw_pipe[n],
168+
169+
// sp_pipes[n],
170+
// sinks.decon_pipe[n],
171+
// sinks.threshold_pipe[n],
172+
// sinks.debug_pipe[n], // use_roi_debug_mode=true in sp.jsonnet
173+
],
174+
'nfsp_pipe_%d' % n)
175+
for n in std.range(0, std.length(tools.anodes) - 1)
176+
];
177+
178+
local fanpipe = f.fanpipe('FrameFanout', nfsp_pipes, 'FrameFanin', 'sn_mag_nf');
179+
180+
local retagger = g.pnode({
181+
type: 'Retagger',
182+
data: {
183+
// Note: retagger keeps tag_rules an array to be like frame fanin/fanout.
184+
tag_rules: [{
185+
// Retagger also handles "frame" and "trace" like fanin/fanout
186+
// merge separately all traces like gaussN to gauss.
187+
frame: {
188+
'.*': 'retagger',
189+
},
190+
merge: {
191+
'raw\\d': 'raw',
192+
// 'gauss\\d': 'gauss',
193+
// 'wiener\\d': 'wiener',
194+
},
195+
}],
196+
},
197+
}, nin=1, nout=1);
198+
199+
local sink = g.pnode({ type: 'DumpFrames' }, nin=1, nout=0);
200+
201+
202+
// local graph = g.pipeline([wcls_input.adc_digits, rootfile_creation_frames, fanpipe, retagger, wcls_output.sp_signals, sink]);
203+
local graph = g.pipeline([wcls_input.adc_digits, fanpipe, retagger, wcls_output.nf_digits, sink]);
204+
205+
local app = {
206+
type: 'TbbFlow',
207+
data: {
208+
edges: g.edges(graph),
209+
},
210+
};
211+
212+
// Finally, the configuration sequence
213+
g.uses(graph) + [app]

0 commit comments

Comments
 (0)