Skip to content
Snippets Groups Projects
Commit 195c9221 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'selIsOKDecor.IsolationSelection-20250320' into 'main'

IsolationSelection: Make isoSelIsOK decorations unique.

See merge request atlas/athena!78692
parents a16637a8 baf1d695
No related branches found
No related tags found
2 merge requests!78692IsolationSelection: Make isoSelIsOK decorations unique.,!76343Draft: MooTrackBuilder: Recalibrate NSW hits in refine method
......@@ -75,6 +75,7 @@ namespace CP {
using PflowSet = std::set<FlowElementPtr>;
using UnorderedClusterSet = std::unordered_set<const xAOD::CaloCluster*>;
using UnorderedContainerSet = std::unordered_set<const SG::AuxVectorData*>;
} // namespace CP
#endif
......@@ -66,7 +66,7 @@ def IsoCloseByCorrAlgCfg(flags, name="IsoCloseByCorrAlg", suff = "", isPhysLite
MuonWPVec = muIsoWPs,
PhotonWPVec = phIsoWPs))
# Set suffix for writing corrected isolation values
selectionDecorator = "isoSelIsOK"
selectionDecorator = "isoSelIsOK" + suff
kwargs.setdefault("IsoCloseByCorrectionTool",
result.popToolsAndMerge(IsoCloseByCorrectionToolCfg(flags,
IsolationSelectionTool = isoTool,
......@@ -101,7 +101,9 @@ def IsoCloseByCorrAlgCfg(flags, name="IsoCloseByCorrAlg", suff = "", isPhysLite
kwargs.setdefault("MinPhotPt", 0.)
the_alg = CompFactory.CP.IsoCloseByCorrectionAlg(name + suff, **kwargs)
the_alg = CompFactory.CP.IsoCloseByCorrectionAlg(name + suff,
SelectionDecorator = selectionDecorator,
**kwargs)
result.addEventAlgo(the_alg)
return result
......
......@@ -12,6 +12,7 @@
#include "StoreGate/ReadHandle.h"
#include "xAODEgamma/EgammaxAODHelpers.h"
#include "AsgTools/CurrentContext.h"
#include "CxxUtils/checker_macros.h"
namespace CP {
......@@ -54,6 +55,8 @@ namespace CP {
ConstDataVector<xAOD::ElectronContainer> electrons{SG::VIEW_ELEMENTS};
ConstDataVector<xAOD::PhotonContainer> photons{SG::VIEW_ELEMENTS};
const SG::Decorator<char> isOK(m_quality_name);
for (const SG::ReadHandleKey<xAOD::IParticleContainer>& contKey : m_contKeys) {
SG::ReadHandle<xAOD::IParticleContainer> parts (contKey, ctx);
for ( const xAOD::IParticle* part : *parts ) {
......@@ -80,9 +83,9 @@ namespace CP {
ATH_MSG_DEBUG("execute: apply selections " );
/// Apply selection to muons, electrons and photons - setting selection decorator
ATH_CHECK(selectLeptonsAndPhotons(ctx, muons));
ATH_CHECK(selectLeptonsAndPhotons(ctx, electrons));
ATH_CHECK(selectLeptonsAndPhotons(ctx, photons));
ATH_CHECK(selectLeptonsAndPhotons(ctx, muons, isOK));
ATH_CHECK(selectLeptonsAndPhotons(ctx, electrons, isOK));
ATH_CHECK(selectLeptonsAndPhotons(ctx, photons, isOK));
ATH_MSG_DEBUG("execute: apply closeBy correction " );
......@@ -92,6 +95,22 @@ namespace CP {
return StatusCode::FAILURE;
}
// Make sure the isoSelIsOK decorations get locked.
// Unfortunately, we can't use decoration handles because we may
// be configured with view containers as input.
UnorderedContainerSet conts;
for (const SG::ReadHandleKey<xAOD::IParticleContainer>& contKey : m_contKeys) {
SG::ReadHandle<xAOD::IParticleContainer> parts (contKey, ctx);
for ( const xAOD::IParticle* part : *parts ) {
const SG::AuxVectorData* c = part->container();
if (conts.insert(c).second) {
SG::AuxVectorData* c_nc ATLAS_THREAD_SAFE =
const_cast<SG::AuxVectorData*> (c);
c_nc->lockDecoration (isOK.auxid());
}
}
}
ATH_MSG_DEBUG("execute: after closeBy correction " );
return StatusCode::SUCCESS;
......@@ -99,21 +118,23 @@ namespace CP {
template <class CONT_TYPE>
StatusCode IsoCloseByCorrectionAlg::selectLeptonsAndPhotons(const EventContext& ctx,
CONT_TYPE particles) const {
CONT_TYPE particles,
const SG::Decorator<char>& isOK) const
{
ATH_MSG_DEBUG("selectLeptonsAndPhotons: entering" );
for ( auto particle : particles ) {
ATH_MSG_DEBUG("selectLeptonsAndPhotons: pt, eta, ph " << particle->pt()/1000. << ", " << particle->eta() << ", " << particle->phi() );
ATH_CHECK(applySelection(ctx, particle));
ATH_CHECK(applySelection(ctx, particle, isOK));
}
return StatusCode::SUCCESS;
}
StatusCode IsoCloseByCorrectionAlg::applySelection(const EventContext& ctx, const xAOD::Muon* muon) const {
// outgoing selection decorator
static const SG::Decorator<char> isOK("isoSelIsOK");
StatusCode IsoCloseByCorrectionAlg::applySelection(const EventContext& ctx,
const xAOD::Muon* muon,
const SG::Decorator<char>& isOK) const
{
// Check incoming selection decorator
if (!m_muonSelKey.empty()) {
......@@ -146,10 +167,10 @@ namespace CP {
return StatusCode::SUCCESS;
}
StatusCode IsoCloseByCorrectionAlg::applySelection(const EventContext& ctx, const xAOD::Electron* elec) const {
// outgoing selection decorator
static const SG::Decorator<char> isOK("isoSelIsOK");
StatusCode IsoCloseByCorrectionAlg::applySelection(const EventContext& ctx,
const xAOD::Electron* elec,
const SG::Decorator<char>& isOK) const
{
// Check incoming selection decorator
if (!m_elecSelKey.empty()) {
......@@ -181,10 +202,10 @@ namespace CP {
return StatusCode::SUCCESS;
}
StatusCode IsoCloseByCorrectionAlg::applySelection(const EventContext& ctx, const xAOD::Photon* phot) const {
// outgoing selection decorator
static const SG::Decorator<char> isOK("isoSelIsOK");
StatusCode IsoCloseByCorrectionAlg::applySelection(const EventContext& ctx,
const xAOD::Photon* phot,
const SG::Decorator<char>& isOK) const
{
// Check incoming selection decorator
if (!m_photSelKey.empty()) {
......
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#ifndef IsoCloseByCorrectionAlg_H
......@@ -34,11 +34,17 @@ namespace CP {
StatusCode initialize() override;
private:
StatusCode applySelection(const EventContext& ctx, const xAOD::Electron* elec) const;
StatusCode applySelection(const EventContext& ctx, const xAOD::Photon* phot) const;
StatusCode applySelection(const EventContext& ctx, const xAOD::Muon* muon) const;
StatusCode applySelection(const EventContext& ctx,
const xAOD::Electron* elec,
const SG::Decorator<char>& isOK) const;
StatusCode applySelection(const EventContext& ctx,
const xAOD::Photon* phot,
const SG::Decorator<char>& isOK) const;
StatusCode applySelection(const EventContext& ctx,
const xAOD::Muon* muon,
const SG::Decorator<char>& isOK) const;
template <class CONT_TYPE>
StatusCode selectLeptonsAndPhotons(const EventContext& ctx, CONT_TYPE particles) const;
StatusCode selectLeptonsAndPhotons(const EventContext& ctx, CONT_TYPE particles, const SG::Decorator<char>& isOK) const;
/// Input containers to retrieve from the storegate
SG::ReadHandleKeyArray<xAOD::IParticleContainer> m_contKeys{this, "ParticleContainerKeys", {} };
......@@ -68,6 +74,10 @@ namespace CP {
Gaudi::Property<float> m_minPhotPt{this, "MinPhotPt", 0,
"Minimum pt cut that the photon needs to pass in order to be selected"};
// Name of the isolation selection decoration
Gaudi::Property<std::string> m_quality_name{
this, "SelectionDecorator", "isoSelIsOK",
"Name of the char auxdata defining whether the particle shall be considered for iso correction"};
};
} // namespace CP
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment