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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Analysis/SLDCorrection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ Green histograms are used to estimate the overall uncertainty due to neutrino co

sigmaAlphaNu = 0.100 rad , sigmaENu = 4.0 GeV

In the end, neutrinos are assumed to be massless and sigmaAlphaNu and sigmaENu are transformed to a covariance matrix in (p,E) space.
In the end, neutrinos are assumed to be massless and sigmaAlphaNu and sigmaENu are transformed to a covariance matrix in (p,E) space.

### SLDStatus Reference
| SLDStatus | Interpretation |
|-----------|-------------------------------------------------|
| 0 | PrimaryVertex collection found, but empty |
| 1 | Reconstructed Lepton is not found |
| 2 | Reconstructed Lepton doesn't belong to any jet |
| 3 | Infer SLD from reconstructed lepton in primary vertex |
| 4 | Infer SLD from reconstructed lepton in a secondary (BuildUp) Vertex. |
| 5 | Infer SLD frmo BuildUp Vertex in a jet. Intersection point of Lepton and other BuildUp Vertices in jet is used as vertex of semi-leptonic decay. |
| 6 | Inferred from lepton track alone. |
| 7 | other |

In the h_SLDStatus histogram, these values are inserted with a shift of -0.5
9 changes: 6 additions & 3 deletions Analysis/SLDCorrection/src/FlightDirection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

{
streamlog_out(DEBUG1) << " (" << SLDStatus << ") No track for linkedRecoLepton. SLDCorrection aborts." << std::endl;
return SLDStatus;
}

if ( recoLeptonIsInVertex )
{
SLDStatus = 4;
Expand Down Expand Up @@ -116,9 +122,6 @@ int getRecoFlightDirection( const RecoParticle &linkedRecoLepton , TVector3 &rec
// thirdVertex = testVertex;
//}
}
if ( thirdVertex != NULL )
{
}
}
else
{
Expand Down
49 changes: 14 additions & 35 deletions Analysis/SLDCorrection/src/SLDCorrection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

h_SLDStatus->GetXaxis()->SetBinLabel(1,"No #font[32]{l}^{REC}" );
h_SLDStatus->GetXaxis()->SetBinLabel(2,"#font[32]{l}#notin^{}jet" );
h_SLDStatus->GetXaxis()->SetBinLabel(3,"#font[32]{l}#in^{}Vtx^{Prim.}" );
Expand Down Expand Up @@ -1743,6 +1743,18 @@ void SLDCorrection::doSLDCorrection( EVENT::LCEvent *pLCEvent , const MCP &SLDLe
LCRelationNavigator RecoMCParticleNav( pLCEvent->getCollection( m_RecoMCTruthLinkCollection ) );
LCRelationNavigator MCParticleRecoNav( pLCEvent->getCollection( m_MCTruthRecoLinkCollection ) );
LCCollection *primaryVertexCollection = pLCEvent->getCollection( m_inputPrimaryVertex );

int SLDStatus = -999;
if ( primaryVertexCollection->getNumberOfElements() == 0 )
{
SLDStatus = 0;
streamlog_out(WARNING) << " ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" << std::endl;
streamlog_out(WARNING) << " ||||||||||||||||||||| PrimaryVertex is not found |||||||||||||||||||||" << std::endl;
streamlog_out(WARNING) << " ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" << std::endl;
if ( m_fillRootTree ) h_SLDStatus->Fill( -0.5 );
return;
}

Vertex* primaryVertex = dynamic_cast<Vertex*>( primaryVertexCollection->getElementAt( 0 ) );
Vertex* startVertex = dynamic_cast<Vertex*>( primaryVertexCollection->getElementAt( 0 ) );
LCCollection *jetCollection = pLCEvent->getCollection( m_inputJetCollection );
Expand Down Expand Up @@ -1995,7 +2007,6 @@ void SLDCorrection::doSLDCorrection( EVENT::LCEvent *pLCEvent , const MCP &SLDLe
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

int SLDStatus = -999;
if ( linkedRecoLepton == NULL )
{
SLDStatus = 1;
Expand Down Expand Up @@ -3536,39 +3547,7 @@ void SLDCorrection::end()
h_secondaryVertex->GetYaxis()->SetTitle("#SLDecay [%]");
h_secondaryVertex->Write();
m_pTFile->Close();
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;
Comment on lines -3539 to -3571
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.


delete m_pTFile;
}
}
Loading