Skip to content

Commit

Permalink
missing validation when bit was not mapped in dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Aug 28, 2024
1 parent 32d50c7 commit 79436fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/filters/collections/mcparticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function renderMCParticleFilters(viewObjects) {
simStatusContainer.appendChild(simStatusTitle);
const simStatusCheckboxesContainer = createCheckboxContainer();

Object.entries(SimStatusBitFieldDisplayValues).forEach(([status, value]) => {
Object.entries(SimStatusBitFieldDisplayValues).forEach(([value, status]) => {
const checkbox = new CheckboxComponent("simulatorStatus", status, value);
checkboxes.simStatus.push(checkbox);
simStatusCheckboxesContainer.appendChild(checkbox.render());
Expand Down
29 changes: 16 additions & 13 deletions mappings/sim-status.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const SimStatusBitFieldDisplayValues = {
"Overlay": 23,
"Stopped": 24,
"LeftDetector": 25,
"DecayedInCalorimeter": 26,
"DecayedInTracker": 27,
"VertexIsNotEndpointOfParent": 28,
"Backscatter": 29,
"CreatedInSimulation": 30,
23: "Overlay",
24: "Stopped",
25: "LeftDetector",
26: "DecayedInCalorimeter",
27: "DecayedInTracker",
28: "VertexIsNotEndpointOfParent",
29: "Backscatter",
30: "CreatedInSimulation",
};

export function parseBits(bit) {
Expand All @@ -22,13 +22,16 @@ export function parseBits(bit) {
}

export function getSimStatusDisplayValues(bits) {
const values = Object.entries(SimStatusBitFieldDisplayValues);
const statuses = [];

return bits.map((bit) => {
const [value, _] = values.find(([_, v]) => v === bit);

return value;
bits.forEach((bit) => {
const value = SimStatusBitFieldDisplayValues[bit];
if (value !== undefined) {
statuses.push(value);
}
});

return statuses;
}

export function getSimStatusDisplayValuesFromBit(bit) {
Expand Down

0 comments on commit 79436fc

Please sign in to comment.