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

Bug fix where no vertex exists #146

Conversation

absolution1
Copy link
Collaborator

Figured it might be easier to discuss this in a PR than on slack

Copy link
Owner

@PandoraPFA PandoraPFA left a comment

Choose a reason for hiding this comment

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

Many thanks @absolution1 - main comment about the LArMvaHelper::MvaFeature.

}
catch (const StatusCodeException &) {}
}

if (error)
else if (!pVertexList->empty())
Copy link
Owner

Choose a reason for hiding this comment

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

So e.g. if (!vertexDistance.IsInitialized() && .. && etc...)

{
CaloHitList threeDCaloHitList;
LArPfoHelper::GetCaloHits(pInputPfo, TPC_3D, threeDCaloHitList);
vertexDistance = (pVertexList->front()->GetPosition() - (threeDCaloHitList.front())->GetPositionVector()).GetMagnitude(); // if n3dHits == 1, can't calculate vertex postion of input pfos hence ask for the position of the single 3D hit instead and set vertexDistance to be the magnitude of the difference between the interaction vertex and the hit's position.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggest lose this comment, and add a commit to correct any whitespace/indentation in the file, thank you.

}

featureVector.push_back(vertexDistance);
featureVector.push_back(std::numeric_limits<LArMvaHelper::MvaFeature>::lowest());
Copy link
Owner

Choose a reason for hiding this comment

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

So an uninitialised vertexDistance should be what is wanted here, but obviously tests required.

@@ -460,6 +460,7 @@ void ThreeDVertexDistanceFeatureTool::Run(LArMvaHelper::MvaFeatureVector &featur
if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;

LArMvaHelper::MvaFeature vertexDistance;
const VertexList *pVertexList(nullptr);
(void) PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);

Copy link
Owner

@PandoraPFA PandoraPFA Oct 16, 2020

Choose a reason for hiding this comment

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

What do you think about i) checking whether pVertexList is not nullptr here, and ii) checking to see whether the list isn't empty, up front, here? Because can't calculate vertexDistance below if there's no vertex. Could then remove some vertex checks below, but that might actually make implementation less robust against future changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good shout, doing the sanity checks earlier is more in keeping with the other pandora code snippets I've seen.
I've added this in.
One point, I've slightly broken the style of the function ie. the vertex list sanity check fills the feature vector and returns. However, the more complicated checks still only set vertexDistance and then wait for the final push_back at the end of the function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the update above to get the MvaFeature type consistency for the vertex distance, the value used has been reset to zero in the case where the vertex list is empty, which, from discussion elsewhere, I think is not what is wanted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

H @AndyChappell
My intention was to return a default-initialised vertexDistance when the actual vertex distance couldn't be calculated, which I think is what the original code tried to do. Is that not the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I saw the email notification for your other comment (but cannot find it here bizarrely).
The very original plan was to return an extreme value for a default but that was before I knew that the type was wrapped in an initialisation bool. So, I opted to preserve how the original code handled defaults.

Copy link
Owner

@PandoraPFA PandoraPFA left a comment

Choose a reason for hiding this comment

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

This looks good to me now (one small cosmetic comment). We should't merge this until we've discussed with @AndyChappell (who's looking after the big picture right now), but if you want this for rapid testing, can push to a nicely-named feature branch?

const VertexList *pVertexList(nullptr);
(void) PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);

if (!pVertexList || pVertexList->empty()){
Copy link
Owner

Choose a reason for hiding this comment

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

Typical style is to have the brace { on the next line 😄

@absolution1
Copy link
Collaborator Author

I've rebased my commits so the comments are probably going to be a bit mangled...

@absolution1 absolution1 changed the base branch from master to feature/larpandoracontent_v03_21_01 October 19, 2020 13:06
Copy link
Collaborator

@AndyChappell AndyChappell left a comment

Choose a reason for hiding this comment

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

Happy with the fix

@AndyChappell AndyChappell merged commit 5b1c607 into PandoraPFA:feature/larpandoracontent_v03_21_01 Oct 19, 2020
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.

3 participants