Verified Commit c2efc7c9 authored by Tadej Novak's avatar Tadej Novak
Browse files

Improve output handling in systematic handles

parent 04dbcec9
Pipeline #3128497 passed with stage
in 0 seconds
......@@ -13,6 +13,7 @@
#include <list>
// Framework include(s):
#include "AsgServices/ServiceHandle.h"
#include "AsgTools/AsgMessaging.h"
#include "AnaAlgorithm/AnaAlgorithm.h"
#include "SystematicsHandles/SysListHandle.h"
......@@ -356,8 +357,8 @@ namespace CP {
///
bool m_isInitialized = false;
/// The systematic list to consider during execution
SysListHandle m_systematicsList{ this };
/// \brief the handle for the systematics service
ServiceHandle<ISystematicsSvc> m_systematicsService {"SystematicsSvc", ""};
/// @}
......
......@@ -308,6 +308,8 @@ namespace CP {
"Name of the tree to write" );
declareProperty( "Branches", m_branches,
"Branches to write to the output tree" );
declareProperty( "systematicsService", m_systematicsService,
"systematics service" );
}
StatusCode AsgxAODNTupleMakerAlg::initialize() {
......@@ -319,7 +321,7 @@ namespace CP {
}
// Set up the systematics list.
ATH_CHECK( m_systematicsList.initialize() );
ATH_CHECK( m_systematicsService.retrieve() );
// Reset the initialisation flag:
m_isInitialized = false;
......@@ -396,7 +398,7 @@ namespace CP {
}
// Consider all systematics but skip the nominal one
for( const auto& sys : m_systematicsList.systematicsVector() ) {
for( const auto& sys : m_systematicsService->makeSystematicsVector() ) {
// Nominal already processed
if( sys.empty() ) {
continue;
......@@ -441,16 +443,17 @@ namespace CP {
bool nominal = sys.empty();
// Event store key for the object under consideration.
std::string key;
ANA_CHECK (m_systematicsList.service().makeSystematicsName( key, match[ 1 ], sys ));
std::string key = match[ 1 ];
if (key.find ("%SYS%") != std::string::npos)
ANA_CHECK (m_systematicsService->makeSystematicsName( key, match[ 1 ], sys ));
// Auxiliary variable name for the object under consideration.
std::string auxName;
ANA_CHECK (m_systematicsList.service().makeSystematicsName( auxName, match[ 2 ],
sys ));
std::string auxName = match[ 2 ];
if (auxName.find ("%SYS%") != std::string::npos)
ANA_CHECK (m_systematicsService->makeSystematicsName( auxName, match[ 2 ], sys ));
// Branch name for the variable.
std::string brName;
ANA_CHECK (m_systematicsList.service().makeSystematicsName( brName, match[ 3 ],
sys ));
std::string brName = match[ 3 ];
if (brName.find ("%SYS%") != std::string::npos)
ANA_CHECK (m_systematicsService->makeSystematicsName( brName, match[ 3 ], sys ));
// If the %SYS% pattern was not used in this setup, then stop
// on non-nominal systematic.
......
......@@ -115,12 +115,22 @@ namespace CP
const CP::SystematicSet& /*fullAffecting*/,
const std::vector<CP::SystematicSet>& sysList)
{
const CP::SystematicSet affecting
const CP::SystematicSet affectingObject
= svc.getObjectSystematics (m_objectHandle->getNamePattern());
const CP::SystematicSet affectingDecor
= svc.getDecorSystematics (m_objectHandle->getNamePattern(), m_decorName);
CP::SystematicSet filterForObjectSystematics;
for (auto& sys : affectingDecor)
{
if (affectingObject.find(sys) == affectingObject.end())
filterForObjectSystematics.insert (sys);
}
for (auto& sys : sysList)
{
CP::SystematicSet inputSys;
ANA_CHECK (SystematicSet::filterForAffectingSystematics (sys, affecting, inputSys));
ANA_CHECK (SystematicSet::filterForAffectingSystematics (sys, filterForObjectSystematics, inputSys));
std::string decorName;
ANA_CHECK (svc.makeSystematicsName (decorName, m_decorName, inputSys));
ANA_MSG_DEBUG ("SysReadDecorHandle: " << decorName << " (" << sys.name() << ")");
......
......@@ -115,10 +115,23 @@ namespace CP
const CP::SystematicSet& fullAffecting,
const std::vector<CP::SystematicSet>& sysList)
{
const CP::SystematicSet affectingObject
= svc.getObjectSystematics (m_objectHandle->getNamePattern());
for (auto& sys : sysList)
{
std::string newName;
ANA_CHECK (svc.makeSystematicsName (newName, m_decorName, sys));
CP::SystematicSet filteredSys;
ANA_CHECK (SystematicSet::filterForAffectingSystematics (sys, affectingObject, filteredSys));
if (filteredSys.empty())
{
ANA_CHECK (svc.makeSystematicsName (newName, m_decorName, sys));
}
else
{
// in case of overlap with object systematics just treat as nominal
ANA_CHECK (svc.makeSystematicsName (newName, m_decorName, {}));
}
ANA_MSG_DEBUG ("SysWriteDecorHandle: " << newName << " (" << sys.name() << ")");
m_dataCache.emplace (sys, std::make_tuple (newName, newName));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment