Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve filter based on feedback #27

Merged
merged 25 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c4950e
remove unnecessary import
brauliorivas May 31, 2024
f381347
make filters more compact
brauliorivas May 31, 2024
7085a38
populate simulation status options based on file
brauliorivas May 31, 2024
4f6fd31
apply sort of dependecy inversion, so elements are taken passed dynam…
brauliorivas Jun 1, 2024
9c643f2
apply same technique for filters
brauliorivas Jun 1, 2024
e67e6eb
[FIX] when filtering particles, these are maintained even if boxes ar…
brauliorivas Jun 2, 2024
489bf69
[FIX] update test based on new filtering logic (new id's for links)
brauliorivas Jun 2, 2024
67bfb6d
create filter for generator status
brauliorivas Jun 3, 2024
5c6833a
add units to range parameters
brauliorivas Jun 3, 2024
1eed533
update filters for ranges to require an object
brauliorivas Jun 3, 2024
83580b7
trigger filter when enter key is pressed
brauliorivas Jun 4, 2024
d3be20b
remove exclamation mark
brauliorivas Jun 4, 2024
1ee4ca8
display gen status and sim status in a smaller space
brauliorivas Jun 4, 2024
0b27623
display each range input in one line
brauliorivas Jun 4, 2024
49f2bf8
fix small bug (change from innerHTML to appendChild
brauliorivas Jun 5, 2024
6ee00c6
set final filter box width on startup
brauliorivas Jun 5, 2024
e6bc547
use full name for checkboxes
brauliorivas Jun 5, 2024
c2c767a
sort checkboxes by value
brauliorivas Jun 5, 2024
a3af9ba
display gen and sim status in column
brauliorivas Jun 5, 2024
2769764
check simStatus as in EDM4hep + display names instead of number
brauliorivas Jun 5, 2024
66222e3
pass dynamically data for bitfield elements and exchange class betwee…
brauliorivas Jun 5, 2024
73624a3
removed unused imports
brauliorivas Jun 5, 2024
82904c8
change names + display dictionary
brauliorivas Jun 6, 2024
ec594c5
bolder title + rearrange checkboxes
brauliorivas Jun 7, 2024
75428b1
rearrange only sim status
brauliorivas Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions js/menu/filter/builders.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Checkbox } from "./parameters.js";

export class CheckboxBuilder {
constructor(name, fullName) {
constructor(name, fullName, classType) {
this.uniqueValues = new Set();
this.checkBoxes = [];
this.name = name;
this.fullName = fullName;
this.classType = classType;
}

add(val) {
Expand All @@ -14,7 +13,7 @@ export class CheckboxBuilder {

setCheckBoxes() {
this.checkBoxes = Array.from(this.uniqueValues).map(
(option) => new Checkbox(this.name, option)
(option) => new this.classType(this.name, option)
);
this.checkBoxes.sort((a, b) => a.value - b.value);
}
Expand Down
20 changes: 17 additions & 3 deletions js/menu/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
visibleParticles,
} from "../../main.js";
import { CheckboxBuilder } from "./builders.js";
import { Range, Checkbox, buildCriteriaFunction } from "./parameters.js";
import {
Range,
Checkbox,
BitfieldCheckbox,
ValueCheckBox,
buildCriteriaFunction,
} from "./parameters.js";
import { reconnect } from "./reconnect.js";
import { getVisible } from "../../events.js";

Expand Down Expand Up @@ -103,8 +109,16 @@ parametersRange = parametersRange.sort((a, b) =>

parametersRange = parametersRange.map((parameter) => new Range(parameter));

const bits = new CheckboxBuilder("simStatus", "Simulator status");
const genStatus = new CheckboxBuilder("genStatus", "Generator status");
const bits = new CheckboxBuilder(
"simStatus",
"Simulator status",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simulator -> Simulation

ValueCheckBox
);
const genStatus = new CheckboxBuilder(
"genStatus",
"Generator status",
BitfieldCheckbox
);

function applyFilter(particlesHandler, currentParticles, visibleParticles) {
const rangeFunctions = Range.buildFilter(parametersRange);
Expand Down
43 changes: 42 additions & 1 deletion js/menu/filter/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export class Checkbox extends FilterParameter {
container.appendChild(div);

const label = document.createElement("label");
label.textContent = `${this.value}`;
const text = this.getDisplayValue();
label.textContent = text;
div.appendChild(label);

const input = document.createElement("input");
Expand All @@ -131,6 +132,10 @@ export class Checkbox extends FilterParameter {
});
}

getDisplayValue() {
return this.displayValue ?? this.value;
}

buildCondition() {
if (!this.checked) return null;

Expand All @@ -153,6 +158,42 @@ export class Checkbox extends FilterParameter {
}
}

export class ValueCheckBox extends Checkbox {
// Classic checkbox
constructor(property, value) {
super(property, value);
}
}

const bitFieldDisplayValues = {
23: "BitOverlay",
24: "BitStopped",
25: "BitLeftDetector",
26: "BitDecayedInCalorimeter",
27: "BitDecayedInTracker",
28: "BitVertexIsNotEndpointOfParent",
29: "BitBackscatter",
30: "BitCreatedInSimulation",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
23: "BitOverlay",
24: "BitStopped",
25: "BitLeftDetector",
26: "BitDecayedInCalorimeter",
27: "BitDecayedInTracker",
28: "BitVertexIsNotEndpointOfParent",
29: "BitBackscatter",
30: "BitCreatedInSimulation",
23: "Overlay",
24: "Stopped",
25: "LeftDetector",
26: "DecayedInCalorimeter",
27: "DecayedInTracker",
28: "VertexIsNotEndpointOfParent",
29: "Backscatter",
30: "CreatedInSimulation",

};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. The one "complaint" I have about this is that now the BitfieldCheckbox is now very tightly tied to these bitfield values and names. However, these are only correct for the MCParticle.simulationStatus. Hence, I think it would be nice to make the BitfieldCheckbox slightly more generic, such that this map can be passed on construction. Then when we construct the specific filter box for the simulationStatus in the MCParticle page, we can pass in this list and get the dedicated filter box for that. For other bit field checkboxes we would then just need to pass another map and would not have to re-implement this again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right! I'm changing this now.


export class BitfieldCheckbox extends Checkbox {
// Bit manipulation EDM4hep
constructor(property, value) {
super(property, value);
}

buildCondition() {
if (!this.checked) return null;

return (particle) =>
(parseInt(particle[this.property]) & (1 << parseInt(this.value))) !== 0;
}

getDisplayValue() {
return bitFieldDisplayValues[this.value] ?? this.value;
}
}

export function buildCriteriaFunction(...functions) {
const filterFunctions = functions.filter((fn) => typeof fn === "function");

Expand Down
Loading