From b408bdc20de60cecb6d8fee2e6c3fe7ca680e5bc Mon Sep 17 00:00:00 2001 From: Abraham Tishelman-Charny Date: Thu, 15 Feb 2024 10:06:21 -0500 Subject: [PATCH] Protection in all_invariant_masses computation (#342) * Adding protection in all_invariant_masses computation * Adding description of analyzer --- analyzers/dataframe/FCCAnalyses/JetConstituentsUtils.h | 6 +++++- analyzers/dataframe/src/JetConstituentsUtils.cc | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/analyzers/dataframe/FCCAnalyses/JetConstituentsUtils.h b/analyzers/dataframe/FCCAnalyses/JetConstituentsUtils.h index 8db72cb9f4..7d2f40a878 100644 --- a/analyzers/dataframe/FCCAnalyses/JetConstituentsUtils.h +++ b/analyzers/dataframe/FCCAnalyses/JetConstituentsUtils.h @@ -252,7 +252,11 @@ namespace FCCAnalyses { rv::RVec compute_tlv_jets(const rv::RVec& jets); rv::RVec sum_tlv_constituents(const rv::RVec& jets); float InvariantMass(const TLorentzVector& tlv1, const TLorentzVector& tlv2); - rv::RVec all_invariant_masses(rv::RVec AllJets); // invariant masses of all jet pairs given a vector of jets + + /** + * @brief all_invariant_masses takes an RVec of TLorentzVectors of jets and computes the invariant masses of all jet pairs, and returns an RVec with all invariant masses. + */ + rv::RVec all_invariant_masses(rv::RVec AllJets); rv::RVec compute_residue_energy(const rv::RVec& tlv_jet, const rv::RVec& sum_tlv_jcs); rv::RVec compute_residue_pt(const rv::RVec& tlv_jet, diff --git a/analyzers/dataframe/src/JetConstituentsUtils.cc b/analyzers/dataframe/src/JetConstituentsUtils.cc index 0fead9fa72..f339920219 100644 --- a/analyzers/dataframe/src/JetConstituentsUtils.cc +++ b/analyzers/dataframe/src/JetConstituentsUtils.cc @@ -1269,6 +1269,8 @@ namespace FCCAnalyses rv::RVec InvariantMasses; + if(AllJets.size() < 2) return InvariantMasses; + // For each jet, take its invariant mass with the remaining jets. Stop at last jet. for(int i = 0; i < AllJets.size()-1; ++i) {