-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feature/howard v09370103p01 nuid features #44
Feature/howard v09370103p01 nuid features #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have requested one change (removal of the destructor).
Other suggestions are up to the author.
One more generic one is that the recommended name convention is using the drinking camel-case ([NV-05]
), e.g. nuTotHits
(instead of nutothits
). I recommend that convention to be adopted, but I don't understand most of the names so I don't know if they are... camelcaseable.
sbnanaobj/StandardRecord/SRNuID.h
Outdated
{ | ||
public: | ||
SRNuID(); | ||
virtual ~SRNuID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that there is no virtual method in this data class, there is no reason for it to be polymorphic, so the destructor should not be virtual. Hence, there should be no destructor at all ([CF-151]
).
So I request the destructor to be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
class SRNuID | ||
{ | ||
public: | ||
SRNuID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend the practice of assigning values to the data members directly rather than via a constructor
([CF-156]
).
That habit makes it easier not to forget to initialize a data field when adding it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the recommendation to explicitly write
float nufspfos { std::numeric_limits<float>::signaling_NaN() }; //!< NuNFinalStatePfos feature in NeutrinoID
etc. and remove the setting in the constructor? Just checking that I understand the comment and convention correctly. (Other SR code that I saw uses the constructor-setting.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use =
there instead of {}
, but I admit I have no idea of the distinction, if any, between them. =
just seems more intuitive to me.
See also this issue #24 in the long tradition of heaping extra work on people who ask questions. It would probably be a good idea to get a kSignalingNaN
or whatever before we totally uglify the headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm that, beyond the choice of syntax, the recommendation is the one @brucehoward-physics described.
We do have a guideline ([CF-060]
) suggesting the use of braces. That is intended as a tie-breaker in case your mind is stuck on a tie.
Some differences between =
and {}
syntax (whose nickname "universal initialization" betrays its ambition) for simple type data member initialization are that the latter will complain about "narrowing" (for example if you try to assign a double
value to a float
variable), and that it allows explicit default initialization, for example:
unsigned short int fNADC {};
short int fADC[16] {};
will initialize fNADC
to 0
and all fADC
to 0
too (with no initializer, both are undefined). You can obtain the same effect with = 0
and = { 0 }
respectively.
Not much difference for simple types, then. When object data members are involved, braces are a superior option (but usually equivalent to parentheses, except for noticeable exceptions like std::vector<int>
and for its role in the most vexing parse).
I try to use braces mostly because since it's newer syntax it makes me look smarter. But my official excuse is that it's more uniform so I can usually manage to have only one type of syntax (available: int a = 0;
, int a (0);
, int a { 0 };
, int a = { 0 };
; so yeah, {}
is the new universal standard).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay - have pushed commits which add a central kSignalingNaN
and applies it to SRSlice and SRNuID (I didn't touch the other StandardRecord objects).
I have it set up to use braces. There are some items which are not seemingly not being forced to initialize in SRSlice. Shall I add an empty {}
here too?
sbnanaobj/StandardRecord/SRNuID.cxx
Outdated
SRNuID::~SRNuID(){ } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless, sometimes deleterious ([CF-151]
): please remove (see later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
sbnanaobj/StandardRecord/SRNuID.cxx
Outdated
#include "sbnanaobj/StandardRecord/SRNuID.h" | ||
|
||
#include <limits> | ||
#include <climits> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think climits
is needed here.
#include <climits> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
believe this is now ✅ - I mean this particular change was made but now I also made changes in SRSlice, in the process of addressing other comments.
sbnanaobj/StandardRecord/SRNuID.h
Outdated
#ifndef SRNUID_H | ||
#define SRNUID_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest having a definition name less easy to collide with, e.g.
#ifndef SRNUID_H | |
#define SRNUID_H | |
#ifndef SBNANAOBJ_STANDARDRECORD_SRNUID_H | |
#define SBNANAOBJ_STANDARDRECORD_SRNUID_H |
(if changed, also change the matching #endif
accordingly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed what I saw in other Standard Record objects but no harm in changing this! Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
sbnanaobj/StandardRecord/SRNuID.cxx
Outdated
//////////////////////////////////////////////////////////////////////// | ||
// \file SRNuID.cxx | ||
// \brief SRNuID object for Neutrino ID score features (MVA inputs). This SR code copied/based on other SR objects. | ||
// \author $Author: howard@fnal.gov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$Author
is a remnant of CVS of no meaning.
// \author $Author: howard@fnal.gov | |
// \author howard@fnal.gov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
sbnanaobj/StandardRecord/SRNuID.h
Outdated
//////////////////////////////////////////////////////////////////////// | ||
// \file SRNuID.h | ||
// \brief SRNuID object for Neutrino ID score features (MVA inputs). This SR code copied/based on other SR objects. | ||
// \author $Author: howard@fnal.gov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// \author $Author: howard@fnal.gov | |
// \author howard@fnal.gov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@PetrilloAtWork we have a conflicting convention of all-lowercase field names in StandardRecord. I'm not sure if that got documented in the guidelines anywhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good! I know this has been discussed before so I'll just throw my two pence in here and say I preferred the capitalisation in the names of the variables. A couple are quite difficult to parse now and things like nufspfos
or nusps
aren't particularly obvious if you haven't got the pandora tools open in front of you!
Thanks for the reviews! I'm happy to follow whatever the convention is. I'll note that in general these things are following what I saw in other Standard Record object(s) so I think perhaps several conventions are being broken in Standard Record 😅 . With the names, I adopted Chris's suggestion to use lower case names in the Standard Record. I originally had longer, camel-cased names. |
…nalingNaN to centralize the signaling NaN (right now just used in SRSlice and SRNuID), could be extended further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more language comments and a question for @cjbackhouse.
Nothing show-stopping though.
SRNuID::SRNuID() | ||
{ } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given its emptiness, the constructor can be removed, unless there is the explicit intention of forbidding aggregate initialization (which I would not forbid).
So I recommend removing the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed your comments before finalizing my statement below. There is no intent from me here, but other Standard Record objects have empty constructors apart from variable assignment. Does this carry the same impact w.r.t. aggregate initialization? If it does then I defer to @cjbackhouse and/or @FernandaPsihas to add their opinion. If not, then I guess these could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no opinion either way about empty constructors.
sbnanaobj/StandardRecord/SRHelper.h
Outdated
|
||
namespace caf | ||
{ | ||
const float kSignalingNaN = std::numeric_limits<float>::signaling_NaN(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend setting it constexpr
:
const float kSignalingNaN = std::numeric_limits<float>::signaling_NaN(); | |
constexpr float kSignalingNaN = std::numeric_limits<float>::signaling_NaN(); |
This other one is more for @cjbackhouse: is it ok to tie the name kSignalingNaN
to a float
value? do you foresee an use for the double
counterpart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! - Only tested in that it builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I do indeed think that we might one day want a double version (I normally resist doubles in the CAFs, but there are potentially legitimate reasons for one). If you assign this into a double, does the double end up NaN too, or not?
Since double will be so much rarer I think having a clunkier name like kSignalingNaNDouble
for it would be ok.
nu_pdg(INT_MIN), | ||
nu_score(std::numeric_limits<float>::signaling_NaN()), | ||
self(INT_MIN) | ||
SRSlice::SRSlice() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for the other class: an empty default constructor impedes some language features, and unless that is intended (in which case it would be good to add a comment stating it), the empty constructor is better gone.
SRSlice::SRSlice() |
I believe I have addressed most of the comments and tested all but the very last (pretty simple) commit on a single event, confirming at least that things ran and the SRNuID values in the output CAF file are set the same as they were when I started this PR. Remaining items I am currently thinking of, please note if I'm missing something:
|
Re the naming convention, I suspect there is a naming convention in Re the initialization and constructors, @FernandaPsihas and @cjbackhouse can comment. My quite strong opinion is that all data classes should move to initialisation with their declaration in the class definition, and no constructor nor destructor, unless there are specific reasons to do otherwise. While the presence of the virtual destructor has a visible impact on runtime (the data structures are one pointer larger) the change I am describing here on the construction has none, so it should not delay the merging. I still solicit a decision for the future. |
sbnanaobj/StandardRecord/SRHelper.h
Outdated
@@ -0,0 +1,11 @@ | |||
#ifndef SBNANAOBJ_STANDARDRECORD_SRHELPER_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like SRHelper
as a name. Maybe SRConstants
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - checked only in that it builds.
All looks good to me, apart from a comment about the filename. Which fields in SRSlice are uninitialized? Anything that's an object, or a vector of anything, will default initialize properly. I have no problem with moving all the initialization into the headers and removing most (all?) of the constructors. I think you just volunteered to do the grunt work Gianluca 😛 There is indeed a local naming convention in force. We should formalize it somewhere and debate some of its darker corners. |
@cjbackhouse
Yeah in SRSlice they are objects or vectors, so okay cool. |
Okay added |
Updated PR that uses v09_37 series as the base. Requires changes in larpandoracontent to be useful.