Skip to content

Commit

Permalink
Geometry cycling
Browse files Browse the repository at this point in the history
  • Loading branch information
DraTeots committed Jun 4, 2024
1 parent dc20f5f commit 54484bb
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 633,277 deletions.
97 changes: 45 additions & 52 deletions firebird-ng/src/app/game-controller.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as THREE from "three";
import {BehaviorSubject, Observable, Subject} from "rxjs";


export enum ControllerButtonIndexes {
export enum GamepadButtonIndexes {
ButtonA = 0,
ButtonB = 1,
ButtonX = 2,
Expand All @@ -16,6 +16,27 @@ export enum ControllerButtonIndexes {
Start = 9,
}

export class GamepadObservableButton {
private onPressSubject = new Subject<boolean>();
public onPress = this.onPressSubject.asObservable();
public state: GamepadButton = {pressed: false, touched: false, value: 0};

constructor(public index: GamepadButtonIndexes) {
}

updateState(newState: GamepadButton) {
if(this.onPressSubject.observed) {
if(newState.pressed != this.state.pressed) {
this.onPressSubject.next(newState.pressed);
}
}
this.state = newState;
}

updateFromGamepadState(gamepad: Gamepad) {
this.updateState(gamepad.buttons[this.index]);
}
}

@Injectable({
providedIn: 'root'
Expand All @@ -32,36 +53,17 @@ export class GameControllerService {
public buttons: GamepadButton[] = [];
public prevButtons: GamepadButton[] = [];

private buttonASubject = new Subject<boolean>();
public buttonAPressed = this.buttonASubject.asObservable();
public buttonA: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonBSubject = new Subject<boolean>();
public buttonBPressed = this.buttonBSubject.asObservable();
public buttonB: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonXSubject = new Subject<boolean>();
public buttonXPressed = this.buttonXSubject.asObservable();
public buttonX: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonYSubject = new Subject<boolean>();
public buttonYPressed = this.buttonYSubject.asObservable();
public buttonY: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonLBSubject = new Subject<boolean>();
public buttonLBPressed = this.buttonLBSubject.asObservable();
public buttonLB: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonRBSubject = new Subject<boolean>();
public buttonRBPressed = this.buttonRBSubject.asObservable();
public buttonRB: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonLTSubject = new Subject<boolean>();
public buttonLTPressed = this.buttonLTSubject.asObservable();
public buttonLT: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonRTSubject = new Subject<boolean>();
public buttonRTPressed = this.buttonRTSubject.asObservable();
public buttonRT: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonSelectSubject = new Subject<boolean>();
public buttonSelectPressed = this.buttonSelectSubject.asObservable();
public buttonSelect: GamepadButton = {pressed: false, touched: false, value: 0};
private buttonStartSubject = new Subject<boolean>();
public buttonStartPressed = this.buttonStartSubject.asObservable();
public buttonStart: GamepadButton = {pressed: false, touched: false, value: 0};

public buttonA: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonA);
public buttonB: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonB);
public buttonX: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonX);
public buttonY: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonY);
public buttonLB: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonLB);
public buttonRB: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonRB);
public buttonLT: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonLT);
public buttonRT: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.ButtonRT);
public buttonStart: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.Start);
public buttonSelect: GamepadObservableButton = new GamepadObservableButton(GamepadButtonIndexes.Select);

public activeGamepad: Gamepad|null = null;

Expand All @@ -87,27 +89,18 @@ export class GameControllerService {
this.yAxisSubject.next(this.yAxis);
}

this.buttonA = gamepad.buttons[ControllerButtonIndexes.ButtonA];
this.buttonB = gamepad.buttons[ControllerButtonIndexes.ButtonB];
this.buttonX = gamepad.buttons[ControllerButtonIndexes.ButtonX];
this.buttonY = gamepad.buttons[ControllerButtonIndexes.ButtonY];
this.buttonLB = gamepad.buttons[ControllerButtonIndexes.ButtonLB];
this.buttonRB = gamepad.buttons[ControllerButtonIndexes.ButtonRB];
this.buttonLT = gamepad.buttons[ControllerButtonIndexes.ButtonLT];
this.buttonRT = gamepad.buttons[ControllerButtonIndexes.ButtonRT];
this.buttonSelect = gamepad.buttons[ControllerButtonIndexes.Select];
this.buttonStart = gamepad.buttons[ControllerButtonIndexes.Start];

