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