From f0ac6815e5928e037e8445168315af197af407b8 Mon Sep 17 00:00:00 2001 From: Benedict Tobias Winter Date: Fri, 13 Dec 2019 11:11:51 +0100 Subject: [PATCH 1/3] Implement fix --- .../src/FastCaloSimCaloExtrapolation.cxx | 13 ++++++++++++- .../src/FastCaloSimCaloExtrapolation.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx index eeaf6e55697..7019d2c7859 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx @@ -130,7 +130,7 @@ void FastCaloSimCaloExtrapolation::extrapolate(TFCSExtrapolationState& result,co ATH_MSG_DEBUG("Done FastCaloSimCaloExtrapolation::extrapolate"); } -std::vector* FastCaloSimCaloExtrapolation::caloHits(const TFCSTruthState* truth) const +std::vector* FastCaloSimCaloExtrapolation::caloHits(const TFCSTruthState* truth, bool forceNeutral) const { // Start calo extrapolation ATH_MSG_DEBUG ("[ fastCaloSim transport ] processing particle "<pdgid() ); @@ -139,6 +139,7 @@ std::vector* FastCaloSimCaloExtrapolation::caloHits(const TFCSTrut int pdgId = truth->pdgid(); double charge = HepPDT::ParticleID(pdgId).charge(); + if (forceNeutral) charge = 0.; // particle Hypothesis for the extrapolation @@ -281,6 +282,16 @@ std::vector* FastCaloSimCaloExtrapolation::caloHits(const TFCSTrut it2++; } + // Extrapolation may fail for very low pT charged particles. Enforce charge 0 to prevent this + if (not forceNeutral and hitVector->size()==0) + { + ATH_MSG_DEBUG("forcing neutral charge in FastCaloSimCaloExtrapolation::caloHits"); + hitVector = caloHits(truth, true); + } + // Don't expect this ever to happen. Nevertheless, error handling should be improved. + // This may require changes in periphery (adjustments after setting function type to StatusCode) + else if(hitVector->size()==0) ATH_MSG_ERROR("Empty hitVector even after forcing neutral charge. This may cause a segfault soon."); + return hitVector; } diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.h index 9392de5f929..60d7503cb0b 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.h @@ -51,7 +51,7 @@ protected: const IFastCaloSimGeometryHelper* GetCaloGeometry() const {return &(*m_CaloGeometryHelper);}; // extrapolation through Calo - std::vector* caloHits(const TFCSTruthState* truth) const; + std::vector* caloHits(const TFCSTruthState* truth, bool forceNeutral=false) const; void extrapolate(TFCSExtrapolationState& result,const TFCSTruthState* truth,std::vector* hitVector) const; void extrapolate_to_ID(TFCSExtrapolationState& result,const TFCSTruthState* truth,std::vector* hitVector) const; bool get_calo_etaphi(TFCSExtrapolationState& result,std::vector* hitVector,int sample,int subpos=SUBPOS_MID) const; -- GitLab From 3803744f0fc3720dc2b7126b29fa72b8f829918b Mon Sep 17 00:00:00 2001 From: Benedict Tobias Winter Date: Fri, 13 Dec 2019 19:10:22 +0100 Subject: [PATCH 2/3] Replace ->size()==0 by ->empty() --- .../src/FastCaloSimCaloExtrapolation.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx index 7019d2c7859..8a80d78383b 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx @@ -283,14 +283,14 @@ std::vector* FastCaloSimCaloExtrapolation::caloHits(const TFCSTrut } // Extrapolation may fail for very low pT charged particles. Enforce charge 0 to prevent this - if (not forceNeutral and hitVector->size()==0) + if (not forceNeutral and hitVector->empty()) { ATH_MSG_DEBUG("forcing neutral charge in FastCaloSimCaloExtrapolation::caloHits"); hitVector = caloHits(truth, true); } // Don't expect this ever to happen. Nevertheless, error handling should be improved. // This may require changes in periphery (adjustments after setting function type to StatusCode) - else if(hitVector->size()==0) ATH_MSG_ERROR("Empty hitVector even after forcing neutral charge. This may cause a segfault soon."); + else if(hitVector->empty()) ATH_MSG_ERROR("Empty hitVector even after forcing neutral charge. This may cause a segfault soon."); return hitVector; -- GitLab From 54584110d11e9c7d6d978174f4c4b027d9f6d282 Mon Sep 17 00:00:00 2001 From: Benedict Tobias Winter Date: Fri, 13 Dec 2019 19:24:13 +0100 Subject: [PATCH 3/3] Cosmetic change --- .../src/FastCaloSimCaloExtrapolation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx index 8a80d78383b..343dcac82ed 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/FastCaloSimCaloExtrapolation.cxx @@ -286,7 +286,7 @@ std::vector* FastCaloSimCaloExtrapolation::caloHits(const TFCSTrut if (not forceNeutral and hitVector->empty()) { ATH_MSG_DEBUG("forcing neutral charge in FastCaloSimCaloExtrapolation::caloHits"); - hitVector = caloHits(truth, true); + return caloHits(truth, true); } // Don't expect this ever to happen. Nevertheless, error handling should be improved. // This may require changes in periphery (adjustments after setting function type to StatusCode) -- GitLab