Skip to content
Snippets Groups Projects
Commit 78cc4205 authored by Bertrand Martin's avatar Bertrand Martin
Browse files

tauRec: add tau thinning algorithm

Hello,

This MR adds a new tauRec thinning algorithm that will remove all entries from tau-related containers for tau candidates below a minimum tau pt threshold.
The motivation is explained in detail in https://indico.cern.ch/event/986226/contributions/4152506/attachments/2164807/3653366/TauCP_Seeds_LRT_17Dec20.pdf (slide 10).
In R22, we will have to relax the seed jet pt cut (15 GeV) currently applied by default in the reconstruction, as it causes tau reconstruction inefficiency.
Instead, we will have to run the tau reconstruction on all seed jets, and at the end, remove tau candidates below a pt threshold (~10 GeV), in order to keep the tau disk size comparable to what it is now.

The algorithm is added to tauRec but not yet deployed in RecExCommon_topOptions, on purpose. This will be done once we converge on the pt threshold, and the seed jet pt cut will have to be dropped at the same time.

Relevant JIRA ticket: ATLASRECTS-5684

Cheers,
Bertrand
parent 1b08b314
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
*/
#include "TauThinningAlg.h"
#include "StoreGate/ReadHandle.h"
#include "StoreGate/ThinningHandle.h"
#include "tauRecTools/HelperFunctions.h"
/**
* @brief Gaudi initialize method.
*/
StatusCode TauThinningAlg::initialize()
{
ATH_CHECK( m_taus.initialize(m_streamName) );
ATH_CHECK( m_tauTracks.initialize(m_streamName) );
ATH_CHECK( m_neutralPFOs.initialize(m_streamName) );
ATH_CHECK( m_pi0clusters.initialize(m_streamName) );
ATH_CHECK( m_pi0CellLinks.initialize(m_streamName) );
ATH_CHECK( m_finalPi0s.initialize(m_streamName) );
ATH_CHECK( m_shotPFOs.initialize(m_streamName) );
ATH_CHECK( m_shotclusters.initialize(m_streamName) );
ATH_CHECK( m_shotCellLinks.initialize(m_streamName) );
ATH_CHECK( m_hadronicPFOs.initialize(m_streamName) );
ATH_CHECK( m_secondaryVertices.initialize(m_streamName) );
return StatusCode::SUCCESS;
}
/**
* @brief Execute the algorithm.
* @param ctx Current event context.
*/
StatusCode TauThinningAlg::execute (const EventContext& ctx) const
{
SG::ThinningHandle<xAOD::TauJetContainer> taus (m_taus, ctx);
taus.thinAll();
SG::ThinningHandle<xAOD::TauTrackContainer> tauTracks (m_tauTracks, ctx);
tauTracks.thinAll();
SG::ThinningHandle<xAOD::PFOContainer> neutralPFOs (m_neutralPFOs, ctx);
neutralPFOs.thinAll();
SG::ThinningHandle<xAOD::CaloClusterContainer> pi0clusters (m_pi0clusters, ctx);
pi0clusters.thinAll();
SG::ThinningHandle<CaloClusterCellLinkContainer> pi0CellLinks (m_pi0CellLinks, ctx);
pi0CellLinks.thinAll();
SG::ThinningHandle<xAOD::ParticleContainer> finalPi0s (m_finalPi0s, ctx);
finalPi0s.thinAll();
SG::ThinningHandle<xAOD::PFOContainer> shotPFOs (m_shotPFOs, ctx);
shotPFOs.thinAll();
SG::ThinningHandle<xAOD::CaloClusterContainer> shotclusters (m_shotclusters, ctx);
shotclusters.thinAll();
SG::ThinningHandle<CaloClusterCellLinkContainer> shotCellLinks (m_shotCellLinks, ctx);
shotCellLinks.thinAll();
SG::ThinningHandle<xAOD::PFOContainer> hadronicPFOs (m_hadronicPFOs, ctx);
hadronicPFOs.thinAll();
SG::ThinningHandle<xAOD::VertexContainer> secondaryVertices (m_secondaryVertices, ctx);
secondaryVertices.thinAll();
for (const xAOD::TauJet* tau : *taus) {
if(tau->pt() < m_minTauPt) continue;
// keep tau
taus.keep(tau->index());
// keep tau tracks
for(const xAOD::TauTrack* track : tau->allTracks()) {
tauTracks.keep(track->index());
}
// keep neutral PFOs, pi0 clusters and cell links
for(size_t i=0; i<tau->nNeutralPFOs(); i++) {
neutralPFOs.keep(tau->neutralPFO(i)->index());
const xAOD::CaloCluster* cluster = tau->neutralPFO(i)->cluster(0);
pi0clusters.keep(cluster->index());
const CaloClusterCellLink* cellLinks = cluster->getCellLinks();
CaloClusterCellLinkContainer::const_iterator cellLinks_it = std::find(pi0CellLinks->begin(), pi0CellLinks->end(), cellLinks);
if(cellLinks_it != pi0CellLinks->end()) {
size_t link_index = std::distance(pi0CellLinks->begin(), cellLinks_it);
pi0CellLinks.keep(link_index);
}
else {
ATH_MSG_WARNING( "Could not find cluster cell link in " << m_pi0CellLinks.key() << ", won't be saved in xAOD." );
}
}
// keep final pi0s
for(size_t i=0; i<tau->nPi0s(); i++) {
finalPi0s.keep(tau->pi0(i)->index());
}
// keep shot PFOs, clusters and cell links
for(size_t i=0; i<tau->nShotPFOs(); i++) {
shotPFOs.keep(tau->shotPFO(i)->index());
const xAOD::CaloCluster* cluster = tau->shotPFO(i)->cluster(0);
shotclusters.keep(cluster->index());
const CaloClusterCellLink* cellLinks = cluster->getCellLinks();
CaloClusterCellLinkContainer::const_iterator cellLinks_it = std::find(shotCellLinks->begin(), shotCellLinks->end(), cellLinks);
if(cellLinks_it != shotCellLinks->end()) {
size_t link_index = std::distance(shotCellLinks->begin(), cellLinks_it);
shotCellLinks.keep(link_index);
}
else {
ATH_MSG_WARNING( "Could not find cluster cell link in " << m_shotCellLinks.key() << ", won't be saved in xAOD." );
}
}
// keep hadronic PFOs
for(size_t i=0; i<tau->nHadronicPFOs(); i++) {
hadronicPFOs.keep(tau->hadronicPFO(i)->index());
}
// keep secondary vertex when present
static const SG::AuxElement::ConstAccessor< ElementLink< xAOD::VertexContainer > > secondaryVertexAcc( "secondaryVertexLink" );
if(secondaryVertexAcc(*tau)) {
secondaryVertices.keep(tau->secondaryVertex()->index());
}
}
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
*/
#ifndef TAUREC_TAUTHINNING_H
#define TAUREC_TAUTHINNING_H
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "xAODTau/TauJetContainer.h"
#include "xAODTau/TauTrackContainer.h"
#include "xAODPFlow/PFOContainer.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "CaloEvent/CaloClusterCellLinkContainer.h"
#include "xAODTracking/VertexContainer.h"
#include "xAODParticleEvent/ParticleContainer.h"
#include "StoreGate/ThinningHandleKey.h"
#include "GaudiKernel/SystemOfUnits.h"
/**
* @brief Thin taus below a minimum pt threshold
*
* Thinning algorithm that removes entries from all tau-related containers for tau candidates below a minimum pt threshold
*/
class TauThinningAlg : public AthReentrantAlgorithm
{
using AthReentrantAlgorithm::AthReentrantAlgorithm;
public:
/**
* @brief Gaudi initialize method.
*/
virtual StatusCode initialize() override;
/**
* @brief Execute the algorithm.
* @param ctx Current event context.
*/
virtual StatusCode execute(const EventContext& ctx) const override;
private:
// tau pt threshold (pt = ptFinalCalib as TauThinning is run after tau reconstruction)
Gaudi::Property<double> m_minTauPt
{ this, "MinTauPt", 0.* Gaudi::Units::GeV, "Minimum tau pt" };
// Name of the stream being thinned
StringProperty m_streamName
{ this, "StreamName", "StreamAOD", "Name of the stream being thinned" };
// Tau container to thin
SG::ThinningHandleKey<xAOD::TauJetContainer> m_taus
{ this, "Taus", "TauJets", "Tau container to thin" };
// Tau track container to thin
SG::ThinningHandleKey<xAOD::TauTrackContainer> m_tauTracks
{ this, "TauTracks", "TauTracks", "Tau track container to thin" };
// Tau neutral PFO container to thin
SG::ThinningHandleKey<xAOD::PFOContainer> m_neutralPFOs
{ this, "TauNeutralPFOs", "TauNeutralParticleFlowObjects", "Tau neutral PFO container to thin" };
// Tau pi0 cluster container to thin
SG::ThinningHandleKey<xAOD::CaloClusterContainer> m_pi0clusters
{ this, "TauPi0Clusters", "TauPi0Clusters", "Tau pi0 cluster container to thin" };
// Tau pi0 cluster cell link container to thin
SG::ThinningHandleKey<CaloClusterCellLinkContainer> m_pi0CellLinks
{ this, "Pi0CellLinks", "TauPi0Clusters_links", "Tau pi0 cluster cell link container to thin" };
// Tau final pi0 container to thin
SG::ThinningHandleKey<xAOD::ParticleContainer> m_finalPi0s
{ this, "TauFinalPi0s", "TauFinalPi0s", "Tau final pi0 container to thin" };
// Tau shot PFO container to thin
SG::ThinningHandleKey<xAOD::PFOContainer> m_shotPFOs
{ this, "TauShotPFOs", "TauShotParticleFlowObjects", "Tau shot PFO container to thin" };
// Tau shot cluster container to thin
SG::ThinningHandleKey<xAOD::CaloClusterContainer> m_shotclusters
{ this, "TauShotClusters", "TauShotClusters", "Tau shot cluster container to thin" };
// Tau shot cluster cell link container to thin
SG::ThinningHandleKey<CaloClusterCellLinkContainer> m_shotCellLinks
{ this, "ShotCellLinks", "TauShotClusters_links", "Tau shot cluster cell link container to thin" };
// Tau hadronic PFO container to thin
SG::ThinningHandleKey<xAOD::PFOContainer> m_hadronicPFOs
{ this, "TauHadronicPFOs", "TauHadronicParticleFlowObjects", "Tau hadronic PFO container to thin" };
// Tau secondary vertex container to thin
SG::ThinningHandleKey<xAOD::VertexContainer> m_secondaryVertices
{ this, "TauSecondaryVertices", "TauSecondaryVertices", "Tau secondary vertex container to thin" };
};
#endif // not TAUREC_TAUTHINNING_H
......@@ -2,8 +2,10 @@
#include "../TauRunnerAlg.h"
#include "../TauCellThinningAlg.h"
#include "../ClusterCellRelinkAlg.h"
#include "../TauThinningAlg.h"
DECLARE_COMPONENT( TauProcessorAlg )
DECLARE_COMPONENT( TauRunnerAlg )
DECLARE_COMPONENT( TauCellThinningAlg )
DECLARE_COMPONENT( ClusterCellRelinkAlg )
DECLARE_COMPONENT( TauThinningAlg )
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