From a6fa55a7a4a9058ec1951afedc21f742119fb95b Mon Sep 17 00:00:00 2001 From: "Gavin P. Salam" Date: Mon, 20 Sep 2021 17:00:03 +0100 Subject: [PATCH 1/4] introduced safer way of constructing PseudoJets --- analyzers/dataframe/JetClusteringUtils.cc | 19 +++++++++++++++++++ analyzers/dataframe/JetClusteringUtils.h | 13 +++++++++++++ examples/FCCee/top/hadronic/analysis.py | 7 ++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/analyzers/dataframe/JetClusteringUtils.cc b/analyzers/dataframe/JetClusteringUtils.cc index 8e92deb4ae..f9e7b2946f 100644 --- a/analyzers/dataframe/JetClusteringUtils.cc +++ b/analyzers/dataframe/JetClusteringUtils.cc @@ -25,6 +25,25 @@ std::vector JetClusteringUtils::set_pseudoJets(ROOT::VecOps: return result; } +std::vector JetClusteringUtils::set_pseudoJets_xyzm(ROOT::VecOps::RVec px, + ROOT::VecOps::RVec py, + ROOT::VecOps::RVec pz, + ROOT::VecOps::RVec m) { + std::vector result; + unsigned index = 0; + for (size_t i = 0; i < px.size(); ++i) { + double px_d = px.at(i); + double py_d = py.at(i); + double pz_d = pz.at(i); + double m_d = m.at(i); + double E_d = sqrt(px_d*px_d + py_d*py_d + pz_d*pz_d + m_d*m_d); + result.emplace_back(px_d, py_D, pz_d, E_d); + result.back().set_user_index(index); + ++index; + } + return result; +} + ROOT::VecOps::RVec JetClusteringUtils::get_px(ROOT::VecOps::RVec in){ ROOT::VecOps::RVec result; diff --git a/analyzers/dataframe/JetClusteringUtils.h b/analyzers/dataframe/JetClusteringUtils.h index 7c50223fbe..8adb14691e 100644 --- a/analyzers/dataframe/JetClusteringUtils.h +++ b/analyzers/dataframe/JetClusteringUtils.h @@ -33,6 +33,19 @@ namespace JetClusteringUtils{ ROOT::VecOps::RVec pz, ROOT::VecOps::RVec e); + /** Set fastjet pseudoJet for later reconstruction using px, py, pz and m + * + * This version is to be preferred over the px,py,pz,E version when m is known + * accurately, because it uses double precision to reconstruct the energy, + * reducing the size of rounding errors on FastJet calculations (e.g. of + * PseudoJet masses) + * + */ + std::vector set_pseudoJets_xyzm(ROOT::VecOps::RVec px, + ROOT::VecOps::RVec py, + ROOT::VecOps::RVec pz, + ROOT::VecOps::RVec m); + /** Get fastjet pseudoJet after reconstruction from FCCAnalyses jets*/ ROOT::VecOps::RVec get_pseudoJets(FCCAnalysesJet); diff --git a/examples/FCCee/top/hadronic/analysis.py b/examples/FCCee/top/hadronic/analysis.py index b1b9b02456..650ad020f1 100644 --- a/examples/FCCee/top/hadronic/analysis.py +++ b/examples/FCCee/top/hadronic/analysis.py @@ -36,10 +36,11 @@ def run(self): .Define("RP_px", "ReconstructedParticle::get_px(ReconstructedParticles)") .Define("RP_py", "ReconstructedParticle::get_py(ReconstructedParticles)") .Define("RP_pz", "ReconstructedParticle::get_pz(ReconstructedParticles)") - .Define("RP_e", "ReconstructedParticle::get_e(ReconstructedParticles)") + .Define("RP_m", "ReconstructedParticle::get_e(ReconstructedParticles)") - #build pseudo jets with the RP - .Define("pseudo_jets", "JetClusteringUtils::set_pseudoJets(RP_px, RP_py, RP_pz, RP_e)") + #build pseudo jets with the RP, using the interface that takes px,py,pz,m for better + #handling of rounding errors + .Define("pseudo_jets", "JetClusteringUtils::set_pseudoJets_xyzm(RP_px, RP_py, RP_pz, RP_m)") #run jet clustering with all reconstructed particles. kt_algorithm, R=0.5, exclusive clustering, exactly 4 jets, E0-scheme .Define("FCCAnalysesJets_kt", "JetClustering::clustering_kt(0.5, 2, 4, 0, 10)(pseudo_jets)") From 043a8c6de02c3d81ce2a1ac858ff124967e6992b Mon Sep 17 00:00:00 2001 From: "Gavin P. Salam" Date: Mon, 20 Sep 2021 17:00:03 +0100 Subject: [PATCH 2/4] introduced safer way of constructing PseudoJets from information in float types (using px,py,pz,m) --- analyzers/dataframe/JetClusteringUtils.cc | 19 +++++++++++++++++++ analyzers/dataframe/JetClusteringUtils.h | 13 +++++++++++++ examples/FCCee/top/hadronic/analysis.py | 7 ++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/analyzers/dataframe/JetClusteringUtils.cc b/analyzers/dataframe/JetClusteringUtils.cc index 8e92deb4ae..f9e7b2946f 100644 --- a/analyzers/dataframe/JetClusteringUtils.cc +++ b/analyzers/dataframe/JetClusteringUtils.cc @@ -25,6 +25,25 @@ std::vector JetClusteringUtils::set_pseudoJets(ROOT::VecOps: return result; } +std::vector JetClusteringUtils::set_pseudoJets_xyzm(ROOT::VecOps::RVec px, + ROOT::VecOps::RVec py, + ROOT::VecOps::RVec pz, + ROOT::VecOps::RVec m) { + std::vector result; + unsigned index = 0; + for (size_t i = 0; i < px.size(); ++i) { + double px_d = px.at(i); + double py_d = py.at(i); + double pz_d = pz.at(i); + double m_d = m.at(i); + double E_d = sqrt(px_d*px_d + py_d*py_d + pz_d*pz_d + m_d*m_d); + result.emplace_back(px_d, py_D, pz_d, E_d); + result.back().set_user_index(index); + ++index; + } + return result; +} + ROOT::VecOps::RVec JetClusteringUtils::get_px(ROOT::VecOps::RVec in){ ROOT::VecOps::RVec result; diff --git a/analyzers/dataframe/JetClusteringUtils.h b/analyzers/dataframe/JetClusteringUtils.h index 7c50223fbe..8adb14691e 100644 --- a/analyzers/dataframe/JetClusteringUtils.h +++ b/analyzers/dataframe/JetClusteringUtils.h @@ -33,6 +33,19 @@ namespace JetClusteringUtils{ ROOT::VecOps::RVec pz, ROOT::VecOps::RVec e); + /** Set fastjet pseudoJet for later reconstruction using px, py, pz and m + * + * This version is to be preferred over the px,py,pz,E version when m is known + * accurately, because it uses double precision to reconstruct the energy, + * reducing the size of rounding errors on FastJet calculations (e.g. of + * PseudoJet masses) + * + */ + std::vector set_pseudoJets_xyzm(ROOT::VecOps::RVec px, + ROOT::VecOps::RVec py, + ROOT::VecOps::RVec pz, + ROOT::VecOps::RVec m); + /** Get fastjet pseudoJet after reconstruction from FCCAnalyses jets*/ ROOT::VecOps::RVec get_pseudoJets(FCCAnalysesJet); diff --git a/examples/FCCee/top/hadronic/analysis.py b/examples/FCCee/top/hadronic/analysis.py index b1b9b02456..650ad020f1 100644 --- a/examples/FCCee/top/hadronic/analysis.py +++ b/examples/FCCee/top/hadronic/analysis.py @@ -36,10 +36,11 @@ def run(self): .Define("RP_px", "ReconstructedParticle::get_px(ReconstructedParticles)") .Define("RP_py", "ReconstructedParticle::get_py(ReconstructedParticles)") .Define("RP_pz", "ReconstructedParticle::get_pz(ReconstructedParticles)") - .Define("RP_e", "ReconstructedParticle::get_e(ReconstructedParticles)") + .Define("RP_m", "ReconstructedParticle::get_e(ReconstructedParticles)") - #build pseudo jets with the RP - .Define("pseudo_jets", "JetClusteringUtils::set_pseudoJets(RP_px, RP_py, RP_pz, RP_e)") + #build pseudo jets with the RP, using the interface that takes px,py,pz,m for better + #handling of rounding errors + .Define("pseudo_jets", "JetClusteringUtils::set_pseudoJets_xyzm(RP_px, RP_py, RP_pz, RP_m)") #run jet clustering with all reconstructed particles. kt_algorithm, R=0.5, exclusive clustering, exactly 4 jets, E0-scheme .Define("FCCAnalysesJets_kt", "JetClustering::clustering_kt(0.5, 2, 4, 0, 10)(pseudo_jets)") From d626f397f876d314f4feec31140405381ff38284 Mon Sep 17 00:00:00 2001 From: "Gavin P. Salam" Date: Mon, 20 Sep 2021 17:10:44 +0100 Subject: [PATCH 3/4] fixed bug where E was being transferred rather than m --- examples/FCCee/top/hadronic/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/FCCee/top/hadronic/analysis.py b/examples/FCCee/top/hadronic/analysis.py index 650ad020f1..de5ee65861 100644 --- a/examples/FCCee/top/hadronic/analysis.py +++ b/examples/FCCee/top/hadronic/analysis.py @@ -36,7 +36,7 @@ def run(self): .Define("RP_px", "ReconstructedParticle::get_px(ReconstructedParticles)") .Define("RP_py", "ReconstructedParticle::get_py(ReconstructedParticles)") .Define("RP_pz", "ReconstructedParticle::get_pz(ReconstructedParticles)") - .Define("RP_m", "ReconstructedParticle::get_e(ReconstructedParticles)") + .Define("RP_m", "ReconstructedParticle::get_m(ReconstructedParticles)") #build pseudo jets with the RP, using the interface that takes px,py,pz,m for better #handling of rounding errors From edcabbaf530588c963ae16162e3a4ec230b7023a Mon Sep 17 00:00:00 2001 From: "Gavin P. Salam" Date: Mon, 20 Sep 2021 17:48:56 +0100 Subject: [PATCH 4/4] fixed _D -> _d, as pointed out by Clement --- analyzers/dataframe/JetClusteringUtils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyzers/dataframe/JetClusteringUtils.cc b/analyzers/dataframe/JetClusteringUtils.cc index f9e7b2946f..af4cb47f39 100644 --- a/analyzers/dataframe/JetClusteringUtils.cc +++ b/analyzers/dataframe/JetClusteringUtils.cc @@ -37,7 +37,7 @@ std::vector JetClusteringUtils::set_pseudoJets_xyzm(ROOT::Ve double pz_d = pz.at(i); double m_d = m.at(i); double E_d = sqrt(px_d*px_d + py_d*py_d + pz_d*pz_d + m_d*m_d); - result.emplace_back(px_d, py_D, pz_d, E_d); + result.emplace_back(px_d, py_d, pz_d, E_d); result.back().set_user_index(index); ++index; }