Warning, /firebird/firebird-ng/src/app/pages/input-config/input-config.component.ts is written in an unsupported language. File is not indexed.
0001 import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
0002 import { FormControl } from '@angular/forms';
0003 import { LocalStorageService } from '../../services/local-storage.service';
0004 import { ReactiveFormsModule } from '@angular/forms';
0005 import { RouterLink } from '@angular/router';
0006 import { PersistentProperty } from '../../utils/persistent-property';
0007 import { MatCard, MatCardContent, MatCardTitle } from '@angular/material/card';
0008 import { MatSlideToggle } from '@angular/material/slide-toggle';
0009 import { MatFormField } from '@angular/material/form-field';
0010 import { NgIf } from '@angular/common';
0011 import { MatInput, MatLabel } from '@angular/material/input';
0012 import { ResourceSelectComponent } from '../../components/resource-select/resource-select.component';
0013 import { defaultFirebirdConfig, ServerConfig, ServerConfigService } from '../../services/server-config.service';
0014 import { MatAccordion, MatExpansionPanel, MatExpansionPanelTitle, MatExpansionPanelHeader } from '@angular/material/expansion';
0015 import {ShellComponent} from "../../components/shell/shell.component";
0016 import {MatButton} from "@angular/material/button";
0017 import {MatSelect} from "@angular/material/select";
0018 import {MatOption} from "@angular/material/autocomplete";
0019
0020 @Component({
0021 selector: 'app-input-config',
0022 standalone: true,
0023 imports: [
0024 ReactiveFormsModule,
0025 RouterLink,
0026 MatCard,
0027 MatCardContent,
0028 MatCardTitle,
0029 MatSlideToggle,
0030 MatFormField,
0031 MatInput,
0032 MatLabel,
0033 ResourceSelectComponent,
0034 MatAccordion,
0035 MatExpansionPanel,
0036 MatExpansionPanelTitle,
0037 MatExpansionPanelHeader,
0038 ShellComponent,
0039 MatButton,
0040 MatSelect,
0041 MatOption,
0042 NgIf,
0043 ],
0044 templateUrl: './input-config.component.html',
0045 styleUrls: ['./input-config.component.scss']
0046 })
0047 export class InputConfigComponent implements OnInit, AfterViewInit {
0048
0049 @ViewChild('geometrySelect')
0050 geometrySelect!: ResourceSelectComponent;
0051
0052 @ViewChild('edm4eicSelect')
0053 edm4eicSelect!: ResourceSelectComponent;
0054
0055 @ViewChild('dexJsonSelect')
0056 dexJsonSelect!: ResourceSelectComponent;
0057
0058 @ViewChild('premadeGeometry') premadeGeometry!: ResourceSelectComponent;
0059
0060 selectedEventSource = new FormControl('');
0061 onlyCentralDetector: FormControl<boolean | null> = new FormControl(true);
0062 serverUseApi: FormControl<boolean | null> = new FormControl(false);
0063 serverApiUrl = new FormControl('http://localhost:5454');
0064 rootEventRange: FormControl<string | null> = new FormControl('0');
0065
0066 // Add form controls and options
0067 geometryThemeName = new FormControl('cool2');
0068 geometryCutListName = new FormControl('off');
0069 geometryRootFilterName = new FormControl('default');
0070 geometryFastAndUgly: FormControl<boolean | null> = new FormControl(false);
0071 useController: FormControl<boolean | null> = new FormControl(false);
0072
0073
0074 firebirdConfig: ServerConfig = defaultFirebirdConfig;
0075
0076 public geometryOptions: string[] = [
0077 "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root",
0078 "https://eic.github.io/epic/artifacts/tgeo/epic_full.root",
0079 "https://eic.github.io/epic/artifacts/tgeo/epic_bhcal.root",
0080 "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_no_bhcal.root",
0081 "https://eic.github.io/epic/artifacts/tgeo/epic_calorimeters.root",
0082 "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_tracking_only.root",
0083 "https://eic.github.io/epic/artifacts/tgeo/epic_dirc_only.root",
0084 "https://eic.github.io/epic/artifacts/tgeo/epic_drich_only.root",
0085 "https://eic.github.io/epic/artifacts/tgeo/epic_forward_detectors.root",
0086 "https://eic.github.io/epic/artifacts/tgeo/epic_forward_detectors_with_inserts.root",
0087 "https://eic.github.io/epic/artifacts/tgeo/epic_imaging_only.root",
0088 "https://eic.github.io/epic/artifacts/tgeo/epic_inner_detector.root",
0089 "https://eic.github.io/epic/artifacts/tgeo/epic_ip6.root",
0090 "https://eic.github.io/epic/artifacts/tgeo/epic_ip6_extended.root",
0091 "https://eic.github.io/epic/artifacts/tgeo/epic_lfhcal_only.root",
0092 "https://eic.github.io/epic/artifacts/tgeo/epic_lfhcal_with_insert.root",
0093 "https://eic.github.io/epic/artifacts/tgeo/epic_mrich_only.root",
0094 "https://eic.github.io/epic/artifacts/tgeo/epic_pfrich_only.root",
0095 "https://eic.github.io/epic/artifacts/tgeo/epic_pid_only.root",
0096 "https://eic.github.io/epic/artifacts/tgeo/epic_tof_endcap_only.root",
0097 "https://eic.github.io/epic/artifacts/tgeo/epic_tof_only.root",
0098 "https://eic.github.io/epic/artifacts/tgeo/epic_vertex_only.root",
0099 "https://eic.github.io/epic/artifacts/tgeo/epic_zdc_lyso_sipm.root",
0100 "https://eic.github.io/epic/artifacts/tgeo/epic_zdc_sipm_on_tile_only.root"
0101 ];
0102
0103 public trajectoryOptions: string[] = [
0104
0105 "asset://data/dirc_optical.v0.4.firebird.zip",
0106 "asset://data/py8_dis-cc_5x41_minq2-1_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0107 "asset://data/py8_dis-cc_5x41_minq2-100_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0108 "asset://data/py8_dis-cc_10x100_minq2-1_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0109 "asset://data/py8_dis-cc_10x100_minq2-100_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0110 "asset://data/py8_dis-cc_10x100_minq2-1000_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0111 "asset://data/py8_dis-cc_18x275_minq2-1_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0112 "asset://data/py8_dis-cc_18x275_minq2-100_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0113 "asset://data/py8_dis-cc_18x275_minq2-1000_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0114 "asset://data/rec_dis_18x275_fdex-v0.4.edm4eic.v0.4.firebird.zip",
0115 ];
0116
0117
0118 public edm4eicOptions: string[] = [
0119 ""
0120 ];
0121
0122
0123 quickLinks: { [title: string]: { geometry: string; dexjson: string; edm4eic: string; eventRange?: string } } = {
0124 'Full ePIC detector geometry (no events)': {
0125 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root",
0126 dexjson: "",
0127 edm4eic: ""
0128 },
0129 'DIS CC in ePIC Beam=5x41 minQ2=1': {
0130 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root",
0131 dexjson: "asset://data/py8_dis-cc_5x41_minq2-1_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0132 edm4eic: ""
0133 },
0134 'DIS CC in ePIC Beam=10x100 minQ2=1': {
0135 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root",
0136 dexjson: "asset://data/py8_dis-cc_10x100_minq2-1_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0137 edm4eic: ""
0138 },
0139 'DIS CC in ePIC Beam=18x275 minQ2=1': {
0140 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root",
0141 dexjson: "asset://data/py8_dis-cc_18x275_minq2-1_minp-150mev_vtxcut-5m_nevt-5.v0.4.firebird.zip",
0142 edm4eic: ""
0143 },
0144 'Tracking reconstruction ePIC Beam=18x275': {
0145 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_tracking_only.root",
0146 dexjson: "asset://data/rec_dis_18x275_fdex-v0.4.edm4eic.v0.4.firebird.zip",
0147 edm4eic: ""
0148 },
0149 'Simulation campaign EDM4EIC': {
0150 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_tracking_only.root",
0151 dexjson: "",
0152 edm4eic: "root://dtn-eic.jlab.org//volatile/eic/EPIC/RECO/25.04.1/epic_craterlake/DIS/NC/18x275/minQ2=10/pythia8NCDIS_18x275_minQ2=10_beamEffects_xAngle=-0.025_hiDiv_1.0000.eicrecon.edm4eic.root"
0153 },
0154 'DIRC optical photons': {
0155 geometry: "https://eic.github.io/epic/artifacts/tgeo/epic_dirc_only.root",
0156 dexjson: "asset://data/dirc_optical.v0.4.firebird.zip",
0157 edm4eic: ""
0158 }
0159 };
0160
0161 public get quickLinkTitles() {
0162 return Object.keys(this.quickLinks);
0163 }
0164
0165 constructor(
0166 private userConfigService: LocalStorageService,
0167 private firebirdConfigService: ServerConfigService
0168 ) {
0169 }
0170
0171 bindConfigToControl<Type>(control: FormControl<Type | null>, config: PersistentProperty<Type>) {
0172 control.setValue(config.value, { emitEvent: false });
0173
0174 config.changes$.subscribe(value => {
0175 control.setValue(value, { emitEvent: false });
0176 });
0177
0178 control.valueChanges.subscribe(value => {
0179 if (value !== null) {
0180 config.value = value;
0181 }
0182 });
0183 }
0184
0185
0186 ngAfterViewInit() {
0187 console.log('[ConfigPage] ngAfterViewInit');
0188
0189 this.bindConfigToControl(this.geometrySelect.value, this.userConfigService.geometryUrl);
0190 this.bindConfigToControl(this.edm4eicSelect.value, this.userConfigService.rootEventSource);
0191 this.bindConfigToControl(this.dexJsonSelect.value, this.userConfigService.dexJsonEventSource);
0192
0193
0194 this.loadInitialConfig();
0195 }
0196
0197 selectedPreset = 'Full ePIC detector geometry (no events)';
0198
0199 ngOnInit(): void {
0200 this.bindConfigToControl(this.onlyCentralDetector, this.userConfigService.geometryFastAndUgly);
0201 this.bindConfigToControl(this.serverUseApi, this.userConfigService.localServerUseApi);
0202 this.bindConfigToControl(this.serverApiUrl, this.userConfigService.localServerUrl);
0203 this.bindConfigToControl(this.rootEventRange, this.userConfigService.rootEventRange);
0204 this.bindConfigToControl(this.geometryThemeName, this.userConfigService.geometryThemeName);
0205 this.bindConfigToControl(this.geometryCutListName, this.userConfigService.geometryCutListName);
0206 this.bindConfigToControl(this.geometryRootFilterName, this.userConfigService.geometryRootFilterName);
0207 this.bindConfigToControl(this.geometryFastAndUgly, this.userConfigService.geometryFastAndUgly);
0208 this.bindConfigToControl(this.useController, this.userConfigService.useController);
0209
0210 this.firebirdConfig = this.firebirdConfigService.config;
0211 setTimeout(() => {
0212 this.geometrySelect?.value.setValue(this.userConfigService.geometryUrl.value);
0213 this.edm4eicSelect?.value.setValue(this.userConfigService.rootEventSource.value);
0214 this.dexJsonSelect?.value.setValue(this.userConfigService.dexJsonEventSource.value);
0215 });
0216 }
0217
0218 onPresetChange(newValue: string) {
0219 this.selectedPreset = newValue;
0220 const config = this.quickLinks[newValue];
0221
0222 if (config) {
0223 this.userConfigService.geometryUrl.value = config.geometry;
0224 this.userConfigService.dexJsonEventSource.value = config.dexjson;
0225 this.userConfigService.rootEventSource.value = config.edm4eic;
0226 if(config.eventRange != null) {
0227 this.userConfigService.rootEventRange.value = config.eventRange;
0228 }
0229
0230 // setTimeout(() => {
0231 // if (this.geometrySelect) {
0232 // this.geometrySelect.value.setValue(config.geometry);
0233 // }
0234 // if (this.dexJsonSelect) {
0235 // this.dexJsonSelect.value.setValue(config.dexjson);
0236 // }
0237 // if (this.edm4eicSelect) {
0238 // this.edm4eicSelect.value.setValue(config.edm4eic);
0239 // }
0240 //
0241 // });
0242 }
0243 }
0244
0245 private loadInitialConfig() {
0246 const savedDex = this.userConfigService.dexJsonEventSource.value;
0247 const savedGeom = this.userConfigService.geometryUrl.value;
0248
0249 if (savedDex || savedGeom) {
0250 return;
0251 }
0252
0253 const preset = this.quickLinks[this.selectedPreset];
0254 if (preset) {
0255 this.onPresetChange(this.selectedPreset);
0256 }
0257 }
0258
0259 resetGeometryToDefaults() {
0260 this.userConfigService.geometryThemeName.setDefault();
0261 this.userConfigService.geometryCutListName.setDefault();
0262 this.userConfigService.geometryRootFilterName.setDefault();
0263 }
0264 }