diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgxAODNTupleMakerAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/AsgxAODNTupleMakerAlg.cxx index 1851db4aacb1f317e2d08087af8feb927964f8fa..ee034e36a4481dc5b93fa9f398cf8c4eced491ff 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() ) {