Skip to content

Commit

Permalink
Make sure we continue to use the JiveXMLLoader configuration, even if…
Browse files Browse the repository at this point in the history
… we load new data

This requires access to EventDisplay configuration, so make this public.
Also, make sure that we handle the possibility that the configuration.eventDataLoader is not the correct type.
  • Loading branch information
EdwardMoyse committed Oct 12, 2024
1 parent 392e045 commit 7a829cb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/phoenix-event-display/src/event-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ declare global {
*/
export class EventDisplay {
/** Configuration for preset views and event data loader. */
private configuration: Configuration;
public configuration: Configuration;
/** An object containing event data. */
private eventsData: any;
/** Array containing callbacks to be called when events change. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ export class AtlasComponent implements OnInit {

// Define the configuration
const configuration: Configuration = {
eventDataLoader: new JiveXMLLoader(['CombinedMuonTracks']),
eventDataLoader: new JiveXMLLoader([
'CombinedMuonTracks',
'MuonSpectrometerTracks',
'CombinedInDetTracks',
'Muons_xAOD',
]),
presetViews: [
new PresetView('Left View', [0, 0, -12000], [0, 0, 0], 'left-cube'),
new PresetView('Center View', [-500, 12000, 0], [0, 0, 0], 'top-cube'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,24 @@ export class IOOptionsDialogComponent implements OnInit {

handleJiveXMLDataInput(files: FileList) {
const callback = (content: any) => {
const jiveloader = new JiveXMLLoader();
const jiveloader = this.getJiveXMLLoader();
jiveloader.process(content);
const eventData = jiveloader.getEventData();
this.eventDisplay.buildEventDataFromJSON(eventData);
};
this.handleFileInput(files[0], 'xml', callback);
}

private getJiveXMLLoader(): JiveXMLLoader {
if (
this.eventDisplay.configuration.eventDataLoader instanceof JiveXMLLoader
) {
return this.eventDisplay.configuration.eventDataLoader as JiveXMLLoader;
} else {
return new JiveXMLLoader();
}
}

handleOBJInput(files: FileList) {
const callback = (content: any, name: string) => {
this.eventDisplay.parseOBJGeometry(content, name);
Expand Down Expand Up @@ -219,7 +229,8 @@ export class IOOptionsDialogComponent implements OnInit {
});

// JiveXML event data
const jiveloader = new JiveXMLLoader();
const jiveloader = this.getJiveXMLLoader();

Object.keys(filesWithData)
.filter((fileName) => {
return fileName.endsWith('.xml') || fileName.startsWith('JiveXML');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ export class FileLoaderService {
}

loadJiveXMLEvent(eventData: string, eventDisplay: EventDisplayService) {
const jiveXMLLoader = new JiveXMLLoader();
let jiveXMLLoader = undefined;

if (eventDisplay.configuration.eventDataLoader instanceof JiveXMLLoader) {
jiveXMLLoader = eventDisplay.configuration
.eventDataLoader as JiveXMLLoader;
} else {
jiveXMLLoader = new JiveXMLLoader();
}

jiveXMLLoader.process(eventData);
const processedEventData = jiveXMLLoader.getEventData();
eventDisplay.buildEventDataFromJSON(processedEventData);
Expand Down

0 comments on commit 7a829cb

Please sign in to comment.