Skip to content

ADD: TRA data loader and tra file fixes - #210

Merged
zoglauer merged 4 commits into
cositools:develop/emfrom
zoglauer:feature/traloader
Sep 21, 2026
Merged

zoglauer merged 4 commits into
cositools:develop/emfrom
zoglauer:feature/traloader

Conversation

@zoglauer

@zoglauer zoglauer commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

*** NEEDS MEGALIB UPDATE ***

New tra file loader for DC5 data conversion.
Some newly discovered issues in MEGAlib lead to new tra files for the unit tests (BD flags and hits where not handled correctly under all circumstances).

@fhagemann fhagemann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated megalib locally and ran the unit tests on my computer, and all tests passed.

I also manually confirmed that all bad flags that can be written by MReadOutAssembly::StreamBDFlags are covered in the new MModuleLoaderMeasurementsTRA::AnalyzeEvent here.

Comment thread src/MModuleLoaderMeasurementsTRA.cxx Outdated
Comment on lines +126 to +127
Event->SetTime(PhysicalEvent->GetTime());
Event->SetTimeUTC(PhysicalEvent->GetTime());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time and TimeUTC is the same? Do we need both or could this be cleaned up?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEGAlib just has time - I want to keep MEGAlib that way, because there is no fixed meaning what time is - it all depends on the context.

Comment thread src/MModuleLoaderMeasurementsTRA.cxx Outdated
Comment on lines +167 to +169
Hit->SetPositionResolution(PhysicalHit.GetPositionUncertainty());
Hit->SetEnergy(PhysicalHit.GetEnergy());
Hit->SetEnergyResolution(PhysicalHit.GetEnergyUncertainty());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Category code clean-up: in the future, we might want to use either Resolution or Uncertainty consistently and avoid mixing both terms to denote the same thing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be uncertainty and not resolution, correct.
If they are the same thing depends on context: Imaging a multimeter with display 00.00 V: it has a resolution of 0.01 V but might have a measurement uncertainty of +-2%

Comment thread src/MModuleLoaderMeasurementsTRA.cxx
Comment thread unittests/UTNModuleLoaderMeasurementsTRA.cxx
Comment thread unittests/UTNModuleLoaderMeasurementsTRA.cxx

@ckierans ckierans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice quick work, @zoglauer ! Just one minor comment.

Did you test this by generating an L2 FITS output, yet?

Comment thread src/MModuleLoaderMeasurementsTRA.cxx Outdated
}

// Hits: Compton events carry their hit sequence, photo events a single position and energy
if (PhysicalEvent->GetNHits() > 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you're trying to find Compton events, so shouldn't GetNHits > 1 to filter out Photo events, or, better yet, why not if (PhysicalEvent->GetType() == MPhysicalEvent::c_Compton)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the code nicer.

@zoglauer

Copy link
Copy Markdown
Collaborator Author

I also added a new unit test data set which is from DC4 for test conversion.

@zoglauer

Copy link
Copy Markdown
Collaborator Author

And i did a test conversion to L2 - looks OK

@zoglauer
zoglauer merged commit b1766ae into cositools:develop/em Sep 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants