Skip to content

Conversation

@sungbinoh
Copy link
Contributor

@sungbinoh sungbinoh commented Oct 20, 2025

Adding a new StandardRecord SRTrkLikePID for likelihood-based PID variables.
It saves sum of the normalized log likelihood (lambda = -lnL/L_max) for muon, charged pion and proton hypotheses.

Relevant PR in larana is PR41.
Also relevant: SBNSoftware/sbncode#593

Copy link
Member

@henrylay97 henrylay97 left a comment

Choose a reason for hiding this comment

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

Couple of comments, one critical, one not.

You also need to request a review from either @JosiePaton or @PetrilloAtWork as it affects the CAF data format.

@sungbinoh sungbinoh changed the title Feature/sungbino likepid into cafmaker Adding SRTrkLikelihoodPID class into the StandardRecord Oct 21, 2025
@sungbinoh
Copy link
Contributor Author

Couple of comments, one critical, one not.

You also need to request a review from either @JosiePaton or @PetrilloAtWork as it affects the CAF data format.

Hi @henrylay97 , thank you for the review!
Please have a look to my responses to your comments.
In addition, requesting a review from @PetrilloAtWork too!

Copy link
Member

@henrylay97 henrylay97 left a comment

Choose a reason for hiding this comment

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

Looking good. Thanks for updating the name.

I'm still being picky about defaults sorry!

Comment on lines 14 to 31
SRTrkLikelihoodPID::SRTrkLikelihoodPID():
pdg(-999),
pid_ndof(-99),
lambda_muon(std::numeric_limits<float>::signaling_NaN()),
lambda_pion(std::numeric_limits<float>::signaling_NaN()),
lambda_proton(std::numeric_limits<float>::signaling_NaN())
{ }

SRTrkLikelihoodPID::~SRTrkLikelihoodPID(){ }

void SRTrkLikelihoodPID::setDefault()
{
pdg = -5;
pid_ndof = -5;
lambda_muon = -5.0;
lambda_pion = -5.0;
lambda_proton = -5.0;
}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to be picky. I still don't like that we have default values set in 3 places. In the default constructor, in the setDefault function and in the corresponding sbncode PR they get set explicitly when making the object.

I like the defaults used in the default constructor here so my suggestion is to remove the other two instances completely. For this PR this means removing the setDefault() function, it doesn't appear to be used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @henrylay97 , no problem at all!
I've removed the other two places setting the default values, also removing void SRTrkLikelihoodPID::setDefault().

Copy link
Member

Choose a reason for hiding this comment

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

I don't like it either, but there was a rationale that aimed to distinguish data that was never initialised (values from constructor), and the data that was defaulted by the user (setDefault()).
Without the former, if code omits an initialisation we end up with random values in the data files, and when we try comparing two versions of data we may see red-herring differences because of that.

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.

I have left some comments.
@henrylay97 has a (partially) different opinion on initialisation than I do, and you are getting caught in the middle... but uninitialised data is bad, so we need to avoid it.

Comment on lines 1 to 5
////////////////////////////////////////////////////////////////////////
// \file SRTrkLikelihoodPID.cxx
// \brief An SRTrkLikelihoodPID is a high level track ParticlePID object for
// for larana LikelihoodPIDAlg results.
////////////////////////////////////////////////////////////////////////
Copy link
Member

Choose a reason for hiding this comment

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

Please turn this into a Doxygen comment and add your name for glory/blame:

Suggested change
////////////////////////////////////////////////////////////////////////
// \file SRTrkLikelihoodPID.cxx
// \brief An SRTrkLikelihoodPID is a high level track ParticlePID object for
// for larana LikelihoodPIDAlg results.
////////////////////////////////////////////////////////////////////////
/**
* @file sbnanaobj/StandardRecord/SRTrkLikelihoodPID.cxx
* @brief An `SRTrkLikelihoodPID` is a high level track ParticlePID object for
* for larana LikelihoodPIDAlg results.
* @author Sungbin Oh
*/

(you can add your e-mail in the @author line if you are comfortable with it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated following the suggested change.
(added my email tooo :) )

Copy link
Member

Choose a reason for hiding this comment

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

Good! If you can fix the repeated "for" in the brief description it's even better.

Comment on lines 14 to 31
SRTrkLikelihoodPID::SRTrkLikelihoodPID():
pdg(-999),
pid_ndof(-99),
lambda_muon(std::numeric_limits<float>::signaling_NaN()),
lambda_pion(std::numeric_limits<float>::signaling_NaN()),
lambda_proton(std::numeric_limits<float>::signaling_NaN())
{ }

SRTrkLikelihoodPID::~SRTrkLikelihoodPID(){ }