if (this.buttonA.pressed !== this.buttonASubject.observed) this.buttonASubject.next(this.buttonA.pressed);
if (this.buttonB.pressed !== this.buttonBSubject.observed) this.buttonASubject.next(this.buttonB.pressed);
if (this.buttonX.pressed !== this.buttonXSubject.observed) this.buttonASubject.next(this.buttonX.pressed);
if (this.buttonY.pressed !== this.buttonYSubject.observed) this.buttonASubject.next(this.buttonY.pressed);
if (this.buttonLB.pressed !== this.buttonLBSubject.observed) this.buttonASubject.next(this.buttonLB.pressed);
if (this.buttonRB.pressed !== this.buttonRBSubject.observed) this.buttonASubject.next(this.buttonRB.pressed);
if (this.buttonLT.pressed !== this.buttonLTSubject.observed) this.buttonASubject.next(this.buttonLT.pressed);
if (this.buttonRT.pressed !== this.buttonRTSubject.observed) this.buttonASubject.next(this.buttonRT.pressed);
if (this.buttonSelect.pressed !== this.buttonSelectSubject.observed) this.buttonASubject.next(this.buttonSelect.pressed);
if (this.buttonStart.pressed !== this.buttonStartSubject.observed) this.buttonASubject.next(this.buttonStart.pressed);
this.buttonSelect.updateFromGamepadState(gamepad);
this.buttonStart.updateFromGamepadState(gamepad);

this.buttonA.updateFromGamepadState(gamepad);
this.buttonB.updateFromGamepadState(gamepad);
this.buttonY.updateFromGamepadState(gamepad);
this.buttonX.updateFromGamepadState(gamepad);

this.buttonLB.updateFromGamepadState(gamepad);
this.buttonRB.updateFromGamepadState(gamepad);
this.buttonLT.updateFromGamepadState(gamepad);
this.buttonRT.updateFromGamepadState(gamepad);

break; // Only use the first connected gamepad
}
Expand Down
67 changes: 62 additions & 5 deletions firebird-ng/src/app/geometry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ import {UserConfigService} from "./user-config.service";
import {Subdetector} from "./model/subdetector";
import {Object3D} from "three";

export const GROUP_CALORIMETRY = "Calorimeters";
export const GROUP_TRACKING = "Tracking";
export const GROUP_PID = "PID";
export const GROUP_MAGNETS = "Magnets";
export const GROUP_SUPPORT = "Beam pipe and support";
export const ALL_GROUPS = [
GROUP_CALORIMETRY,
GROUP_TRACKING,
GROUP_PID,
GROUP_MAGNETS,
GROUP_SUPPORT,
]

// constants.ts
export const DEFAULT_GEOMETRY = 'epic-central-optimized';

