Skip to content

Commit

Permalink
[ng] Pretty particle trajectories and whole lot of updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DraTeots committed May 29, 2024
1 parent e28dab2 commit e3d6db6
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 117 deletions.
56 changes: 28 additions & 28 deletions firebird-ng/src/app/eic-edm4hep-json-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
rawVertices.forEach((rawVertex: any) => {
const position: any[] = [];
if ('position' in rawVertex) {
position.push(rawVertex['position']['x'] * 0.1);
position.push(rawVertex['position']['y'] * 0.1);
position.push(rawVertex['position']['z'] * 0.1);
position.push(rawVertex['position']['x']);
position.push(rawVertex['position']['y']);
position.push(rawVertex['position']['z']);
}

const vertex = {
pos: position,
size: 0.2,
size: 3,
color: '#' + vertexColor,
};
vertices.push(vertex);
Expand Down Expand Up @@ -244,9 +244,9 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
);
const trackerHit = trackerHits[trackerHitRef['index']];
positions.push([
trackerHit['position']['x'] * 0.1,
trackerHit['position']['y'] * 0.1,
trackerHit['position']['z'] * 0.1,
trackerHit['position']['x'],
trackerHit['position']['y'],
trackerHit['position']['z'],
]);
});
}
Expand All @@ -255,9 +255,9 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
trackStates.forEach((trackState: any) => {
if ('referencePoint' in trackState) {
positions.push([
trackState['referencePoint']['x'] * 0.1,
trackState['referencePoint']['y'] * 0.1,
trackState['referencePoint']['z'] * 0.1,
trackState['referencePoint']['x'],
trackState['referencePoint']['y'],
trackState['referencePoint']['z'],
]);
}
});
Expand Down Expand Up @@ -337,16 +337,16 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
rawHits.forEach((rawHit: any) => {
const position: any[] = [];
if ('position' in rawHit) {
position.push(rawHit['position']['x'] * 0.1);
position.push(rawHit['position']['y'] * 0.1);
position.push(rawHit['position']['z'] * 0.1);
position.push(rawHit['position']['x']);
position.push(rawHit['position']['y']);
position.push(rawHit['position']['z']);
}

const hit = {
type: 'CircularPoint',
pos: position,
color: '#' + hitColor,
size: 2,
size: 20,
};
hits.push(hit);
});
Expand Down Expand Up @@ -419,9 +419,9 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
const cellsHue = Math.floor(Math.random() * 358);

