Skip to content

Commit

Permalink
add protections for xregion configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqiang-gu committed Nov 6, 2024
1 parent c138b92 commit e532442
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cfg/pgrapher/common/sim/nodes.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function(params, tools)
{
// Create a drifter Pnode.
drifter: g.pnode({
local xregions = wc.unique_list(std.flattenArrays([v.faces for v in params.det.volumes])),
// local xregions = wc.unique_list(std.flattenArrays([v.faces for v in params.det.volumes])),
// Filter out any null values in xregions
local xregions = std.filter(function(x) x!= null, wc.unique_list(std.flattenArrays([v.faces for v in params.det.volumes]))),

type: "Drifter",
data: params.lar {
Expand Down
13 changes: 10 additions & 3 deletions gen/src/AnodePlane.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,16 @@ void Gen::AnodePlane::configure(const WireCell::Configuration& cfg)
sensitive_face = false;
log->debug("anode {} face {} is not sensitive", m_ident, iface);
}
const double response_x = jface["response"].asDouble();
const double anode_x = get(jface, "anode", response_x);
const double cathode_x = jface["cathode"].asDouble();
// const double response_x = jface["response"].asDouble();
// const double anode_x = get(jface, "anode", response_x);
// const double cathode_x = jface["cathode"].asDouble();
// FIXME: Due to a recent change in the xregion configuration (see
// https://github.com/WireCell/wire-cell-toolkit/pull/336), the
// fields (cathode, anode, response) may no longer be scalar values.
// In such cases, a backup scalar input is required.
const double response_x = jface["response"].isNumeric() ? jface["response"].asDouble() : jface["response_ref"].asDouble();
const double anode_x = jface["anode"].isNumeric() ? jface["anode"].asDouble() : jface["anode_ref"].asDouble();
const double cathode_x = jface["cathode"].isNumeric() ? jface["cathode"].asDouble() : jface["cathode_ref"].asDouble();
log->debug("X planes: \"cathode\"@ {}m, \"response\"@{}m, \"anode\"@{}m", cathode_x / units::m,
response_x / units::m, anode_x / units::m);

Expand Down
4 changes: 3 additions & 1 deletion gen/src/Drifter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ void Gen::Drifter::configure(const WireCell::Configuration& cfg)
THROW(ValueError() << errmsg{"no xregions given"});
}
for (auto jone : jxregions) {
m_xregions.emplace_back(Xregion(jone));
if (!jone.isNull()) {
m_xregions.emplace_back(Xregion(jone));
}
}
log->debug("time offset: {} ms, drift speed: {} mm/us", m_toffset / units::ms,
m_speed / (units::mm / units::us));
Expand Down

0 comments on commit e532442

Please sign in to comment.