Warning, /firebird/firebird-ng/src/app/model/point-trajectory.event-component.ts is written in an unsupported language. File is not indexed.
0001 /**
0002 * A data-model component for "TrackerLinePointTrajectory" typed data.
0003 *
0004 * This represents data in the Firebird Dex format:
0005 *
0006 * {
0007 * "name": "CentralTrackSegments",
0008 * "type": "TrackerLinePointTrajectory",
0009 * "originType": [...],
0010 * "paramColumns": [...],
0011 * "pointColumns": [...],
0012 * "lines": [
0013 * {
0014 * "points": [ [x, y, z, t, dx, dy, dz, dt], ... ],
0015 * "params": [ ... ]
0016 * },
0017 * ...
0018 * ]
0019 * }
0020 *
0021 * For example, each "line" may correspond to one track segment,
0022 * and "points" is an array of arrays containing position/time/uncertainties.
0023 */
0024
0025 import {
0026 EntryComponent,
0027 EntryComponentFactory,
0028 registerComponentFactory
0029 } from "./entry-component";
0030
0031 /**
0032 * Representation of a single line in the trajectory.
0033 */
0034 export interface TrackerLineSegment {
0035 /**
0036 * Array of points, each point is a numeric array matching the "pointColumns"
0037 * e.g. [ x, y, z, t, dx, dy, dz, dt ] or however many columns.
0038 */
0039 points: number[][];
0040 /**
0041 * Array of track parameters matching "paramColumns"
0042 * e.g. [theta, phi, qOverP, pdg, etc...]
0043 */
0044 params: number[];
0045 }
0046
0047 /**
0048 * The main component class that holds multiple lines (track segments)
0049 * along with the definitions of paramColumns and pointColumns.
0050 */
0051 export class PointTrajectoryComponent extends EntryComponent {
0052 static type = "TrackerLinePointTrajectory";
0053
0054 /**
0055 * The param columns define the meaning of the `params` array in each line.
0056 * Example: ["theta","phi","qOverP","charge","pdg"]
0057 */
0058 paramColumns: string[] = [];
0059
0060 /**
0061 * The point columns define the meaning of the each entry in `points`.
0062 * Example: ["x","y","z","t","dx","dy","dz","dt"]
0063 */
0064 pointColumns: string[] = [];
0065
0066 /**
0067 * The lines array, each containing a set of points and the param array.
0068 */
0069 lines: TrackerLineSegment[] = [];
0070
0071 constructor(name: string, originType?: string) {
0072 super(name, PointTrajectoryComponent.type, originType);
0073 }
0074
0075 /**
0076 * Convert this component to a Dex-format JS object
0077 */
0078 override toDexObject(): any {
0079 // Serialize lines
0080 const linesObj = this.lines.map((line) => {
0081 return {
0082 points: line.points,
0083 params: line.params
0084 };
0085 });
0086
0087 return {
0088 name: this.name,
0089 type: this.type,
0090 originType: this.originType,
0091 paramColumns: this.paramColumns,
0092 pointColumns: this.pointColumns,
0093 lines: linesObj
0094 };
0095 }
0096 }
0097
0098 /**
0099 * Factory class to deserialize from the Dex object to our component instance.
0100 */
0101 export class TrackerLinePointTrajectoryComponentFactory implements EntryComponentFactory {
0102 type = PointTrajectoryComponent.type;
0103
0104 fromDexObject(obj: any): PointTrajectoryComponent {
0105 const comp = new PointTrajectoryComponent(obj["name"], obj["originType"]);
0106
0107 // paramColumns
0108 if (Array.isArray(obj["paramColumns"])) {
0109 comp.paramColumns = [...obj["paramColumns"]];
0110 }
0111
0112 // pointColumns
0113 if (Array.isArray(obj["pointColumns"])) {
0114 comp.pointColumns = [...obj["pointColumns"]];
0115 }
0116
0117 // lines
0118 comp.lines = [];
0119 if (Array.isArray(obj["lines"])) {
0120 for (const lineObj of obj["lines"]) {
0121 comp.lines.push({
0122 points: Array.isArray(lineObj["points"]) ? lineObj["points"] : [],
0123 params: Array.isArray(lineObj["params"]) ? lineObj["params"] : []
0124 });
0125 }
0126 }
0127 return comp;
0128 }
0129 }
0130
0131 /** Register the factory so it gets picked up by the Entry deserialization. */
0132 registerComponentFactory(new TrackerLinePointTrajectoryComponentFactory());