void SRTrkLikelihoodPID::setDefault()
{
pdg = -5;
pid_ndof = -5;
lambda_muon = -5.0;
lambda_pion = -5.0;
lambda_proton = -5.0;
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't like it either, but there was a rationale that aimed to distinguish data that was never initialised (values from constructor), and the data that was defaulted by the user (setDefault()).
Without the former, if code omits an initialisation we end up with random values in the data files, and when we try comparing two versions of data we may see red-herring differences because of that.

public:

SRTrkLikelihoodPID();
virtual ~SRTrkLikelihoodPID();
Copy link
Member

Choose a reason for hiding this comment

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

Remove the destructor, since it does not do anything (CF-151).
Also I would like to know if you copied that idea from anywhere in our code, so that we can fix that too.

Suggested change
virtual ~SRTrkLikelihoodPID();

[edit] I guess that's SRTrkChi2PID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the destructor in both .h and .cxx.
And yes, I've copied a structure in SRTrkChi2PID .

virtual ~SRTrkLikelihoodPID();

int pdg; ///< Likelihood PID pdg
int pid_ndof; ///< Number of degress of freedom in likelihood PID
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int pid_ndof; ///< Number of degress of freedom in likelihood PID
int pid_ndof; ///< Number of degrees of freedom in likelihood PID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the space

Comment on lines 1 to 3
////////////////////////////////////////////////////////////////////////
// \file SRTrkLikelihoodPID.h
////////////////////////////////////////////////////////////////////////
Copy link
Member

Choose a reason for hiding this comment

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

Please turn this comment block into Doxygen format:

Suggested change
////////////////////////////////////////////////////////////////////////
// \file SRTrkLikelihoodPID.h
////////////////////////////////////////////////////////////////////////
/**
* @file sbnanaobj/StandardRecord/SRTrkLikelihoodPID.h
* @brief An `SRTrkLikelihoodPID` is a high level track ParticlePID object for
* for larana LikelihoodPIDAlg results.
* @author Sungbin Oh
*/

(like in the class implementation file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to the suggested change.

@sungbinoh
Copy link
Contributor Author

sungbinoh commented Oct 28, 2025

Hi @PetrilloAtWork , thanks a lot for your review.
I have made updates following your comments.

For default values, I am reviving void SRTrkLikelihoodPID::setDefault() function.
In sbncode , I have added this function in FillReco.cxx so that variables to be initialized with values in the void SRTrkLikelihoodPID::setDefault(). Pinging @henrylay97 for this update!

@kjplows kjplows moved this to Partially reviewed in SBN software development Nov 4, 2025
@sungbinoh
Copy link
Contributor Author

sungbinoh commented Nov 18, 2025

Hi @PetrilloAtWork , suggested update for class_def.xml is committed!
Thank you!

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.

Approved.

Copy link
Member

@henrylay97 henrylay97 left a comment

Choose a reason for hiding this comment

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

One technical change still needed, but with that addressed I'm happy to approve.

@sungbinoh
Copy link
Contributor Author

sungbinoh commented Nov 19, 2025

One technical change still needed, but with that addressed I'm happy to approve.

Hi @henrylay97 , the suggested update is committed. Thank you!

@kjplows kjplows moved this from Partially reviewed to Testing in SBN software development Nov 20, 2025
@kjplows
Copy link
Contributor

kjplows commented Nov 20, 2025

trigger build LArSoft/lar*@LARSOFT_SUITE_v10_12_02

@kjplows kjplows moved this from Testing to Urgent checks in SBN software development Nov 20, 2025
@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 LArSoft Succeeded on slf7 for e26: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 - ignored warnings for build -- 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 Failed at phase ci_tests ICARUS on slf7 for e26:prof - ignored warnings for build -- details available through the CI dashboard

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

parent CI build details are available through the CI dashboard

@kjplows kjplows moved this from Urgent checks to To merge in SBN software development Nov 20, 2025
@kjplows kjplows moved this to RM Approved in SBND 2025 Fall Production Nov 20, 2025
@kjplows kjplows merged commit f1ff49c into SBNSoftware:develop Nov 21, 2025
@github-project-automation github-project-automation bot moved this from To merge to Done in SBN software development Nov 21, 2025
@kjplows kjplows moved this from Done to Recently done in SBN software development Nov 21, 2025
@nathanielerowe nathanielerowe moved this from RM Approved to In tagged release in SBND 2025 Fall Production Nov 22, 2025
@kjplows kjplows moved this from Recently done to Done in SBN software development Dec 8, 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
Status: In tagged release

Development

Successfully merging this pull request may close these issues.

5 participants