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

Persist Slice BDT Inputs #189

Conversation

henrylay97
Copy link
Contributor

Add the functionality to persist the features used in the slice ID MVA but only with an opt-in xml parameter, should have no change to current functionality.

Comment on lines +428 to +438
m_featureMap["NuNFinalStatePfos"] = nuNFinalStatePfos;
m_featureMap["NuNHitsTotal"] = nuNHitsTotal;
m_featureMap["NuVertexY"] = nuVertexY;
m_featureMap["NuWeightedDirZ"] = nuWeightedDirZ;
m_featureMap["NuNSpacePointsInSphere"] = nuNSpacePointsInSphere;
m_featureMap["NuEigenRatioInSphere"] = nuEigenRatioInSphere;
m_featureMap["CRLongestTrackDirY"] = crLongestTrackDirY;
m_featureMap["CRLongestTrackDeflection"] = crLongestTrackDeflection;
m_featureMap["CRFracHitsInLongestTrack"] = crFracHitsInLongestTrack;
m_featureMap["CRNHitsMax"] = nCRHitsMax;

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not necessarily a comment for now but it would be 'nice' for this to be automated in such a way that we don't have to manually append lines here if we come up with new features.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I discussed this offline with @AndyChappell but without significant changes to the MvaFeatureVector there didn't seem to be an obvious clean way of achieving this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess one way would be not creating the interim variables (like nuFinalStatePfos) and instead storing the calculations straight onto the map. There would need to be some cleanup functionality to nuke the map if an exception gets thrown though...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, in principle we could populate the map as each variable is defined/updated and then populate the feature vector from the map. You do then lose some of the intuitiveness of the variable types from declaring everything as a double, but maybe reduces the chance that you miss a variable in any update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to implement this change if you think this would be better. I think in some ways it will becomes less obvious to follow the logic but as you say it may protect from future mistakes in adding variables.

Copy link
Collaborator

@AndyChappell AndyChappell Jan 27, 2022

Choose a reason for hiding this comment

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

I have mixed views about it, would be curious to hear @johnmarshall80 's thoughts?

Copy link
Owner

Choose a reason for hiding this comment

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

Hmmm, can't think of anything great immediately. Could (although it could be easily subverted) just pass the addition to the vector and map over to a member function? E.g. This would take the string and the double, and just do the vector push back and map insertion, via operator[]?

At the moment it doesn't look like any of this has any explicit error handling, but you could of course have the calls to this member function (to add to map and vector) within a try/catch block, with both map and vector wiped clean if there's a relevant exception raised for any one feature?

(Note that BeamParticleId tool currently very similar implementation, but presumably up to e..g ProtoDUNE if they'd like these features persisted too, then would need to follow approach chosen here.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is probably something for a tidying up PR. I noticed that there's a hardcoded magic number a little about here (line 395 in Henry's PR). So, there could for sure be a bit of sprucing up. Addressing this could be done as part of that sprucing.

@absolution1
Copy link
Collaborator

Looks nice to me @henrylay97
I added an opinion to mull over but doesn't need to be enacted on now.

@@ -255,13 +256,33 @@ void NeutrinoIdTool<T>::SelectPfosByProbability(const pandora::Algorithm *const
{
object_creation::ParticleFlowObject::Metadata metadata;
metadata.m_propertiesToAdd["NuScore"] = nuProbability;

if (m_persistFeatures)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will need a run through clang format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

@@ -147,6 +154,7 @@ class NeutrinoIdTool : public SliceIdBaseTool

bool m_isAvailable; ///< Is the feature vector available
LArMvaHelper::MvaFeatureVector m_featureVector; ///< The MVA feature vector
std::map<std::string, double> m_featureMap; ///< A map between MVA features and their names
Copy link
Owner

Choose a reason for hiding this comment

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

Could add a typedef for this, as per LArMvaHelper::MvaFeatureVector above, and use throughout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

@@ -259,6 +267,9 @@ class NeutrinoIdTool : public SliceIdBaseTool
float m_minProbability; ///< Minimum probability required to classify a slice as the neutrino
unsigned int m_maxNeutrinos; ///< The maximum number of neutrinos to select in any one event

// Persistence
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary, I'd say, already covered by comment attached to member variable below.

@brucehoward-physics
Copy link
Contributor

Hey all - wanted to check in on the status of this PR? Sorry for bothering but have been following a bit and have not seen comments in a bit so wanted to check :) thanks in advance for info!

@AndyChappell
Copy link
Collaborator

Hi Bruce, I'll look to merge this one in either at the end of this week or the beginning of next, so hopefully it will be available via next week's LArSoft release.

@brucehoward-physics
Copy link
Contributor

Thanks for the update!

@henrylay97 henrylay97 force-pushed the feature/hlay_persist_slice_bdt_inputs branch from 4b38ac3 to 6a2a994 Compare February 11, 2022 09:39
@AndyChappell AndyChappell changed the base branch from master to feature/larpandoracontent_v03_26_04 February 11, 2022 12:48
@AndyChappell AndyChappell merged commit 9495e76 into PandoraPFA:feature/larpandoracontent_v03_26_04 Feb 11, 2022
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.

5 participants