Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/firebird-ng/src/app/model/box-tracker-hit.component.ts is written in an unsupported language. File is not indexed.

0001 // box-tracker-hit.component.ts
0002 
0003 import { EntryComponent, EntryComponentFactory, registerComponentFactory } from './entry-component';
0004 
0005 /**
0006  * Represents an individual tracker hit with position, dimensions, time, and energy deposit.
0007  */
0008 export class BoxTrackerHit {
0009 
0010   /** The position of the hit [mm] as [x, y, z]. */
0011   position: [number, number, number];
0012 
0013   /** The dimensions of the hit box [mm] as [dx, dy, dz]. */
0014   dimensions: [number, number, number];
0015 
0016   /** The time information [ns] as [time, err_time]. */
0017   time: [number, number];
0018 
0019   /** The energy deposit with error [GeV] as [edep, err_edep]. */
0020   energyDeposit: [number, number];
0021 
0022   /**
0023    * Constructs a new BoxTrackerHit instance.
0024    *
0025    * @param position - The position of the hit as [x, y, z].
0026    * @param dimensions - The dimensions of the hit box as [dx, dy, dz].
0027    * @param time - The time information as [time, err_time].
0028    * @param energyDeposit - The energy deposit with error as [edep, err_edep].
0029    */
0030   constructor(
0031     position: [number, number, number],
0032     dimensions: [number, number, number],
0033     time: [number, number],
0034     energyDeposit: [number, number]
0035   ) {
0036     this.position = position;
0037     this.dimensions = dimensions;
0038     this.time = time;
0039     this.energyDeposit = energyDeposit;
0040   }
0041 
0042   /**
0043    * Serializes the BoxTrackerHit instance into a JSON-compatible object.
0044    *
0045    * @returns A JSON-compatible object representing the serialized BoxTrackerHit.
0046    */
0047   toDexObject(): any {
0048     return {
0049       pos: this.position,
0050       dim: this.dimensions,
0051       t: this.time,
0052       ed: this.energyDeposit,
0053     };
0054   }
0055 
0056   /**
0057    * Creates a BoxTrackerHit instance from a deserialized object.
0058    *
0059    * @param obj - The deserialized object representing a BoxTrackerHit.
0060    * @returns A new instance of BoxTrackerHit populated with data from the object.
0061    */
0062   static fromDexObject(obj: any): BoxTrackerHit {
0063     return new BoxTrackerHit(
0064       obj["pos"],
0065       obj["dim"],
0066       obj["t"],
0067       obj["ed"]
0068     );
0069   }
0070 }
0071 
0072 /**
0073  * Represents a component that contains multiple BoxTrackerHits.
0074  */
0075 export class BoxTrackerHitComponent extends EntryComponent {
0076   /** The static type identifier for the BoxTrackerHitComponent. */
0077   static type = 'BoxTrackerHit';
0078 
0079   /** An array of BoxTrackerHits contained in this component. */
0080   hits: BoxTrackerHit[] = [];
0081 
0082   /**
0083    * Constructs a new BoxTrackerHitComponent instance.
0084    *
0085    * @param name - The name of the component.
0086    * @param originType - Optional origin type of the component.
0087    */
0088   constructor(name: string, originType?: string) {
0089     super(name, BoxTrackerHitComponent.type, originType);
0090   }
0091 
0092   /**
0093    * Serializes the BoxTrackerHitComponent instance into a JSON-compatible object.
0094    *
0095    * @returns A JSON-compatible object representing the serialized BoxTrackerHitComponent.
0096    */
0097   toDexObject(): any {
0098     const objHits = [];
0099     for (const hit of this.hits) {
0100       objHits.push(hit.toDexObject());
0101     }
0102 
0103     return {
0104       name: this.name,
0105       type: this.type,
0106       originType: this.originType,
0107       hits: objHits,
0108     };
0109   }
0110 }
0111 
0112 /**
0113  * Factory for creating instances of BoxTrackerHitComponent from deserialized data.
0114  */
0115 export class BoxTrackerHitComponentFactory implements EntryComponentFactory {
0116   /** The type of the component that this factory creates. */
0117   type: string = BoxTrackerHitComponent.type;
0118 
0119   /**
0120    * Creates an instance of BoxTrackerHitComponent from a deserialized object.
0121    *
0122    * @param obj - The deserialized object representing a BoxTrackerHitComponent.
0123    * @returns An instance of BoxTrackerHitComponent.
0124    */
0125   fromDexObject(obj: any): EntryComponent {
0126     const result = new BoxTrackerHitComponent(obj["name"]);
0127 
0128     if (obj["originType"]) {
0129       result.originType = obj["originType"];
0130     }
0131 
0132     for (const objHit of obj["hits"]) {
0133       result.hits.push(BoxTrackerHit.fromDexObject(objHit));
0134     }
0135 
0136     return result;
0137   }
0138 }
0139 
0140 // Register the component factory
0141 registerComponentFactory(new BoxTrackerHitComponentFactory());