Skip to content
Snippets Groups Projects
Commit d4ea16ac authored by Scott Snyder's avatar Scott Snyder Committed by Walter Lampl
Browse files

TauAnalysisTools: Make some interfaces const.

Make some interfaces const to fix ToolHandle constness problems.
This involves moving some member variables to auxiliary structures
which can themselves be passed around.
parent 94d07fa9
Branches
Tags
No related merge requests found
Showing
with 273 additions and 248 deletions
......@@ -44,8 +44,7 @@ namespace DerivationFramework {
bool m_maxDeltaR;
bool m_minPt;
#warning FIXME: ToolHandle constness workaround.
mutable ToolHandle < TauAnalysisTools::ITauTruthTrackMatchingTool > m_T3MT;
ToolHandle < TauAnalysisTools::ITauTruthTrackMatchingTool > m_T3MT;
StatusCode select(xAOD::TrackParticleContainer*& tauPVTracks) const;
......
......@@ -34,8 +34,7 @@ namespace DerivationFramework {
private:
std::string m_tauContainerName;
#warning FIXME mutable to work around ToolHandle constness problem.
mutable ToolHandle < TauAnalysisTools::ITauTruthMatchingTool > m_tTauTruthMatchingTool;
ToolHandle < TauAnalysisTools::ITauTruthMatchingTool > m_tTauTruthMatchingTool;
};
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -44,8 +44,10 @@ namespace DerivationFramework {
return StatusCode::FAILURE;
}
std::unique_ptr<TauAnalysisTools::ITauTruthMatchingTool::ITruthTausEvent>
truthTausEvent = m_tTauTruthMatchingTool->getEvent();
for(auto xTau : *xTauContainer)
m_tTauTruthMatchingTool->applyTruthMatch(*xTau);
m_tTauTruthMatchingTool->getTruth(*xTau, *truthTausEvent);
return StatusCode::SUCCESS;
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
// Local include(s)
......@@ -85,23 +85,17 @@ void DiTauTruthMatchingTool::applyTruthMatch(const std::vector<const xAOD::DiTau
StatusCode DiTauTruthMatchingTool::findTruthTau(const xAOD::DiTauJet& xDiTau)
{
// check if decorations were already added to the first passed tau
if (!m_bIsTruthMatchedAvailableChecked)
{
m_bIsTruthMatchedAvailable = xDiTau.isAvailable<char>("IsTruthMatched");
m_bIsTruthMatchedAvailableChecked = true;
if (m_bIsTruthMatchedAvailable)
{
ATH_MSG_DEBUG("IsTruthMatched decoration is available on first tau processed, switched of rerun for further taus.");
ATH_MSG_DEBUG("If a truth matching needs to be redone, please pass a shallow copy of the original tau.");
}
if (!m_bIsTruthMatchedAvailable.isValid()) {
bool avail = xDiTau.isAvailable<char>("IsTruthMatched");
m_bIsTruthMatchedAvailable.set (avail);
}
if (m_bIsTruthMatchedAvailable)
if (*m_bIsTruthMatchedAvailable.ptr())
return StatusCode::SUCCESS;
if (m_bTruthTauAvailable)
return checkTruthMatch(xDiTau, *m_xTruthTauContainerConst);
return checkTruthMatch(xDiTau, *m_truthTausEvent.m_xTruthTauContainerConst);
else
return checkTruthMatch(xDiTau, *m_xTruthTauContainer);
return checkTruthMatch(xDiTau, *m_truthTausEvent.m_xTruthTauContainer);
}
//______________________________________________________________________________
......@@ -174,12 +168,12 @@ StatusCode DiTauTruthMatchingTool::checkTruthMatch (const xAOD::DiTauJet& xDiTau
}
else if (eTruthMatchedParticleType == TruthMuon)
{
ElementLink <xAOD::TruthParticleContainer> lTruthParticleLink(xTruthMatch, *m_xTruthMuonContainerConst);
ElementLink <xAOD::TruthParticleContainer> lTruthParticleLink(xTruthMatch, *m_truthTausEvent.m_xTruthMuonContainerConst);
vTruthLinks.push_back(lTruthParticleLink);
}
else if (eTruthMatchedParticleType == TruthElectron)
{
ElementLink <xAOD::TruthParticleContainer> lTruthParticleLink(xTruthMatch, *m_xTruthElectronContainerConst);
ElementLink <xAOD::TruthParticleContainer> lTruthParticleLink(xTruthMatch, *m_truthTausEvent.m_xTruthElectronContainerConst);
vTruthLinks.push_back(lTruthParticleLink);
}
}
......@@ -243,10 +237,10 @@ StatusCode DiTauTruthMatchingTool::truthMatch(const TLorentzVector& vSubjetTLV,
}
}
if (!xTruthMatch and m_xTruthMuonContainerConst)
if (!xTruthMatch and m_truthTausEvent.m_xTruthMuonContainerConst)
{
double dPtMax = 0;
for (auto xTruthMuonIt : *m_xTruthMuonContainerConst)
for (auto xTruthMuonIt : *m_truthTausEvent.m_xTruthMuonContainerConst)
{
if (vSubjetTLV.DeltaR(xTruthMuonIt->p4()) <= m_dMaxDeltaR)
{
......@@ -260,10 +254,10 @@ StatusCode DiTauTruthMatchingTool::truthMatch(const TLorentzVector& vSubjetTLV,
}
}
if (!xTruthMatch and m_xTruthElectronContainerConst)
if (!xTruthMatch and m_truthTausEvent.m_xTruthElectronContainerConst)
{
double dPtMax = 0;
for (auto xTruthElectronIt : *m_xTruthElectronContainerConst)
for (auto xTruthElectronIt : *m_truthTausEvent.m_xTruthElectronContainerConst)
{
if (vSubjetTLV.DeltaR(xTruthElectronIt->p4()) <= m_dMaxDeltaR)
{
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
// Local include(s)
......@@ -44,16 +44,34 @@ StatusCode TauTruthMatchingTool::initialize()
return StatusCode::SUCCESS;
}
//______________________________________________________________________________
std::unique_ptr<TauTruthMatchingTool::ITruthTausEvent>
TauTruthMatchingTool::getEvent() const
{
auto truthTausEvent = std::make_unique<TruthTausEvent>();
if (retrieveTruthTaus(*truthTausEvent).isFailure()) {
truthTausEvent.reset();
}
return truthTausEvent;
}
//______________________________________________________________________________
const xAOD::TruthParticle* TauTruthMatchingTool::getTruth(const xAOD::TauJet& xTau)
{
return getTruth (xTau, m_truthTausEvent);
}
const xAOD::TruthParticle*
TauTruthMatchingTool::getTruth(const xAOD::TauJet& xTau,
ITruthTausEvent& itruthTausEvent) const
{
TruthTausEvent& truthTausEvent = dynamic_cast<TruthTausEvent&> (itruthTausEvent);
if (m_bIsData)
return nullptr;
if (retrieveTruthTaus().isFailure())
if (retrieveTruthTaus(truthTausEvent).isFailure())
return nullptr;
if (findTruthTau(xTau).isFailure())
if (findTruthTau(xTau, truthTausEvent).isFailure())
ATH_MSG_WARNING("There was a failure in finding the matched truth tau");
// if matched to a truth tau return its pointer, else return a null pointer
......@@ -333,20 +351,15 @@ xAOD::TauJetParameters::DecayMode TauTruthMatchingTool::getDecayMode(const xAOD:
////////////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
StatusCode TauTruthMatchingTool::findTruthTau(const xAOD::TauJet& xTau)
StatusCode TauTruthMatchingTool::findTruthTau(const xAOD::TauJet& xTau,
TruthTausEvent& truthTausEvent) const
{
// check if decorations were already added to the first passed tau
if (!m_bIsTruthMatchedAvailableChecked)
{
m_bIsTruthMatchedAvailable = xTau.isAvailable<char>("IsTruthMatched");
m_bIsTruthMatchedAvailableChecked = true;
if (m_bIsTruthMatchedAvailable)
{
ATH_MSG_DEBUG("IsTruthMatched decoration is available on first tau processed, switched of rerun for further taus.");
ATH_MSG_DEBUG("If a truth matching needs to be redone, please pass a shallow copy of the original tau.");
}
if (!m_bIsTruthMatchedAvailable.isValid()) {
bool avail = xTau.isAvailable<char>("IsTruthMatched");
m_bIsTruthMatchedAvailable.set (avail);
}
if (m_bIsTruthMatchedAvailable)
if (*m_bIsTruthMatchedAvailable.ptr())
return StatusCode::SUCCESS;
// only search for truth taus once
......@@ -360,9 +373,9 @@ StatusCode TauTruthMatchingTool::findTruthTau(const xAOD::TauJet& xTau)
// || (xTau.auxdata<char>("IsTruthMatched") && xTau.auxdata< ElementLink< xAOD::TruthParticleContainer > >("truthParticleLink") == NULL ))
// {
if (m_bTruthTauAvailable)
return checkTruthMatch(xTau, *m_xTruthTauContainerConst);
return checkTruthMatch(xTau, *truthTausEvent.m_xTruthTauContainerConst);
else
return checkTruthMatch(xTau, *m_xTruthTauContainer);
return checkTruthMatch(xTau, *truthTausEvent.m_xTruthTauContainer);
// }
// return StatusCode::SUCCESS;
......@@ -401,10 +414,10 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons
}
}
if (!xTruthMatch and m_xTruthMuonContainerConst)
if (!xTruthMatch and m_truthTausEvent.m_xTruthMuonContainerConst)
{
double dPtMax = 0;
for (auto xTruthMuonIt : *m_xTruthMuonContainerConst)
for (auto xTruthMuonIt : *m_truthTausEvent.m_xTruthMuonContainerConst)
{
if (xTau.p4().DeltaR(xTruthMuonIt->p4()) <= m_dMaxDeltaR)
{
......@@ -418,10 +431,10 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons
}
}
if (!xTruthMatch and m_xTruthElectronContainerConst)
if (!xTruthMatch and m_truthTausEvent.m_xTruthElectronContainerConst)
{
double dPtMax = 0;
for (auto xTruthElectronIt : *m_xTruthElectronContainerConst)
for (auto xTruthElectronIt : *m_truthTausEvent.m_xTruthElectronContainerConst)
{
if (xTau.p4().DeltaR(xTruthElectronIt->p4()) <= m_dMaxDeltaR)
{
......@@ -434,10 +447,10 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons
}
}
if (m_xTruthJetContainerConst)
if (m_truthTausEvent.m_xTruthJetContainerConst)
{
double dPtMax = 0;
for (auto xTruthJetIt : *m_xTruthJetContainerConst)
for (auto xTruthJetIt : *m_truthTausEvent.m_xTruthJetContainerConst)
{
if (xTau.p4().DeltaR(xTruthJetIt->p4()) <= m_dMaxDeltaR)
{
......@@ -456,7 +469,7 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons
if (xTruthJetMatch)
{
ElementLink < xAOD::JetContainer > lTruthParticleLink(xTruthJetMatch, *m_xTruthJetContainerConst);
ElementLink < xAOD::JetContainer > lTruthParticleLink(xTruthJetMatch, *m_truthTausEvent.m_xTruthJetContainerConst);
decTruthJetLink(xTau) = lTruthParticleLink;
}
else
......@@ -488,12 +501,12 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons
}
else if (eTruthMatchedParticleType == TruthMuon)
{
ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, *m_xTruthMuonContainerConst);
ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, *m_truthTausEvent.m_xTruthMuonContainerConst);
decTruthParticleLink(xTau) = lTruthParticleLink;
}
else if (eTruthMatchedParticleType == TruthElectron)
{
ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, *m_xTruthElectronContainerConst);
ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, *m_truthTausEvent.m_xTruthElectronContainerConst);
decTruthParticleLink(xTau) = lTruthParticleLink;
}
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include <TauAnalysisTools/TauTruthTrackMatchingTool.h>
......@@ -13,8 +13,6 @@ using namespace TauAnalysisTools;
//______________________________________________________________________________
TauTruthTrackMatchingTool::TauTruthTrackMatchingTool( const std::string& name )
: AsgTool(name)
, m_bIsHadronicTrackAvailable(false)
, m_bIsHadronicTrackAvailableChecked(false)
{
}
......@@ -30,20 +28,20 @@ StatusCode TauTruthTrackMatchingTool::initialize()
}
//______________________________________________________________________________
StatusCode TauTruthTrackMatchingTool::classifyTrack(const TAUTRACKPARTICLE& xTrackParticle)
StatusCode TauTruthTrackMatchingTool::classifyTrack(const TAUTRACKPARTICLE& xTrackParticle) const
{
// don't classify tracks if this was already done
if (!m_bIsHadronicTrackAvailableChecked)
if (!m_bIsHadronicTrackAvailable.isValid())
{
m_bIsHadronicTrackAvailable = xTrackParticle.isAvailable<char>("IsHadronicTrack");
m_bIsHadronicTrackAvailableChecked = true;
if (m_bIsHadronicTrackAvailable)
bool avail = xTrackParticle.isAvailable<char>("IsHadronicTrack");
m_bIsHadronicTrackAvailable.set (avail);
if (avail)
{
ATH_MSG_DEBUG("IsHadronicTrack decoration is available on first track processed, switched of rerun for further taus.");
ATH_MSG_DEBUG("If a truth track matching needs to be redone, please pass a shallow copy of the original track.");
}
}
if (m_bIsHadronicTrackAvailable)
if (*m_bIsHadronicTrackAvailable.ptr())
return StatusCode::SUCCESS;
ATH_CHECK(checkTrackIsTauInheritant(xTrackParticle));
......@@ -52,7 +50,7 @@ StatusCode TauTruthTrackMatchingTool::classifyTrack(const TAUTRACKPARTICLE& xTra
}
//______________________________________________________________________________
StatusCode TauTruthTrackMatchingTool::classifyTracks(std::vector<const TAUTRACKPARTICLE*>& vTrackParticles)
StatusCode TauTruthTrackMatchingTool::classifyTracks(std::vector<const TAUTRACKPARTICLE*>& vTrackParticles) const
{
for (auto xTrackParticle : vTrackParticles)
{
......@@ -64,18 +62,18 @@ StatusCode TauTruthTrackMatchingTool::classifyTracks(std::vector<const TAUTRACKP
//=================================PRIVATE-PART=================================
//______________________________________________________________________________
StatusCode TauTruthTrackMatchingTool::checkTrackType(const TAUTRACKPARTICLE& xTrackParticle)
StatusCode TauTruthTrackMatchingTool::checkTrackType(const TAUTRACKPARTICLE& xTrackParticle) const
{
const xAOD::TruthParticle* xTruthParticle = getTruthParticle(xTrackParticle);
static SG::AuxElement::Decorator<int> decTruthType("TruthType");
static const SG::AuxElement::Decorator<int> decTruthType("TruthType");
if (!xTruthParticle)
{
decTruthType(xTrackParticle) = TauAnalysisTools::UnclassifiedTrack;
return StatusCode::SUCCESS;
}
static SG::AuxElement::ConstAccessor<float> accTruthMatchProbability("truthMatchProbability");
static const SG::AuxElement::ConstAccessor<float> accTruthMatchProbability("truthMatchProbability");
#ifndef XAODTAU_VERSIONS_TAUJET_V3_H
if (accTruthMatchProbability(xTrackParticle) < 0.5)
#else
......@@ -86,8 +84,8 @@ StatusCode TauTruthTrackMatchingTool::checkTrackType(const TAUTRACKPARTICLE& xTr
return StatusCode::SUCCESS;
}
static SG::AuxElement::ConstAccessor< char > accIsHadronicTrack("IsHadronicTrack");
static SG::AuxElement::ConstAccessor< int > accIsHadronicTrackDecayDepth("IsHadronicTrackDecayDepth");
static const SG::AuxElement::ConstAccessor< char > accIsHadronicTrack("IsHadronicTrack");
static const SG::AuxElement::ConstAccessor< int > accIsHadronicTrackDecayDepth("IsHadronicTrackDecayDepth");
if ((bool)accIsHadronicTrack(xTrackParticle) and accIsHadronicTrackDecayDepth(xTrackParticle) == 0)
{
decTruthType(xTrackParticle) = TauAnalysisTools::TauTrack;
......@@ -105,9 +103,9 @@ StatusCode TauTruthTrackMatchingTool::checkTrackType(const TAUTRACKPARTICLE& xTr
}
//______________________________________________________________________________
StatusCode TauTruthTrackMatchingTool::classifyConversion(const TAUTRACKPARTICLE& xTrackParticle, const xAOD::TruthParticle& xTruthParticle)
StatusCode TauTruthTrackMatchingTool::classifyConversion(const TAUTRACKPARTICLE& xTrackParticle, const xAOD::TruthParticle& xTruthParticle) const
{
static SG::AuxElement::Decorator<int> decTruthType("TruthType");
static const SG::AuxElement::Decorator<int> decTruthType("TruthType");
if (!xTruthParticle.isElectron())
{
decTruthType(xTrackParticle) = TauAnalysisTools::SecondaryTrack;
......@@ -162,9 +160,9 @@ StatusCode TauTruthTrackMatchingTool::classifyConversion(const TAUTRACKPARTICLE&
}
//______________________________________________________________________________
const xAOD::TruthParticle* TauTruthTrackMatchingTool::getTruthParticle(const TAUTRACKPARTICLE& xTrackParticle)
const xAOD::TruthParticle* TauTruthTrackMatchingTool::getTruthParticle(const TAUTRACKPARTICLE& xTrackParticle) const
{
static SG::AuxElement::ConstAccessor< ElementLink<xAOD::TruthParticleContainer> > accTruthParticleLink("truthParticleLink");
static const SG::AuxElement::ConstAccessor< ElementLink<xAOD::TruthParticleContainer> > accTruthParticleLink("truthParticleLink");
#ifdef XAODTAU_VERSIONS_TAUJET_V3_H
auto xTruthParticleContainer = accTruthParticleLink(*(xTrackParticle.track()));
#else
......@@ -177,11 +175,11 @@ const xAOD::TruthParticle* TauTruthTrackMatchingTool::getTruthParticle(const TAU
}
//______________________________________________________________________________
StatusCode TauTruthTrackMatchingTool::checkTrackIsTauInheritant(const TAUTRACKPARTICLE& xTrackParticle)
StatusCode TauTruthTrackMatchingTool::checkTrackIsTauInheritant(const TAUTRACKPARTICLE& xTrackParticle) const
{
static SG::AuxElement::Decorator< char > decIsHadronicTrack("IsHadronicTrack");
static SG::AuxElement::Decorator< int > decIsHadronicTrackDecayDepth("IsHadronicTrackDecayDepth");
static SG::AuxElement::Decorator< std::string > decDecayHistory("DecayHistory");
static const SG::AuxElement::Decorator< char > decIsHadronicTrack("IsHadronicTrack");
static const SG::AuxElement::Decorator< int > decIsHadronicTrackDecayDepth("IsHadronicTrackDecayDepth");
static const SG::AuxElement::Decorator< std::string > decDecayHistory("DecayHistory");
decIsHadronicTrack(xTrackParticle) = (char)false;
int iDepth = -1;
const xAOD::TruthParticle* xTruthParticle = getTruthParticle(xTrackParticle);
......@@ -201,7 +199,7 @@ StatusCode TauTruthTrackMatchingTool::checkTrackIsTauInheritant(const TAUTRACKPA
}
//______________________________________________________________________________
bool TauTruthTrackMatchingTool::checkTruthParent(const xAOD::TruthParticle& xTruthParticle, int& iDepth, std::string& sHistory)
bool TauTruthTrackMatchingTool::checkTruthParent(const xAOD::TruthParticle& xTruthParticle, int& iDepth, std::string& sHistory) const
{
iDepth++;
if (xTruthParticle.hasProdVtx())
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUANALYSISTOOLS_BUILDTRUTHTAUS_H
......@@ -30,6 +30,9 @@
// Local include(s):
#include "TauAnalysisTools/IBuildTruthTaus.h"
#include "CxxUtils/CachedValue.h"
#include <atomic>
namespace TauAnalysisTools
{
......@@ -43,28 +46,66 @@ class BuildTruthTaus
public:
struct TruthTausEvent
: public ITruthTausEvent
{
bool m_valid = false;
const xAOD::TruthParticleContainer* m_xTruthTauContainerConst = nullptr;
const xAOD::TruthParticleContainer* m_xTruthMuonContainerConst = nullptr;
const xAOD::TruthParticleContainer* m_xTruthElectronContainerConst = nullptr;
const xAOD::JetContainer* m_xTruthJetContainerConst = nullptr;
xAOD::TruthParticleContainer* m_xTruthTauContainer = nullptr;
xAOD::TruthParticleAuxContainer* m_xTruthTauAuxContainer = nullptr;
const xAOD::TruthParticleContainer* m_xTruthParticleContainer = nullptr;
};
BuildTruthTaus( const std::string& name );
virtual ~BuildTruthTaus();
// initialize the tool
virtual StatusCode initialize();
virtual StatusCode initialize() override;
// get TruthTauContainer
virtual xAOD::TruthParticleContainer* getTruthTauContainer();
virtual xAOD::TruthParticleContainer* getTruthTauContainer() override;
// get TruthTauAuxContainer
virtual xAOD::TruthParticleAuxContainer* getTruthTauAuxContainer();
virtual xAOD::TruthParticleAuxContainer* getTruthTauAuxContainer() override;
virtual StatusCode retrieveTruthTaus() override;
virtual StatusCode retrieveTruthTaus(ITruthTausEvent& truthTausEvent) const override;
protected:
StatusCode retrieveTruthTaus(TruthTausEvent& truthTausEvent) const;
StatusCode retrieveTruthTaus();
private:
struct TauTruthInfo
{
size_t m_iNChargedPions = 0;
size_t m_iNNeutralPions = 0;
size_t m_iNChargedOthers = 0;
size_t m_iNNeutralOthers = 0;
size_t m_iNChargedDaughters = 0;
std::vector<int> m_vDecayMode;
// default false, if there is a hadron in decay products, it is switched to true
bool m_bIsHadronicTau = false;
// truth visible kinematic variables
TLorentzVector m_vTruthVisTLV;
TLorentzVector m_vTruthVisTLVCharged;
TLorentzVector m_vTruthVisTLVNeutral;
};
// Execute at each event
virtual StatusCode beginEvent();
virtual StatusCode beginEvent() override;
StatusCode buildTruthTausFromTruthParticles();
StatusCode examineTruthTau(const xAOD::TruthParticle& xTruthParticle);
StatusCode examineTruthTauDecay(const xAOD::TruthParticle& xTruthParticle);
StatusCode buildTruthTausFromTruthParticles(TruthTausEvent& truthTausEvent) const;
StatusCode examineTruthTau(const xAOD::TruthParticle& xTruthParticle) const;
StatusCode examineTruthTauDecay(const xAOD::TruthParticle& xTruthParticle,
TauTruthInfo& truthInfo) const;
void printDecay(const xAOD::TruthParticle& xTruthParticle, int depth = 0) const;
protected:
......@@ -73,23 +114,14 @@ protected:
// steering variables
bool m_bWriteTruthTaus;
bool m_bTruthTauAvailable;
mutable std::atomic<bool> m_bTruthTauAvailable;
const xAOD::TruthParticleContainer* m_xTruthTauContainerConst;
const xAOD::TruthParticleContainer* m_xTruthMuonContainerConst;
const xAOD::TruthParticleContainer* m_xTruthElectronContainerConst;
const xAOD::JetContainer* m_xTruthJetContainerConst;
xAOD::TruthParticleContainer* m_xTruthTauContainer;
TruthTausEvent m_truthTausEvent;
bool m_bIsTruthMatchedAvailable;
bool m_bIsTruthMatchedAvailableChecked;
bool m_bNewEvent;
CxxUtils::CachedValue<bool> m_bIsTruthMatchedAvailable;
private:
const xAOD::TruthParticleContainer* m_xTruthParticleContainer;
xAOD::TruthParticleAuxContainer* m_xTruthTauAuxContainer;
// steering variables
std::string m_sNewTruthTauContainerName;
std::string m_sNewTruthTauContainerNameAux;
......@@ -99,27 +131,15 @@ private:
std::string m_sTruthJetContainerName;
std::string m_sTruthParticlesContainerName;
bool m_bTruthMuonAvailable;
bool m_bTruthElectronAvailable;
bool m_bTruthJetAvailable;
mutable std::atomic<bool> m_bTruthMuonAvailable;
mutable std::atomic<bool> m_bTruthElectronAvailable;
mutable std::atomic<bool> m_bTruthJetAvailable;
bool m_bWriteInvisibleFourMomentum;
bool m_bWriteVisibleChargedFourMomentum;
bool m_bWriteVisibleNeutralFourMomentum;
bool m_bWriteDecayModeVector;
size_t m_iNChargedPions;
size_t m_iNNeutralPions;
size_t m_iNChargedOthers;
size_t m_iNNeutralOthers;
size_t m_iNChargedDaughters;
std::vector<int> m_vDecayMode;
TLorentzVector m_vTruthVisTLV;
TLorentzVector m_vTruthVisTLVCharged;
TLorentzVector m_vTruthVisTLVNeutral;
bool m_bIsHadronicTau;
private:
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUANALYSISTOOLS_IBUILDTRUTHTAUS_H
......@@ -35,6 +35,12 @@ class IBuildTruthTaus :
ASG_TOOL_INTERFACE( TauAnalysisTools::IBuildTruthTaus )
public:
class ITruthTausEvent
{
public:
virtual ~ITruthTausEvent() = default;
};
// initialize the tool
virtual StatusCode initialize() = 0;
......@@ -45,6 +51,7 @@ public:
virtual xAOD::TruthParticleAuxContainer* getTruthTauAuxContainer() = 0;
virtual StatusCode retrieveTruthTaus() = 0;
virtual StatusCode retrieveTruthTaus(ITruthTausEvent& truthTausEvent) const = 0;
}; // class IBuildTruthTaus
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUANALYSISTOOLS_ITAUTRUTHMATCHINGTOOL_H
......@@ -50,8 +50,12 @@ public:
// apply match to all taus in a vector
virtual std::vector<const xAOD::TruthParticle*> applyTruthMatch(const std::vector<const xAOD::TauJet*>& vTaus) = 0;
virtual std::unique_ptr<ITruthTausEvent> getEvent() const = 0;
// get pointer to truth tau, if no truth tau was found a null pointer is returned
virtual const xAOD::TruthParticle* getTruth(const xAOD::TauJet& xTau) = 0;
virtual const xAOD::TruthParticle* getTruth(const xAOD::TauJet& xTau,
ITruthTausEvent& truthTausEvent) const = 0;
// wrapper function to get truth tau visible TLorentzvector
virtual TLorentzVector getTruthTauP4Vis(const xAOD::TauJet& xTau) = 0;
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUANALYSISTOOLS_ITAUTRUTHTRACKMATCHINGTOOL_H
......@@ -48,10 +48,10 @@ public:
virtual StatusCode initialize() = 0;
// classify vector of tracks
virtual StatusCode classifyTracks(std::vector<const TAUTRACKPARTICLE*>& vTracks) = 0;
virtual StatusCode classifyTracks(std::vector<const TAUTRACKPARTICLE*>& vTracks) const = 0;
// classify a single track
virtual StatusCode classifyTrack(const TAUTRACKPARTICLE& xTrackParticle) = 0;
virtual StatusCode classifyTrack(const TAUTRACKPARTICLE& xTrackParticle) const = 0;
}; // class ITauTruthTrackMatchingTool
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUANALYSISTOOLS_TAUTRUTHMATCHINGTOOL_H
......@@ -42,8 +42,12 @@ public: // Interface functions
// initialize the tool
virtual StatusCode initialize() override final;
virtual std::unique_ptr<ITruthTausEvent> getEvent() const override final;
// get pointer to the truth matched particle, if no truth particle was found a null pointer is returned
virtual const xAOD::TruthParticle* getTruth(const xAOD::TauJet& xTau) override final;
virtual const xAOD::TruthParticle* getTruth(const xAOD::TauJet& xTau,
ITruthTausEvent& truthTausEVent) const override final;
// apply match to a single tau
virtual const xAOD::TruthParticle* applyTruthMatch(const xAOD::TauJet& xTau) override final;
......@@ -78,7 +82,8 @@ public: // Wrapper functions
private: // private helper functions
StatusCode findTruthTau(const xAOD::TauJet& xTau);
StatusCode findTruthTau(const xAOD::TauJet& xTau,
TruthTausEvent& truthTausEvent) const;
StatusCode checkTruthMatch (const xAOD::TauJet& xTau, const xAOD::TruthParticleContainer& xTauContainer) const;
private: // steering variables
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUANALYSISTOOLS_TAUTRUTHTRACKMATCHINGTOOL_H
......@@ -27,6 +27,8 @@
// EDM include(s)
#include "xAODTruth/TruthVertex.h"
#include "CxxUtils/CachedValue.h"
namespace TauAnalysisTools
{
......@@ -56,25 +58,24 @@ public:
virtual ~TauTruthTrackMatchingTool();
virtual StatusCode initialize();
virtual StatusCode initialize() override;
// classify vector of tracks
virtual StatusCode classifyTracks(std::vector<const TAUTRACKPARTICLE*>& vTracks);
virtual StatusCode classifyTracks(std::vector<const TAUTRACKPARTICLE*>& vTracks) const override;
// classify a single track
virtual StatusCode classifyTrack(const TAUTRACKPARTICLE& xTrackParticle);
virtual StatusCode classifyTrack(const TAUTRACKPARTICLE& xTrackParticle) const override;
private:
StatusCode classifyConversion(const TAUTRACKPARTICLE& xTrackParticle, const xAOD::TruthParticle& xTruthParticle);
StatusCode checkTrackType(const TAUTRACKPARTICLE& xTrackParticle);
StatusCode checkTrackIsTauInheritant(const TAUTRACKPARTICLE& xTrackParticle);
bool checkTruthParent(const xAOD::TruthParticle& xTruthParticle, int& iDepth, std::string& sHistory);
const xAOD::TruthParticle* getTruthParticle(const TAUTRACKPARTICLE& xTrackParticle);
StatusCode classifyConversion(const TAUTRACKPARTICLE& xTrackParticle, const xAOD::TruthParticle& xTruthParticle) const;
StatusCode checkTrackType(const TAUTRACKPARTICLE& xTrackParticle) const;
StatusCode checkTrackIsTauInheritant(const TAUTRACKPARTICLE& xTrackParticle) const;
bool checkTruthParent(const xAOD::TruthParticle& xTruthParticle, int& iDepth, std::string& sHistory) const;
const xAOD::TruthParticle* getTruthParticle(const TAUTRACKPARTICLE& xTrackParticle) const;
private:
bool m_bIsHadronicTrackAvailable;
bool m_bIsHadronicTrackAvailableChecked;
CxxUtils::CachedValue<bool> m_bIsHadronicTrackAvailable;
}; // class TauTruthTrackMatchingTool
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment