Skip to content

Commit

Permalink
Deploy preview for PR 25 🛫
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Jun 6, 2024
1 parent 212994f commit afdb091
Show file tree
Hide file tree
Showing 10 changed files with 325 additions and 122 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions pr-preview/pr-25/js/types/dynamic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function dynamicLoad(object, data, ignore = null) {
let filteredData = {};

if (ignore !== null) {
for (const key in data) {
if (!ignore.has(key)) filteredData[key] = data[key];
}
} else {
filteredData = data;
}

for (const [key, value] of Object.entries(filteredData)) {
object[key] = value;
}
}
32 changes: 1 addition & 31 deletions pr-preview/pr-25/js/types/load.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import jsonData from "../../input/wzp6_ee_mumuH_ecm240_CLD_RECO.edm4hep.json" assert { type: "json" }; // node 20
import {
Cluster,
ParticleID,
ReconstructedParticle,
Vertex,
Track,
} from "./reconstruction.js";
import { types } from "./reconstruction.js";
import { compatible } from "./version.js";

const types = {
"Cluster": Cluster,
"ParticleID": ParticleID,
"ReconstructedParticle": ReconstructedParticle,
"Vertex": Vertex,
"Track": Track,
};

const loadersConfig = [
"ReconstructedParticle",
"ParticleID",
Expand Down Expand Up @@ -68,20 +54,4 @@ export function loadParticles(jsonData, event, loadersConfig) {
return particles;
}

export function dynamicLoad(object, data, ignore = null) {
let filteredData = {};

if (ignore !== null) {
for (const key in data) {
if (!ignore.has(key)) filteredData[key] = data[key];
}
} else {
filteredData = data;
}

for (const [key, value] of Object.entries(filteredData)) {
object[key] = value;
}
}

loadParticles(jsonData, 0, loadersConfig);
30 changes: 24 additions & 6 deletions pr-preview/pr-25/js/types/reconstruction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dynamicLoad } from "./load.js";
import { dynamicLoad } from "./dynamic.js";

export class Cluster {
static MIN_VERSION = "0.7.0"; // may vary per type of particle
Expand Down Expand Up @@ -46,7 +46,7 @@ export class ParticleID {
constructor() {
// Physics properties
this.type = 0;
this.pdg = 0;
this.PDG = 0;
this.algorithmType = 0;
this.likelihood = 0;
this.parameters = [];
Expand Down Expand Up @@ -78,7 +78,7 @@ export class ReconstructedParticle {

constructor() {
// Physics properties
this.pdg = 0;
this.PDG = 0;
this.energy = 0; // GeV
this.momentum = {}; // GeV
this.referencePoint = {}; // mm
Expand Down Expand Up @@ -213,7 +213,7 @@ export class GenericLink {
}
}

function createLinksManager(types) {
export function createLinksManager(types) {
const links = {};
types.forEach((type) => (links[type] = []));
return links;
Expand All @@ -225,7 +225,12 @@ export function createGenericLink(id, from, { collectionID, index }) {
return genericLink;
}

function extractOneToManyLinks(linksManager, keys, newParticle, particleData) {
export function extractOneToManyLinks(
linksManager,
keys,
newParticle,
particleData
) {
for (const key of keys) {
particleData[key].map((val) => {
const link = createGenericLink(
Expand All @@ -239,7 +244,12 @@ function extractOneToManyLinks(linksManager, keys, newParticle, particleData) {
}
}

function extractOneToOneLink(linksManager, key, newParticle, particleData) {
export function extractOneToOneLink(
linksManager,
key,
newParticle,
particleData
) {
const link = createGenericLink(
linksManager[key].length,
newParticle.index,
Expand All @@ -248,3 +258,11 @@ function extractOneToOneLink(linksManager, key, newParticle, particleData) {
linksManager[key].push(link);
newParticle[key] = link.id;
}

export const types = {
"Cluster": Cluster,
"ParticleID": ParticleID,
"ReconstructedParticle": ReconstructedParticle,
"Vertex": Vertex,
"Track": Track,
};
8 changes: 4 additions & 4 deletions pr-preview/pr-25/js/types/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ export class Version {

greaterOrEqualThan(version) {
return (
this.major >= version.major ||
this.major > version.major ||
(this.major === version.major &&
(this.minor >= version.minor ||
(this.minor > version.minor ||
(this.minor === version.minor && this.patch >= version.patch)))
);
}

lessOrEqualThan(version) {
return (
this.major <= version.major ||
this.major < version.major ||
(this.major === version.major &&
(this.minor <= version.minor ||
(this.minor < version.minor ||
(this.minor === version.minor && this.patch <= version.patch)))
);
}
Expand Down
Loading

0 comments on commit afdb091

Please sign in to comment.