Commit efa2f2da authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'cp/read-master' into 'master'

CP algs: move more algorithms to use SysReadHandle

See merge request atlas/athena!47268
parents a5e8835d e2dc034e
......@@ -8,8 +8,8 @@
#define ASG_ANALYSIS_ALGORITHMS__ASG_CLASSIFICATION_DECORATION_ALG_H
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <xAODBase/IParticle.h>
#include <xAODBase/IParticleContainer.h>
......@@ -46,7 +46,7 @@ private:
/// \brief particles container handle
private:
CP::SysCopyHandle<xAOD::IParticleContainer> m_particlesHandle {
CP::SysReadHandle<xAOD::IParticleContainer> m_particlesHandle {
this, "particles", "", "the container to use"};
/// \brief the decoration for the truth classification
......@@ -55,7 +55,7 @@ private:
/// \brief the accessor for \ref m_truthClassificationDecoration
private:
std::unique_ptr<const SG::AuxElement::Accessor<unsigned int> > m_classificationAccessor {};
std::unique_ptr<const SG::AuxElement::Decorator<unsigned int> > m_classificationDecorator {};
};
} // namespace CP
......
......@@ -13,8 +13,9 @@
#include <PATCore/IAsgSelectionTool.h>
#include <SelectionHelpers/ISelectionAccessor.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <xAODBase/IParticleContainer.h>
namespace CP
{
......@@ -69,7 +70,7 @@ namespace CP
/// \brief the particle continer we run on
private:
SysCopyHandle<xAOD::IParticleContainer> m_particlesHandle {
SysReadHandle<xAOD::IParticleContainer> m_particlesHandle {
this, "particles", "", "the asg collection to run on"};
/// \brief the preselection we apply to our input
......
......@@ -29,7 +29,7 @@ StatusCode AsgClassificationDecorationAlg::initialize()
return StatusCode::FAILURE;
}
m_classificationAccessor = std::make_unique<SG::AuxElement::Accessor<unsigned int> > (m_classificationDecoration);
m_classificationDecorator = std::make_unique<SG::AuxElement::Decorator<unsigned int> > (m_classificationDecoration);
ANA_CHECK (m_particlesHandle.initialize (m_systematicsList));
ANA_CHECK(m_systematicsList.initialize());
......@@ -45,13 +45,14 @@ StatusCode AsgClassificationDecorationAlg::execute()
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::IParticleContainer *particles{};
ANA_CHECK(m_particlesHandle.getCopy(particles, sys));
const xAOD::IParticleContainer *particles{};
ANA_CHECK(m_particlesHandle.retrieve(particles, sys));
for (xAOD::IParticle *particle : *particles) {
for (const xAOD::IParticle *particle : *particles)
{
unsigned int classification{};
ANA_CHECK(m_tool->classify(*particle, classification));
(*m_classificationAccessor)(*particle) = classification;
(*m_classificationDecorator)(*particle) = classification;
}
}
return StatusCode::SUCCESS;
......
......@@ -116,9 +116,9 @@ namespace CP
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::IParticleContainer *particles = nullptr;
ANA_CHECK (m_particlesHandle.getCopy (particles, sys));
for (xAOD::IParticle *particle : *particles)
const xAOD::IParticleContainer *particles = nullptr;
ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
for (const xAOD::IParticle *particle : *particles)
{
asg::AcceptData acceptData (&m_accept);
......@@ -127,9 +127,9 @@ namespace CP
std::size_t cutIndex {0};
const xAOD::TrackParticle *track {nullptr};
if (const xAOD::Muon *muon = dynamic_cast<xAOD::Muon*>(particle))
if (const xAOD::Muon *muon = dynamic_cast<const xAOD::Muon *>(particle))
track = muon->primaryTrackParticle();
else if (const xAOD::Electron *electron = dynamic_cast<xAOD::Electron*>(particle))
else if (const xAOD::Electron *electron = dynamic_cast<const xAOD::Electron *>(particle))
track = electron->trackParticle();
else
{
......
......@@ -15,8 +15,8 @@
#include <SelectionHelpers/ISelectionAccessor.h>
#include <SelectionHelpers/OutOfValidityHelper.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
namespace CP
{
......@@ -53,7 +53,7 @@ namespace CP
/// \brief the particle continer we run on
private:
SysCopyHandle<xAOD::EgammaContainer> m_egammasHandle {
SysReadHandle<xAOD::EgammaContainer> m_egammasHandle {
this, "egammas", "Electrons", "the egamma collection to run on"};
/// \brief the decoration for the asg selection
......
......@@ -58,9 +58,9 @@ namespace CP
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::EgammaContainer *egammas = nullptr;
ANA_CHECK (m_egammasHandle.getCopy (egammas, sys));
for (xAOD::Egamma *egamma : *egammas)
const xAOD::EgammaContainer *egammas = nullptr;
ANA_CHECK (m_egammasHandle.retrieve (egammas, sys));
for (const xAOD::Egamma *egamma : *egammas)
{
if (m_preselection.getBool (*egamma))
{
......
......@@ -94,7 +94,6 @@ def makePhotonAnalysisSequence( dataType, workingPoint,
addPrivateTool( alg, 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
seq.append( alg, inputPropName = 'particles',
outputPropName = 'particlesOut',
stageName = 'calibration',
metaConfig = {'selectionDecorNames' : [alg.selectionDecoration],
'selectionDecorCount' : [1]},
......@@ -154,7 +153,7 @@ def makePhotonAnalysisSequence( dataType, workingPoint,
alg.selectionDecoration = 'isolated' + postfix
addPrivateTool( alg, 'selectionTool', 'CP::IsolationSelectionTool' )
alg.selectionTool.PhotonWP = isolationWP
seq.append( alg, inputPropName = 'egammas', outputPropName = 'egammasOut',
seq.append( alg, inputPropName = 'egammas',
stageName = 'selection',
metaConfig = {'selectionDecorNames' : [alg.selectionDecoration],
'selectionDecorCount' : [1]} )
......
......@@ -84,15 +84,14 @@ def makeFTagAnalysisSequence( seq, dataType, jetCollection,
addPrivateTool( alg, 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
alg.selectionTool.minPt = minPt
alg.selectionTool.maxEta = 2.5
alg.selectionDecoration = 'ftag_kin_select'
seq.append( alg, inputPropName = 'particles',
outputPropName = 'particlesOut' )
alg.selectionDecoration = 'ftag_kin_select_' + btagger + '_' + btagWP
seq.append( alg, inputPropName = 'particles' )
# Set up an algorithm that makes a view container using the selections
# performed previously:
alg = createAlgorithm( 'CP::AsgViewFromSelectionAlg',
'FTagKinViewFromSelectionAlg'+postfix )
alg.selection = [ 'ftag_kin_select' ]
alg.selection = [ 'ftag_kin_select_' + btagger + '_' + btagWP ]
seq.append( alg, inputPropName = 'input', outputPropName = 'output',
stageName = 'selection' )
......@@ -108,7 +107,6 @@ def makeFTagAnalysisSequence( seq, dataType, jetCollection,
alg.preselection = preselection
alg.selectionDecoration = 'ftag_select_' + btagger + '_' + btagWP + ',as_char'
seq.append( alg, inputPropName = 'particles',
outputPropName = 'particlesOut',
stageName = 'selection' )
if not noEfficiency and dataType != 'data':
......
......@@ -12,8 +12,8 @@
#include <JetInterface/IJetSelector.h>
#include <SelectionHelpers/ISelectionAccessor.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <xAODJet/JetContainer.h>
namespace CP
......@@ -46,7 +46,7 @@ namespace CP
/// \brief the jet collection we run on
private:
SysCopyHandle<xAOD::JetContainer> m_jetHandle {
SysReadHandle<xAOD::JetContainer> m_jetHandle {
this, "jets", "AntiKt4EMTopoJets", "the jet collection to run on"};
/// \brief the preselection we apply to our input
......
......@@ -56,9 +56,9 @@ namespace CP
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::JetContainer *jets = nullptr;
ANA_CHECK (m_jetHandle.getCopy (jets, sys));
for (xAOD::Jet *jet : *jets)
const xAOD::JetContainer *jets = nullptr;
ANA_CHECK (m_jetHandle.retrieve (jets, sys));
for (const xAOD::Jet *jet : *jets)
{
if (m_preselection.getBool (*jet))
{
......
......@@ -13,8 +13,8 @@
#include <IsolationSelection/IIsolationSelectionTool.h>
#include <SelectionHelpers/ISelectionAccessor.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <xAODMuon/MuonContainer.h>
namespace CP
......@@ -47,7 +47,7 @@ namespace CP
/// \brief the muon collection we run on
private:
SysCopyHandle<xAOD::MuonContainer> m_muonHandle {
SysReadHandle<xAOD::MuonContainer> m_muonHandle {
this, "muons", "Muons", "the muon collection to run on"};
/// \brief the preselection we apply to our input
......
......@@ -11,8 +11,8 @@
#include <MuonAnalysisInterfaces/IMuonSelectionTool.h>
#include <SelectionHelpers/ISelectionAccessor.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <xAODMuon/MuonContainer.h>
namespace CP
......@@ -50,7 +50,7 @@ namespace CP
/// \brief the particle continer we run on
private:
SysCopyHandle<xAOD::MuonContainer> m_muonsHandle {
SysReadHandle<xAOD::MuonContainer> m_muonsHandle {
this, "muons", "Muons", "the muons collection to run on"};
/// \brief the decoration for the quality selection
......
......@@ -60,9 +60,9 @@ namespace CP
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::MuonContainer *muons = nullptr;
ANA_CHECK (m_muonHandle.getCopy (muons, sys));
for (xAOD::Muon *muon : *muons)
const xAOD::MuonContainer *muons = nullptr;
ANA_CHECK (m_muonHandle.retrieve (muons, sys));
for (const xAOD::Muon *muon : *muons)
{
if (m_preselection.getBool (*muon))
{
......
......@@ -65,9 +65,9 @@ namespace CP
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::MuonContainer *muons = nullptr;
ANA_CHECK (m_muonsHandle.getCopy (muons, sys));
for (xAOD::Muon *muon : *muons)
const xAOD::MuonContainer *muons = nullptr;
ANA_CHECK (m_muonsHandle.retrieve (muons, sys));
for (const xAOD::Muon *muon : *muons)
{
if (m_preselection.getBool (*muon))
{
......
......@@ -152,7 +152,7 @@ def makeMuonAnalysisSequence( dataType, workingPoint,
'MuonIsolationAlg' + postfix )
addPrivateTool( alg, 'isolationTool', 'CP::IsolationSelectionTool' )
alg.isolationDecoration = 'isolated_muon' + postfix + ',as_bits'
seq.append( alg, inputPropName = 'muons', outputPropName = 'muonsOut',
seq.append( alg, inputPropName = 'muons',
stageName = 'selection',
metaConfig = {'selectionDecorNames' : [alg.isolationDecoration],
'selectionDecorNamesOutput' : [alg.isolationDecoration],
......
......@@ -25,7 +25,6 @@ namespace CP
, m_efficiencyCorrectionsTool ("TauAnalysisTools::DiTauEfficiencyCorrectionsTool", this)
{
declareProperty ("efficiencyCorrectionsTool", m_efficiencyCorrectionsTool, "the calibration and smearing tool we apply");
declareProperty ("scaleFactorDecoration", m_scaleFactorDecoration, "the decoration for the tau scale factor");
}
......@@ -38,10 +37,10 @@ namespace CP
ANA_MSG_ERROR ("no scale factor decoration name set");
return StatusCode::FAILURE;
}
m_scaleFactorAccessor = std::make_unique<SG::AuxElement::Accessor<float> > (m_scaleFactorDecoration);
ANA_CHECK (m_efficiencyCorrectionsTool.retrieve());
ANA_CHECK (m_tauHandle.initialize (m_systematicsList));
ANA_CHECK (m_scaleFactorDecoration.initialize (m_systematicsList, m_tauHandle));
ANA_CHECK (m_systematicsList.addSystematics (*m_efficiencyCorrectionsTool));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_preselection.initialize());
......@@ -57,15 +56,17 @@ namespace CP
for (const auto& sys : m_systematicsList.systematicsVector())
{
ANA_CHECK (m_efficiencyCorrectionsTool->applySystematicVariation (sys));
xAOD::DiTauJetContainer *taus = nullptr;
ANA_CHECK (m_tauHandle.getCopy (taus, sys));
for (xAOD::DiTauJet *tau : *taus)
const xAOD::DiTauJetContainer *taus = nullptr;
ANA_CHECK (m_tauHandle.retrieve (taus, sys));
for (const xAOD::DiTauJet *tau : *taus)
{
if (m_preselection.getBool (*tau))
{
double sf = 0;
ANA_CHECK_CORRECTION (m_outOfValidity, *tau, m_efficiencyCorrectionsTool->getEfficiencyScaleFactor (*tau, sf));
(*m_scaleFactorAccessor) (*tau) = sf;
m_scaleFactorDecoration.set (*tau, sf, sys);
} else {
m_scaleFactorDecoration.set (*tau, invalidScaleFactor(), sys);
}
}
}
......
......@@ -46,9 +46,9 @@ namespace CP
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::DiTauJetContainer *taus = nullptr;
ANA_CHECK (m_tauHandle.getCopy (taus, sys));
for (xAOD::DiTauJet *tau : *taus)
const xAOD::DiTauJetContainer *taus = nullptr;
ANA_CHECK (m_tauHandle.retrieve (taus, sys));
for (const xAOD::DiTauJet *tau : *taus)
{
if (m_preselection.getBool (*tau))
{
......
......@@ -46,9 +46,9 @@ namespace CP
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::TauJetContainer *taus = nullptr;
ANA_CHECK (m_tauHandle.getCopy (taus, sys));
for (xAOD::TauJet *tau : *taus)
const xAOD::TauJetContainer *taus = nullptr;
ANA_CHECK (m_tauHandle.retrieve (taus, sys));
for (const xAOD::TauJet *tau : *taus)
{
if (m_preselection.getBool (*tau))
{
......
......@@ -12,9 +12,9 @@
#include <TauAnalysisTools/IDiTauEfficiencyCorrectionsTool.h>
#include <SelectionHelpers/OutOfValidityHelper.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <SystematicsHandles/SysWriteDecorHandle.h>
#include <xAODTau/DiTauJetContainer.h>
namespace CP
......@@ -47,7 +47,7 @@ namespace CP
/// \brief the tau collection we run on
private:
SysCopyHandle<xAOD::DiTauJetContainer> m_tauHandle {
SysReadHandle<xAOD::DiTauJetContainer> m_tauHandle {
this, "taus", "DiTauJets", "the tau collection to run on"};
/// \brief the preselection we apply to our input
......@@ -59,13 +59,10 @@ namespace CP
private:
OutOfValidityHelper m_outOfValidity {this};
/// \brief the decoration for the tau scale factor
/// \brief the decoration for the muon scale factor
private:
std::string m_scaleFactorDecoration;
/// \brief the accessor for \ref m_scaleFactorDecoration
private:
std::unique_ptr<const SG::AuxElement::Accessor<float> > m_scaleFactorAccessor;
SysWriteDecorHandle<float> m_scaleFactorDecoration {
this, "scaleFactorDecoration", "", "the decoration for the di-tau efficiency scale factor"};
};
}
......
......@@ -12,8 +12,8 @@
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <TauAnalysisTools/IDiTauTruthMatchingTool.h>
#include <SelectionHelpers/SelectionReadHandle.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
#include <SystematicsHandles/SysReadHandle.h>
#include <xAODTau/DiTauJetContainer.h>
namespace CP
......@@ -46,7 +46,7 @@ namespace CP
/// \brief the tau collection we run on
private:
SysCopyHandle<xAOD::DiTauJetContainer> m_tauHandle {
SysReadHandle<xAOD::DiTauJetContainer> m_tauHandle {
this, "taus", "DiTauJets", "the tau collection to run on"};
/// \brief the preselection we apply to our input
......
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