WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@cerati
Copy link
Contributor

@cerati cerati commented Apr 11, 2025

This PR adds a few NuGraph-related variables to CAFs, along the lines of what presented on docdb 40585. Once SBNSoftware/icaruscode#815 is merged the needed data products can be produced, but it won't break CAF making if they are not there. The related SBNSoftware/sbncode#532 is also being made.

Copy link
Contributor

@brucehoward-physics brucehoward-physics left a comment

Choose a reason for hiding this comment

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

Seems pretty uncontroversial, but I do have a few suggestions for collapsing the checksum versions.

Comment on lines 71 to 72
<version ClassVersion="23" checksum="2124497341"/>
<version ClassVersion="22" checksum="4187618741"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you can just collapse these to ClassVersion 22 with the latest checksum no?

Comment on lines 247 to 248
<version ClassVersion="17" checksum="135310109"/>
<version ClassVersion="16" checksum="1684266144"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

@cerati
Copy link
Contributor Author

cerati commented May 5, 2025

@brucehoward-physics Suggestions implemented. Thanks

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.

Left a few comments.
Only two, really.
A shame.

Comment on lines 34 to 40
int ng_sem_cat; ///< NuGraph semantic category with largest hit fraction
float ng_mip_frac; ///< Fraction of PFP hits labeled by NuGraph as MIP
float ng_hip_frac; ///< Fraction of PFP hits labeled by NuGraph as HIP
float ng_shr_frac; ///< Fraction of PFP hits labeled by NuGraph as shower
float ng_mhl_frac; ///< Fraction of PFP hits labeled by NuGraph as Michel
float ng_dif_frac; ///< Fraction of PFP hits labeled by NuGraph as diffuse
float ng_bkg_frac; ///< Fraction of PFP hits labeled by NuGraph as background
Copy link
Member

Choose a reason for hiding this comment

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

I recommend to enclose this group of data members into their own class, like in SRCNNScore (e.g. SRNGScore) or, even better from my point of view, use and extend SRCNNScore itself (half the categories are the same), with the unsupported categories defaulting to 0.0 (and nclusters to -5).


SRCNNScore cnnscore; // CNN scores for this PFP

int ng_sem_cat; ///< NuGraph semantic category with largest hit fraction
Copy link
Member

Choose a reason for hiding this comment

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

Consider an enum type instead of a bare int.
And consider very well having at very least an enum to describe the possible categories rather than using integer values in the code.

@kjplows
Copy link
Contributor

kjplows commented May 7, 2025

trigger build

@FNALbuild
Copy link

✔️ CI build for LArSoft Succeeded on slf7 for e26:prof -- details available through the CI dashboard

@FNALbuild
Copy link

✔️ CI build for LArSoft Succeeded on slf7 for c14:prof -- details available through the CI dashboard

@FNALbuild
Copy link

❌ CI build for ICARUS Failed at phase build ICARUS on slf7 for c14:prof -- details available through the CI dashboard

🚨 For more details about the failed phase, check the build ICARUS phase logs

parent CI build details are available through the CI dashboard

@FNALbuild
Copy link

❌ CI build for SBND Failed at phase build SBND on slf7 for c14:prof -- details available through the CI dashboard

🚨 For more details about the failed phase, check the build SBND phase logs

parent CI build details are available through the CI dashboard

@FNALbuild
Copy link

⚠️ CI build for SBND Warning at phase ci_tests SBND on slf7 for e26:prof -- details available through the CI dashboard

🚨 For more details about the warning phase, check the ci_tests SBND phase logs

parent CI build details are available through the CI dashboard

@FNALbuild
Copy link

⚠️ CI build for ICARUS Warning at phase ci_tests ICARUS on slf7 for e26:prof - ignored failure for unit_test -- details available through the CI dashboard

🚨 For more details about the warning phase, check the ci_tests ICARUS phase logs

parent CI build details are available through the CI dashboard

@kjplows kjplows moved this from Open pull requests to Testing in SBN software development May 7, 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.

Several formal C++ fixes requested.
Also, I believe the new class should be added to classes_def.xml.
As usual, do not accept suggested documentation without checking what I wrote, that may be badly written, misleading or plain wrong.

class SRNuGraphScore {
public:
SRNuGraphScore();
~SRNuGraphScore() {}
Copy link
Member

@PetrilloAtWork PetrilloAtWork May 8, 2025

Choose a reason for hiding this comment

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

Remove this destructor: it's useless and sometimes deleterious.

Suggested change
~SRNuGraphScore() {}

Comment on lines 24 to 29
float mip_frac;
float hip_frac;
float shr_frac;
float mhl_frac;
float dif_frac;
float bkg_frac;
Copy link
Member

Choose a reason for hiding this comment

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

