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

Add BTaggingInformationDecoratorAlg to query detailed b-tagging information

parent 2b02c17d
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/// @author Tadej Novak
#ifndef F_TAG_ANALYSIS_ALGORITHMS__B_TAGGING_INFORMATION_DECORATION_ALG_H
#define F_TAG_ANALYSIS_ALGORITHMS__B_TAGGING_INFORMATION_DECORATION_ALG_H
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <FTagAnalysisInterfaces/IBTaggingSelectionTool.h>
#include <SelectionHelpers/OutOfValidityHelper.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysWriteDecorHandle.h>
#include <xAODJet/JetContainer.h>
namespace CP
{
class BTaggingInformationDecoratorAlg final : public EL::AnaAlgorithm
{
/// \brief the standard constructor
public:
BTaggingInformationDecoratorAlg (const std::string& name,
ISvcLocator* pSvcLocator);
public:
StatusCode initialize () override;
public:
StatusCode execute () override;
/// \brief the systematics list we run
private:
SysListHandle m_systematicsList {this};
/// \brief the selection tool
private:
ToolHandle<IBTaggingSelectionTool> m_selectionTool;
/// \brief the jets continer we run on
private:
SysReadHandle<xAOD::JetContainer> m_jetHandle {
this, "jets", "", "the jets collection to run on"};
/// \brief the preselection we apply to our input
private:
SelectionReadHandle m_preselection {
this, "preselection", "", "the preselection to apply"};
/// \brief the helper for OutOfValidity results
private:
OutOfValidityHelper m_outOfValidity {this};
/// \brief the decoration for writing the weight
private:
SysWriteDecorHandle<float> m_taggerWeightDecoration {
this, "taggerWeightDecoration", "", "the decoration for the tagger weight"};
/// \brief the decoration for writing the quantiles
private:
SysWriteDecorHandle<int> m_quantileDecoration {
this, "quantileDecoration", "", "the decoration for the continuous WP quantile"};
};
}
#endif
......@@ -9,5 +9,6 @@
#define F_TAG_ANALYSIS_ALGORITHMS__F_TAG_ANALYSIS_ALGORITHMS_DICT_H
#include <FTagAnalysisAlgorithms/BTaggingEfficiencyAlg.h>
#include <FTagAnalysisAlgorithms/BTaggingInformationDecoratorAlg.h>
#endif
<lcgdict>
<class name="CP::BTaggingEfficiencyAlg" />
<class name="CP::BTaggingInformationDecoratorAlg" />
</lcgdict>
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/// @author Tadej Novak
//
// includes
//
#include <FTagAnalysisAlgorithms/BTaggingInformationDecoratorAlg.h>
//
// method implementations
//
namespace CP
{
BTaggingInformationDecoratorAlg ::
BTaggingInformationDecoratorAlg (const std::string& name,
ISvcLocator* pSvcLocator)
: AnaAlgorithm (name, pSvcLocator)
, m_selectionTool ("", this)
{
declareProperty ("selectionTool", m_selectionTool, "the b-tagging selection tool");
}
StatusCode BTaggingInformationDecoratorAlg ::
initialize ()
{
if (m_taggerWeightDecoration.empty() && m_quantileDecoration.empty())
{
ANA_MSG_ERROR ("can't specify both tagger weight and quantile decorations are empty");
return StatusCode::FAILURE;
}
ANA_CHECK (m_selectionTool.retrieve());
ANA_CHECK (m_jetHandle.initialize (m_systematicsList));
ANA_CHECK (m_taggerWeightDecoration.initialize (m_systematicsList, m_jetHandle, SG::AllowEmpty));
ANA_CHECK (m_quantileDecoration.initialize (m_systematicsList, m_jetHandle, SG::AllowEmpty));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
ANA_CHECK (m_outOfValidity.initialize());
return StatusCode::SUCCESS;
}
StatusCode BTaggingInformationDecoratorAlg ::
execute ()
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
const xAOD::JetContainer *jets{};
ANA_CHECK (m_jetHandle.retrieve (jets, sys));
for (const xAOD::Jet *jet : *jets)
{
if (m_preselection.getBool (*jet))
{
if (m_taggerWeightDecoration)
{
double weight{-1.};
ANA_CHECK_CORRECTION (m_outOfValidity, *jet, m_selectionTool->getTaggerWeight (*jet, weight));
m_taggerWeightDecoration.set (*jet, weight, sys);
}
if (m_quantileDecoration)
{
const int quantile = m_selectionTool->getQuantile(*jet);
m_quantileDecoration.set (*jet, quantile, sys);
}
} else {
if (m_taggerWeightDecoration)
{
m_taggerWeightDecoration.set (*jet, -100., sys);
}
if (m_quantileDecoration)
{
m_quantileDecoration.set (*jet, -1, sys);
}
}
}
}
return StatusCode::SUCCESS;
}
}
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
# AnaAlgorithm import(s):
from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool
......@@ -110,6 +110,20 @@ def makeFTagAnalysisSequence( seq, dataType, jetCollection,
alg.selectionDecoration = 'ftag_select_' + btagger + '_' + btagWP + ',as_char'
seq.append( alg, inputPropName = 'particles',
stageName = 'selection' )
if btagWP == 'Continuous':
alg = createAlgorithm( 'CP::BTaggingInformationDecoratorAlg', 'FTagInfoAlg' + btagger + btagWP + postfix )
addPrivateTool( alg, 'selectionTool', 'BTaggingSelectionTool' )
alg.selectionTool.TaggerName = btagger
alg.selectionTool.OperatingPoint = btagWP
alg.selectionTool.JetAuthor = jetCollection
alg.selectionTool.FlvTagCutDefinitionsFileName = bTagCalibFile
alg.selectionTool.MinPt = minPt
if preselection is not None:
alg.preselection = preselection
alg.quantileDecoration = 'ftag_quantile_' + btagger
seq.append( alg, inputPropName = 'jets',
stageName = 'selection' )
if not noEfficiency and dataType != 'data':
# Set up the efficiency calculation algorithm:
......
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