Skip to content

Commit

Permalink
Merge pull request #83 from brauliorivas/fix/issue-#82
Browse files Browse the repository at this point in the history
Missing validation when bit was not mapped in dictionary
  • Loading branch information
kjvbrt authored Sep 2, 2024
2 parents 32d50c7 + 79436fc commit 3d1af63
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 3d1af63

Please sign in to comment.