rawCells.forEach((rawCell: any) => {
const x = rawCell.position.x * 0.1;
const y = rawCell.position.y * 0.1;
const z = rawCell.position.z * 0.1;
const x = rawCell.position.x;
const y = rawCell.position.y;
const z = rawCell.position.z;

const r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
const rho = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
Expand Down Expand Up @@ -476,9 +476,9 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
const clusters: any[] = [];

rawClusters.forEach((rawCluster: any) => {
const x = rawCluster.position.x * 0.1;
const y = rawCluster.position.y * 0.1;
const z = rawCluster.position.z * 0.1;
const x = rawCluster.position.x;
const y = rawCluster.position.y;
const z = rawCluster.position.z;

const r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
const rho = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
Expand All @@ -490,7 +490,7 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
phi: phi,
energy: rawCluster.energy * 100,
radius: r,
side: 4,
side: 40,
};
clusters.push(cluster);
});
Expand Down Expand Up @@ -612,8 +612,8 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {
const ety = (rawMET['energy'] * py) / p;

const MET = {
etx: etx * 10,
ety: ety * 10,
etx: etx * 100,
ety: ety * 100,
color: '#ff69b4',
};
METs.push(MET);
Expand Down Expand Up @@ -662,12 +662,12 @@ export class EicEdm4hepJsonLoader extends PhoenixLoader {

/** Return a opacity value from the passed number and range */
private valToOpacity(v: number, min: number, max: number): number {
let opacity = 0.2 + ((v - min) * 0.65) / (max - min);
if (opacity < 0.2) {
opacity = 0.2;
let opacity = 0.5 + ((v - min) * 0.65) / (max - min);
if (opacity < 0.5) {
opacity = 0.5;
}
if (opacity > 0.8) {
opacity = 0.8;
if (opacity > 1) {
opacity = 1;
}

return opacity;
Expand Down
11 changes: 11 additions & 0 deletions firebird-ng/src/app/input-config/input-config.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ <h5 class="card-title">Geometry Source</h5>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_zdc_sipm_on_tile_only.root">epic_zdc_sipm_on_tile_only.root</option>
</select>
</div>

<h5 class="card-title">Events Source</h5>
<div class="form-group">
<select class="form-control" [formControl]="selectedEventSource">
<option value="epic-central-optimized">No events (may upload later)</option>
<option value="epic-central-optimized">Open house events</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>
</select>
</div>


</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions firebird-ng/src/app/input-config/input-config.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {ConfigProperty} from "../utils/config-property";
export class InputConfigComponent implements OnInit {

selectedGeometry = new FormControl('');
selectedEventSource = new FormControl('');
onlyCentralDetector: FormControl<boolean | null> = new FormControl(true);

constructor(private configService: UserConfigService) {
Expand Down
15 changes: 5 additions & 10 deletions firebird-ng/src/app/main-display/main-display.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<!--<app-ui-menu></app-ui-menu>-->
<app-experiment-info experiment="ePIC" experimentTagline="EPIC experiment at EIC"></app-experiment-info>
<!-- Phoenix menu at the top right -->
<!--<app-phoenix-menu [rootNode]="phoenixMenuRoot"></app-phoenix-menu>-->
<app-phoenix-menu [rootNode]="phoenixMenuRoot"></app-phoenix-menu>

<app-ui-menu-wrapper>
<!-- Event selector -->
<app-event-selector></app-event-selector>
Expand All @@ -31,9 +32,6 @@
<!-- Toggle for selected object panel -->
<app-object-selection></app-object-selection>

<!-- Info panel -->
<app-info-panel></app-info-panel>

<!-- Toggle for animating the event data -->
<app-animate-event></app-animate-event>

Expand All @@ -46,18 +44,15 @@
<!-- Toggle for performance -->
<app-performance-toggle></app-performance-toggle>

<!-- Toggle for screenshot mode -->
<app-ss-mode></app-ss-mode>

<!-- Make pictures from scene -->
<app-make-picture></app-make-picture>

<!-- Toggle for loading geometries modal-->
<eic-io-options></eic-io-options>

<!-- Toggle for shareable link constructor modal-->
<app-share-link></app-share-link>

<!-- Info panel -->
<app-info-panel></app-info-panel>

<!-- Extra options -->
<ng-content></ng-content>
</app-ui-menu-wrapper>
Expand Down
102 changes: 29 additions & 73 deletions firebird-ng/src/app/main-display/main-display.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Component, Input, OnInit} from '@angular/core';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {
EventDataFormat,
EventDataImportOption,
Expand Down Expand Up @@ -29,13 +30,14 @@ import {LineMaterial} from "three/examples/jsm/lines/LineMaterial";
import {Line2} from "three/examples/jsm/lines/Line2";
import {LineGeometry} from "three/examples/jsm/lines/LineGeometry";
import {IoOptionsComponent} from "./io-options/io-options.component";
import {ThreeEventProcessor} from "../three-event.processor";
// import { LineMaterial } from 'three/addons/lines/LineMaterial.js';


@Component({
selector: 'app-test-experiment',
templateUrl: './main-display.component.html',
imports: [PhoenixUIModule, IoOptionsComponent],
imports: [PhoenixUIModule, IoOptionsComponent, HttpClientModule ],
standalone: true,
styleUrls: ['./main-display.component.scss']
})
Expand All @@ -48,6 +50,7 @@ export class MainDisplayComponent implements OnInit {
phoenixMenuRoot = new PhoenixMenuNode("Phoenix Menu");

threeGeometryProcessor = new ThreeGeometryProcessor();
threeEventProcessor = new ThreeEventProcessor();

/** is geometry loaded */
loaded: boolean = false;
Expand All @@ -66,11 +69,13 @@ export class MainDisplayComponent implements OnInit {

private threeFacade: PhoenixThreeFacade;


constructor(
private geomService: GeometryService,
private eventDisplay: EventDisplayService,
private controller: GameControllerService,
private route: ActivatedRoute) {
private route: ActivatedRoute,
private http: HttpClient) {
this.threeFacade = new PhoenixThreeFacade(this.eventDisplay);
}

Expand Down Expand Up @@ -302,6 +307,17 @@ export class MainDisplayComponent implements OnInit {
camera.updateProjectionMatrix();
}

downloadFile() {

this.http.get('https://firebird-eic.org/py9_all_dis-cc_beam-5x41_minq2-100_nevt-5.evt.json.zip', {
observe: 'response'
}).subscribe(response => {
console.log(response.headers); // Log response headers
}, error => {
console.log('CORS error:', error);
});
}


ngOnInit() {

Expand All @@ -325,7 +341,8 @@ export class MainDisplayComponent implements OnInit {
// (Assuming the file exists in the `src/assets` directory of the app)
//eventFile: 'assets/herwig_18x275_5evt.json',
//eventFile: 'assets/events/py8_all_dis-cc_beam-18x275_minq2-1000_nevt-20.evt.json',
eventFile: 'assets/events/py8_dis-cc_mixed.json.zip',
//eventFile: 'assets/events/py8_dis-cc_mixed.json.zip',
eventFile: 'https://firebird-eic.org/py8_all_dis-cc_beam-5x41_minq2-100_nevt-5.evt.json.zip',
eventType: 'zip' // or zip
},
}
Expand Down Expand Up @@ -354,6 +371,7 @@ export class MainDisplayComponent implements OnInit {
gui.add(this, "produceRenderOrder");
gui.add(this, "logGamepadStates").name( 'Log controls' );
gui.add(this, "logCamera").name( 'Log camera' );
gui.add(this, "downloadFile").name( 'downloadFile' );
gui.add(this, "updateProjectionMatrix").name( 'Update Projection Matrix' );
gui.close();

Expand All @@ -362,80 +380,18 @@ export class MainDisplayComponent implements OnInit {
this.eventDisplay.getUIManager().rotateOpeningAngleClipping(180);
this.eventDisplay.getUIManager().rotateStartAngleClipping(90);

this.eventDisplay.listenToDisplayedEventChange(event => {
console.log("listenToDisplayedEventChange");
console.log(event);
let mcTracksGroup = threeManager.getSceneManager().getObjectByName("mc_tracks");
if(mcTracksGroup) {
this.threeEventProcessor.processMcTracks(mcTracksGroup);
}
})
// Display event loader
this.eventDisplay.getLoadingManager().addLoadListenerWithCheck(() => {
console.log('Loading default configuration.');
this.loaded = true;


console.log(threeManager.getSceneManager().getEventData());

let mcTracksGroup = threeManager.getSceneManager().getObjectByName("mc_tracks");
if(mcTracksGroup) {
for(let trackGroup of mcTracksGroup.children) {


for(let obj of trackGroup.children) {
if(obj.type == "Line") {



let material = new LineMaterial( {

color: 0xffff00,
linewidth: 50, // in world units with size attenuation, pixels otherwise
vertexColors: true,

//resolution: // to be set by renderer, eventually
dashed: true,
alphaToCoverage: true,

} );
let positions = (obj.userData as any).pos;
let flat = [];
for(let position of positions) {

flat.push(position[0], position[1], position[2]);
}
const geometry = new LineGeometry();
geometry.setPositions( flat );
// geometry.setColors( colors );

let matLine = new LineMaterial( {

color: 0xffff00,
linewidth: 10, // in world units with size attenuation, pixels otherwise
//vertexColors: true,
worldUnits: true,
//needsUpdate=: true;
//resolution: // to be set by renderer, eventually
dashed: true,
//dashScale: 100,
dashSize: 100,
gapSize: 100,
alphaToCoverage: true,

} );

let line = new Line2( geometry, matLine );

line.scale.set( 1, 1, 1 );
line.computeLineDistances();
line.visible = true;
trackGroup.add( line );
obj.visible = false;
}

if(obj.type == "Mesh") {
obj.visible = false;
}
}
console.log(trackGroup);

}

}

});

this.eventDisplay
Expand Down
Loading

0 comments on commit e3d6db6

Please sign in to comment.