  1. Initialize the data members inline.
  2. Add in comment what these are supposed to be. Maybe something like:
Suggested change
float mip_frac;
float hip_frac;
float shr_frac;
float mhl_frac;
float dif_frac;
float bkg_frac;
static constexpr float kUnassigned = std::numeric_limits<float>::signaling_NaN();
float mip_frac = kUnassigned; ///< Fraction of hits that are most likely to be `MIP`.
float hip_frac = kUnassigned; ///< Fraction of hits that are most likely to be `HIP`.
float shr_frac = kUnassigned; ///< Fraction of hits that are most likely to be `Shower`.
float mhl_frac = kUnassigned; ///< Fraction of hits that are most likely to be `Michel`.
float dif_frac = kUnassigned; ///< Fraction of hits that are most likely to be `Diffuse`.
float bkg_frac = kUnassigned; ///< Fraction of hits that are most likely to be none of the above.

(for this example you also have to #include <limits> here instead of the implementation file).
Here I am defining kUnassigned just for convenience. It may be private, it may be just spelled out — your choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to use signaling NaN why not just use this ;)

https://github.com/SBNSoftware/sbnanaobj/blob/develop/sbnanaobj/StandardRecord/SRConstants.h#L8

Diffuse = 4
};

int sem_cat;
Copy link
Member

Choose a reason for hiding this comment

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

  1. Initialize the data members inline ([CF-155]). It used to be not the CAF standard, but it is going to become under by guard. Too many times members are added that are left uninitialised, and this helps a lot against it.
  2. Add in comment what these are supposed to be. For example:
Suggested change
int sem_cat;
int sem_cat = NuGraphCategory::Unset; ///< The category of the majority of the hits.

