diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgxAODNTupleMakerAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgxAODNTupleMakerAlg.cxx index 86ddfe06b8c831d4b10cfb124158a5f6b1916f35..01302cf23637241b326095193f8230818ed8b251 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgxAODNTupleMakerAlg.cxx +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgxAODNTupleMakerAlg.cxx @@ -466,7 +466,31 @@ namespace CP { if( auxName.find( "%SYS%" ) != std::string::npos ) { systematicsDecoration = true; - const CP::SystematicSet affecting = m_systematicsService->getDecorSystematics( match[ 1 ], auxName ); + CP::SystematicSet affecting = m_systematicsService->getDecorSystematics( match[ 1 ], auxName ); + if( affecting.empty() ) + { + // Sometimes while object systematics were applied we are not interested in them, + // NOSYS will then be used on the container name. + // Decoration systematics however will only be aware of containers with %SYS% included. + // Some special handling is needed to translate from NOSYS back to %SYS%. + const auto nosysInKey = key.find( "NOSYS" ); + if( nosysInKey != std::string::npos ) + { + std::string sysKey = key; + sysKey.replace (nosysInKey, 5, "%SYS%"); + // these will be all systematics (object+decor) + const CP::SystematicSet affectingDecor = m_systematicsService->getDecorSystematics( sysKey, auxName ); + // we now need to filter-out object systematics + const CP::SystematicSet affectingObject = m_systematicsService->getObjectSystematics( sysKey ); + for( const CP::SystematicVariation &variation : affectingDecor ) + { + if( affectingObject.find( variation ) == affectingObject.end() ) + { + affecting.insert( variation ); + } + } + } + } CP::SystematicSet matching; ANA_CHECK( SystematicSet::filterForAffectingSystematics( sys, affecting, matching ) ); if( !nominal && matching.empty() ) {