Skip to content

Conversation

@lynnt20
Copy link
Contributor

@lynnt20 lynnt20 commented Dec 10, 2025

@kjplows
Copy link
Contributor

kjplows commented Dec 14, 2025

@lynnt20 could you nominate reviewers please?

@kjplows kjplows moved this to Open pull requests in SBN software development Dec 14, 2025
@linyan-w linyan-w moved this to Expected for Later in SBND 2025 Fall Production Dec 15, 2025
Copy link
Member

@PetrilloAtWork PetrilloAtWork left a comment

Choose a reason for hiding this comment

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

The class version business must be fixed.
I have left also a technical C++ comment: fell completely free to decide how to approach it.

Comment on lines +87 to +95
<class name="art::Assns<recob::Slice, sbn::LightCalo>" />
<class name="art::Wrapper<art::Assns<recob::Slice, sbn::LightCalo>>" />
<class name="art::Assns<sbn::LightCalo, recob::Slice, void>" />
<class name="art::Wrapper<art::Assns<sbn::LightCalo, recob::Slice, void>>"/>

<class name="art::Assns<recob::OpFlash, sbn::LightCalo>" />
<class name="art::Assns<sbn::LightCalo, recob::OpFlash, void>" />
<class name="art::Wrapper<art::Assns<recob::OpFlash, sbn::LightCalo>>" />
<class name="art::Wrapper<art::Assns<sbn::LightCalo, recob::OpFlash, void>>" />
Copy link
Member

Choose a reason for hiding this comment

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

The void in the associations is default and not necessary, but either way it should be consistent for ease of reading. Also for ease of reading, it would be better to have them in the same order.
Finally, I was under the impression that the explicit registration of the std::pair was needed too (at least it used to be).

Suggested change
<class name="art::Assns<recob::Slice, sbn::LightCalo>" />
<class name="art::Wrapper<art::Assns<recob::Slice, sbn::LightCalo>>" />
<class name="art::Assns<sbn::LightCalo, recob::Slice, void>" />
<class name="art::Wrapper<art::Assns<sbn::LightCalo, recob::Slice, void>>"/>
<class name="art::Assns<recob::OpFlash, sbn::LightCalo>" />
<class name="art::Assns<sbn::LightCalo, recob::OpFlash, void>" />
<class name="art::Wrapper<art::Assns<recob::OpFlash, sbn::LightCalo>>" />
<class name="art::Wrapper<art::Assns<sbn::LightCalo, recob::OpFlash, void>>" />
<class name="std::pair<recob::Slice, sbn::LightCalo>" />
<class name="art::Assns<recob::Slice, sbn::LightCalo>" />
<class name="art::Wrapper<art::Assns<recob::Slice, sbn::LightCalo>>" />
<class name="std::pair<sbn::LightCalo, recob::Slice>" />
<class name="art::Assns<sbn::LightCalo, recob::Slice>" />
<class name="art::Wrapper<art::Assns<sbn::LightCalo, recob::Slice>>"/>
<class name="std::pair<recob::OpFlash, sbn::LightCalo>" />
<class name="art::Assns<recob::OpFlash, sbn::LightCalo>" />
<class name="art::Wrapper<art::Assns<recob::OpFlash, sbn::LightCalo>>" />
<class name="std::pair<sbn::LightCalo, recob::OpFlash>" />
<class name="art::Assns<sbn::LightCalo, recob::OpFlash>" />
<class name="art::Wrapper<art::Assns<sbn::LightCalo, recob::OpFlash>>" />

Comment on lines +81 to +82
<class name="sbn::LightCalo">
</class>
Copy link
Member

Choose a reason for hiding this comment

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

This needs a checksum and a class version, so that when we change it ROOT knows how to read the old versions. Start with:

Suggested change
<class name="sbn::LightCalo">
</class>
<class name="sbn::LightCalo" classVersion="10" />

then build: it will tell you to build again. Rebuild... at this point you should see a fully successful build. Lastly, commit the new classes_def.xml to the branch.

Comment on lines +20 to +21
class LightCalo {
public:
Copy link
Member

Choose a reason for hiding this comment

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

Since the whole class content is public, I would declare it struct:

Suggested change
class LightCalo {
public:
struct LightCalo {

It is 100% equivalent, and I think clearer.

Comment on lines +34 to +43
/**
* Default constructor.
*/
LightCalo() = default;
LightCalo(double charge, double light, double energy, int bestplane)
: charge(charge)
, light(light)
, energy(energy)
, bestplane(bestplane)
{}
Copy link
Member

Choose a reason for hiding this comment

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

You have introduced a value constructor, and I want to make sure you are aware of the implications. I will compare yours with the same class in "plain old data" version, with no user-defined constructor (yours has two: the value constructor and the default one).

With your version, it's harder for the user to initialise the object only partially (e.g. initialise charge but not light). This is in general good, but note that partial initialization may still happen (LightCalo calo; calo.charge = 40000.0;).
With the POD version, aggregate initialisation can be used (LightCalo lc { 40000.0, 30000.0, 3.5, 2 };) that can omit the last arguments. This may or may not be desired. On the other end, POD have such guarantees (can be copied with a memcpy(), for example) that allow libraries writing them to disk to take shortcuts. I don't know whether ROOT takes advantage of any of the shortcuts.

In general I recommend POD classes, but that opens for partial initialisation.
So it's up to you and how you feel about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Open pull requests
Status: Expected for Later

Development

Successfully merging this pull request may close these issues.

4 participants