-
Notifications
You must be signed in to change notification settings - Fork 225
Updates to HFTrackEfficiency and KFParticle #4259
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
base: master
Are you sure you want to change the base?
Changes from all commits
e92fee9
02d2278
80d3dea
55d4b1a
fd05ef9
dd98db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -215,6 +215,14 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) | |||||||||||||||||
| m_true_mother_p = std::sqrt(std::pow(mother->momentum().px(), 2) + std::pow(mother->momentum().py(), 2) + std::pow(mother->momentum().pz(), 2)); // Must have an old HepMC build, no mag function | ||||||||||||||||||
| m_true_mother_eta = mother->momentum().eta(); | ||||||||||||||||||
| m_true_mother_phi = mother->momentum().phi(); | ||||||||||||||||||
| if (mother->momentum().e() > abs(mother->momentum().pz())) | ||||||||||||||||||
| { | ||||||||||||||||||
| m_true_mother_rapidity = 0.5 * log((mother->momentum().e() + mother->momentum().pz())/(mother->momentum().e() - mother->momentum().pz())); | ||||||||||||||||||
| } | ||||||||||||||||||
| else | ||||||||||||||||||
| { | ||||||||||||||||||
| m_true_mother_rapidity = -999.; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| HepMC::GenVertex *thisVtx = mother->production_vertex(); | ||||||||||||||||||
| m_primary_vtx_x = thisVtx->point3d().x(); | ||||||||||||||||||
|
|
@@ -241,6 +249,7 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) | |||||||||||||||||
| std::abs(decay[i].second)) != std::end(trackableParticles)) | ||||||||||||||||||
| { | ||||||||||||||||||
| ++index; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (theEvent && decay[i].first.second > -1) | ||||||||||||||||||
| { | ||||||||||||||||||
| HepMC::GenParticle *daughterHepMC = theEvent->barcode_to_particle(decay[i].first.second); | ||||||||||||||||||
|
|
@@ -297,8 +306,75 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) | |||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (motherG4->get_pid() == decay[0].second && motherG4->get_barcode() == decay[0].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second) | ||||||||||||||||||
| if (motherG4->get_pid() == decay[0].second && motherG4->get_barcode() == decay[0].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second && m_nDaughters == 2) | ||||||||||||||||||
| { | ||||||||||||||||||
| if (Verbosity() >= VERBOSITY_MORE || true) // fix later | ||||||||||||||||||
| { | ||||||||||||||||||
| daughterG4->identify(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+311
to
+314
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug code left in: The condition Proposed fix- if (Verbosity() >= VERBOSITY_MORE || true) // fix later
+ if (Verbosity() >= VERBOSITY_MORE)
{
daughterG4->identify();
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| m_is_primary = m_truthInfo->is_sPHENIX_primary(motherG4); | ||||||||||||||||||
|
|
||||||||||||||||||
| CLHEP::Hep3Vector *mother3Vector = new CLHEP::Hep3Vector(motherG4->get_px(), motherG4->get_py(), motherG4->get_pz()); | ||||||||||||||||||
| motherTrueLV->setVectM((*mother3Vector), getParticleMass(decay[0].second)); | ||||||||||||||||||
| m_true_mother_pT = motherTrueLV->perp(); | ||||||||||||||||||
| m_true_mother_p = mother3Vector->mag(); | ||||||||||||||||||
| m_true_mother_eta = motherTrueLV->pseudoRapidity(); | ||||||||||||||||||
| m_true_mother_phi = motherTrueLV->phi(); | ||||||||||||||||||
| m_true_mother_rapidity = motherTrueLV->rapidity(); | ||||||||||||||||||
|
|
||||||||||||||||||
| PHG4VtxPoint *thisVtx = m_truthInfo->GetVtx(motherG4->get_vtx_id()); | ||||||||||||||||||
| m_primary_vtx_x = thisVtx->get_x(); | ||||||||||||||||||
| m_primary_vtx_y = thisVtx->get_y(); | ||||||||||||||||||
| m_primary_vtx_z = thisVtx->get_z(); | ||||||||||||||||||
|
|
||||||||||||||||||
| daughterTrueLV->setVectM(CLHEP::Hep3Vector(daughterG4->get_px(), daughterG4->get_py(), daughterG4->get_pz()), getParticleMass(decay[i].second)); | ||||||||||||||||||
| daughterSumTrueLV += *daughterTrueLV; | ||||||||||||||||||
|
|
||||||||||||||||||
| // Now get the decay vertex position | ||||||||||||||||||
| thisVtx = m_truthInfo->GetVtx(daughterG4->get_vtx_id()); | ||||||||||||||||||
| m_secondary_vtx_x = thisVtx->get_x(); | ||||||||||||||||||
| m_secondary_vtx_y = thisVtx->get_y(); | ||||||||||||||||||
| m_secondary_vtx_z = thisVtx->get_z(); | ||||||||||||||||||
|
|
||||||||||||||||||
| m_true_track_PID[index] = daughterG4->get_pid(); | ||||||||||||||||||
| truth_ID = daughterG4->get_track_id(); | ||||||||||||||||||
|
|
||||||||||||||||||
| delete mother3Vector; | ||||||||||||||||||
| } | ||||||||||||||||||
| else if (m_nDaughters == 3) | ||||||||||||||||||
| { | ||||||||||||||||||
| if (i != 4 && motherG4->get_pid() == decay[3].second && motherG4->get_barcode() == decay[3].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second) | ||||||||||||||||||
| { | ||||||||||||||||||
| PHG4Particle *motherG4_temp = nullptr; | ||||||||||||||||||
| if (motherG4->get_parent_id() != 0) | ||||||||||||||||||
| { | ||||||||||||||||||
| motherG4_temp = m_truthInfo->GetParticle(motherG4->get_parent_id()); | ||||||||||||||||||
| } | ||||||||||||||||||
| else | ||||||||||||||||||
| { | ||||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (motherG4_temp->get_pid() == decay[0].second && motherG4_temp->get_barcode() == decay[0].first.second) | ||||||||||||||||||
| { | ||||||||||||||||||
| motherG4 = motherG4_temp; | ||||||||||||||||||
| } | ||||||||||||||||||
| else | ||||||||||||||||||
| { | ||||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| else if (i != 4) | ||||||||||||||||||
| { | ||||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (i==4 && !(motherG4->get_pid() == decay[0].second && motherG4->get_barcode() == decay[0].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second)) | ||||||||||||||||||
| { | ||||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (Verbosity() >= VERBOSITY_MORE) | ||||||||||||||||||
| { | ||||||||||||||||||
| daughterG4->identify(); | ||||||||||||||||||
|
|
@@ -312,6 +388,7 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) | |||||||||||||||||
| m_true_mother_p = mother3Vector->mag(); | ||||||||||||||||||
| m_true_mother_eta = motherTrueLV->pseudoRapidity(); | ||||||||||||||||||
| m_true_mother_phi = motherTrueLV->phi(); | ||||||||||||||||||
| m_true_mother_rapidity = motherTrueLV->rapidity(); | ||||||||||||||||||
|
|
||||||||||||||||||
| PHG4VtxPoint *thisVtx = m_truthInfo->GetVtx(motherG4->get_vtx_id()); | ||||||||||||||||||
| m_primary_vtx_x = thisVtx->get_x(); | ||||||||||||||||||
|
|
@@ -327,16 +404,18 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) | |||||||||||||||||
| m_secondary_vtx_y = thisVtx->get_y(); | ||||||||||||||||||
| m_secondary_vtx_z = thisVtx->get_z(); | ||||||||||||||||||
|
|
||||||||||||||||||
| m_true_track_PID[index] = daughterG4->get_pid(); | ||||||||||||||||||
| m_true_track_PID[index] = daughterG4->get_pid(); | ||||||||||||||||||
| truth_ID = daughterG4->get_track_id(); | ||||||||||||||||||
|
|
||||||||||||||||||
| delete mother3Vector; | ||||||||||||||||||
| break; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| m_true_track_pT[index] = (float) daughterTrueLV->perp(); | ||||||||||||||||||
| m_true_track_eta[index] = (float) daughterTrueLV->pseudoRapidity(); | ||||||||||||||||||
| m_true_track_rapidity[index] = (float) daughterTrueLV->rapidity(); | ||||||||||||||||||
| m_true_track_phi[index] = (float) daughterTrueLV->phi(); | ||||||||||||||||||
| m_min_true_track_pT = std::min(m_true_track_pT[index], m_min_true_track_pT); | ||||||||||||||||||
| m_max_true_track_pT = std::max(m_true_track_pT[index], m_max_true_track_pT); | ||||||||||||||||||
|
|
@@ -480,6 +559,7 @@ void HFTrackEfficiency::initializeBranches() | |||||||||||||||||
| m_tree->Branch("reco_mother_pT", &m_reco_mother_pT, "reco_mother_pT/F"); | ||||||||||||||||||
| m_tree->Branch("true_mother_p", &m_true_mother_p, "true_mother_p/F"); | ||||||||||||||||||
| m_tree->Branch("true_mother_eta", &m_true_mother_eta, "true_mother_eta/F"); | ||||||||||||||||||
| m_tree->Branch("true_mother_rapidity", &m_true_mother_rapidity, "true_mother_rapidity/F"); | ||||||||||||||||||
| m_tree->Branch("true_mother_phi", &m_true_mother_phi, "true_mother_phi/F"); | ||||||||||||||||||
| m_tree->Branch("min_true_track_pT", &m_min_true_track_pT, "min_true_track_pT/F"); | ||||||||||||||||||
| m_tree->Branch("min_reco_track_pT", &m_min_reco_track_pT, "min_reco_track_pT/F"); | ||||||||||||||||||
|
|
@@ -495,6 +575,7 @@ void HFTrackEfficiency::initializeBranches() | |||||||||||||||||
| m_tree->Branch("reco_" + TString(daughter_number) + "_pT", &m_reco_track_pT[iTrack], "reco_" + TString(daughter_number) + "_pT/F"); | ||||||||||||||||||
| m_tree->Branch("true_" + TString(daughter_number) + "_eta", &m_true_track_eta[iTrack], "true_" + TString(daughter_number) + "_eta/F"); | ||||||||||||||||||
| m_tree->Branch("reco_" + TString(daughter_number) + "_eta", &m_reco_track_eta[iTrack], "reco_" + TString(daughter_number) + "_eta/F"); | ||||||||||||||||||
| m_tree->Branch("true_" + TString(daughter_number) + "_rapidity", &m_true_track_rapidity[iTrack], "true_" + TString(daughter_number) + "_rapidity/F"); | ||||||||||||||||||
| m_tree->Branch("true_" + TString(daughter_number) + "_phi", &m_true_track_phi[iTrack], "true_" + TString(daughter_number) + "_phi/F"); | ||||||||||||||||||
| m_tree->Branch("reco_" + TString(daughter_number) + "_phi", &m_reco_track_phi[iTrack], "reco_" + TString(daughter_number) + "_phi/F"); | ||||||||||||||||||
| m_tree->Branch("true_" + TString(daughter_number) + "_PID", &m_true_track_PID[iTrack], "true_" + TString(daughter_number) + "_PID/F"); | ||||||||||||||||||
|
|
@@ -521,6 +602,7 @@ void HFTrackEfficiency::resetBranches() | |||||||||||||||||
| m_reco_mother_pT = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_mother_p = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_mother_eta = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_mother_rapidity = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_min_true_track_pT = std::numeric_limits<float>::max(); | ||||||||||||||||||
| m_min_reco_track_pT = std::numeric_limits<float>::max(); | ||||||||||||||||||
| m_max_true_track_pT = -1 * std::numeric_limits<float>::max(); | ||||||||||||||||||
|
|
@@ -533,6 +615,7 @@ void HFTrackEfficiency::resetBranches() | |||||||||||||||||
| m_reco_track_pT[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_track_eta[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_reco_track_eta[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_track_rapidity[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_track_phi[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_reco_track_phi[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
| m_true_track_PID[iTrack] = std::numeric_limits<float>::quiet_NaN(); | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,6 +174,8 @@ class KFParticle_nTuple : public KFParticle_truthAndDetTools, public KFParticle_ | |
| float m_calculated_daughter_mass[max_tracks]{0}; | ||
| float m_calculated_daughter_ip[max_tracks]{0}; | ||
| float m_calculated_daughter_ip_xy[max_tracks]{0}; | ||
| float m_calculated_daughter_PV_dca_sig[max_tracks]{0}; | ||
| float m_calculated_daughter_PV_dca_xy_sig[max_tracks]{0}; | ||
| float m_calculated_daughter_ipchi2[max_tracks]{0}; | ||
| float m_calculated_daughter_ip_err[max_tracks]{0}; | ||
| float m_calculated_daughter_x[max_tracks]{0}; | ||
|
|
@@ -207,6 +209,8 @@ class KFParticle_nTuple : public KFParticle_truthAndDetTools, public KFParticle_ | |
|
|
||
| float m_daughter_dca[99]{0}; | ||
| float m_daughter_dca_xy[99]{0}; | ||
| float m_daughter_dca_sig[99]{0}; | ||
| float m_daughter_dca_sig_xy[99]{0}; | ||
|
Comment on lines
+212
to
+213
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pairwise DCA-significance buffers are undersized and can overflow. At Line 212 and Line 213, capacity is 99, but pairwise loops in 💡 Proposed fix--- a/offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.h
+++ b/offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.h
@@
- float m_daughter_dca[99]{0};
- float m_daughter_dca_xy[99]{0};
- float m_daughter_dca_sig[99]{0};
- float m_daughter_dca_sig_xy[99]{0};
+ static constexpr int max_track_pairs{max_tracks * (max_tracks - 1) / 2};
+ float m_daughter_dca[max_track_pairs]{0};
+ float m_daughter_dca_xy[max_track_pairs]{0};
+ float m_daughter_dca_sig[max_track_pairs]{0};
+ float m_daughter_dca_sig_xy[max_track_pairs]{0};As per coding guidelines, |
||
|
|
||
| float m_calculated_vertex_x{-1}; | ||
| float m_calculated_vertex_y{-1}; | ||
|
|
||
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.
Inconsistent sentinel value for invalid rapidity.
When the rapidity cannot be computed,
-999.is used, but elsewhere in the class (e.g.,resetBranches()at line 605),quiet_NaN()is used to indicate invalid/unset values. Downstream analysis code checkingstd::isnan()will miss these cases.Consider using NaN for consistency:
Proposed fix
if (mother->momentum().e() > abs(mother->momentum().pz())) { m_true_mother_rapidity = 0.5 * log((mother->momentum().e() + mother->momentum().pz())/(mother->momentum().e() - mother->momentum().pz())); } - else - { - m_true_mother_rapidity = -999.; - } + // else: m_true_mother_rapidity remains at its initialized NaN valueAlternatively, if
-999.is intentional for compatibility with existing analysis code, please document this choice clearly.