ATLAS Offline Software
Loading...
Searching...
No Matches
JetTruthLabelingTool.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 PARTICLEJETTOOLS_JETTRUTHLABELINGTOOL_H
6#define PARTICLEJETTOOLS_JETTRUTHLABELINGTOOL_H
7
8#include "AsgTools/AsgTool.h"
15
21#include <optional>
22
24 public asg::AsgTool,
25 virtual public IJetDecorator
26{
28
29public:
30
32 JetTruthLabelingTool(const std::string& name = "JetTruthLabelingTool");
33 virtual StatusCode initialize() override;
34
36 StatusCode decorate(const xAOD::JetContainer& jets) const override;
37
39 void print() const override;
40
42 const std::string& getLargeRJetTruthLabelName() const {
43 return m_truthLabelName;
44 };
45
46protected:
47
48 Gaudi::Property<std::string> m_jetContainerName{this, "RecoJetContainer", "", "Input reco jet container name"};
49 Gaudi::Property<std::string> m_truthLabelName{this, "TruthLabelName", "R10TruthLabel_R21Consolidated", "Truth label name"};
50
51 Gaudi::Property<bool> m_isTruthJetCol{this, "IsTruthJetCollection", false, "Flag indicating whether input collection is a truth jet container"};
52
53 SG::ReadHandleKey<xAOD::EventInfo> m_evtInfoKey{this, "EventInfoKey", "EventInfo", "Name of EventInfo object"};
54
56 Gaudi::Property<bool> m_useTRUTH3{this, "UseTRUTH3", false, "True for TRUTH3 format, false for TRUTH1"};
57 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthParticleContainerName{this, "TruthParticleContainerName", "TruthParticles", "Truth particle container name"};
58 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthBosonContainerName{this, "TruthBosonContainerName", "TruthBosonsWithDecayParticles", "Truth boson container name"};
59 SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthTopQuarkContainerName{this, "TruthTopQuarkContainerName", "TruthTopQuarkWithDecayParticles", "Truth top container name"};
60
62 SG::ReadHandleKey<xAOD::JetContainer> m_truthJetCollectionName{this, "TruthJetContainer", "", "Do not configure manually!"};
63 SG::ReadHandleKey<xAOD::JetContainer> m_truthGroomedJetCollectionName{this, "TruthGroomedJetContainer", "", "Do not configure manually!"};
64 bool m_useDRMatch{};
68 double m_dRTruthJet{};
69 double m_dRTruthPart{};
70 double m_mLowTop{};
71 double m_mLowW{};
72 double m_mHighW{};
73 double m_mLowZ{};
74 double m_mHighZ{};
75
102 friend struct DecorHandles;
103
105 StatusCode labelTruthJets( DecorHandles& dh,
106 const EventContext& ctx ) const;
107 StatusCode labelTruthJets( DecorHandles& dh,
108 const xAOD::JetContainer &jets,
109 const EventContext& ctx ) const;
110
112 StatusCode labelRecoJets(DecorHandles& dh,
113 const xAOD::JetContainer &jets,
114 const EventContext& ctx) const;
115
118 const xAOD::Jet &jet,
119 const std::vector<std::pair<TLorentzVector,int> >& tlv_truthParts,
120 const EventContext& ctx ) const;
121
124 const xAOD::Jet &jet,
125 const EventContext& ctx ) const;
126
128 int getLabel( DecorHandles& dh,
129 const xAOD::Jet &jet, bool matchH, bool matchW, bool matchZ, bool matchTop,
130 const EventContext& ctx ) const;
131
133 float getWZSplit12Cut( float pt ) const;
134
136 float getTopSplit23Cut( float pt ) const;
137
139 int getNGhostParticles( const xAOD::Jet &jet, std::string collection ) const;
140
142 bool getIsSherpa( const int DSID ) const {
143 if(
144 (304307 <= DSID && DSID <= 304309) || // Sherpa 2.2.1 W+jets
145 (304707 <= DSID && DSID <= 304709) // Sherpa 2.2.1 Z+jets
146 ) {
147 return true;
148 }
149 return false;
150 };
151
153 void getTLVs( std::vector< std::pair<TLorentzVector,int> > &tlvs, const xAOD::TruthParticleContainer *truthBosons, const xAOD::TruthParticleContainer *truthTop, bool isSherpa = false ) const;
154
156 bool selectTruthParticle( const xAOD::TruthParticle *tp, int pdgId ) const;
157
158 SG::WriteDecorHandleKey<xAOD::JetContainer> m_label_truthKey{this, "label_TruthKey", "", "Do not configure manually!"};
159 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_W_truthKey{this, "dR_W_TruthKey", "", "Do not configure manually!"};
160 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Z_truthKey{this, "dR_Z_TruthKey", "", "Do not configure manually!"};
161 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_H_truthKey{this, "dR_H_TruthKey", "", "Do not configure manually!"};
162 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Top_truthKey{this, "dR_Top_TruthKey", "", "Do not configure manually!"};
163 SG::WriteDecorHandleKey<xAOD::JetContainer> m_NB_truthKey{this, "NB_TruthKey", "", "Do not configure manually!"};
164 SG::ReadDecorHandleKey<xAOD::JetContainer> m_split12_truthKey{this, "Split12_TruthKey", "", "Do not configure manually!"};
165 SG::ReadDecorHandleKey<xAOD::JetContainer> m_split23_truthKey{this, "Split23_TruthKey", "", "Do not configure manually!"};
166
167 SG::WriteDecorHandleKey<xAOD::JetContainer> m_label_recoKey{this, "label_RecoKey", "", "Do not configure manually!"};
168 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_W_recoKey{this, "dR_W_RecoKey", "", "Do not configure manually!"};
169 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Z_recoKey{this, "dR_Z_RecoKey", "", "Do not configure manually!"};
170 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_H_recoKey{this, "dR_H_RecoKey", "", "Do not configure manually!"};
171 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Top_recoKey{this, "dR_Top_RecoKey", "", "Do not configure manually!"};
172 SG::WriteDecorHandleKey<xAOD::JetContainer> m_NB_recoKey{this, "NB_RecoKey", "", "Do not configure manually!"};
173 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthSplit12_recoKey{this, "TruthSplit12_RecoKey", "", "Do not configure manually!"};
174 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthSplit23_recoKey{this, "TruthSplit23_RecoKey", "", "Do not configure manually!"};
175 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthJetMass_recoKey{this, "TruthJetMass_RecoKey", "", "Do not configure manually!"};
176 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthJetPt_recoKey{this, "TruthJetPt_RecoKey", "", "Do not configure manually!"};
177 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthGroomedJetMass_recoKey{this, "TruthGroomedJetMass_RecoKey", "", "Do not configure manually!"};
178 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthGroomedJetPt_recoKey{this, "TruthGroomedJetPt_RecoKey", "", "Do not configure manually!"};
179};
180
181#endif
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
Property holding a SG store/key/clid from which a ReadHandle is made.
Handle class for adding a decoration to an object.
Interface for adding a decoration to a jet container.
Gaudi::Property< std::string > m_jetContainerName
Gaudi::Property< std::string > m_truthLabelName
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthTopQuarkContainerName
double m_mHighZ
Lower mass cut for Z label.
bool m_getTruthGroomedJetValues
Use the ungroomed reco jet parent to match to truth jet.
double m_mLowZ
Upper mass cut for W label.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_truthJetMass_recoKey
double m_dRTruthPart
dR to match truth jet to reco jet
SG::WriteDecorHandleKey< xAOD::JetContainer > m_NB_truthKey
StatusCode labelRecoJets(DecorHandles &dh, const xAOD::JetContainer &jets, const EventContext &ctx) const
Apply labels to all jets in a container.
float getTopSplit23Cut(float pt) const
Get top label Split23 cut.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_label_recoKey
StatusCode labelTruthJets(DecorHandles &dh, const EventContext &ctx) const
Label truth jet collection.
double m_mLowTop
dR to match truth particles to truth jet
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthBosonContainerName
Gaudi::Property< bool > m_useTRUTH3
TRUTH1 or TRUTH3.
void print() const override
Print configured parameters.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_truthJetPt_recoKey
bool selectTruthParticle(const xAOD::TruthParticle *tp, int pdgId) const
Check if truth particle has correct DSID and isn't self decay.
int getTruthJetLabelGA(DecorHandles &dh, const xAOD::Jet &jet, const EventContext &ctx) const
Get truth label using ghost-associated particles.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_truthGroomedJetPt_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_H_recoKey
Gaudi::Property< bool > m_isTruthJetCol
void getTLVs(std::vector< std::pair< TLorentzVector, int > > &tlvs, const xAOD::TruthParticleContainer *truthBosons, const xAOD::TruthParticleContainer *truthTop, bool isSherpa=false) const
Extract heavy particle 4-vectors from truth record.
SG::ReadHandleKey< xAOD::JetContainer > m_truthGroomedJetCollectionName
int getLabel(DecorHandles &dh, const xAOD::Jet &jet, bool matchH, bool matchW, bool matchZ, bool matchTop, const EventContext &ctx) const
Get label based on matching and containment criteria.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_truthSplit23_recoKey
bool m_useWZMassHigh
Use dR to match partons to truth jet.
const std::string & getLargeRJetTruthLabelName() const
returns the name of large-R jet truth label
float getWZSplit12Cut(float pt) const
Get W/Z label Split12 cut.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_H_truthKey
int getNGhostParticles(const xAOD::Jet &jet, std::string collection) const
Get number of ghost associated particles.
SG::ReadDecorHandleKey< xAOD::JetContainer > m_split23_truthKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_Top_recoKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_split12_truthKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerName
SG::WriteDecorHandleKey< xAOD::JetContainer > m_truthSplit12_recoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
int getTruthJetLabelDR(DecorHandles &dh, const xAOD::Jet &jet, const std::vector< std::pair< TLorentzVector, int > > &tlv_truthParts, const EventContext &ctx) const
Get truth label using dR-matched particles.
bool m_matchUngroomedParent
Use upper mass cut for W/Z labels.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_Z_recoKey
JetTruthLabelingTool(const std::string &name="JetTruthLabelingTool")
default constructor - to be used in all derived classes
SG::WriteDecorHandleKey< xAOD::JetContainer > m_label_truthKey
StatusCode decorate(const xAOD::JetContainer &jets) const override
decorate truth label to a jet collection
SG::ReadHandleKey< xAOD::JetContainer > m_truthJetCollectionName
parameters for truth labeling
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_Z_truthKey
double m_mLowW
Lower mass cut for top label.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_NB_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_W_truthKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_truthGroomedJetMass_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_W_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_Top_truthKey
bool getIsSherpa(const int DSID) const
Check for Sherpa DSIDs.
double m_dRTruthJet
When truth jet matching to ungroomed truth, allow saving properties of groomed truth jets.
double m_mHighW
Lower mass cut for W label.
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.
Handle class for adding a decoration to an object.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Jet_v1 Jet
Definition of the current "jet version".
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::optional< FloatHandle_t > FloatHandleOp_t
DecorHandles(const JetTruthLabelingTool &tool, const EventContext &ctx)
std::optional< IntHandle_t > IntHandleOp_t
SG::WriteDecorHandle< xAOD::JetContainer, int > IntHandle_t
SG::WriteDecorHandle< xAOD::JetContainer, float > FloatHandle_t