Finally, in CAF the pattern used to distinguish between default-constructed and positively set as invalid/unknown; consider to use -5 instead of Unset for this construction (yes, it's not in the enum, and it might be ok considering that it represents a "logic error" state where the object was not appropriately initialised).
I am even not sure whether I would do that, but as CAF maintainer I am bound to explain that this is the custom ([NA-01]).


SRCNNScore cnnscore; // CNN scores for this PFP

SRNuGraphScore ngscore; // NuGraph scores for this PFP
Copy link
Member

Choose a reason for hiding this comment

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

Doxy it!

Suggested change
SRNuGraphScore ngscore; // NuGraph scores for this PFP
SRNuGraphScore ngscore; ///< NuGraph scores for this PFP

(if you can, also the cnnscore one above)

Comment on lines 245 to 247
<class name="caf::SRPFP" ClassVersion="17">
<version ClassVersion="17" checksum="2252062519"/>
<version ClassVersion="16" checksum="135310109"/>
Copy link
Member

Choose a reason for hiding this comment

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

Please compress this into a single checksum:

Suggested change
<class name="caf::SRPFP" ClassVersion="17">
<version ClassVersion="17" checksum="2252062519"/>
<version ClassVersion="16" checksum="135310109"/>
<class name="caf::SRPFP" ClassVersion="16">
<version ClassVersion="16" checksum="2252062519"/>

Comment on lines 2 to 16
#include <limits>

namespace caf
{
SRNuGraphScore::SRNuGraphScore() :
sem_cat(NuGraphCategory::Unset),
mip_frac(std::numeric_limits<float>::signaling_NaN()),
hip_frac(std::numeric_limits<float>::signaling_NaN()),
shr_frac(std::numeric_limits<float>::signaling_NaN()),
mhl_frac(std::numeric_limits<float>::signaling_NaN()),
dif_frac(std::numeric_limits<float>::signaling_NaN()),
bkg_frac(std::numeric_limits<float>::signaling_NaN())
{
}
}
Copy link
Member

Choose a reason for hiding this comment

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

When following the recommendations on the constructor (below), not much is left here.

Suggested change
#include <limits>
namespace caf
{
SRNuGraphScore::SRNuGraphScore() :
sem_cat(NuGraphCategory::Unset),
mip_frac(std::numeric_limits<float>::signaling_NaN()),
hip_frac(std::numeric_limits<float>::signaling_NaN()),
shr_frac(std::numeric_limits<float>::signaling_NaN()),
mhl_frac(std::numeric_limits<float>::signaling_NaN()),
dif_frac(std::numeric_limits<float>::signaling_NaN()),
bkg_frac(std::numeric_limits<float>::signaling_NaN())
{
}
}

(in fact, the only reason to include a .cxx is to make sure that the header is compiled and checked)


class SRNuGraphScore {
public:
SRNuGraphScore();
Copy link
Member

Choose a reason for hiding this comment

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

Following the recommendation on the in-class initialization, this is not needed:

Suggested change
SRNuGraphScore();

Comment on lines 15 to 20
Unset = -1,
Mip = 0,
Hip = 1,
Shower = 2,
Michel = 3,
Diffuse = 4
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't MIP and HIP go all capital?
Also have some comment, e.g. to explain that MIP and HIP refer to a track-like object, what is "diffuse" meaning, that Michel is not the pianist...

Suggested change
Unset = -1,
Mip = 0,
Hip = 1,
Shower = 2,
Michel = 3,
Diffuse = 4
Unset = -1, ///< Unset/unknown/undecided/ category.
Mip = 0, ///< Track from a minimum-ionizing particle.
Hip = 1, ///< Track from a high ionization particle.
Shower = 2, ///< Particle shower.
Michel = 3, ///< Michel electron (from muon decay).
Diffuse = 4 ///< Diffuse background.

Still not sure how to define Diffuse.

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.

Just one fix to the documentation left.

Comment on lines 9 to 20
/**
* @brief Categorization of the object/PFP by NuGraph.
*
* This object summarizes the results from running NuGraph over hits in a slice
* (see e.g. [https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=40585](SBN DocDB 40585).
*
* The semantic category is the one that most hits belong to.
* The fractions describe the categorization of the hits in the object/PFP.
*/
namespace caf {

class SRNuGraphScore {
Copy link
Member

@PetrilloAtWork PetrilloAtWork May 8, 2025

Choose a reason for hiding this comment

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

The comment needs to be just before the object it's commenting about (in this code, the documentation would have been attached to the caf namespace):

Suggested change
/**
* @brief Categorization of the object/PFP by NuGraph.
*
* This object summarizes the results from running NuGraph over hits in a slice
* (see e.g. [https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=40585](SBN DocDB 40585).
*
* The semantic category is the one that most hits belong to.
* The fractions describe the categorization of the hits in the object/PFP.
*/
namespace caf {
class SRNuGraphScore {
namespace caf {
/**
* @brief Categorization of the object/PFP by NuGraph.
*
* This object summarizes the results from running NuGraph over hits in a slice
* (see e.g. [https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=40585](SBN
* DocDB 40585).
*
* The semantic category is the one that most hits belong to.
* The fractions describe the categorization of the hits in the object/PFP.
*/
class SRNuGraphScore {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ops...

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.

Thank you, Giuseppe.

@kjplows
Copy link
Contributor

kjplows commented May 8, 2025

trigger build

@FNALbuild
Copy link

✔️ CI build for LArSoft Succeeded on slf7 for e26:prof -- details available through the CI dashboard

@FNALbuild
Copy link

✔️ CI build for LArSoft Succeeded on slf7 for c14:prof -- details available through the CI dashboard

@FNALbuild
Copy link

❌ CI build for SBND Failed at phase build SBND on slf7 for c14:prof -- details available through the CI dashboard

🚨 For more details about the failed phase, check the build SBND phase logs

parent CI build details are available through the CI dashboard

@FNALbuild
Copy link

❌ CI build for ICARUS Failed at phase build ICARUS on slf7 for c14:prof -- details available through the CI dashboard

🚨 For more details about the failed phase, check the build ICARUS phase logs

parent CI build details are available through the CI dashboard

@FNALbuild
Copy link

⚠️ CI build for SBND Warning at phase ci_tests SBND on slf7 for e26:prof -- details available through the CI dashboard

🚨 For more details about the warning phase, check the ci_tests SBND phase logs

parent CI build details are available through the CI dashboard

@FNALbuild
Copy link

⚠️ CI build for ICARUS Warning at phase ci_tests ICARUS on slf7 for e26:prof - ignored failure for unit_test -- details available through the CI dashboard

🚨 For more details about the warning phase, check the ci_tests ICARUS phase logs

parent CI build details are available through the CI dashboard

@kjplows kjplows moved this from Testing to To merge in SBN software development May 8, 2025
@kjplows kjplows merged commit 8e68ee8 into SBNSoftware:develop May 8, 2025
@github-project-automation github-project-automation bot moved this from To merge to Done in SBN software development May 8, 2025
@kjplows kjplows moved this from Done to Recently done in SBN software development May 8, 2025
@kjplows kjplows moved this from Recently done to Done in SBN software development Jul 10, 2025
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: Done

Development

Successfully merging this pull request may close these issues.

5 participants