Expand All @@ -38,11 +51,55 @@ export class GeometryService {

public groupsByDetName: Map<string, string>;



constructor(private settings: UserConfigService) {
this.groupsByDetName = new Map<string,string> ([
["hello", "world"]
["SolenoidBarrel_assembly_0", GROUP_MAGNETS],
["SolenoidEndcapP_1", GROUP_MAGNETS],
["SolenoidEndcapN_2", GROUP_MAGNETS],
["VertexBarrelSubAssembly_3", GROUP_TRACKING],
["InnerSiTrackerSubAssembly_4", GROUP_TRACKING],
["MiddleSiTrackerSubAssembly_5", GROUP_TRACKING],
["OuterSiTrackerSubAssembly_6", GROUP_TRACKING],
["EndcapMPGDSubAssembly_7", GROUP_TRACKING],
["InnerMPGDBarrelSubAssembly_8", GROUP_TRACKING],
["EndcapTOFSubAssembly_9", GROUP_PID],
["BarrelTOFSubAssembly_10", GROUP_PID],
["OuterBarrelMPGDSubAssembly_11", GROUP_TRACKING],
["B0TrackerSubAssembly_12", GROUP_TRACKING],
["InnerTrackerSupport_assembly_13", GROUP_SUPPORT],
["DIRC_14", GROUP_PID],
["RICHEndcapN_Vol_15", GROUP_PID],
["DRICH_16", GROUP_PID],
["EcalEndcapP_17", GROUP_CALORIMETRY],
["EcalEndcapPInsert_18", GROUP_CALORIMETRY],
["EcalBarrelImaging_19", GROUP_CALORIMETRY],
["EcalBarrelScFi_20", GROUP_CALORIMETRY],
["EcalEndcapN_21", GROUP_CALORIMETRY],
["LFHCAL_env_22", GROUP_CALORIMETRY],
["HcalEndcapPInsert_23", GROUP_CALORIMETRY],
["HcalBarrel_24", GROUP_CALORIMETRY],
["FluxBarrel_env_25", GROUP_SUPPORT],
["FluxEndcapP_26", GROUP_SUPPORT],
["HcalEndcapN_27", GROUP_CALORIMETRY],
["FluxEndcapN_28", GROUP_SUPPORT],
["BeamPipe_assembly_29", GROUP_SUPPORT],
["B0PF_BeamlineMagnet_assembly_30", GROUP_MAGNETS],
["B0APF_BeamlineMagnet_assembly_31", GROUP_MAGNETS],
["Q1APF_BeamlineMagnet_assembly_32", GROUP_MAGNETS],
["Q1BPF_BeamlineMagnet_assembly_33", GROUP_MAGNETS],
["BeamPipeB0_assembly_38", GROUP_SUPPORT],
["Pipe_cen_to_pos_assembly_39", GROUP_SUPPORT],
["Q0EF_assembly_40", GROUP_MAGNETS],
["Q0EF_vac_41", GROUP_MAGNETS],
["Q1EF_assembly_42", GROUP_MAGNETS],
["Q1EF_vac_43", GROUP_MAGNETS],
["B0ECal_44", GROUP_CALORIMETRY],
["Pipe_Q1eR_to_B2BeR_assembly_54", GROUP_SUPPORT],
["Magnet_Q1eR_assembly_55", GROUP_MAGNETS],
["Magnet_Q2eR_assembly_56", GROUP_MAGNETS],
["Magnet_B2AeR_assembly_57", GROUP_MAGNETS],
["Magnet_B2BeR_assembly_58", GROUP_MAGNETS],
["Magnets_Q3eR_assembly_59", GROUP_MAGNETS],
])

}
Expand Down Expand Up @@ -127,9 +184,9 @@ export class GeometryService {
sourceGeometryName: rootNode?.fName ?? "",
geometry: topNode,
name: this.stripIdFromName(originalName),
groupName: this.groupsByDetName.get(name) || ""
groupName: this.groupsByDetName.get(originalName) || ""
}
console.log(subdetector.name, subdetector);
console.log(subdetector.sourceGeometryName);
this.subdetectors.push(subdetector);
}
console.timeEnd('[GeometryService]: Map root geometry to threejs geometry');
Expand Down
29 changes: 23 additions & 6 deletions firebird-ng/src/app/input-config/input-config.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,29 @@ <h5 class="card-title">Events Source</h5>
<option value="no-events">No events (may upload later)</option>
<option value="https://firebird-eic.org/dirc_event.json.zip">DIRC optical (load DIRC only geometry)</option>

<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-1000_nevt-10.evt.zip">py8_all_dis-nc_beam-10x100_minq2-1000_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-100_nevt-10.evt.zip">py8_all_dis-nc_beam-10x100_minq2-100_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-1_nevt-10.evt.zip">py8_all_dis-nc_beam-10x100_minq2-1_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-18x275_minq2-1_nevt-10.evt.zip">py8_all_dis-nc_beam-18x275_minq2-1_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-5x41_minq2-100_nevt-10.evt.zip">py8_all_dis-nc_beam-5x41_minq2-100_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-5x41_minq2-1_nevt-10.evt.zip">py8_all_dis-nc_beam-5x41_minq2-1_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-cc_beam-18x275_minq2-1000_nevt-5.evt.zip"> py8 (50MeV+) dis-CC_beam-18x275_minq2-1000_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-cc_beam-18x275_minq2-100_nevt-5.evt.zip"> py8 (50MeV+) dis-CC_beam-18x275_minq2-100_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-cc_beam-10x100_minq2-1000_nevt-5.evt.zip"> py8 (50MeV+) dis-CC_beam-10x100_minq2-1000_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-cc_beam-10x100_minq2-100_nevt-5.evt.zip"> py8 (50MeV+) dis-CC_beam-10x100_minq2-100_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-cc_beam-5x41_minq2-100_nevt-5.evt.zip"> py8 (50MeV+) dis-CC_beam-5x41_minq2-100_nevt-5</option>

