ATLAS Offline Software
BuildTruthTaus.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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/master/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauTruthMatchingTool.rst
11 */
12 
13 // Framework include(s):
15 #include "AsgTools/AnaToolHandle.h"
18 
19 // Core include(s):
21 
22 // EDM include(s):
23 #include "xAODJet/JetContainer.h"
24 
25 // Local include(s):
27 
28 namespace TauAnalysisTools
29 {
30 
32  : public virtual TauAnalysisTools::IBuildTruthTaus
33  , public asg::AsgMetadataTool
34 {
38 
39 public:
40 
41  struct TruthTausEvent
42  : public ITruthTausEvent
43  {
44  const xAOD::TruthParticleContainer* m_xTruthTauContainerConst = nullptr;
45  const xAOD::TruthParticleContainer* m_xTruthMuonContainerConst = nullptr;
46  const xAOD::TruthParticleContainer* m_xTruthElectronContainerConst = nullptr;
47  const xAOD::JetContainer* m_xTruthJetContainerConst = nullptr;
48  xAOD::TruthParticleContainer* m_xTruthTauContainer = nullptr;
49  xAOD::TruthParticleAuxContainer* m_xTruthTauAuxContainer = nullptr;
50  const xAOD::TruthParticleContainer* m_xTruthParticleContainer = nullptr;
51  };
52 
53  BuildTruthTaus( const std::string& name );
54 
55  virtual ~BuildTruthTaus() = default;
56 
57  // initialize the tool
58  virtual StatusCode initialize() override;
59 
60  virtual void setTruthMatchingMode() override {
61  m_truthMatchingMode = true;
62  };
63 
64  virtual StatusCode retrieveTruthTaus() override;
65  virtual StatusCode retrieveTruthTaus(ITruthTausEvent& truthTausEvent) const override;
66 
67 
68 protected:
69  StatusCode retrieveTruthTaus(TruthTausEvent& truthTausEvent) const;
70 
71 
72 private:
73 
74  struct TauTruthInfo
75  {
76  size_t m_iNChargedPions = 0;
77  size_t m_iNNeutralPions = 0;
78  size_t m_iNChargedOthers = 0;
79  size_t m_iNNeutralOthers = 0;
81  std::vector<int> m_vDecayMode;
82  // default false, if there is a hadron in decay products, it is switched to true
83  bool m_bIsHadronicTau = false;
84 
85  // truth visible kinematic variables
86  TLorentzVector m_vTruthVisTLV;
87  TLorentzVector m_vTruthVisTLVCharged;
88  TLorentzVector m_vTruthVisTLVNeutral;
89 
90  // truth vertices
91  TVector3 m_vDecayVertex;
92  TVector3 m_vProdVertex;
93 
94  };
95 
96 
97  StatusCode buildTruthTausFromTruthParticles(TruthTausEvent& truthTausEvent) const;
98  StatusCode examineTruthTau(const xAOD::TruthParticle& xTruthParticle) const;
100  TauTruthInfo& truthInfo) const;
101  void printDecay(const xAOD::TruthParticle& xTruthParticle, int depth = 0) const;
102 
103 protected:
104 
105  TruthTausEvent m_truthTausEvent;
106 
107  // temporary, drop at the first occasion
109 
110 private:
111 
112  // input containers
113  SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthTauInputContainer { this, "TruthTauContainerName", "TruthTaus", "Truth tau input container name (truth matching mode)" };
114  SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthParticleContainer { this, "TruthParticleContainerName", "TruthParticles", "Truth particles input container name" };
115  SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthElectronContainer { this, "TruthElectronContainerName", "TruthElectrons", "Truth electrons input container name" };
116  SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthMuonContainer { this, "TruthMuonContainerName", "TruthMuons", "Truth muons input container name" };
117  SG::ReadHandleKey<xAOD::JetContainer> m_truthJetContainer { this, "TruthJetContainerName", "AntiKt4TruthDressedWZJets", "Truth jets input container name" };
118  // output container
119  SG::WriteHandleKey<xAOD::TruthParticleContainer> m_truthTauOutputContainer { this, "NewTruthTauContainerName", "TruthTaus", "Truth tau output container name" };
120 
121  bool m_truthMatchingMode = false;
127 
129 
130 }; // class BuildTruthTaus
131 
132 }
133 #endif // TAUANALYSISTOOLS_BUILDTRUTHTAUS_H
TauAnalysisTools::BuildTruthTaus::examineTruthTau
StatusCode examineTruthTau(const xAOD::TruthParticle &xTruthParticle) const
Definition: BuildTruthTaus.cxx:211
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_iNChargedOthers
size_t m_iNChargedOthers
Definition: BuildTruthTaus.h:78
TauAnalysisTools
Definition: TruthCollectionMakerTau.h:16
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_vTruthVisTLV
TLorentzVector m_vTruthVisTLV
Definition: BuildTruthTaus.h:86
asg::AnaToolHandle< IMCTruthClassifier >
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
TauAnalysisTools::BuildTruthTaus::m_tMCTruthClassifier
asg::AnaToolHandle< IMCTruthClassifier > m_tMCTruthClassifier
Definition: BuildTruthTaus.h:128
TauAnalysisTools::BuildTruthTaus::m_truthElectronContainer
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthElectronContainer
Definition: BuildTruthTaus.h:115
TauAnalysisTools::BuildTruthTaus::TauTruthInfo
Definition: BuildTruthTaus.h:75
TauAnalysisTools::BuildTruthTaus::m_bWriteDecayModeVector
bool m_bWriteDecayModeVector
Definition: BuildTruthTaus.h:125
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_vDecayVertex
TVector3 m_vDecayVertex
Definition: BuildTruthTaus.h:91
TauAnalysisTools::BuildTruthTaus::printDecay
void printDecay(const xAOD::TruthParticle &xTruthParticle, int depth=0) const
Definition: BuildTruthTaus.cxx:431
TauAnalysisTools::BuildTruthTaus::setTruthMatchingMode
virtual void setTruthMatchingMode() override
Definition: BuildTruthTaus.h:60
TauAnalysisTools::IBuildTruthTaus::ITruthTausEvent
Declare the interface that the class provides.
Definition: IBuildTruthTaus.h:35
TauAnalysisTools::BuildTruthTaus::m_bWriteVisibleNeutralFourMomentum
bool m_bWriteVisibleNeutralFourMomentum
Definition: BuildTruthTaus.h:124
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_iNNeutralPions
size_t m_iNNeutralPions
Definition: BuildTruthTaus.h:77
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_bIsHadronicTau
bool m_bIsHadronicTau
Definition: BuildTruthTaus.h:83
TauAnalysisTools::BuildTruthTaus::retrieveTruthTaus
virtual StatusCode retrieveTruthTaus() override
Definition: BuildTruthTaus.cxx:69
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_vDecayMode
std::vector< int > m_vDecayMode
Definition: BuildTruthTaus.h:81
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_vTruthVisTLVCharged
TLorentzVector m_vTruthVisTLVCharged
Definition: BuildTruthTaus.h:87
TauAnalysisTools::BuildTruthTaus::m_bWriteVisibleChargedFourMomentum
bool m_bWriteVisibleChargedFourMomentum
Definition: BuildTruthTaus.h:123
TauAnalysisTools::BuildTruthTaus::m_truthTauOutputContainer
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_truthTauOutputContainer
Definition: BuildTruthTaus.h:119
TauAnalysisTools::BuildTruthTaus::m_bWriteInvisibleFourMomentum
bool m_bWriteInvisibleFourMomentum
Definition: BuildTruthTaus.h:122
TauAnalysisTools::BuildTruthTaus::m_truthMatchingMode
bool m_truthMatchingMode
Definition: BuildTruthTaus.h:121
SG::ReadHandleKey< xAOD::TruthParticleContainer >
TauAnalysisTools::BuildTruthTaus::m_bWriteVertices
bool m_bWriteVertices
Definition: BuildTruthTaus.h:126
TauAnalysisTools::BuildTruthTaus::initialize
virtual StatusCode initialize() override
Definition: BuildTruthTaus.cxx:39
TauAnalysisTools::BuildTruthTaus
Definition: BuildTruthTaus.h:34
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_vProdVertex
TVector3 m_vProdVertex
Definition: BuildTruthTaus.h:92
xAOD::TruthParticleAuxContainer_v1
Auxiliary store for the truth vertices.
Definition: TruthParticleAuxContainer_v1.h:27
IMCTruthClassifier.h
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TauAnalysisTools::BuildTruthTaus::m_bTruthTauAvailable
bool m_bTruthTauAvailable
Definition: BuildTruthTaus.h:108
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_iNChargedPions
size_t m_iNChargedPions
Definition: BuildTruthTaus.h:76
TauAnalysisTools::BuildTruthTaus::buildTruthTausFromTruthParticles
StatusCode buildTruthTausFromTruthParticles(TruthTausEvent &truthTausEvent) const
Definition: BuildTruthTaus.cxx:156
AnaToolHandle.h
IBuildTruthTaus.h
TauAnalysisTools::BuildTruthTaus::m_truthTausEvent
TruthTausEvent m_truthTausEvent
Definition: BuildTruthTaus.h:105
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TauAnalysisTools::BuildTruthTaus::m_truthTauInputContainer
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthTauInputContainer
Definition: BuildTruthTaus.h:113
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_vTruthVisTLVNeutral
TLorentzVector m_vTruthVisTLVNeutral
Definition: BuildTruthTaus.h:88
TauAnalysisTools::BuildTruthTaus::m_truthJetContainer
SG::ReadHandleKey< xAOD::JetContainer > m_truthJetContainer
Definition: BuildTruthTaus.h:117
JetContainer.h
TauAnalysisTools::BuildTruthTaus::m_truthMuonContainer
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuonContainer
Definition: BuildTruthTaus.h:116
asg::AsgMetadataTool
Base class for dual-use tools that provide file metadata access.
Definition: AsgMetadataTool.h:48
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
AsgMetadataTool.h
TauAnalysisTools::IBuildTruthTaus
Definition: IBuildTruthTaus.h:28
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_iNNeutralOthers
size_t m_iNNeutralOthers
Definition: BuildTruthTaus.h:79
TauAnalysisTools::BuildTruthTaus::TauTruthInfo::m_iNChargedDaughters
size_t m_iNChargedDaughters
Definition: BuildTruthTaus.h:80
TauAnalysisTools::BuildTruthTaus::m_truthParticleContainer
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainer
Definition: BuildTruthTaus.h:114
TauAnalysisTools::BuildTruthTaus::examineTruthTauDecay
StatusCode examineTruthTauDecay(const xAOD::TruthParticle &xTruthParticle, TauTruthInfo &truthInfo) const
Definition: BuildTruthTaus.cxx:344
TauAnalysisTools::BuildTruthTaus::~BuildTruthTaus
virtual ~BuildTruthTaus()=default