Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CsvWriter example #350

Merged
merged 6 commits into from
Sep 2, 2024
Merged

Update CsvWriter example #350

merged 6 commits into from
Sep 2, 2024

Conversation

nathanwbrei
Copy link
Collaborator

@nathanwbrei nathanwbrei commented Sep 2, 2024

This replaces the JANA/JCsvWriter.h with examples/CsvWriter. The reasoning is as follows:

JCsvWriter produces a format that is not particularly useful for anybody. It produces a single CSV file containing a table with rows for all objects in a particular collection over a range of events. Unlike JInspector, it can't be used interactively or from a debugger. Because it is a class template, it can't be put in its own plugin; to use it requires recompilation. However, since running it imposes a dramatic performance penalty, it should only be run for debugging! Finally, it only works with JObject-based data models, and hence can't be used with EICrecon at all. Halld_recon users, meanwhile, would prefer hd_dump or janadump because those (a) are interactive, (b) print multiple collections from a single event without recompilation, and (c) live in an independent plugin.

Aside from the clear functional deficiencies, JCsvWriter has design deficiencies. Firstly, it is a class template rather than a class. This goes against the principle of keeping the surface area of templates small. Secondly, the templating is unnecessary, because all of the information that JCsvWriter extracts from its target collection lives at the JObject level. Finally, the ability to extract entire families of data model objects from the JEvent is an action most JANA users need, but have no example for, and the current JCsvWriter obfuscates this rather than clarifies it.

Users do not need JCsvWriter; they have JInspector, hd_dump, and regressiontest, each of which serves at least one use case more effectively than JCsvWriter. What users do need is a simple example of how to generically extract JObjects from a JEvent, how to use JObjectSummaries, and how to leverage the plugin architecture to add functionality at runtime. JCsvWriter is conceptually simple enough that users can learn from the source code without being bogged down by the details of other APIs or file formats.

To bring this about, JCsvWriter should be moved out of the core JANA library and into examples. It should be de-templatized, redesigned so that it prints the contents of multiple collections per event, and extensively commented. It should use the new CallbackMode::ExpertMode interface and Parameter helpers, to help test the new interface out, and help users get used to them.

@nathanwbrei nathanwbrei changed the title Update examples Update CsvWriter example Sep 2, 2024
@nathanwbrei nathanwbrei marked this pull request as ready for review September 2, 2024 04:01
@nathanwbrei nathanwbrei merged commit 28ae5bd into master Sep 2, 2024
9 checks passed
@nathanwbrei nathanwbrei deleted the nbrei_update_examples branch September 2, 2024 04:01
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.

1 participant