<option value="https://firebird-eic.org/py8_all_dis-nc_beam-18x275_minq2-1000_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-18x275_minq2-1000_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-18x275_minq2-100_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-18x275_minq2-100_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-18x275_minq2-1_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-18x275_minq2-1_nevt-5</option>

<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-1000_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-10x100_minq2-1000_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-100_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-10x100_minq2-100_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-1_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-10x100_minq2-1_nevt-5</option>

<option value="https://firebird-eic.org/py8_all_dis-nc_beam-5x41_minq2-100_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-5x41_minq2-100_nevt-5</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-5x41_minq2-1_nevt-5.evt.zip"> py8 (50MeV+) dis-nc_beam-5x41_minq2-1_nevt-5</option>

<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-1000_nevt-10.evt.zip"> py8 (300MeV+) dis-nc_beam-10x100_minq2-1000_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-100_nevt-10.evt.zip"> py8 (300MeV+) dis-nc_beam-10x100_minq2-100_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-10x100_minq2-1_nevt-10.evt.zip"> py8 (300MeV+) dis-nc_beam-10x100_minq2-1_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-18x275_minq2-1_nevt-10.evt.zip"> py8 (300MeV+) dis-nc_beam-18x275_minq2-1_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-5x41_minq2-100_nevt-10.evt.zip"> py8 (300MeV+) dis-nc_beam-5x41_minq2-100_nevt-10</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-5x41_minq2-1_nevt-10.evt.zip"> py8 (300MeV+) dis-nc_beam-5x41_minq2-1_nevt-10</option>

<option value="https://firebird-eic.org/py8_all_dis-cc_beam-5x41_minq2-100_nevt-5.evt.json.zip">Pyth8 All(300MeV+) DIC-CC 5x41 minQ2-100 5 events</option>
<option value="https://firebird-eic.org/py8_all_dis-nc_beam-18x275_minq2-1000_nevt-5.evt.zip">Pyth8 All(200MeV+) DIC-NC 18x275 minQ2-1000 5 events</option>
Expand Down
20 changes: 18 additions & 2 deletions firebird-ng/src/app/main-display/main-display.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@
<mat-slider min="0" [max]="maxTime" step="1" showTickMarks discrete [displayWith]="formatCurrentTime" (input)="changeCurrentTime($event)">
<input matSliderThumb [value]="currentTime">
</mat-slider>
<div>{{maxTime | number:'1.0'}}</div>
<div>{{maxTime | number:'1.0-0'}} [ns] &nbsp;&nbsp;</div>

<button mat-raised-button aria-label="Rewind" matTooltip="Rewind time to 0" class="tcontrol" (click)="rewindTime()">
<mat-icon>first_page</mat-icon>
</button>
<button mat-raised-button aria-label="Stop" matTooltip="Animate with beam particles collision" class="tcontrol" (click)="animateWithCollision()">
<mat-icon>close_fullscreen</mat-icon>
</button>
<button mat-raised-button aria-label="Play" matTooltip="Play time forward" class="tcontrol" (click)="animateTime()">
<mat-icon>play_arrow</mat-icon>
</button>
Expand All @@ -87,8 +90,21 @@
<button mat-raised-button aria-label="Stop" matTooltip="Stop and show all particles" class="tcontrol" (click)="exitTimedDisplay()" >
<mat-icon>stop</mat-icon>
</button>
<div>{{currentTime | number:'1.1-1'}} {{message}}</div>
&nbsp;&nbsp;

<button mat-raised-button aria-label="Stop" matTooltip="Stop and show all particles" class="tcontrol" (click)="cycleGeometry()" >
<mat-icon>view_in_ar</mat-icon>
</button>

<div>{{currentGeometry}}</div>







<div>{{currentTime | number:'1.1'}} {{message}}</div>
</div>

<div id="eventDisplay"></div>
Loading

0 comments on commit 54484bb

Please sign in to comment.