ATLAS Offline Software
Loading...
Searching...
No Matches
BuildTruthTaus.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TAUANALYSISTOOLS_BUILDTRUTHTAUS_H
6#define TAUANALYSISTOOLS_BUILDTRUTHTAUS_H
7
8/*
9 author: Dirk Duschinger
10 documentation: https://gitlab.cern.ch/atlas/athena/-/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauTruthMatchingTool.rst
11*/
12
13// Framework include(s):
21// dummy EventContext for AnalysisBase
23
24// Core include(s):
26
27// EDM include(s):
29
30// Local include(s):
32
33namespace TauAnalysisTools
34{
35
39{
43
44public:
45
46 struct TruthTausEvent
47 : public ITruthTausEvent
48 {
49 const xAOD::TruthParticleContainer* m_xTruthTauContainerConst = nullptr;
50 const xAOD::TruthParticleContainer* m_xTruthMuonContainerConst = nullptr;
51 const xAOD::TruthParticleContainer* m_xTruthElectronContainerConst = nullptr;
52 const xAOD::JetContainer* m_xTruthJetContainerConst = nullptr;
53 xAOD::TruthParticleContainer* m_xTruthTauContainer = nullptr;
54 xAOD::TruthParticleAuxContainer* m_xTruthTauAuxContainer = nullptr;
55 const xAOD::TruthParticleContainer* m_xTruthParticleContainer = nullptr;
56 };
57
58 BuildTruthTaus( const std::string& name );
59
60 virtual ~BuildTruthTaus() = default;
61
62 // initialize the tool
63 virtual StatusCode initialize() override;
64
65 virtual void setTruthMatchingMode() override {
67 };
68
69 virtual StatusCode retrieveTruthTaus() override;
70 virtual StatusCode retrieveTruthTaus(ITruthTausEvent& truthTausEvent, const EventContext& ctx) const override;
71
72
73protected:
74 StatusCode retrieveTruthTausImpl(TruthTausEvent& truthTausEvent, const EventContext& ctx) const;
75
76
77private:
78
80 {
81 size_t m_iNChargedPions = 0;
82 size_t m_iNNeutralPions = 0;
86 std::vector<int> m_vDecayMode;
87 // default false, if there is a hadron in decay products, it is switched to true
88 bool m_bIsHadronicTau = false;
89
90 // truth visible kinematic variables
91 TLorentzVector m_vTruthVisTLV;
92 TLorentzVector m_vTruthVisTLVCharged;
93 std::vector<TLorentzVector> m_TLVCharged;
94 TLorentzVector m_vTruthVisTLVNeutral;
95 std::vector<TLorentzVector> m_TLVNeutral;
96
97 // truth vertices
99 TVector3 m_vProdVertex;
100
101 };
102
103
104 StatusCode buildTruthTausFromTruthParticles(TruthTausEvent& truthTausEvent, const EventContext& ctx) const;
105 StatusCode examineTruthTau(const xAOD::TruthParticle& xTruthParticle) const;
106 StatusCode examineTruthTauDecay(const xAOD::TruthParticle& xTruthParticle,
107 TauTruthInfo& truthInfo) const;
108 void printDecay(const xAOD::TruthParticle& xTruthParticle, int depth = 0) const;
109
110protected:
111
112 TruthTausEvent m_truthTausEvent;
113
114 // temporary, drop at the first occasion
116
117private:
118
119 // properties
120 Gaudi::Property<bool> m_bWriteInvisibleFourMomentum{ this, "WriteInvisibleFourMomentum", false};
121 Gaudi::Property<bool> m_bWriteVisibleChargedFourMomentum{ this, "WriteVisibleChargedFourMomentum", false};
122 Gaudi::Property<bool> m_bWriteVisibleChargedFourMomentumComponent{ this, "WriteVisibleChargedFourMomentumComponent", false};
123 Gaudi::Property<bool> m_bWriteVisibleNeutralFourMomentum{ this, "WriteVisibleNeutralFourMomentum", false};
124 Gaudi::Property<bool> m_bWriteVisibleNeutralFourMomentumComponent{ this, "WriteVisibleNeutralFourMomentumComponent", false};
125 Gaudi::Property<bool> m_bWriteDecayModeVector{ this, "WriteDecayModeVector", true};
126 Gaudi::Property<bool> m_bWriteVertices{ this, "WriteVertices", true};
127
128 // input containers
129 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthTauInputContainer { this, "TruthTauContainerName", "TruthTaus", "Truth tau input container name (truth matching mode)" };
130 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthParticleContainer { this, "TruthParticleContainerName", "TruthParticles", "Truth particles input container name" };
131 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthElectronContainer { this, "TruthElectronContainerName", "TruthElectrons", "Truth electrons input container name" };
132 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthMuonContainer { this, "TruthMuonContainerName", "TruthMuons", "Truth muons input container name" };
133 SG::ReadHandleKey<xAOD::JetContainer> m_truthJetContainer { this, "TruthJetContainerName", "AntiKt4TruthDressedWZJets", "Truth jets input container name" };
134 // output container
135 SG::WriteHandleKey<xAOD::TruthParticleContainer> m_truthTauOutputContainer { this, "NewTruthTauContainerName", "TruthTaus", "Truth tau output container name" };
136
137 // decorations to be read from TruthParticles and copied onto TruthTaus
138 SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> m_originReadDecorKey {this, "inputClassifierParticleOrigin", "TruthParticles.classifierParticleOrigin", "Particle origin"};
139 SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> m_typeReadDecorKey {this, "inputClassifierParticleType", "TruthParticles.classifierParticleType", "Particle type"};
140 SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> m_outcomeReadDecorKey {this, "inputClassifierParticleOutCome", "TruthParticles.classifierParticleOutCome", "Particle outcome"};
141 SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> m_classificationReadDecorKey {this, "inputClassification", "TruthParticles.Classification", "Classification code"};
142
143 SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> m_linkDecoratorKey {this, "originalTruthParticle", "TruthTaus.originalTruthParticle", "Name of the decoration linking to the original truth particle"};
144 SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> m_originDecoratorKey {this, "classifierParticleOrigin", "TruthTaus.classifierParticleOrigin", "Name of the decoration which records the particle origin"};
145 SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> m_typeDecoratorKey {this, "classifierParticleType", "TruthTaus.classifierParticleType", "Name of the decoration which records the particle type"};
146 SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> m_outcomeDecoratorKey {this, "classifierParticleOutCome", "TruthTaus.classifierParticleOutCome", "Name of the decoration which records the particle outcome"};
147 SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> m_classificationDecoratorKey {this, "Classification", "TruthTaus.Classification", "Name of the decoration which records the particle classification"};
148
150
151}; // class BuildTruthTaus
152
153}
154#endif // TAUANALYSISTOOLS_BUILDTRUTHTAUS_H
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
ATLAS-specific HepMC functions.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
virtual void setTruthMatchingMode() override
Gaudi::Property< bool > m_bWriteDecayModeVector
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthElectronContainer
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuonContainer
void printDecay(const xAOD::TruthParticle &xTruthParticle, int depth=0) const
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeReadDecorKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainer
Gaudi::Property< bool > m_bWriteVisibleChargedFourMomentumComponent
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_originReadDecorKey
SG::ReadHandleKey< xAOD::JetContainer > m_truthJetContainer
Gaudi::Property< bool > m_bWriteVisibleChargedFourMomentum
ASG_TOOL_CLASS(BuildTruthTaus, TauAnalysisTools::IBuildTruthTaus) public BuildTruthTaus(const std::string &name)
Create a proper constructor for Athena.
Gaudi::Property< bool > m_bWriteVertices
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_classificationReadDecorKey
virtual ~BuildTruthTaus()=default
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_typeReadDecorKey
virtual StatusCode retrieveTruthTaus() override
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_linkDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_typeDecoratorKey
Gaudi::Property< bool > m_bWriteInvisibleFourMomentum
Gaudi::Property< bool > m_bWriteVisibleNeutralFourMomentum
StatusCode examineTruthTauDecay(const xAOD::TruthParticle &xTruthParticle, TauTruthInfo &truthInfo) const
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_truthTauOutputContainer
virtual StatusCode initialize() override
StatusCode examineTruthTau(const xAOD::TruthParticle &xTruthParticle) const
StatusCode buildTruthTausFromTruthParticles(TruthTausEvent &truthTausEvent, const EventContext &ctx) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthTauInputContainer
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_classificationDecoratorKey
StatusCode retrieveTruthTausImpl(TruthTausEvent &truthTausEvent, const EventContext &ctx) const
Gaudi::Property< bool > m_bWriteVisibleNeutralFourMomentumComponent
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeDecoratorKey
Declare the interface that the class provides.
Base class for dual-use tools that provide file metadata access.
std::string depth
tag string for intendation
Definition fastadd.cxx:46
TruthParticleAuxContainer_v2 TruthParticleAuxContainer
Declare the latest version of the truth particle auxiliary container.
TruthParticle_v1 TruthParticle
Typedef to implementation.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
std::vector< TLorentzVector > m_TLVNeutral
std::vector< TLorentzVector > m_TLVCharged