Skip to content

Commit

Permalink
Add configurable option to make some track collections thicker
Browse files Browse the repository at this point in the history
Remove extraneous debugging
  • Loading branch information
EdwardMoyse committed Sep 15, 2024
1 parent 8fc9ada commit dd12e22
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
15 changes: 14 additions & 1 deletion packages/phoenix-event-display/src/loaders/jivexml-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import { CoordinateHelper } from '../helpers/coordinate-helper.js';
export class JiveXMLLoader extends PhoenixLoader {
/** Event data in JiveXML data format */
private data: any;
thickTrackCollections: string[];

/**
* Constructor for the JiveXMLLoader.
* @param thickTrackCollections A list of names of track collections which should be drawn thicker
*/
constructor() {
constructor(thickTrackCollections: string[] = []) {
super();
this.data = {};
this.thickTrackCollections = thickTrackCollections;
}

/**
Expand Down Expand Up @@ -173,6 +176,15 @@ export class JiveXMLLoader extends PhoenixLoader {
trackCollectionName = 'Tracks_'; //We have problems if the name of the collection is a type
}

let thickTracks = false;
if (
this.thickTrackCollections.find(
(collection) => collection === trackCollectionName,
)
) {
thickTracks = true;
}

// if (!trackCollectionName.includes('MuonSpectrometer')) continue;
const numOfTracks = Number(collection.getAttribute('count'));
const jsontracks = [];
Expand Down Expand Up @@ -265,6 +277,7 @@ export class JiveXMLLoader extends PhoenixLoader {
hits: {},
author: {},
badtrack: [] as string[],
linewidth: thickTracks ? 20.0 : undefined,
};
if (chi2.length >= i) track.chi2 = chi2[i];
if (numDoF.length >= i) track.dof = numDoF[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class PhoenixObjects {
? parseInt(trackParams.color, 16)
: EVENT_DATA_TYPE_COLORS.Tracks.getHex();

const linewidth = trackParams.linewidth ? trackParams.linewidth : 2;
const points = [];

for (let i = 0; i < positions.length; i++) {
Expand All @@ -162,7 +163,7 @@ export class PhoenixObjects {
const curve = new CatmullRomCurve3(points);

// TubeGeometry
const geometry = new TubeGeometry(curve, undefined, 2);
const geometry = new TubeGeometry(curve, undefined, linewidth);
const material = new MeshToonMaterial({ color: objectColor });
const tubeObject = new Mesh(geometry, material);

Expand All @@ -171,7 +172,7 @@ export class PhoenixObjects {
const lineGeometry = new BufferGeometry().setFromPoints(vertices);
const lineMaterial = new LineBasicMaterial({
color: objectColor,
linewidth: 2,
linewidth: linewidth,
});
const lineObject = new Line(lineGeometry, lineMaterial);
lineObject.name = 'Track';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export class PhoenixLoader implements EventDataLoader {
continue;
}


this.addCollection(
objectCollection,
collectionName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ export class URLOptionsManager {
*/
private async handleJiveXMLEvent(fileURL: string) {
const fileData = await (await fetch(fileURL)).text();
const loader = new JiveXMLLoader();
this.configuration.eventDataLoader = loader;
if (!this.configuration.eventDataLoader) {
this.configuration.eventDataLoader = new JiveXMLLoader();
}
// Parse the XML to extract events and their data
const loader = this.configuration.eventDataLoader as JiveXMLLoader;
loader.process(fileData);
const eventData = loader.getEventData();
this.eventDisplay.buildEventDataFromJSON(eventData);
Expand Down Expand Up @@ -188,7 +190,10 @@ export class URLOptionsManager {
});

// JiveXML event data
const jiveloader = new JiveXMLLoader();
const jiveloader =
this.configuration.eventDataLoader instanceof JiveXMLLoader
? (this.configuration.eventDataLoader as JiveXMLLoader)
: new JiveXMLLoader();
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 @@ -10,7 +10,6 @@ export class HomeComponent implements AfterViewInit {
year: number;

constructor(private eventDisplay: EventDisplayService) {
console.log('Home component created');
this.year = new Date().getFullYear();
this.eventDisplay.getThreeManager().stopAnimationLoop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import {
PresetView,
PhoenixMenuNode,
PhoenixLoader,
JiveXMLLoader,
StateManager,
} from 'phoenix-event-display';
import type { Configuration } from 'phoenix-event-display';
Expand Down Expand Up @@ -48,7 +48,7 @@ export class AtlasComponent implements OnInit {

// Define the configuration
const configuration: Configuration = {
eventDataLoader: new PhoenixLoader(),
eventDataLoader: new JiveXMLLoader(['CombinedMuonTracks']),
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

0 comments on commit dd12e22

Please sign in to comment.