Skip to content
Snippets Groups Projects
Commit cb4a5321 authored by Ruth Pottgen's avatar Ruth Pottgen
Browse files

Merge branch 'FastCaloSim-AddingProtectionForNaNInCenterPositionCalculation' into '21.0'

Adding protection for NaN in TFCSCenterPositionCalculation (ATLASSIM-4474)

See merge request atlas/athena!31562
parents f8b5a430 f10ef640
No related branches found
No related tags found
No related merge requests found
......@@ -19,10 +19,28 @@ TFCSCenterPositionCalculation::TFCSCenterPositionCalculation(const char* name, c
FCSReturnCode TFCSCenterPositionCalculation::simulate_hit(Hit& hit,TFCSSimulationState& /*simulstate*/,const TFCSTruthState* /*truth*/, const TFCSExtrapolationState* extrapol)
{
const int cs=calosample();
hit.setCenter_r( (1.-m_extrapWeight)*extrapol->r(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->r(cs, SUBPOS_EXT) );
hit.setCenter_z( (1.-m_extrapWeight)*extrapol->z(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->z(cs, SUBPOS_EXT) );
hit.setCenter_eta( (1.-m_extrapWeight)*extrapol->eta(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->eta(cs, SUBPOS_EXT) );
hit.setCenter_phi( (1.-m_extrapWeight)*extrapol->phi(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->phi(cs, SUBPOS_EXT) );
double r = (1.-m_extrapWeight)*extrapol->r(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->r(cs, SUBPOS_EXT);
double z = (1.-m_extrapWeight)*extrapol->z(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->z(cs, SUBPOS_EXT);
double eta = (1.-m_extrapWeight)*extrapol->eta(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->eta(cs, SUBPOS_EXT);
double phi = (1.-m_extrapWeight)*extrapol->phi(cs, SUBPOS_ENT) + m_extrapWeight*extrapol->phi(cs, SUBPOS_EXT);
if(!std::isfinite(r) || !std::isfinite(z) || !std::isfinite(eta) || !std::isfinite(phi)) {
ATH_MSG_WARNING("Extrapolator contains NaN or infinite number.\nSetting center position to calo boundary.");
ATH_MSG_WARNING("Before fix: center_r: " << r << " center_z: " << z << " center_phi: " << phi << " center_eta: " << eta << " weight: " << m_extrapWeight << " cs: " << cs);
// If extrapolator fails we can set position to calo boundary
r = extrapol->IDCaloBoundary_r();
z = extrapol->IDCaloBoundary_z();
eta = extrapol->IDCaloBoundary_eta();
phi = extrapol->IDCaloBoundary_phi();
ATH_MSG_WARNING("After fix: center_r: " << r << " center_z: " << z << " center_phi: " << phi << " center_eta: " << eta << " weight: " << m_extrapWeight << " cs: " << cs);
}
hit.setCenter_r( r );
hit.setCenter_z( z );
hit.setCenter_eta( eta );
hit.setCenter_phi( phi );
ATH_MSG_DEBUG("TFCSCenterPositionCalculation: center_r: " << hit.center_r() << " center_z: " << hit.center_z() << " center_phi: " << hit.center_phi() << " center_eta: " << hit.center_eta() << " weight: " << m_extrapWeight << " cs: " << cs);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment