Skip to content

Commit

Permalink
fix(event-display): run prettier (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardMoyse committed Apr 12, 2021
1 parent eadbd59 commit f279898
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 29 deletions.
18 changes: 11 additions & 7 deletions packages/phoenix-event-display/src/loaders/jivexml-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class JiveXMLLoader extends PhoenixLoader {
track.pos = pos;
}
// Now loop over hits, and if possible, see if we can extend the track
if (numHits.length>0) {
if (numHits.length > 0) {
let hitIdentifier = 0;
let distance = 0.0;
let found = false;
Expand Down Expand Up @@ -324,7 +324,7 @@ export class JiveXMLLoader extends PhoenixLoader {
eventData.Hits.SCT = [];

for (let i = 0; i < numOfSCTClusters; i++) {
let sct = { pos: [], id: 0, phiModule:0, side:0 };
let sct = { pos: [], id: 0, phiModule: 0, side: 0 };
sct.pos = [x0[i] * 10.0, y0[i] * 10.0, z0[i] * 10.0];
sct.id = id[i];
sct.phiModule = phiModule[i];
Expand Down Expand Up @@ -353,7 +353,10 @@ export class JiveXMLLoader extends PhoenixLoader {
const rhoz = this.getNumberArrayFromHTML(dcHTML, 'rhoz');
const sub = this.getNumberArrayFromHTML(dcHTML, 'sub');
const threshold = this.getNumberArrayFromHTML(dcHTML, 'threshold');
const timeOverThreshold = this.getNumberArrayFromHTML(dcHTML, 'timeOverThreshold');
const timeOverThreshold = this.getNumberArrayFromHTML(
dcHTML,
'timeOverThreshold'
);

eventData.Hits.TRT = [];

Expand All @@ -366,7 +369,7 @@ export class JiveXMLLoader extends PhoenixLoader {
driftR: 0.0,
threshold: 0.0,
timeOverThreshold: 0.0,
noise: false
noise: false,
};

if (sub[i] == 1 || sub[i] == 2) {
Expand All @@ -376,7 +379,8 @@ export class JiveXMLLoader extends PhoenixLoader {
trt.pos = [
Math.cos(phi[i]) * rhoz[i] * 10.0,
Math.sin(phi[i]) * rhoz[i] * 10.0,
z1, Math.cos(phi[i]) * rhoz[i] * 10.0,
z1,
Math.cos(phi[i]) * rhoz[i] * 10.0,
Math.sin(phi[i]) * rhoz[i] * 10.0,
z2,
];
Expand Down Expand Up @@ -419,8 +423,8 @@ export class JiveXMLLoader extends PhoenixLoader {
const dcHTML = firstEvent.getElementsByTagName(name)[0];

// Bit of a nasty hack, but JiveXML stores CSCs as CSCD for some reason.
if (name=='CSCD') name = 'CSC';
if (name == 'CSCD') name = 'CSC';

const numOfDC = Number(dcHTML.getAttribute('count'));
const x = this.getNumberArrayFromHTML(dcHTML, 'x');
const y = this.getNumberArrayFromHTML(dcHTML, 'y');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class PhoenixObjects {

positions = RKHelper.extrapolateTrackPositions(trackParams, inBounds);
}
}
}

// Check again, in case there was an issue with the extrapolation.
if (positions.length < 3) {
Expand Down Expand Up @@ -196,42 +196,53 @@ export class PhoenixObjects {
* @param type Tells Phoenix how to draw this - currently can be Point (default), or Line.
* @returns Hits object.
*/
public static getHits(hitsParams: [ { pos:[], type?: string }]): Object3D {
public static getHits(hitsParams: [{ pos: []; type?: string }]): Object3D {
let hitsParamsClone = hitsParams;
let type:string = 'Point'; // Default is point and 3 coordinates per hit
let type: string = 'Point'; // Default is point and 3 coordinates per hit
let coordlength = 3;
if (hitsParams.length>1){
if (hitsParams.length > 1) {
// Peek at first one. Would be better to make these properties of the collections.
if ('type' in hitsParams[0]) {
type = hitsParams[0].type;
coordlength=6;
coordlength = 6;
}
}
// attributes
const pointPos = new Float32Array(hitsParams.length*coordlength);
const pointPos = new Float32Array(hitsParams.length * coordlength);
let i = 0;
let imax = 0;
for (const hit of hitsParams) {
imax = i+coordlength;
for (let j=0 ; j<coordlength; ++j, ++i){
imax = i + coordlength;
for (let j = 0; j < coordlength; ++j, ++i) {
pointPos[i] = hit.pos[j];
}
}

// geometry
switch (type){
case 'Point':
return PhoenixObjects.hitsToPoints(pointPos, hitsParams, hitsParamsClone);
case 'Line':
return PhoenixObjects.hitsToLines(pointPos, hitsParams, hitsParamsClone);
default:
console.log('ERROR: Unknown hit type!')
return;
switch (type) {
case 'Point':
return PhoenixObjects.hitsToPoints(
pointPos,
hitsParams,
hitsParamsClone
);
case 'Line':
return PhoenixObjects.hitsToLines(
pointPos,
hitsParams,
hitsParamsClone
);
default:
console.log('ERROR: Unknown hit type!');
return;
}
}

private static hitsToPoints(pointPos: any, hitsParams: any, hitParamsClone: any): Object3D {

private static hitsToPoints(
pointPos: any,
hitsParams: any,
hitParamsClone: any
): Object3D {
const geometry = new BufferGeometry();
geometry.setAttribute('position', new BufferAttribute(pointPos, 3));
geometry.computeBoundingSphere();
Expand All @@ -250,10 +261,11 @@ private static hitsToPoints(pointPos: any, hitsParams: any, hitParamsClone: any)
return pointsObj;
}



private static hitsToLines(pointPos: any, hitsParams: any, hitParamsClone: any): Object3D {

private static hitsToLines(
pointPos: any,
hitsParams: any,
hitParamsClone: any
): Object3D {
// geometry
const geometry = new BufferGeometry();
geometry.setAttribute('position', new BufferAttribute(pointPos, 3));
Expand Down

0 comments on commit f279898

Please sign in to comment.