Skip to content

Commit

Permalink
fix(event-display): fixes and improvements for track import from JiveXML
Browse files Browse the repository at this point in the history
No longer suppress some collections, since not in all JiveXML
Add 'badtracks' output for debugging
Fix scale of measurement points
  • Loading branch information
EdwardMoyse committed Apr 26, 2021
1 parent 02440e9 commit c92d65f
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions packages/phoenix-event-display/src/loaders/jivexml-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,11 @@ export class JiveXMLLoader extends PhoenixLoader {
public getTracks(firstEvent: Element, eventData: { Tracks: any; Hits: any }) {
const tracksHTML = firstEvent.getElementsByTagName('Track');
const trackCollections = Array.from(tracksHTML);
const nameOfCollection = 'Tracks';
let badTracks = { 'Negative theta':0 };

for (const collection of trackCollections) {
let trackCollectionName = collection.getAttribute('storeGateKey');
if (
trackCollectionName === 'Tracks' ||
trackCollectionName === 'GSFTracks' ||
trackCollectionName === 'GSFTrackParticles'
) {
// Tracks are duplicates of CombinedInDetTracks (though so maybe check that they're in the file before skipping?)
// GSF tracks cause problems at the moment.
continue;
}
// if (!trackCollectionName.includes('MuonSpectrometer')) continue;
const numOfTracks = Number(collection.getAttribute('count'));
const jsontracks = [];

Expand All @@ -179,7 +172,7 @@ export class JiveXMLLoader extends PhoenixLoader {
numPolyline = this.getNumberArrayFromHTML(collection, 'numPolyline');

const polyLineXHTML = collection.getElementsByTagName('polylineX');
if (polyLineXHTML.length) {
if (polyLineXHTML.length>0) {
// This can happen with e.g. TrackParticles
var polylineX = polyLineXHTML[0].innerHTML
.replace(/\r\n|\n|\r/gm, ' ')
Expand Down Expand Up @@ -224,11 +217,17 @@ export class JiveXMLLoader extends PhoenixLoader {
dparams: [],
hits: {},
author: {},
badtrack: [],
};
if (chi2.length >= i) track.chi2 = chi2[i];
if (numDoF.length >= i) track.dof = numDoF[i];
if (trackAuthor.length >= i) track.author = trackAuthor[i];

const theta = Math.tan(cotTheta[i]);
if (theta<0){
badTracks['Negative theta']++;
track.badtrack.push('Negative theta');
}
track.pT = Math.abs(pT[i]);
const momentum = (pT[i] / Math.sin(theta)) * 1000; // JiveXML uses GeV
track.dparams = [d0[i], z0[i], phi0[i], theta, 1.0 / momentum];
Expand All @@ -245,22 +244,29 @@ export class JiveXMLLoader extends PhoenixLoader {
const pos = [],
listOfHits = [];
let maxR = 0.0,
radius=0.0,
x = 0.0,
y = 0.0,
z = 0.0;
if (numPolyline) {
for (let p = 0; p < numPolyline[i]; p++) {
x = polylineX[polylineCounter + p];
y = polylineY[polylineCounter + p];
z = polylineZ[polylineCounter + p];
x = polylineX[polylineCounter + p] * 10.0;
y = polylineY[polylineCounter + p] * 10.0;
z = polylineZ[polylineCounter + p] * 10.0;
pos.push([x, y, z]);
maxR = Math.sqrt(x * x + y * y + z * z);
radius = Math.sqrt(x * x + y * y + z * z);
if (radius<maxR) {
console.log('WARNING: track positions do not seem to be sorted radially');
badTracks['Hits not sorted']++;
track.badtrack.push('Hits not sorted');
}
maxR = radius;
}
polylineCounter += numPolyline[i];
track.pos = pos;
}
if (trackCollectionName.includes('Muon')) {
// Only try this for Muons at the moment.
if (trackCollectionName.includes('XXXXXX')) {
// Disable for the moment.

// Now loop over hits, and if possible, see if we can extend the track
let measurementPositions = [];
Expand Down Expand Up @@ -324,6 +330,9 @@ export class JiveXMLLoader extends PhoenixLoader {
eventData.Tracks[trackCollectionName] = jsontracks;
// }
}
for (let error in badTracks){
if (badTracks[error]>0 ) console.log( badTracks[error] + ' had "'+error + '" and were marked as bad.')
}
}

/**
Expand Down Expand Up @@ -564,7 +573,6 @@ export class JiveXMLLoader extends PhoenixLoader {
) {
const clustersHTML = firstEvent.getElementsByTagName('Cluster');
const clusterCollections = Array.from(clustersHTML);
const nameOfCollection = 'CaloTopoCluster_ESD';
for (const clusterColl of clusterCollections) {
const numOfClusters = Number(clusterColl.getAttribute('count'));

Expand Down

0 comments on commit c92d65f

Please sign in to comment.