diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx index fba739ee0cdc09f60a423c8bd517a5268a664acd..ac28bfb22b69c84b3d488294cd50205a7cd1c63c 100644 --- a/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx +++ b/Reconstruction/Jet/JetMomentTools/Root/JetCaloQualityTool.cxx @@ -32,6 +32,7 @@ StatusCode JetCaloQualityTool::decorate(const xAOD::JetContainer& jets) const if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Inside decorate() method" << endmsg; + bool checkedContainer = false; const size_t nDecorations = m_writeDecorKeys.size(); if(m_doFracSamplingMax==true){ @@ -43,6 +44,14 @@ StatusCode JetCaloQualityTool::decorate(const xAOD::JetContainer& jets) const SG::WriteDecorHandle<xAOD::JetContainer, float> maxHandle(m_writeDecorKeys.at(nDecorations-2)); SG::WriteDecorHandle<xAOD::JetContainer, int> samplingHandle(m_writeDecorKeys.at(nDecorations-1)); + // Make sure the user passed in the right jet container + if(maxHandle.ptr() != &jets){ + ATH_MSG_ERROR("Jet container to decorate doesn't match the configured name!"); + return StatusCode::FAILURE; + } + else + checkedContainer = true; + for(const xAOD::Jet* jet : jets){ int sampling=-1; double fracSamplingMax=JetCaloQualityUtils::fracSamplingMax(jet,sampling); @@ -54,12 +63,24 @@ StatusCode JetCaloQualityTool::decorate(const xAOD::JetContainer& jets) const // Do all other calculations for(const xAOD::Jet* jet : jets){ + std::vector<double> results = m_calcProcessor->process(jet); // store them in the jet for(size_t i=0;i < m_calcProcessor->numCalculators();i++) { // We inserted WriteDecorKeys in the same order as calculators SG::WriteDecorHandle<xAOD::JetContainer, float> decHandle(m_writeDecorKeys.at(i)); + + // Make sure the user passed in the right jet container (only need to do once) + if(!checkedContainer){ + if(decHandle.ptr() != &jets){ + ATH_MSG_ERROR("Jet container to decorate doesn't match the configured name!"); + return StatusCode::FAILURE; + } + else + checkedContainer = true; + } + const JetCaloCalculator* calc = m_calcProcessor->at(i); ATH_MSG_DEBUG( calc->name() << " -> "<<results[i] ); decHandle(*jet) = results[i]; @@ -72,6 +93,11 @@ StatusCode JetCaloQualityTool::decorate(const xAOD::JetContainer& jets) const StatusCode JetCaloQualityTool::initialize() { ATH_MSG_DEBUG( "Inside initialize() method" ); + if(m_jetContainerName.empty()){ + ATH_MSG_ERROR("JetCaloQualityTool needs to have its input jet container name configured!"); + return StatusCode::FAILURE; + } + // In this tool we're using the cluster-based calculators // (this is different in the cell-based calculation tool). m_calcProcessor = & m_jetCalculations;