Commit d8e73fd2 authored by Nils Erik Krumnack's avatar Nils Erik Krumnack Committed by Johannes Elmsheuser
Browse files

track systematics through the SystematicsSvc

parent d48e938a
......@@ -9,7 +9,9 @@
#define ASG_ANALYSIS_ALGORITHMS__ASG_CUT_BOOKKEEPER_ALG_H
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <AsgServices/ServiceHandle.h>
#include <PMGAnalysisInterfaces/IPMGTruthWeightTool.h>
#include <SystematicsHandles/ISystematicsSvc.h>
namespace CP
{
......@@ -43,6 +45,10 @@ namespace CP
private:
ToolHandle<PMGTools::IPMGTruthWeightTool> m_truthWeightTool;
/// \brief the systematics service
private:
ServiceHandle<ISystematicsSvc> m_systematics {"SystematicsSvc", ""};
/// \brief run number we are processing
private:
uint32_t m_runNumber {};
......
......@@ -12,7 +12,8 @@
#include <SelectionHelpers/ISelectionAccessor.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysDecorationHandle.h>
#include <SystematicsHandles/SysReadDecorHandle.h>
#include <SystematicsHandles/SysWriteDecorHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <xAODBase/IParticleContainer.h>
#include <xAODEventInfo/EventInfo.h>
......@@ -57,12 +58,12 @@ namespace CP
/// \brief the decoration for reading the scale factor
private:
SysDecorationHandle<float> m_scaleFactorInputDecoration {
SysReadDecorHandle<float> m_scaleFactorInputDecoration {
this, "scaleFactorInputDecoration", "", "the decoration for the input efficiency scale factor"};
/// \brief the decoration for writing the scale factor
private:
SysDecorationHandle<float> m_scaleFactorOutputDecoration {
SysWriteDecorHandle<float> m_scaleFactorOutputDecoration {
this, "scaleFactorOutputDecoration", "", "the decoration for the output efficiency scale factor"};
};
}
......
......@@ -9,7 +9,6 @@
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysDecorationHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysFilterReporterParams.h>
#include <SystematicsHandles/SysListHandle.h>
......
......@@ -12,7 +12,7 @@
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <PMGAnalysisInterfaces/IPMGTruthWeightTool.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysDecorationHandle.h>
#include <SystematicsHandles/SysWriteDecorHandle.h>
#include <SystematicsHandles/SysListHandle.h>
namespace CP
......@@ -47,7 +47,7 @@ namespace CP
/// \brief the decoration for the truth weights
private:
SysDecorationHandle<float> m_decoration {
SysWriteDecorHandle<float> m_decoration {
this, "decoration", "", "the decoration for the truth weights"};
};
}
......
......@@ -31,7 +31,7 @@ StatusCode AsgClassificationDecorationAlg::initialize()
m_classificationAccessor = std::make_unique<SG::AuxElement::Accessor<unsigned int> > (m_classificationDecoration);
m_systematicsList.addHandle(m_particlesHandle);
ANA_CHECK (m_particlesHandle.initialize (m_systematicsList));
ANA_CHECK(m_systematicsList.initialize());
ANA_CHECK(m_tool->initialize());
......
......@@ -9,7 +9,6 @@
//
#include <AsgAnalysisAlgorithms/AsgCutBookkeeperAlg.h>
#include <SystematicsHandles/Helpers.h>
#include <RootCoreUtils/StringUtil.h>
#include <TH1.h>
......@@ -38,6 +37,7 @@ namespace CP
declareProperty ("histPattern", m_histPattern, "the pattern for histogram names");
declareProperty ("truthWeightTool", m_truthWeightTool, "the truth weight tool");
declareProperty ("enableSystematics", m_enableSystematics, "enable systematics");
declareProperty ("systematics", m_systematics, "systematics service");
}
......@@ -168,6 +168,8 @@ namespace CP
m_enableSystematics = false;
}
ANA_CHECK (m_systematics.retrieve());
return StatusCode::SUCCESS;
}
......@@ -191,7 +193,7 @@ namespace CP
{
std::string name = RCU::substitute(m_histPattern, "%DSID%", std::to_string(m_mcChannelNumber));
name = RCU::substitute(name, "%RUN%", std::to_string(m_runNumber));
name = makeSystematicsName (name, sys);
ANA_CHECK (m_systematics->makeSystematicsName (name, name, sys));
ANA_CHECK (book(TH1F(name.c_str(), "CutBookkeeper Information", 3, 0.5, 3.5)));
TH1 *h = hist(name);
......
......@@ -37,7 +37,10 @@ namespace CP
return StatusCode::FAILURE;
}
m_systematicsList.addHandle (m_particleHandle);
ANA_CHECK (m_eventInfoHandle.initialize (m_systematicsList));
ANA_CHECK (m_particleHandle.initialize (m_systematicsList));
ANA_CHECK (m_scaleFactorInputDecoration.initialize (m_systematicsList, m_particleHandle));
ANA_CHECK (m_scaleFactorOutputDecoration.initialize (m_systematicsList, m_eventInfoHandle));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
......@@ -49,9 +52,6 @@ namespace CP
StatusCode AsgEventScaleFactorAlg ::
execute ()
{
ANA_CHECK (m_scaleFactorInputDecoration.preExecute (m_systematicsList));
ANA_CHECK (m_scaleFactorOutputDecoration.preExecute (m_systematicsList));
return m_systematicsList.foreach ([&] (const CP::SystematicSet& sys) -> StatusCode {
xAOD::EventInfo *eventInfo = nullptr;
ANA_CHECK (m_eventInfoHandle.getCopy (eventInfo, sys));
......
......@@ -73,7 +73,7 @@ namespace CP
if (m_nMinSCTHits != -1 || m_nMaxSCTHits != -1)
m_accept.addCut ("numSCTHits", "Minimum and/or maxiumum SCT hits");
m_systematicsList.addHandle (m_particlesHandle);
ANA_CHECK (m_particlesHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
return StatusCode::SUCCESS;
......
......@@ -36,7 +36,7 @@ namespace CP
return StatusCode::FAILURE;
}
m_systematicsList.addHandle (m_particleHandle);
ANA_CHECK (m_particleHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.initialize());
return StatusCode::SUCCESS;
}
......
......@@ -45,9 +45,9 @@ namespace CP
ANA_CHECK (m_selectionTool.retrieve());
m_systematicsTool = dynamic_cast<ISystematicsTool*>(&*m_selectionTool);
if (m_systematicsTool)
ANA_CHECK (m_systematicsList.addAffectingSystematics (m_systematicsTool->affectingSystematics()));
ANA_CHECK (m_systematicsList.addSystematics (*m_systematicsTool));
m_systematicsList.addHandle (m_particlesHandle);
ANA_CHECK (m_particlesHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
......
......@@ -195,8 +195,9 @@ namespace CP
StatusCode AsgViewFromSelectionAlg ::
initialize ()
{
m_systematicsList.addHandle (m_inputHandle);
m_systematicsList.addHandle (m_outputHandle);
ANA_CHECK (m_systematicsList.service().registerCopy (m_inputHandle.getNamePattern(), m_outputHandle.getNamePattern()));
ANA_CHECK (m_inputHandle.initialize (m_systematicsList));
ANA_CHECK (m_outputHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.initialize());
if (m_ignore.size() > m_selection.size())
......
......@@ -9,9 +9,6 @@
#include "AthContainers/AuxVectorBase.h"
#include "AthContainers/normalizedTypeinfoName.h"
// Framework include(s):
#include "SystematicsHandles/Helpers.h"
// ROOT include(s):
#include <TClass.h>
#include <TTree.h>
......@@ -444,13 +441,16 @@ namespace CP {
bool nominal = sys.empty();
// Event store key for the object under consideration.
const std::string key = makeSystematicsName( match[ 1 ], sys );
std::string key;
ANA_CHECK (m_systematicsList.service().makeSystematicsName( key, match[ 1 ], sys ));
// Auxiliary variable name for the object under consideration.
const std::string auxName = makeSystematicsName( match[ 2 ],
sys );
std::string auxName;
ANA_CHECK (m_systematicsList.service().makeSystematicsName( auxName, match[ 2 ],
sys ));
// Branch name for the variable.
const std::string brName = makeSystematicsName( match[ 3 ],
sys );
std::string brName;
ANA_CHECK (m_systematicsList.service().makeSystematicsName( brName, match[ 3 ],
sys ));
// If the %SYS% pattern was not used in this setup, then stop
// on non-nominal systematic.
......
......@@ -24,7 +24,7 @@ EventSelectionByObjectFlagAlg ::EventSelectionByObjectFlagAlg(
StatusCode EventSelectionByObjectFlagAlg ::initialize() {
m_systematicsList.addHandle(m_particleHandle);
ANA_CHECK(m_particleHandle.initialize (m_systematicsList));
ANA_CHECK(m_systematicsList.initialize());
ANA_CHECK(m_preselection.initialize());
ANA_CHECK(m_veto.initialize());
......@@ -35,7 +35,7 @@ StatusCode EventSelectionByObjectFlagAlg ::initialize() {
StatusCode EventSelectionByObjectFlagAlg ::execute() {
SysFilterReporterCombiner filterCombiner (m_filterParams, m_systematicsList, true);
SysFilterReporterCombiner filterCombiner (m_filterParams, true);
// loop over systematics
return m_systematicsList.foreach ([&](const CP::SystematicSet &sys) -> StatusCode {
......
......@@ -32,9 +32,9 @@ namespace CP
initialize ()
{
ANA_CHECK (m_isolationCorrectionTool.retrieve());
if (m_electronsHandle) m_systematicsList.addHandle (m_electronsHandle);
if (m_muonsHandle) m_systematicsList.addHandle (m_muonsHandle);
if (m_photonsHandle) m_systematicsList.addHandle (m_photonsHandle);
ANA_CHECK (m_electronsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_muonsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_photonsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_outOfValidity.initialize());
return StatusCode::SUCCESS;
......
......@@ -33,7 +33,7 @@ namespace CP
StatusCode KinematicHistAlg ::
initialize ()
{
m_systematicsList.addHandle (m_inputHandle);
ANA_CHECK (m_inputHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
return StatusCode::SUCCESS;
......@@ -55,7 +55,7 @@ namespace CP
HistGroup group;
name = RCU::substitute (m_histPattern, "%VAR%", "multiplicity");
name = makeSystematicsName (name, sys);
ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
ANA_CHECK (book (TH1F (name.c_str(), "multiplicity", 20, 0, 20)));
group.multiplicity = hist (name);
......@@ -76,17 +76,17 @@ namespace CP
HistSubgroup group;
name = RCU::substitute (m_histPattern, "%VAR%", "pt" + std::to_string(histIter->second.perObject.size()));
name = makeSystematicsName (name, sys);
ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
ANA_CHECK (book (TH1F (name.c_str(), "pt", 20, 0, 200e3)));
group.pt = hist (name);
name = RCU::substitute (m_histPattern, "%VAR%", "eta" + std::to_string(histIter->second.perObject.size()));
name = makeSystematicsName (name, sys);
ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
ANA_CHECK (book (TH1F (name.c_str(), "eta", 20, -5, 5)));
group.eta = hist (name);
name = RCU::substitute (m_histPattern, "%VAR%", "phi" + std::to_string(histIter->second.perObject.size()));
name = makeSystematicsName (name, sys);
ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
ANA_CHECK (book (TH1F (name.c_str(), "phi", 20, -M_PI, M_PI)));
group.phi = hist (name);
......
......@@ -36,7 +36,7 @@ namespace CP
StatusCode ObjectCutFlowHistAlg ::
initialize ()
{
m_systematicsList.addHandle (m_inputHandle);
ANA_CHECK (m_inputHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
......@@ -87,8 +87,8 @@ namespace CP
auto histIter = m_hist.find (sys);
if (histIter == m_hist.end())
{
const std::string name
= makeSystematicsName (m_histPattern, sys);
std::string name;
ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, m_histPattern, sys));
ANA_CHECK (book (TH1F (name.c_str(), "object cut flow", m_allCutsNum+1, 0, m_allCutsNum+1)));
......
......@@ -31,12 +31,12 @@ namespace CP
initialize ()
{
ANA_CHECK (m_overlapTool.retrieve());
if (m_electronsHandle) m_systematicsList.addHandle (m_electronsHandle);
if (m_muonsHandle) m_systematicsList.addHandle (m_muonsHandle);
if (m_jetsHandle) m_systematicsList.addHandle (m_jetsHandle);
if (m_tausHandle) m_systematicsList.addHandle (m_tausHandle);
if (m_photonsHandle) m_systematicsList.addHandle (m_photonsHandle);
if (m_fatJetsHandle) m_systematicsList.addHandle (m_fatJetsHandle);
ANA_CHECK (m_electronsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_muonsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_jetsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_tausHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_photonsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_fatJetsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_systematicsList.initialize());
return StatusCode::SUCCESS;
}
......
......@@ -38,8 +38,9 @@ namespace CP
}
ANA_CHECK (m_truthWeightTool.retrieve());
ANA_CHECK (m_systematicsList.addAffectingSystematics (m_truthWeightTool->affectingSystematics()));
m_systematicsList.addHandle (m_eventInfoHandle);
ANA_CHECK (m_systematicsList.addSystematics (*m_truthWeightTool));
ANA_CHECK (m_eventInfoHandle.initialize (m_systematicsList));
ANA_CHECK (m_decoration.initialize (m_systematicsList, m_eventInfoHandle));
ANA_CHECK (m_systematicsList.initialize());
return StatusCode::SUCCESS;
......@@ -49,8 +50,6 @@ namespace CP
StatusCode PMGTruthWeightAlg ::
execute ()
{
ANA_CHECK (m_decoration.preExecute (m_systematicsList));
return m_systematicsList.foreach ([&] (const CP::SystematicSet& sys) -> StatusCode
{
ANA_CHECK (m_truthWeightTool->applySystematicVariation (sys));
......
......@@ -48,8 +48,8 @@ namespace CP
}
ANA_CHECK (m_pileupReweightingTool.retrieve());
m_systematicsList.addHandle (m_eventInfoHandle);
ANA_CHECK (m_systematicsList.addAffectingSystematics (m_pileupReweightingTool->affectingSystematics()));
ANA_CHECK (m_eventInfoHandle.initialize (m_systematicsList));
ANA_CHECK (m_systematicsList.addSystematics (*m_pileupReweightingTool));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_outOfValidity.initialize());
return StatusCode::SUCCESS;
......
......@@ -10,7 +10,6 @@
//
#include <AsgAnalysisAlgorithms/SysListDumperAlg.h>
#include <SystematicsHandles/Helpers.h>
#include <TH1.h>
//
......@@ -55,7 +54,7 @@ namespace CP
m_firstEvent = false;
const std::unordered_set<CP::SystematicSet> systematics = m_systematicsList.systematicsVector();
const decltype(auto) systematics = m_systematicsList.systematicsVector();
ANA_CHECK (book (TH1F (m_histogramName.c_str(), "systematics", systematics.size(), 0, systematics.size())));
TH1 *histogram = hist (m_histogramName);
......@@ -63,9 +62,8 @@ namespace CP
int i = 1;
return m_systematicsList.foreach ([&] (const CP::SystematicSet& sys) -> StatusCode
{
std::string name = sys.name();
if (name.empty())
name = nominalSystematicsName();
std::string name;
ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, "%SYS%", sys));
histogram->GetXaxis()->SetBinLabel(i, name.c_str());
i++;
......
Supports Markdown
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