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

Bugfixes in SLDCorrection #143

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Bugfixes in SLDCorrection #143

wants to merge 3 commits into from

Conversation

nVentis
Copy link

@nVentis nVentis commented Nov 5, 2024

BEGINRELEASENOTES

  • fixed segfaults in SLDCorrection:
  • affects all versions: implemented checks if assumed elements exist
  • affects recent key4hep versions: delete of histograms crashing the end method

ENDRELEASENOTES

Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

Thanks, especially also for documenting some parts. I have a few comments / questions, see below.

@@ -33,6 +33,12 @@ int getRecoFlightDirection( const RecoParticle &linkedRecoLepton , TVector3 &rec
daughterHadronFlightDistance = 0.0;
daughterHadronFlightDirection = TVector3( 0.0 , 0.0 , 0.0 );
sldVertexPosition.clear();
if ( linkedRecoLepton->getTracks().size() == 0 )
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ( linkedRecoLepton->getTracks().size() == 0 )
if ( linkedRecoLepton->getTracks().empty() )

This is the recommended (and more readable) way for checking whether a vector has no elements.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! Will include this suggestion here and everywhere where the same check occurs.

@@ -801,7 +801,7 @@ void SLDCorrection::init()
m_pTTree1->Branch( "DSVDistanceFromPV" , &m_DSVDistanceFromPV );
m_pTTree1->Branch( "Lepton3DImpactParameter" , &m_Lepton3DImpactParameter );
m_pTTree1->Branch( "OtherParticle3DImpactParameter" , &m_OtherParticle3DImpactParameter );
h_SLDStatus = new TH1I( "SLDStatus" , ";" , 7 , 0 , 7 );
h_SLDStatus = new TH1I( "SLDStatus" , ";" , 8 , -1 , 7 );
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the number of bins should change here as well? Or was it incorrect before? I suppose the main reason for doing this is to have access to things that haven't been classified into any of the pre-assigned categories? However, the previous version had that already if you use the under-/overflow bins.

Copy link
Author

Choose a reason for hiding this comment

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

Before, the values were before 0/7, now -1/7 (throughout the code, floats are inserted, i.e. 0.5 -> 1. I didn't change this). According to here the third argument is the bin count, so it should be fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, thanks for the clear up. I was once more confusing the order of arguments in the TH1I constructor. But as far as I can see there is no actual need for a negative bin with value -1? h_SLDStatus is only filled with the values -0.5, 0.5 and 1.5 at the moment.

Comment on lines -3539 to -3571
delete h_SLDStatus;
delete h_BHadronType;
delete h_CHadronType;
delete h_NuPxResidual;
delete h_NuPyResidual;
delete h_NuPzResidual;
delete h_NuEResidual;
delete h_NuPxNormalizedResidual;
delete h_NuPyNormalizedResidual;
delete h_NuPzNormalizedResidual;
delete h_NuENormalizedResidual;
delete h_recoNuPx_mcNuPx;
delete h_recoNuPy_mcNuPy;
delete h_recoNuPz_mcNuPz;
delete h_recoNuE_mcNuE;
delete h_parentPx_daughtersPx;
delete h_parentPy_daughtersPy;
delete h_parentPz_daughtersPz;
delete h_parentE_daughtersE;
delete h_recoPFOLinkedToElectron_Type;
delete h_recoPFOLinkedToMuon_Type;
delete h_SLDecayFlavour;
delete h_SLDecayModeB;
delete h_SLDecayModeC;
delete h_SLDecayOrder;
delete h_foundVertex;
delete h_secondaryVertex;
delete h_parentHadronCharge;
delete h_MCPTracks;
delete h_MCPTracks_Eweighted;
delete h_MCPTracks_Ptweighted;
delete h_FlightDirectionError;
delete h_distRecoLeptonToDownStreamVertex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these removed?

Copy link
Author

Choose a reason for hiding this comment

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

In older key4hep releases (e.g. 2024-04-10), there were no problems with the histograms, but in a more recent stack (e.g. 2024-10-XX), I had segfaults related to the ::end method of the SLD Correction. This affected the output of other processors as well. Maybe there was a change in how ROOT keeps track of stuff in between?
When I removed the delete statements, it was working fine.

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.

2 participants